@@ -339,7 +339,8 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
339339 const designatedLayer = this . activeSubpath ?. layer
340340 return Array . from ( neighbors ) . filter ( ( n ) => {
341341 // Must not be obstacle
342- if ( n . _completelyInsideObstacle || n . _containsObstacle ) return false
342+ if ( n . _containsObstacle && ! n . _containsTarget ) return false
343+ if ( this . usedNodeMap . has ( n . capacityMeshNodeId ) ) return false
343344
344345 // Must contain the designated layer in availableZ
345346 if (
@@ -365,14 +366,7 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
365366 ) {
366367 // Base movement cost: Euclidean step
367368 const step = this . _dist ( prevCandidate . node , node )
368- let g = prevCandidate . g + step
369-
370- // Strongly discourage reusing nodes already part of prior paths
371- // TODO modify so that they don't even become neighbors
372- if ( this . usedNodeMap . has ( node . capacityMeshNodeId ) ) {
373- g += 1e6
374- }
375-
369+ const g = prevCandidate . g + step
376370 return g
377371 }
378372
@@ -382,13 +376,7 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
382376 endGoal : CapacityMeshNode ,
383377 ) {
384378 // Straight-line heuristic to the goal
385- let h = this . _dist ( node , endGoal )
386-
387- // Slight nudge away from already-used nodes
388- // TODO modify so that they don't even become neighbors
389- if ( this . usedNodeMap . has ( node . capacityMeshNodeId ) ) {
390- h += 100
391- }
379+ const h = this . _dist ( node , endGoal )
392380
393381 return h
394382 }
@@ -688,7 +676,32 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
688676 }
689677 }
690678
691- // 4. Visualize current active subpath with thick orange line
679+ // 4. Visualize solved subpaths in green
680+ if ( this . solvedSubpaths ) {
681+ for ( let i = 0 ; i < this . solvedSubpaths . length ; i ++ ) {
682+ const subpath = this . solvedSubpaths [ i ]
683+ if ( subpath . path && subpath . path . length > 1 ) {
684+ for ( let j = 0 ; j < subpath . path . length - 1 ; j ++ ) {
685+ const node1 = subpath . path [ j ]
686+ const node2 = subpath . path [ j + 1 ]
687+ if (
688+ node1 ?. center &&
689+ node2 ?. center &&
690+ isValidPoint ( node1 . center ) &&
691+ isValidPoint ( node2 . center )
692+ ) {
693+ graphics . lines ! . push ( {
694+ points : [ node1 . center , node2 . center ] ,
695+ strokeColor : "green" ,
696+ strokeDash : subpath . layer === 1 ? "3 3" : undefined ,
697+ } )
698+ }
699+ }
700+ }
701+ }
702+ }
703+
704+ // 5. Visualize current active subpath with thick orange line
692705 if ( this . activeSubpath ) {
693706 const start = this . activeSubpath . start ?. center
694707 const end = this . activeSubpath . end ?. center
@@ -711,7 +724,7 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
711724 }
712725 }
713726
714- // 5 . Visualize top 10 candidate paths with decreasing opacity
727+ // 6 . Visualize top 10 candidate paths with decreasing opacity
715728 const topCandidates = this . queuedCandidateNodes
716729 . slice ( 0 , 10 )
717730 . sort ( ( a , b ) => a . f - b . f )
@@ -740,20 +753,20 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
740753 }
741754 }
742755
743- // 6 . Visualize active connection pair (if any)
756+ // 7 . Visualize active connection pair (if any)
744757 if ( this . activeConnectionPair ) {
745758 const start = this . activeConnectionPair . start ?. center
746759 const end = this . activeConnectionPair . end ?. center
747760 if ( start && end && isValidPoint ( start ) && isValidPoint ( end ) ) {
748761 graphics . lines ! . push ( {
749762 points : [ start , end ] ,
750- strokeColor : "green " ,
763+ strokeColor : "cyan " ,
751764 strokeDash : "20 5" ,
752765 } )
753766 }
754767 }
755768
756- // 7 . Visualize directive vias (if using directive strategy)
769+ // 8 . Visualize directive vias (if using directive strategy)
757770 if ( this . ogUnprocessedSubpaths ) {
758771 const [ , mid ] = this . ogUnprocessedSubpaths
759772 if ( mid . start ?. center && isValidPoint ( mid . start . center ) ) {
@@ -788,7 +801,7 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
788801 }
789802 }
790803
791- // 8 . Visualize candidate nodes with small circles
804+ // 9 . Visualize candidate nodes with small circles
792805 if ( this . queuedCandidateNodes . length > 0 ) {
793806 for ( const candidate of this . queuedCandidateNodes ) {
794807 const node = candidate . node
@@ -803,7 +816,7 @@ export class AssignableViaCapacityPathingSolver_DirectiveSubOptimal extends Base
803816 }
804817 }
805818
806- // 9 . Visualize visited nodes with gray circles
819+ // 10 . Visualize visited nodes with gray circles
807820 if ( this . visitedNodes . size > 0 ) {
808821 for ( const nodeId of this . visitedNodes ) {
809822 const node = this . nodeMap . get ( nodeId )
0 commit comments