/* * Make this faster by building the list to push here */ public void AddObject(PPObject obj) { if (obj != null) { if (CheckBounds(obj, bbox)) { objectList.Add(obj); } } }
public bool CheckBounds(PPObject obj, BBox region) { float x1 = obj.position.x; float w1 = obj.bbox.xmax - obj.bbox.xmin; float y1 = obj.position.y; float h1 = obj.bbox.ymax - obj.bbox.ymin; float dx = Math.Abs(x1 - position.x); float dy = Math.Abs(y1 - position.y); if (dx < ((width + w1) * 0.5f) && dy < (height + h1) * 0.5f) { return(true); } return(false); }