java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.ContactKey
All Implemented Interfaces:
ConstContactKey, ConstJoltPhysicsObject, AutoCloseable, Comparable<JoltPhysicsObject>
Direct Known Subclasses:
Contact

public class ContactKey extends JoltPhysicsObject implements ConstContactKey
Identify a contact between a virtual character and a body or another virtual character. (native type: CharacterVirtual::ContactKey)
  • Constructor Details

    • ContactKey

      public ContactKey()
      Instantiate a default key.
    • ContactKey

      public ContactKey(ContactKey original)
      Instantiate a copy of the specified key.
      Parameters:
      original - the settings to copy (not null, unaffected)
    • ContactKey

      public ContactKey(char idType, int bodyOrCharacterId, int subShapeId)
      Instantiate a key with the specified parameters.
      Parameters:
      idType - "b" for body or "c" for character
      bodyOrCharacterId - the BodyID or CharacterID of the other colliding object
      subShapeId - the SubShapeID of the shape that is in contact
  • Method Details

    • restoreState

      public void restoreState(StateRecorder recorder)
      Restore the key from the specified recorder.
      Parameters:
      recorder - the recorder to restore from (not null)
    • getBodyB

      public int getBodyB()
      Return the ID of the colliding body. The key is unaffected. (native attribute: mBodyB)
      Specified by:
      getBodyB in interface ConstContactKey
      Returns:
      the BodyID value
    • getCharacterIdB

      public int getCharacterIdB()
      Return the ID of the colliding character. The key is unaffected. (native attribute: mCharacterIDB)
      Specified by:
      getCharacterIdB in interface ConstContactKey
      Returns:
      the CharacterID value
    • getSubShapeIdB

      public int getSubShapeIdB()
      Return the sub-shape ID of the colliding body. The contact is unaffected. (native attribute: mSubShapeIDB)
      Specified by:
      getSubShapeIdB in interface ConstContactKey
      Returns:
      a SubShapeID value (typically negative)
    • isEqual

      public boolean isEqual(ConstContactKey other)
      Test for equivalence with another key. The key is unaffected. (native operator: binary ==)
      Specified by:
      isEqual in interface ConstContactKey
      Parameters:
      other - the key to compare with (not null, unaffected)
      Returns:
      true if equivalent, otherwise false
    • isNotEqual

      public boolean isNotEqual(ConstContactKey other)
      Test for equivalence with another key. The key is unaffected.(native operator: binary !=)
      Specified by:
      isNotEqual in interface ConstContactKey
      Parameters:
      other - the key to compare with (not null, unaffected)
      Returns:
      false if equivalent, otherwise true
    • saveState

      public void saveState(StateRecorder recorder)
      Save the key to the specified recorder. The key is unaffected.
      Specified by:
      saveState in interface ConstContactKey
      Parameters:
      recorder - the recorder to save to (not null)