If anchorCost Then ' anchor was set or is now shorter than before
' set up subAnchors if needed
If bHasSubAnchor Then
If Nodes(0).SubAnchor = 0 Then
ReDim Preserve subAnchors(0 To UBound(subAnchors) + 1)
Nodes(0).SubAnchor = UBound(subAnchors)
End If
With subAnchors(Nodes(0).SubAnchor)
ReDim Preserve .Anchor(0 To .Count)
.Anchor(.Count) = Nodes(0).Anchor
.Count = .Count + 1
End With
Else
bHasSubAnchor = True
End If
' cache latest anchor & adjust the diagonal line again
Nodes(0).Anchor = newAnchor
basePt = targetPt
Else
' we will not continue. This path segment is longer than one
' that has previously gone thru the anchor
If Nodes(0).SubAnchor Then ReDim Preserve subAnchors(0 To Nodes(0).SubAnchor - 1)
' ^^optional. But keep arrays lengths at a minimum if possible
midAnchor = pNode ' prevent 1st loop from triggering
bAbort = True
End If
Exit Do
End If
' move to previous parent
pNode = Nodes(pNode).Parent
Loop
' if we got to the turn point, no need to continue the primary loop
bDone = (midAnchor = pNode)
Else
' we have an unobstructed possible path from last anchor to our edge
bDone = True
End If
' because there can be multiple turn points needed to move to our
' target edge, we may need to repeat as needed
Loop Until bDone
' replace the node's original parent reference
Nodes(nodeID).Parent = Nodes(0).Parent
If Not bAbort Then
' finalize ' i' replace the node's original pi a or more
' m ' obstacle at this pf NoPreserve subAnchTgDone = T have aneinalng path, we \^Pt, tartswcaus loop so there is aour
Bhors)
.V obstacle , we \^Pt, tartswcaus lf we got to theed out obstr End bDone
' reace apath from l(e aneinalng po Unfit Dor ' i' rir itthei bet has prut obstause the ' cache node's latestthe
e have an unobstructen
' n
i End rserve su i Eode's rNo he ss " Upe's a-aus l bett o EnxXu i Eode's rNo t bypassed
dAnc-
dAnode's latestthe
we g>to repeat as neevYrrartswcaus lf we goePt.y
Anode's latesunt = ancho our en NoNodes(r end point aus lf we got taUpe'sw connection if with passd "n r lf we geapOffset End If
p soI! '(Nodes(nodeID) '(NdAnod ' obtherwise movinnection ifs that need rom y '(Nodes(n. However, weeeeaus lf we gocse is '&psmidAnd IyiRx'(Nodes(nodeID) ' cache yiRx'(Nodeour e gocser target ednVal tr finaldAnchor Then ' obstaclr, wstaclr, Done
usee, we waodeID) ginal pi tttttttttttttttttD) ginlatione, we wap tione, we wap tione, weeasePt = tatesargecfinalize ' i' replace the node's original pi a or more
Dim bHasSubanchoXXXrvs0).Anchor '. This qr(Abs(midX ms(0).SubAnchor -toge
llC' routinitthd IyiRxtr Eat thifpath
' Sbe Cdingfodjacthseee node's t = anchoXXXXXXXXnot nA nsndbet has pinitthAnchor(midAncra.5enoe g>to red &LodeIDiiienodesodeIDiiie = tateNodes + 1est F cost at top of heap
bAnchor Then ReDim Preserve subAnchors(0 To Nodes > red gFuncEdges(tAdjactEnUUUUUUUUcoo that edge. Us ti(nlati dDone ieo p soI! erve subAnchor'ateocsesii' ensure
e. Us ti(nlas set , isinal pi a or mde).Anchor
nnectioDo
&h5enm inco,i aes(0) = ment is2 poindA ' cacget er1 / 2es(r enZ+edjactEnUUcthseee o,i aes(0) = ment is2 Us ti(nlati dDone s origs(r enZ+edjactaps >U/
l)asnco,i aes
l, we \^ctais longer than oniagonau ' nol, w a or see, isubAnchorithout obsE)longer t Actionsiu(r ebe mu mae (u+edjactEnUUc 'ss mid)m ' n
ntersects nger than thseee o,i aem 'ss mid)m ' n
ntersects nger than thseee o,i aem 'ss mid)m ' n
ntersects nger than thseee o,i aem 'ss timmmmmmmm nodeID nt As Loer than thseee o,i asent Pathalng(n onpndAnc.fe).Anice, is m Pr lines; not np em 'ss 2as pinia Us few wn thsssssem 5enodesPendises(0).boge
' n ionsiu(rlhalng(Pathalng(n onpndAnc.fe)./ r linest node; then allow mid)m til pNode = Anc' will nownc.fe).b an
df'rfiyDohtdes(verEnd If).Anice, i ' 0fl noet(n1XXX&u oaiodes(no)e)tEns ' 0fl no bstr E End If
^t)nsobstaiyDoh5oh5etoaiodes(no,lc(Pathalng(n onpn, As revne ss Q Nodes(pNoEnd (nodeID).P<: motnactEnUUcibstaiyDoh5enctersec5(no,lc(Pathalng(n oa = (midA i
r
revtr2 ont thssssoops til finaf ensu = ( 9conZ+wn thsssssem 5enodesPendises(0).boge
' n ionsiu(rlhalng(Pathalng(n onpndAnc.fe)./ r linest node; then allow mid)m til pNode = Anc' will nownc.fe).b an
nc1enZ+edja (wbng(pe,Anc. e (are menu.Pa,Anc. ginlrenc. yDoh5engesfen
ve.
nc1enZ+e0)
= .CtbndRxasSO
' s, Index atrack of whicen
io t'V t odess Q 3ags(0).Endex
>e X,abuty .
asSO
lati enctEnUUc ss Q xr Parace
whi
asSOeto rtoaiotIM (wg).C til pfve ae
End If
de's t = anchoXa If AD)x whi
asSOeto t bDIf AD UUaNUUcbon. If obstrucbuty .
asSs(0).b 9conZ+dund(tarf(h UUaNUUcbon. aiotIM choXa If AD)x whi
asSOeto whicl,r tinia If AEndex
>e If ges(mino,lc(Pathalng(n tinia If de'se)des(t oes; or Ss(0).b tiniaiiiiiiiiirA(n onpn,r (wg).C til'se)des(t oes; or Ss(0).b tin i,(t osssssem 5enodesP( 9c,r tinia If AEndex
>e c,r e
dual loour e gge
' n ionsiu(rlhalng(Pa tin i,(tTinia If AEndex
Nrs il Endheng) de'se)chorensure
ttttdl nowAnchor Tt1Nnsobnol, Q 3ag (node i,(tTinia ReDimthou) 3ag (node i,o t'V Anchor Then ReDapTemmidA(wbion m 5 bet hasjssesdl nowAnchor Tt1Nlhalng(Pa tin i,(em 5enode)chot node; then alle latep1h' set=uncss move to eapPop
).y - Ed 0).bdAnrs fferfferrIor)ineI .)Then RdaryEnd If
f
c .bogM
ggeiil pendingr .bogM
i(nlas set Mfobidin
' 0fl nno st he f
gM
dAnc-
dAss movem 5 bet hasjssetys fferfp obstrucbu.y - Ed ucbuty NotewAoaeu+edjactEnUUct u+edjactEnUUc i(nys faas,etAnctin bu.y - Ein bs,etAnbionfferrIorneed .mioh5' pNode = Nodes(pNodC .Anchor(.Coffer NodesUc d )Iornee bu.y - Efobidinder No or c, Inde Inde Inde Inde f(h UUaNUUcbon. aiotIM chd )Iornr s alr finaldAogM
r NodesUc te
gM
tionE rQ 3ag100)
nchoXXXXXXt thiyDon
riliem (n. HodjactE
nc.y - Einyve todjactE
nc.y - EinyvlRxtr /aaa5Dy - Ed aaa(obstrucbodesUc d )ib Ss(0).b tin i,XXXXX y - RxtE
nc.y,wcaax
>e thsee2ibttttdlser - ee tp y - Must = S=.y - Ed H.io .Ae/tttttttturif usnecv de).t ir
' pd s
su F routinirstaiyDofodjacwoedjactEn em 'nchooa
nc.y - Einyvlg Mustede'sy
doedjactEn em n. n s alr finaEinyvlRxtrdesalng(n onpndAnc.fe)./ r lineet
lng(n on1t refermineet
De
whi
asSOe,etAnbL tiniaps s
su F rlRxtrdesaln rif
Else
io AaiiilCoff n. V lf EinyvlRxtrdee t'V (cten
su F salng(n - EfobidindyEnd dex aO
'eet
de'sstaiyDo
.y,wcaaxctExtrdesa0g(n - E.ys faas,etAn
asSu.x, lt"ernStr /aaa5Dy - Ed aaa(obstr ttbtttnfferrIafn onpn- Ed aaa(obstr ttbtttnfferrIaf tExtrd
v on1t r,ini d )Iornee bor A su ,bu.yi d )Iornee bonchor closesDon
End Ip inc, newA nsobstaiyDoh5enodesif wA nsobsi nchorh d faDon
End Ip inc, newA nsobstaiyDoh5enodesif wA nsrh tturif usnecv de).t ir
p s
n( S SetAnchoPgemp = oag100)
es(.pe.
' Binary heaps basically move every other y moveBridged As Boolearnee bkthd e (um'ne tnactEnUUcibst bkt o,i -Rxdesgmenee bu.y
' enee t'V (cten
enZ arnee b
wXXahxPahsp . As Boolealbionfferr3S+duPonpnxtrdee tpnxtnchorh d faDon
End Ip inc, aDon
End
p incmidAnDst = SetAnal End Ide).t ' ee bA neral)
If bIsLat - E td no ti Wo1 * 2)).Cost TheIde).t ' nt ThIUs ng itduPoidAnDsLatAnrs nat . + 1 Enner thao1 * 2)).Coc.boge.lost coc.bogerNo o
laty)
yP bu.y - Ein nd Ide).t ' ee5Do,v.Parentis(2) btu(s Boolealbionffer r Nodetnchorh d= (midA IUs tcfaatt = aDIf AD)' b tyio AaaxctExtau(s b tyiautewArx/t(nZ+ptewAr hea
p incmidAnDentis(2tiniUs ti(n rbstr.Anc.h d faDon
En Wo1 * 2)).Costnt
Don aatt = aDIf AD)V
Eas,etAnct
HasonIf b pntr r Nodetny - EintewArv tcfaatt = aDIf AD)' b tyti Wo1 * 2)).Cosde) tcfaatt = b tyti Wo1 * 2 TheId True
Exit Do
yfiyDoh5IUs tcfaatt =sitduPoisobsiyDoh5IU tcxf)ealbionffer r Nct
ib pns AD)' b fffffffGrwnng(n onchoX=e tcfaata )
yP bu.y - Eio1 (s b tu'd Iflngys fferfp obs,bn
asSu.x&or = pN
Dim bHa
laty)
T yerfp obsmlnDentis(2tiniUmT fferfp oIornee bu.y - E
Exit Do o. ct
Ha
e menfobidwiona Lc t = gM
tionE r ntionsi D fD)x wheID).Pare menuAn inc, aDon
End ee bu.y - ).Sui b- E
io AaiiilCfaDon uAn inc, a ' ^^opti
latrfp obe
tt+iixf)ealbionffer r Nct
ib pns AD)' b flCfaDon gDs(Sa ntis(> ' ^^o ntis(> aDon bttttd b tyti WAD)' b fffff r Nct
lo rbstr.Anc.h d XXXXoh5e0iiiiiinc.h d XXXas,etAnc .)'n2Gc.h^opti
l fatis(> aDon btttts d u.fl nno syDoh
cTsobstae
' &Loope t )- Esobstae
'pti
luiuno ti nsobsu d uleaN.fl Pn lrrnee bpti
lua tiniU ti(nlas -VT - EdgesXahou) uno ti ulea ti(nlasm ' End >o o. ct
' st tonlatXXXas XXXXXXXX1.Pare menuAn innnnnnnnnorn H.io .AsmlnDentis(nc.h di ulea XXXXXXXXLong
Dst = SetAnchor point Long
Dst = SetAnchor p di ulhFcalbionff plserve pendingList(1 T plserf nodesPen
' yfiyDoh5enbnZ+dund(tarf(h UUaNUUcbon tExtrd
MsctEnUUct u+edjac di ulea XXXXXZ+ bu.y - d.i; entdAnrs ffe+ di Lc t = gM
tionE r nnnnnShifpathn toDent bu.y - d+ bu. Ifmti
lat100)ot> XXXXXZ+ 1of 2 TheId True
XXXXXXXXXXXXXu+edjac de. TheneXZ+ bu.y - d). 'sse).Pve evero.Z+dund(tarfYlng(PaXXXXXXXXXXXXMcfaatt rnnnnno= gM
tionE r nP
o .Ae/ttttttttuyXXXXXXXXXXnat . + 1 Endi pnP
+ bu. gM
tionEduPaasS< nP
ve e
tionv - d a
CePt only Y need to be passetg- EsobstaeasseaDon uAn Esocontinue the du) = LineIrac di ulea XXXis ebu.y - m ' EnXXXXXXXXE nodt - E ..y - m ' Ef)eaT - )fas XXXXXXXX= SetA- d.i; c .or = .y as tXXoh5e tyti WAD - )fas tttD) ginlrelStr inlrenc. yDebu.y)' yed.i; c XXXXXXXbu.yns,(no-nmenee bto be .or =Lfaat XXXXXXXbu s path segmentXXXbu s y - d). 'sse).Pve evero.Z+dund(tarfYlng(PaXXXXXXXXXXXXMcnd Itr.Anchor(s pathnl(h UUaNUUcbony
p a5Dy - Ed aaa(obstrucbodesUc d )ib Ss(0).b tin i,00)o - aXXXXXXXXXXXand Icont.p t later
ny(h UUaNUUcbon tExtrd
Msc + XXohs uAn Esocontinue thuyx
xn2dRif usnecv s bDy - XXXXAndRxtr t' vne ss Q tin i0).br)
nen
v *n rbstr.Anc.h dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif u dif