@@ -167,7 +167,7 @@ func (v *Visibility) computePolygon(viewPt geom.Point, lines []geom.Line) []geom
167167 remove (mapper .elem (sorted [i ].lineIndex ), heap , mapper , lines , viewPt , vertex )
168168 } else {
169169 insert (sorted [i ].lineIndex , heap , mapper , lines , viewPt , vertex )
170- if heap .size () == 0 || heap . elem (0 ) != oldLine {
170+ if heap .elem (0 ) != oldLine {
171171 shorten = true
172172 }
173173 }
@@ -178,12 +178,10 @@ func (v *Visibility) computePolygon(viewPt geom.Point, lines []geom.Line) []geom
178178 }
179179 if extend {
180180 polygon = append (polygon , geom.Point {X : vertex .X , Y : vertex .Y })
181- if heap .size () > 0 {
182- line := lines [heap .elem (0 )]
183- if cur , intersects := intersectLines (line .Start , line .End , viewPt , vertex ); intersects &&
184- ! cur .EqualWithin (vertex , epsilon ) {
185- polygon = append (polygon , geom.Point {X : cur .X , Y : cur .Y })
186- }
181+ line := lines [heap .elem (0 )]
182+ if cur , intersects := intersectLines (line .Start , line .End , viewPt , vertex ); intersects &&
183+ ! cur .EqualWithin (vertex , epsilon ) {
184+ polygon = append (polygon , geom.Point {X : cur .X , Y : cur .Y })
187185 }
188186 } else if shorten {
189187 line := lines [oldLine ]
@@ -257,9 +255,6 @@ loop:
257255}
258256
259257func insert (index int , heap , mapper * array , lines []geom.Line , position , destination geom.Point ) {
260- // if _, intersects := intersectLines(lines[index].Start, lines[index].End, position, destination); !intersects {
261- // return
262- // }
263258 cur := heap .size ()
264259 heap .push (index )
265260 mapper .set (index , cur )
0 commit comments