Package org.jbox2d.dynamics.contacts
Class Contact
java.lang.Object
org.jbox2d.dynamics.contacts.Contact
- Direct Known Subclasses:
ChainAndCircleContact,ChainAndPolygonContact,CircleContact,EdgeAndCircleContact,EdgeAndPolygonContact,PolygonAndCircleContact,PolygonContact
The class manages contact between two shapes. A contact exists for each
overlapping AABB in the broad-phase (except if filtered). Therefore, a
contact object may exist that has no contact points.
- Author:
- Daniel Murphy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis bullet contact had a TOI eventstatic final intThis contact can be disabled (by user)static final intThis contact needs filtering because a fixture filter was changed.intfloatintintstatic final intFlags stored in flags Used when crawling contact graph when forming islands.final ManifoldNodes for connecting bodies.protected final WorldPoolWorld pool and list pointers.floatfloatfloatstatic final intfloatstatic final intSet when the shapes are touching. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidEvaluate this contact with your own manifold and transforms.voidFlag this contact for filtering.intGet the child primitive index for fixture A.intGet the child primitive index for fixture B.Get fixture A in this contact.Get fixture B in this contact.floatGet the friction.Get the contact manifold.getNext()Get the next contact in the world’s contact list.floatGet the restitution.floatGet the desired tangent speed.voidgetWorldManifold(WorldManifold worldManifold) Get the world manifold.voidinitialization for poolingbooleanHas this contact been disabled?booleanIs this contact touching?static floatmixFriction(float friction1, float friction2) Friction mixing law.static floatmixRestitution(float restitution1, float restitution2) Restitution mixing law.voidReset the friction mixture to the default value.voidReset the restitution to the default value.voidsetEnabled(boolean flag) Enable/disable this contact.voidsetFriction(float friction) Override the default friction mixture.voidsetRestitution(float restitution) Override the default restitution mixture.voidsetTangentSpeed(float speed) Set the desired tangent speed for a conveyor belt behavior.voidupdate(ContactListener listener)
-
Field Details
-
ISLAND_FLAG
public static final int ISLAND_FLAGFlags stored in flags Used when crawling contact graph when forming islands.- See Also:
-
TOUCHING_FLAG
public static final int TOUCHING_FLAGSet when the shapes are touching.- See Also:
-
ENABLED_FLAG
public static final int ENABLED_FLAGThis contact can be disabled (by user)- See Also:
-
FILTER_FLAG
public static final int FILTER_FLAGThis contact needs filtering because a fixture filter was changed.- See Also:
-
BULLET_HIT_FLAG
public static final int BULLET_HIT_FLAGThis bullet contact had a TOI event- See Also:
-
TOI_FLAG
public static final int TOI_FLAG- See Also:
-
flags
public int flags -
prev
World pool and list pointers. -
next
-
nodeA
Nodes for connecting bodies. -
nodeB
-
fixtureA
-
fixtureB
-
indexA
public int indexA -
indexB
public int indexB -
manifold
-
toiCount
public float toiCount -
toi
public float toi -
friction
public float friction -
restitution
public float restitution -
tangentSpeed
public float tangentSpeed -
pool
-
-
Constructor Details
-
Contact
-
-
Method Details
-
init
initialization for pooling -
getManifold
Get the contact manifold. Do not modify the manifold unless you understand the internals of JBox2D. -
getWorldManifold
Get the world manifold. -
isTouching
public boolean isTouching()Is this contact touching? -
setEnabled
public void setEnabled(boolean flag) Enable/disable this contact.This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).
- Parameters:
flag-trueif the contact should be enable elsefalse.
-
isEnabled
public boolean isEnabled()Has this contact been disabled? -
getNext
Get the next contact in the world’s contact list. -
getFixtureA
Get fixture A in this contact. -
getChildIndexA
public int getChildIndexA()Get the child primitive index for fixture A. -
getFixtureB
Get fixture B in this contact. -
getChildIndexB
public int getChildIndexB()Get the child primitive index for fixture B. -
setFriction
public void setFriction(float friction) Override the default friction mixture. You can call this inContactListener.preSolve(Contact, Manifold). This value persists until set or reset. -
getFriction
public float getFriction()Get the friction. -
resetFriction
public void resetFriction()Reset the friction mixture to the default value. -
setRestitution
public void setRestitution(float restitution) Override the default restitution mixture. You can call this inContactListener.preSolve(Contact, Manifold). The value persists until you set or reset. -
getRestitution
public float getRestitution()Get the restitution. -
resetRestitution
public void resetRestitution()Reset the restitution to the default value. -
setTangentSpeed
public void setTangentSpeed(float speed) Set the desired tangent speed for a conveyor belt behavior. In meters per second. -
getTangentSpeed
public float getTangentSpeed()Get the desired tangent speed. In meters per second.- Returns:
- the desired tangent speed. In meters per second.
-
evaluate
Evaluate this contact with your own manifold and transforms. -
flagForFiltering
public void flagForFiltering()Flag this contact for filtering. Filtering will occur the next time step. -
update
-
mixFriction
public static float mixFriction(float friction1, float friction2) Friction mixing law. The idea is to allow either fixture to drive the restitution to zero. For example, anything slides on ice. -
mixRestitution
public static float mixRestitution(float restitution1, float restitution2) Restitution mixing law. The idea is allowed for anything to bounce off an inelastic surface. For example, a superball bounces on anything.
-