Skip to content

Commit

Permalink
fix #24 crash when using spatial hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman committed Jul 4, 2022
1 parent eaeb481 commit a283908
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions spacehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (hash *SpaceHash) Query(obj interface{}, bb BB, f SpatialIndexQuery, data i
hash.stamp++
}

func (hash *SpaceHash) segmentQueryHelper(binPtr **SpaceHashBin, obj *Shape, f SpatialIndexSegmentQuery, data interface{}) float64 {
func (hash *SpaceHash) segmentQueryHelper(binPtr **SpaceHashBin, obj interface{}, f SpatialIndexSegmentQuery, data interface{}) float64 {
t := 1.0

restart:
Expand All @@ -236,7 +236,6 @@ restart:

// modified from http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html
func (hash *SpaceHash) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{}) {
shape := obj.(*Shape)
a = a.Mult(1.0 / hash.celldim)
b = b.Mult(1.0 / hash.celldim)

Expand Down Expand Up @@ -293,7 +292,7 @@ func (hash *SpaceHash) SegmentQuery(obj interface{}, a, b Vector, t_exit float64

for t < t_exit {
idx := hashFunc(HashValue(cellX), HashValue(cellY), HashValue(hash.numCells))
t_exit = math.Min(t_exit, hash.segmentQueryHelper(&hash.table[idx], shape, f, data))
t_exit = math.Min(t_exit, hash.segmentQueryHelper(&hash.table[idx], obj, f, data))

if nextV < nextH {
cellY += yInc
Expand Down

0 comments on commit a283908

Please sign in to comment.