java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.Contact
- All Implemented Interfaces:
ConstContact
,ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
Describe a contact between a
Character
and a body or another
character. (native type: CharacterVirtual::Contact
)-
Method Summary
Modifier and TypeMethodDescriptionint
getBodyB()
Return the ID of the colliding body.boolean
Test whether the velocity of the contact point can push the character.Return the colliding character.Return the contact normal.float
Return the contact separation.float
Return the fraction along the path where the contact takes place.boolean
Test whether the character has actually collided.boolean
Test whether the colliding object is a sensor.Copy the velocity of the contact point.Return the motion type of the colliding object.Copy the location where the contact occurs.int
Return the sub-shape ID of the colliding body.Copy the surface normal of the contact.long
Return the user data of the colliding object.boolean
Test whether the contact was discarded by the contact-validate callback.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Method Details
-
getBodyB
public int getBodyB()Return the ID of the colliding body. The contact is unaffected. (native attribute: mBodyB)- Specified by:
getBodyB
in interfaceConstContact
- Returns:
- the
BodyID
value
-
getCanPushCharacter
public boolean getCanPushCharacter()Test whether the velocity of the contact point can push the character. The contact is unaffected. (native attribute: mCanPushCharacter)- Specified by:
getCanPushCharacter
in interfaceConstContact
- Returns:
true
if can push, otherwisefalse
-
getCharacterB
Return the colliding character. The contact is unaffected. (native attribute: mCharacterB)- Specified by:
getCharacterB
in interfaceConstContact
- Returns:
- a new JVM object with the pre-existing native object assigned, or
null
if no colliding character
-
getContactNormal
Return the contact normal. The contact is unaffected. (native attribute: mContactNormal)- Specified by:
getContactNormal
in interfaceConstContact
- Returns:
- a new direction vector, pointing toward the character
-
getDistance
public float getDistance()Return the contact separation. The contact is unaffected. (native attribute: mDistance)- Specified by:
getDistance
in interfaceConstContact
- Returns:
- the signed distance (in meters, ≤0→actual contact, >0→predictive contact)
-
getFraction
public float getFraction()Return the fraction along the path where the contact takes place. The contact is unaffected. (native attribute: mFraction)- Specified by:
getFraction
in interfaceConstContact
- Returns:
- the fraction
-
getHadCollision
public boolean getHadCollision()Test whether the character has actually collided. The contact is unaffected. (native attribute: mHadCollision)- Specified by:
getHadCollision
in interfaceConstContact
- Returns:
true
if a real collision,false
for a predictive contact that never became a real one
-
getIsSensorB
public boolean getIsSensorB()Test whether the colliding object is a sensor. The contact is unaffected. (native attribute: mIsSensorB)- Specified by:
getIsSensorB
in interfaceConstContact
- Returns:
true
for a sensor, otherwisefalse
-
getLinearVelocity
Copy the velocity of the contact point. The contact is unaffected. (native attribute: mLinearVelocity)- Specified by:
getLinearVelocity
in interfaceConstContact
- Returns:
- a new velocity vector
-
getMotionTypeB
Return the motion type of the colliding object. The contact is unaffected. (native attribute: mGetMotionTypeB)- Specified by:
getMotionTypeB
in interfaceConstContact
- Returns:
- an enum value (not null)
-
getPosition
Copy the location where the contact occurs. The contact is unaffected. (native attribute: mPosition)- Specified by:
getPosition
in interfaceConstContact
- Returns:
- a new vector (in system coordinates)
-
getSubShapeIdB
public int getSubShapeIdB()Return the sub-shape ID of the colliding body. The contact is unaffected. (native attribute: mSubShapeIDB)- Specified by:
getSubShapeIdB
in interfaceConstContact
- Returns:
- a
SubShapeID
value
-
getSurfaceNormal
Copy the surface normal of the contact. The contact is unaffected. (native attribute: mSurfaceNormal)- Specified by:
getSurfaceNormal
in interfaceConstContact
- Returns:
- a new direction vector
-
getUserData
public long getUserData()Return the user data of the colliding object. The contact is unaffected. (native attribute: mUserData)- Specified by:
getUserData
in interfaceConstContact
- Returns:
- the data value
-
getWasDiscarded
public boolean getWasDiscarded()Test whether the contact was discarded by the contact-validate callback. The contact is unaffected. (native attribute: mWasDiscarded)- Specified by:
getWasDiscarded
in interfaceConstContact
- Returns:
true
if discarded, otherwisefalse
-