public void SplitToRects() { if (level >= MAX_LEVEL) { return; } numLevels++; float subWidth = bounds.halfDims.X; float subHeight = bounds.halfDims.Y; float x = bounds.topLeft.X; float y = bounds.topLeft.Y; pNW = new cQuadTree <T>(level + 1, new AABB(new Vector2f(x, y), new Vector2f(subWidth, subHeight)), refState); pNE = new cQuadTree <T>(level + 1, new AABB(new Vector2f(x + subWidth, y), new Vector2f(subWidth, subHeight)), refState); pSW = new cQuadTree <T>(level + 1, new AABB(new Vector2f(x, y + subHeight), new Vector2f(subWidth, subHeight)), refState); pSE = new cQuadTree <T>(level + 1, new AABB(new Vector2f(x + subWidth, y + subHeight), new Vector2f(subWidth, subHeight)), refState); }
public bool Contains(cQuadTree <T> child, T entity) { //bool b = (cCollision.OverlapAABB(child.Bounds, entity.Bounds)); //bool b = pChild->GetBounds().AsFloatRect().intersects(pEntity->GetBoundingBox().AsFloatRect()); return(cCollision.OverlapAABB(child.Bounds, entity.Bounds)); }