1 package org.jbox2d.collision.broadphase; 2 3 import org.jbox2d.callbacks.DebugDraw; 4 import org.jbox2d.callbacks.TreeCallback; 5 import org.jbox2d.callbacks.TreeRayCastCallback; 6 import org.jbox2d.collision.AABB; 7 import org.jbox2d.collision.RayCastInput; 8 import org.jbox2d.common.Vec2; 9 10 public interface BroadPhaseStrategy { 11 12 /** 13 * Create a proxy. Provide a tight fitting AABB and a userData pointer. 14 * 15 * @param aabb 16 * @param userData 17 * @return 18 */ 19 int createProxy(AABB aabb, Object userData); 20 21 /** 22 * Destroy a proxy 23 * 24 * @param proxyId 25 */ 26 void destroyProxy(int proxyId); 27 28 /** 29 * Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB, then the 30 * proxy is removed from the tree and re-inserted. Otherwise the function returns immediately. 31 * 32 * @return true if the proxy was re-inserted. 33 */ 34 boolean moveProxy(int proxyId, AABB aabb, Vec2 displacement); 35 36 Object getUserData(int proxyId); 37 38 AABB getFatAABB(int proxyId); 39 40 /** 41 * Query an AABB for overlapping proxies. The callback class is called for each proxy that 42 * overlaps the supplied AABB. 43 * 44 * @param callback 45 * @param araabbgAABB 46 */ 47 void query(TreeCallback callback, AABB aabb); 48 49 /** 50 * Ray-cast against the proxies in the tree. This relies on the callback to perform a exact 51 * ray-cast in the case were the proxy contains a shape. The callback also performs the any 52 * collision filtering. This has performance roughly equal to k * log(n), where k is the number of 53 * collisions and n is the number of proxies in the tree. 54 * 55 * @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). 56 * @param callback a callback class that is called for each proxy that is hit by the ray. 57 */ 58 void raycast(TreeRayCastCallback callback, RayCastInput input); 59 60 /** 61 * Compute the height of the tree. 62 */ 63 int computeHeight(); 64 65 /** 66 * Compute the height of the binary tree in O(N) time. Should not be called often. 67 * 68 * @return 69 */ 70 int getHeight(); 71 72 /** 73 * Get the maximum balance of an node in the tree. The balance is the difference in height of the 74 * two children of a node. 75 * 76 * @return 77 */ 78 int getMaxBalance(); 79 80 /** 81 * Get the ratio of the sum of the node areas to the root area. 82 * 83 * @return 84 */ 85 float getAreaRatio(); 86 87 void drawTree(DebugDraw draw); 88 }