Skip to content

Commit a16b04e

Browse files
committed
Put unbundled beziers in a separate entry in the table for control points
Ref: Edge points not calculated properly for bundled beziers when an unbundled edge exists between the same source and target #3322
1 parent f34682c commit a16b04e

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

src/extensions/renderer/base/coord-ele-math/edge-control-points.js

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -706,28 +706,11 @@ BRp.findEdgeControlPoints = function( edges ){
706706
let cy = r.cy;
707707
let hasCompounds = cy.hasCompoundNodes();
708708

709-
let hashTable = {
710-
map: new Map(),
711-
get: function(pairId){
712-
let map2 = this.map.get(pairId[0]);
713-
714-
if( map2 != null ){
715-
return map2.get(pairId[1]);
716-
} else {
717-
return null;
718-
}
719-
},
720-
set: function(pairId, val){
721-
let map2 = this.map.get(pairId[0]);
722-
723-
if( map2 == null ){
724-
map2 = new Map();
725-
this.map.set(pairId[0], map2);
726-
}
727-
728-
map2.set(pairId[1], val);
729-
}
730-
};
709+
let hashTable = new Map();
710+
let getKey = (pairId, edgeIsUnbundled) => [
711+
...pairId,
712+
edgeIsUnbundled ? 1 : 0
713+
].join('-');
731714

732715
let pairIds = [];
733716
let haystackEdges = [];
@@ -757,14 +740,15 @@ BRp.findEdgeControlPoints = function( edges ){
757740
let tgtIndex = tgt.poolIndex();
758741

759742
let pairId = [ srcIndex, tgtIndex ].sort();
743+
let key = getKey(pairId, edgeIsUnbundled);
760744

761-
let tableEntry = hashTable.get( pairId );
745+
let tableEntry = hashTable.get( key );
762746

763747
if( tableEntry == null ){
764748
tableEntry = { eles: [] };
765749

766-
hashTable.set( pairId, tableEntry );
767-
pairIds.push( pairId );
750+
pairIds.push({ pairId, edgeIsUnbundled });
751+
hashTable.set( key, tableEntry );
768752
}
769753

770754
tableEntry.eles.push( edge );
@@ -781,8 +765,9 @@ BRp.findEdgeControlPoints = function( edges ){
781765
// for each pair (src, tgt), create the ctrl pts
782766
// Nested for loop is OK; total number of iterations for both loops = edgeCount
783767
for( let p = 0; p < pairIds.length; p++ ){
784-
let pairId = pairIds[ p ];
785-
let pairInfo = hashTable.get( pairId );
768+
let { pairId, edgeIsUnbundled } = pairIds[ p ];
769+
let key = getKey(pairId, edgeIsUnbundled);
770+
let pairInfo = hashTable.get( key );
786771
let swappedpairInfo;
787772

788773
if( !pairInfo.hasUnbundled ){

0 commit comments

Comments
 (0)