Package org.jbox2d.collision
Class Collision
- java.lang.Object
-
- org.jbox2d.collision.Collision
-
public class Collision extends java.lang.ObjectFunctions used for computing contact points, distance queries, and TOI queries. Collision methods are non-static for pooling speed, retrieve a collision object from theSingletonPool. Should not be finalructed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCollision.ClipVertexUsed for computing contact manifolds.private static classCollision.EdgeResultsJava-specific class for returning edge results(package private) static classCollision.EPAxisThis structure is used to keep track of the best separating axis.(package private) static classCollision.EPColliderThis class collides and edge and a polygon, taking into account edge adjacency.static classCollision.PointStateThis is used for determining the state of contact points.(package private) static classCollision.ReferenceFaceReference face used for clipping(package private) static classCollision.TempPolygonThis holds polygon B expressed in frame A.
-
Field Summary
Fields Modifier and Type Field Description private Distance.SimplexCachecacheprivate ContactIDcfprivate Collision.ClipVertex[]clipPoints1private Collision.ClipVertex[]clipPoints2private Collision.EPCollidercolliderprivate static Vec2dprivate Vec2eprivate Vec2e1private Collision.ClipVertex[]incidentEdgeprivate DistanceInputinputprivate Vec2localNormalprivate Vec2localTangentprivate Vec2nstatic intNULL_FEATUREprivate DistanceOutputoutputprivate Vec2Pprivate Vec2planePointprivate IWorldPoolpoolprivate Vec2Qprivate Collision.EdgeResultsresults1private Collision.EdgeResultsresults2private Vec2tangentprivate Vec2tempprivate Vec2v11private Vec2v12
-
Constructor Summary
Constructors Constructor Description Collision(IWorldPool argPool)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intclipSegmentToLine(Collision.ClipVertex[] vOut, Collision.ClipVertex[] vIn, Vec2 normal, float offset, int vertexIndexA)Clipping for contact manifolds.voidcollideCircles(Manifold manifold, CircleShape circle1, Transform xfA, CircleShape circle2, Transform xfB)Compute the collision manifold between two circles.voidcollideEdgeAndCircle(Manifold manifold, EdgeShape edgeA, Transform xfA, CircleShape circleB, Transform xfB)voidcollideEdgeAndPolygon(Manifold manifold, EdgeShape edgeA, Transform xfA, PolygonShape polygonB, Transform xfB)voidcollidePolygonAndCircle(Manifold manifold, PolygonShape polygon, Transform xfA, CircleShape circle, Transform xfB)Compute the collision manifold between a polygon and a circle.voidcollidePolygons(Manifold manifold, PolygonShape polyA, Transform xfA, PolygonShape polyB, Transform xfB)Compute the collision manifold between two polygons.floatedgeSeparation(PolygonShape poly1, Transform xf1, int edge1, PolygonShape poly2, Transform xf2)Find the separation between poly1 and poly2 for a given edge normal on poly1.voidfindIncidentEdge(Collision.ClipVertex[] c, PolygonShape poly1, Transform xf1, int edge1, PolygonShape poly2, Transform xf2)voidfindMaxSeparation(Collision.EdgeResults results, PolygonShape poly1, Transform xf1, PolygonShape poly2, Transform xf2)Find the max separation between poly1 and poly2 using edge normals from poly1.static voidgetPointStates(Collision.PointState[] state1, Collision.PointState[] state2, Manifold manifold1, Manifold manifold2)Compute the point states given two manifolds.booleantestOverlap(Shape shapeA, int indexA, Shape shapeB, int indexB, Transform xfA, Transform xfB)Determine if two generic shapes overlap.
-
-
-
Field Detail
-
NULL_FEATURE
public static final int NULL_FEATURE
- See Also:
- Constant Field Values
-
pool
private final IWorldPool pool
-
input
private final DistanceInput input
-
cache
private final Distance.SimplexCache cache
-
output
private final DistanceOutput output
-
d
private static Vec2 d
-
temp
private final Vec2 temp
-
results1
private final Collision.EdgeResults results1
-
results2
private final Collision.EdgeResults results2
-
incidentEdge
private final Collision.ClipVertex[] incidentEdge
-
localTangent
private final Vec2 localTangent
-
localNormal
private final Vec2 localNormal
-
planePoint
private final Vec2 planePoint
-
tangent
private final Vec2 tangent
-
v11
private final Vec2 v11
-
v12
private final Vec2 v12
-
clipPoints1
private final Collision.ClipVertex[] clipPoints1
-
clipPoints2
private final Collision.ClipVertex[] clipPoints2
-
Q
private final Vec2 Q
-
e
private final Vec2 e
-
cf
private final ContactID cf
-
e1
private final Vec2 e1
-
P
private final Vec2 P
-
n
private final Vec2 n
-
collider
private final Collision.EPCollider collider
-
-
Constructor Detail
-
Collision
public Collision(IWorldPool argPool)
-
-
Method Detail
-
testOverlap
public final boolean testOverlap(Shape shapeA, int indexA, Shape shapeB, int indexB, Transform xfA, Transform xfB)
Determine if two generic shapes overlap.- Parameters:
shapeA-shapeB-xfA-xfB-- Returns:
-
getPointStates
public static final void getPointStates(Collision.PointState[] state1, Collision.PointState[] state2, Manifold manifold1, Manifold manifold2)
Compute the point states given two manifolds. The states pertain to the transition from manifold1 to manifold2. So state1 is either persist or remove while state2 is either add or persist.- Parameters:
state1-state2-manifold1-manifold2-
-
clipSegmentToLine
public static final int clipSegmentToLine(Collision.ClipVertex[] vOut, Collision.ClipVertex[] vIn, Vec2 normal, float offset, int vertexIndexA)
Clipping for contact manifolds. Sutherland-Hodgman clipping.- Parameters:
vOut-vIn-normal-offset-- Returns:
-
collideCircles
public final void collideCircles(Manifold manifold, CircleShape circle1, Transform xfA, CircleShape circle2, Transform xfB)
Compute the collision manifold between two circles.- Parameters:
manifold-circle1-xfA-circle2-xfB-
-
collidePolygonAndCircle
public final void collidePolygonAndCircle(Manifold manifold, PolygonShape polygon, Transform xfA, CircleShape circle, Transform xfB)
Compute the collision manifold between a polygon and a circle.- Parameters:
manifold-polygon-xfA-circle-xfB-
-
edgeSeparation
public final float edgeSeparation(PolygonShape poly1, Transform xf1, int edge1, PolygonShape poly2, Transform xf2)
Find the separation between poly1 and poly2 for a given edge normal on poly1.- Parameters:
poly1-xf1-edge1-poly2-xf2-
-
findMaxSeparation
public final void findMaxSeparation(Collision.EdgeResults results, PolygonShape poly1, Transform xf1, PolygonShape poly2, Transform xf2)
Find the max separation between poly1 and poly2 using edge normals from poly1.- Parameters:
edgeIndex-poly1-xf1-poly2-xf2-
-
findIncidentEdge
public final void findIncidentEdge(Collision.ClipVertex[] c, PolygonShape poly1, Transform xf1, int edge1, PolygonShape poly2, Transform xf2)
-
collidePolygons
public final void collidePolygons(Manifold manifold, PolygonShape polyA, Transform xfA, PolygonShape polyB, Transform xfB)
Compute the collision manifold between two polygons.- Parameters:
manifold-polygon1-xf1-polygon2-xf2-
-
collideEdgeAndCircle
public void collideEdgeAndCircle(Manifold manifold, EdgeShape edgeA, Transform xfA, CircleShape circleB, Transform xfB)
-
collideEdgeAndPolygon
public void collideEdgeAndPolygon(Manifold manifold, EdgeShape edgeA, Transform xfA, PolygonShape polygonB, Transform xfB)
-
-