AdamAtomic/flixel — Issue #203: FlxQuadTrees.as - overlapProcessed isn't properly cleared
Author: ChainedLupine
Created: 2011-11-28 01:44:35+00:00
State: open

In FlxQuadTrees.as, around line 568, the overlapProcessed flag isn't be cleared every cycle through the iterator. This will cause problems if you are using processingCallback to prevent overlap detection in certain circumstances.

Example: Using FlxQuadTrees as a broad-phase detector and doing more detailed collision detection in the processingCallback.

This leads to notifyCallbacks being called where they shouldn't be, so false positives in the example above.

Corrected version below:

//check for intersection of the two hulls
if(	(_objectHullX + _objectHullWidth > _checkObjectHullX) &&
(_objectHullX < _checkObjectHullX + _checkObjectHullWidth) &&
(_objectHullY + _objectHullHeight > _checkObjectHullY) &&
(_objectHullY < _checkObjectHullY + _checkObjectHullHeight) )
{
overlapProcessed = false ; // bugfix, this should be set to false on every iterative check

//Execute callback functions if they exist
if((_processingCallback == null) || _processingCallback(_object,checkObject))
overlapProcessed = true;
if(overlapProcessed && (_notifyCallback != null))
_notifyCallback(_object,checkObject);
}
_iterator = _iterator.next;