1 package org.jbox2d.collision.broadphase; 2 3 import org.jbox2d.callbacks.DebugDraw; 4 import org.jbox2d.callbacks.PairCallback; 5 import org.jbox2d.callbacks.TreeCallback; 6 import org.jbox2d.callbacks.TreeRayCastCallback; 7 import org.jbox2d.collision.AABB; 8 import org.jbox2d.collision.RayCastInput; 9 import org.jbox2d.common.Vec2; 10 11 12 public interface BroadPhase { 13 14 public static final int NULL_PROXY = -1; 15 16 /** 17 * Create a proxy with an initial AABB. Pairs are not reported until updatePairs is called. 18 * 19 * @param aabb 20 * @param userData 21 * @return 22 */ 23 int createProxy(AABB aabb, Object userData); 24 25 /** 26 * Destroy a proxy. It is up to the client to remove any pairs. 27 * 28 * @param proxyId 29 */ 30 void destroyProxy(int proxyId); 31 32 /** 33 * Call MoveProxy as many times as you like, then when you are done call UpdatePairs to finalized 34 * the proxy pairs (for your time step). 35 */ 36 void moveProxy(int proxyId, AABB aabb, Vec2 displacement); 37 38 void touchProxy(int proxyId); 39 40 Object getUserData(int proxyId); 41 42 AABB getFatAABB(int proxyId); 43 44 boolean testOverlap(int proxyIdA, int proxyIdB); 45 46 /** 47 * Get the number of proxies. 48 * 49 * @return 50 */ 51 int getProxyCount(); 52 53 void drawTree(DebugDraw argDraw); 54 55 /** 56 * Update the pairs. This results in pair callbacks. This can only add pairs. 57 * 58 * @param callback 59 */ 60 void updatePairs(PairCallback callback); 61 62 /** 63 * Query an AABB for overlapping proxies. The callback class is called for each proxy that 64 * overlaps the supplied AABB. 65 * 66 * @param callback 67 * @param aabb 68 */ 69 void query(TreeCallback callback, AABB aabb); 70 71 /** 72 * Ray-cast against the proxies in the tree. This relies on the callback to perform a exact 73 * ray-cast in the case were the proxy contains a shape. The callback also performs the any 74 * collision filtering. This has performance roughly equal to k * log(n), where k is the number of 75 * collisions and n is the number of proxies in the tree. 76 * 77 * @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). 78 * @param callback a callback class that is called for each proxy that is hit by the ray. 79 */ 80 void raycast(TreeRayCastCallback callback, RayCastInput input); 81 82 /** 83 * Get the height of the embedded tree. 84 * 85 * @return 86 */ 87 int getTreeHeight(); 88 89 int getTreeBalance(); 90 91 float getTreeQuality(); 92 } 93