@@ -325,10 +325,9 @@ protected boolean insert(AABB b) {
325
325
return true ;
326
326
}
327
327
return false ;
328
+ } else {
329
+ return true ;
328
330
}
329
-
330
- // Otherwise, the point cannot be inserted for some unknown reason (which should never happen)
331
- return false ;
332
331
}
333
332
334
333
private void subdivide () {
@@ -352,13 +351,12 @@ private void subdivide() {
352
351
}
353
352
354
353
private boolean insertIntoChildren (AABB b ) {
355
- //Try to insert into all children, it will fail on children which don't intersect box
356
- boolean successful = false ;
357
- successful = northWest .insert (b );
358
- successful = (successful || northEast .insert (b ));
359
- successful = (successful || southWest .insert (b ));
360
- successful = (successful || southEast .insert (b ));
361
- return successful ;
354
+ //Try to insert into all children
355
+ if (northWest .insert (b )) return true ;
356
+ if (northEast .insert (b )) return true ;
357
+ if (southWest .insert (b )) return true ;
358
+ if (southEast .insert (b )) return true ;
359
+ return false ;
362
360
}
363
361
364
362
/**
@@ -369,16 +367,18 @@ protected void queryRange(AxisAlignedBoundingBox range, List<AABB> geometricObje
369
367
// Automatically abort if the range does not collide with this quad
370
368
if (!aabb .intersectsBox (range )) return ;
371
369
372
- // If leaf, check objects at this level
370
+ // Check objects at this level
373
371
for (AABB b : aabbs ) {
374
372
if (range .intersectsBox (b )) geometricObjectsInRange .add (b );
375
373
}
376
374
377
- // Otherwise, add the points from the children
378
- if (northWest !=null ) northWest .queryRange (range ,geometricObjectsInRange );
379
- if (northEast !=null ) northEast .queryRange (range ,geometricObjectsInRange );
380
- if (southWest !=null ) southWest .queryRange (range ,geometricObjectsInRange );
381
- if (southEast !=null ) southEast .queryRange (range ,geometricObjectsInRange );
375
+ // Otherwise, add the objects from the children
376
+ if (!isLeaf ()) {
377
+ northWest .queryRange (range ,geometricObjectsInRange );
378
+ northEast .queryRange (range ,geometricObjectsInRange );
379
+ southWest .queryRange (range ,geometricObjectsInRange );
380
+ southEast .queryRange (range ,geometricObjectsInRange );
381
+ }
382
382
}
383
383
384
384
/**
0 commit comments