Class CustomCharacterContactListener

java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.CustomCharacterContactListener
All Implemented Interfaces:
CharacterContactListener, ConstJoltPhysicsObject, AutoCloseable, Comparable<ConstJoltPhysicsObject>

public class CustomCharacterContactListener extends JoltPhysicsObject implements CharacterContactListener
A customizable CharacterContactListener.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate a customizable listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onAdjustBodyVelocity(long characterVa, long body2Va, float[] velocities)
    Callback invoked (by native code) to adjust the velocity of the specified body as seen by the specified character.
    void
    onCharacterContactAdded(long characterVa, long otherCharacterVa, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, long settingsVa)
    Callback invoked (by native code) whenever 2 characters collide.
    void
    onCharacterContactSolve(long characterVa, long otherCharacterVa, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, float contactVelocityX, float contactVelocityY, float contactVelocityZ, long materialVa, float characterVelocityX, float characterVelocityY, float characterVelocityZ, float[] newCharacterVelocity)
    Callback invoked (by native code) whenever a character-versus-character contact is being solved.
    boolean
    onCharacterContactValidate(long characterVa, long otherCharacterVa, long subShapeId2Va)
    Callback invoked (by native code) to test whether the specified characters can collide.
    void
    onContactAdded(long characterVa, long bodyId2Va, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, long settingsVa)
    Callback invoked (by native code) whenever a character collides with a body.
    void
    onContactSolve(long characterVa, long bodyId2Va, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, float contactVelocityX, float contactVelocityY, float contactVelocityZ, long materialVa, float characterVelocityX, float characterVelocityY, float characterVelocityZ, float[] newCharacterVelocity)
    Callback invoked (by native code) whenever a character-versus-body contact is being solved.
    boolean
    onContactValidate(long characterVa, long bodyId2Va, long subShapeId2Va)
    Callback invoked (by native code) to test whether the specified character can collide with the specified body.

    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, va
  • Constructor Details

    • CustomCharacterContactListener

      public CustomCharacterContactListener()
      Instantiate a customizable listener.
  • Method Details

    • onAdjustBodyVelocity

      public void onAdjustBodyVelocity(long characterVa, long body2Va, float[] velocities)
      Callback invoked (by native code) to adjust the velocity of the specified body as seen by the specified character.
      Specified by:
      onAdjustBodyVelocity in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual (not zero)
      body2Va - the virtual address of the ConstBody (not zero)
      velocities - the components of the linear and angular velocities (length≥6, may be modified)
    • onCharacterContactAdded

      public void onCharacterContactAdded(long characterVa, long otherCharacterVa, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, long settingsVa)
      Callback invoked (by native code) whenever 2 characters collide.
      Specified by:
      onCharacterContactAdded in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual being solved (not zero)
      otherCharacterVa - the virtual address of the other ConstCharacterVirtual (not zero)
      subShapeId2Va - the virtual address of the ConstSubShapeId of the shape that is being hit (not zero)
      contactLocationX - the X component of the contact location (in system coordinates)
      contactLocationY - the Y component of the contact location (in system coordinates)
      contactLocationZ - the Z component of the contact location (in system coordinates)
      contactNormalX - the X component of the contact normal (in system coordinates)
      contactNormalY - the Y component of the contact normal (in system coordinates)
      contactNormalZ - the Z component of the contact normal (in system coordinates)
      settingsVa - the virtual address of the CharacterContactSettings for storing the desired behavior
    • onCharacterContactSolve

      public void onCharacterContactSolve(long characterVa, long otherCharacterVa, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, float contactVelocityX, float contactVelocityY, float contactVelocityZ, long materialVa, float characterVelocityX, float characterVelocityY, float characterVelocityZ, float[] newCharacterVelocity)
      Callback invoked (by native code) whenever a character-versus-character contact is being solved.
      Specified by:
      onCharacterContactSolve in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual being solved (not zero)
      otherCharacterVa - the virtual address of the other ConstCharacterVirtual (not zero)
      subShapeId2Va - the virtual address of the ConstSubShapeId of the shape that is being hit (not zero)
      contactLocationX - the X component of the contact location (in system coordinates)
      contactLocationY - the Y component of the contact location (in system coordinates)
      contactLocationZ - the Z component of the contact location (in system coordinates)
      contactNormalX - the X component of the contact normal (in system coordinates)
      contactNormalY - the Y component of the contact normal (in system coordinates)
      contactNormalZ - the Z component of the contact normal (in system coordinates)
      contactVelocityX - the X component of the velocity of the contact point (meters per second in system coordinates)
      contactVelocityY - the Y component of the velocity of the contact point (meters per second in system coordinates)
      contactVelocityZ - the Z component of the velocity of the contact point (meters per second in system coordinates)
      materialVa - the virtual address of the ConstPhysicsMaterial at the contact point (not zero)
      characterVelocityX - the X component of the character's prior velocity (in system coordinates)
      characterVelocityY - the Y component of the character's prior velocity (in system coordinates)
      characterVelocityZ - the Z component of the character's prior velocity (in system coordinates)
      newCharacterVelocity - storage for the new velocity vector (in system coordinates, length≥3)
    • onCharacterContactValidate

      public boolean onCharacterContactValidate(long characterVa, long otherCharacterVa, long subShapeId2Va)
      Callback invoked (by native code) to test whether the specified characters can collide.
      Specified by:
      onCharacterContactValidate in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual being solved (not zero)
      otherCharacterVa - the virtual address of the other ConstCharacterVirtual (not zero)
      subShapeId2Va - the virtual address of the ConstSubShapeId of the shape that is being hit (not zero)
      Returns:
      true if the contact is valid, otherwise false
    • onContactAdded

      public void onContactAdded(long characterVa, long bodyId2Va, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, long settingsVa)
      Callback invoked (by native code) whenever a character collides with a body.
      Specified by:
      onContactAdded in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual being solved (not zero)
      bodyId2Va - the virtual address of the ConstBody being solved (not zero)
      subShapeId2Va - the virtual address of the ConstSubShapeId of the shape that is being hit (not zero)
      contactLocationX - the X component of the contact location (in system coordinates)
      contactLocationY - the Y component of the contact location (in system coordinates)
      contactLocationZ - the Z component of the contact location (in system coordinates)
      contactNormalX - the X component of the contact normal (in system coordinates)
      contactNormalY - the Y component of the contact normal (in system coordinates)
      contactNormalZ - the Z component of the contact normal (in system coordinates)
      settingsVa - the virtual address of the CharacterContactSettings for storing the desired behavior
    • onContactSolve

      public void onContactSolve(long characterVa, long bodyId2Va, long subShapeId2Va, double contactLocationX, double contactLocationY, double contactLocationZ, float contactNormalX, float contactNormalY, float contactNormalZ, float contactVelocityX, float contactVelocityY, float contactVelocityZ, long materialVa, float characterVelocityX, float characterVelocityY, float characterVelocityZ, float[] newCharacterVelocity)
      Callback invoked (by native code) whenever a character-versus-body contact is being solved.
      Specified by:
      onContactSolve in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual being solved (not zero)
      bodyId2Va - the virtual address of the ConstBody being solved (not zero)
      subShapeId2Va - the virtual address of the ConstSubShapeId of the shape that is being hit (not zero)
      contactLocationX - the X component of the contact location (in system coordinates)
      contactLocationY - the Y component of the contact location (in system coordinates)
      contactLocationZ - the Z component of the contact location (in system coordinates)
      contactNormalX - the X component of the contact normal (in system coordinates)
      contactNormalY - the Y component of the contact normal (in system coordinates)
      contactNormalZ - the Z component of the contact normal (in system coordinates)
      contactVelocityX - the X component of the velocity of the contact point (meters per second in system coordinates)
      contactVelocityY - the Y component of the velocity of the contact point (meters per second in system coordinates)
      contactVelocityZ - the Z component of the velocity of the contact point (meters per second in system coordinates)
      materialVa - the virtual address of the ConstPhysicsMaterial at the contact point (not zero)
      characterVelocityX - the X component of the character's prior velocity (meters per second in system coordinates)
      characterVelocityY - the Y component of the character's prior velocity (meters per second in system coordinates)
      characterVelocityZ - the Z component of the character's prior velocity (meters per second in system coordinates)
      newCharacterVelocity - storage for the new velocity vector (in system coordinates, length≥3)
    • onContactValidate

      public boolean onContactValidate(long characterVa, long bodyId2Va, long subShapeId2Va)
      Callback invoked (by native code) to test whether the specified character can collide with the specified body.
      Specified by:
      onContactValidate in interface CharacterContactListener
      Parameters:
      characterVa - the virtual address of the ConstCharacterVirtual being solved (not zero)
      bodyId2Va - the virtual address of the ConstBody being solved (not zero)
      subShapeId2Va - the virtual address of the ConstSubShapeId of the shape that is being hit (not zero)
      Returns:
      true if the contact is valid, otherwise false