-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taxi edge turn radius (i.e. smooth curve on each turn) #3142
Changes from all commits
606714c
6c1644c
e68f1af
a73a6c1
a95aa5b
2c825ec
acf2009
61980eb
92d7dc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,7 +456,10 @@ When a taxi edge would be impossible to draw along the regular turning plan --- | |
* Note that bundling may not work with an explicit direction (`upward`, `downward`, `leftward`, or `rightward`) in tandem with a turn distance specified in percent units. | ||
* **`taxi-turn-min-distance`** : The minimum distance along the primary axis that is maintained between the nodes and the turns. | ||
* This value only takes on absolute values (e.g. `5px`). | ||
* This property makes the taxi edge be re-routed when the turns would be otherwise too close to the source or target. As such, it also helps to avoid turns overlapping edge endpoint arrows. | ||
* This property makes the taxi edge be re-routed when the turns would be otherwise too close to the source or target. As such, it also helps to avoid turns overlapping edge endpoint arrows | ||
* **`taxi-radius`** : The taxi-radius property applies a curve to a taxi edge, providing a rounded appearance to any 90 degree bend. | ||
* This value should be a floating point number (e.g. `3.14`). | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if we cap the radius (see the comments later on), it may be useful to have another sub-bullet-point that notes that the radius should not be too large. It depends on how your other taxi properties are specified, the layout, etc. |
||
* **`edge-distances`** : With value `intersection` (default), the distances (`taxi-turn` and `taxi-turn-min-distance`) are considered from the outside of the source's bounds to the outside of the target's bounds. With value `node-position`, the distances are considered from the source position to the target position. The `node-position` option makes calculating edge points easier --- but it should be used carefully because you can create invalid points that `intersection` would have automatically corrected. | ||
|
||
|
||
|
@@ -717,4 +720,4 @@ Selection box: | |
Texture during viewport gestures: | ||
|
||
* **`outside-texture-bg-color`** : The colour of the area outside the viewport texture when `initOptions.textureOnViewport === true`. | ||
* **`outside-texture-bg-opacity`** : The opacity of the area outside the viewport texture. | ||
* **`outside-texture-bg-opacity`** : The opacity of the area outside the viewport texture. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,13 +169,37 @@ BRp.findNearestElements = function( x, y, interactiveElementsOnly, isTouch ){ | |
var pts = rs.allpts; | ||
|
||
for( var i = 0; i + 3 < pts.length; i += 2 ){ | ||
if( | ||
(math.inLineVicinity( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3], width2 )) | ||
&& | ||
widthSq > ( sqDist = math.sqdistToFiniteLine( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3] ) ) | ||
){ | ||
addEle( edge, sqDist ); | ||
return true; | ||
if( rs.edgeType === 'segments' && edge.pstyle( 'taxi-radius' ).value > 0 ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that this is intended to be a performant simplification, but it doesn't seem to work as intended, e.g. you get clear false positives on the debug page example: Screen.Recording.2023-08-03.at.14.53.06.movThe curved taxi edge gets false positives way off the edge. You can compare to other edges, such as the haystacks in the video, to get a sense of how it should feel in proximity. The corners need to be handled more accurately. For instance, you could
If you try (2), temporarily using (3) would help to visualise your approximation even if you don't actually do (3) in the end result. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also: Hit test code that is curved-taxi-specific should check |
||
const radius = edge.pstyle( 'taxi-radius' ).value/6 | ||
const isHor = pts[ i+1 ] === pts[ i + 3] | ||
let x1,x2,y1,y2 | ||
if (isHor){ | ||
x1 = pts[ i ] | ||
x2 = ( pts[ i ] === pts[ i + 2 ] ) ? pts[i+2] : ( pts[ i + 2 ] > pts[ i ] ) ? pts[ i + 2 ] - radius : pts[ i + 2 ] + radius; | ||
y1 = pts[ i + 1] - radius | ||
y2 = pts[ i + 3 ] + radius | ||
}else{ | ||
x1 = pts[ i ] - radius | ||
x2 = pts[ i + 2] + radius | ||
y1 = pts[ i + 1] | ||
y2 = ( pts[ i + 1 ] === pts[ i + 3 ] ) ? pts[ i + 1 ] : pts[ i + 3 ] > pts[ i+1 ] ? pts[ i + 3 ] - radius : pts[ i + 3 ] + radius; | ||
} | ||
|
||
if( | ||
(math.inLineVicinity( x, y, x1, y1, x2, y2, width2 )) | ||
){ | ||
addEle( edge, sqDist ); | ||
return true; | ||
} | ||
} else { | ||
if( | ||
(math.inLineVicinity( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3], width2 )) | ||
&& | ||
widthSq > ( sqDist = math.sqdistToFiniteLine( x, y, pts[ i ], pts[ i + 1], pts[ i + 2], pts[ i + 3] ) ) | ||
){ | ||
addEle( edge, sqDist ); | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,8 +208,18 @@ CRp.drawEdgePath = function( edge, context, pts, type ){ | |
case 'straight': | ||
case 'segments': | ||
case 'haystack': | ||
Adam-Shea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for( let i = 2; i + 1 < pts.length; i += 2 ){ | ||
context.lineTo( pts[ i ], pts[ i + 1] ); | ||
const taxiRadius= edge.pstyle( 'taxi-radius' ) | ||
const taxiRadiusValue = taxiRadius ? taxiRadius.pfValue : 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to how For the edges, the radius could be capped by the available space on the line. If you have a larger radius, then the edge will bug out depending on the orientation of the nodes: Screen.Recording.2023-08-03.at.15.29.33.movThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. N.b. this issue also effects smaller radii, but not as obviously. |
||
|
||
if( edge.pstyle('curve-style').value == 'taxi' && taxiRadiusValue > 0 ) { | ||
for( let i = 2; i + 1 < pts.length; i += 2 ) { | ||
context.arcTo( pts[ i - 2 ], pts[ i - 1 ], pts[ i ], pts[ i + 1 ], taxiRadiusValue ) | ||
} | ||
context.lineTo( pts[ pts.length - 2 ], pts[ pts.length - 1 ] ); | ||
Adam-Shea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
for( let i = 2; i + 1 < pts.length; i += 2 ) { | ||
context.lineTo( pts[ i ], pts[ i + 1] ); | ||
} | ||
Adam-Shea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
break; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a clarification