Class NativePhysicsObject

java.lang.Object
com.jme3.bullet.NativePhysicsObject
All Implemented Interfaces:
Comparable<NativePhysicsObject>
Direct Known Subclasses:
BoundingValueHierarchy, CharacterController, CollisionConfiguration, CollisionShape, CollisionSpace, CompoundMesh, IndexedMesh, MultiBody, MultiBodyLink, PhysicsCollisionEvent, PhysicsCollisionObject, PhysicsJoint, RigidBodyMotionState, RotationalLimitMotor, RotationMotor, SoftBodyMaterial, SoftBodyWorldInfo, SolverInfo, TranslationalLimitMotor, TranslationMotor, VehicleController, VehicleTuning, Vhacd4Parameters, VHACDParameters

public abstract class NativePhysicsObject extends Object implements Comparable<NativePhysicsObject>
An abstract class to represent a native (Bullet) physics object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Logger
    message logger for this class
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Instantiate with no tracker and no assigned native object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compare (by ID) with another native object.
    static final int
    Count how many native objects are being tracked.
    static final void
    Dump all native-object trackers to System.out.
    boolean
    equals(Object otherObject)
    Test for ID equality with another object.
    static final void
    Free any assigned native objects that are known to be unused.
    final boolean
    Test whether a native object is assigned to this instance.
    int
    Return the hash code for this instance.
    long
    Return the ID of the assigned native object, assuming that one is assigned.
    protected final void
    reassignNativeId(long nativeId)
    Assign a tracked native object to this instance, unassigning (but not freeing) any previously assigned one.
    protected void
    setNativeId(long nativeId)
    Assign a tracked native object to this instance, assuming that no native object is assigned.
    protected final void
    setNativeIdNotTracked(long nativeId)
    Assign an untracked native object to this instance, assuming that no native object is assigned.
    Represent this instance as a String.
    protected final void
    Unassign (but don't free) the assigned native object, assuming that one is assigned.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • loggerN

      public static final Logger loggerN
      message logger for this class
  • Constructor Details

    • NativePhysicsObject

      protected NativePhysicsObject()
      Instantiate with no tracker and no assigned native object.

      This no-arg constructor was made explicit to avoid javadoc warnings from JDK 18+.

  • Method Details

    • countTrackers

      public static final int countTrackers()
      Count how many native objects are being tracked. This method is intended for debugging.
      Returns:
      the count (≥0)
    • dumpTrackers

      public static final void dumpTrackers()
      Dump all native-object trackers to System.out. This method is intended for debugging.
    • freeUnusedObjects

      public static final void freeUnusedObjects()
      Free any assigned native objects that are known to be unused.
    • hasAssignedNativeObject

      public final boolean hasAssignedNativeObject()
      Test whether a native object is assigned to this instance.
      Returns:
      true if one is assigned, otherwise false
    • nativeId

      public long nativeId()
      Return the ID of the assigned native object, assuming that one is assigned.
      Returns:
      the native identifier (not zero)
    • reassignNativeId

      protected final void reassignNativeId(long nativeId)
      Assign a tracked native object to this instance, unassigning (but not freeing) any previously assigned one. Typically invoked while cloning a subclass.
      Parameters:
      nativeId - the identifier of the native object to assign (not zero)
    • setNativeId

      protected void setNativeId(long nativeId)
      Assign a tracked native object to this instance, assuming that no native object is assigned.
      Parameters:
      nativeId - the identifier of the native object to assign (not zero)
    • setNativeIdNotTracked

      protected final void setNativeIdNotTracked(long nativeId)
      Assign an untracked native object to this instance, assuming that no native object is assigned.
      Parameters:
      nativeId - the identifier of the native object to assign (not zero)
    • unassignNativeObject

      protected final void unassignNativeObject()
      Unassign (but don't free) the assigned native object, assuming that one is assigned. Typically invoked while cloning, destroying, or rebuilding a subclass.
    • compareTo

      public int compareTo(NativePhysicsObject other)
      Compare (by ID) with another native object.
      Specified by:
      compareTo in interface Comparable<NativePhysicsObject>
      Parameters:
      other - (not null, unaffected)
      Returns:
      0 if the objects have the same native ID; negative if this comes before other; positive if this comes after other
    • equals

      public boolean equals(Object otherObject)
      Test for ID equality with another object.
      Overrides:
      equals in class Object
      Parameters:
      otherObject - the object to compare (may be null, unaffected)
      Returns:
      true if this and otherObject have the same ID, otherwise false
    • hashCode

      public int hashCode()
      Return the hash code for this instance.

      Note: operations that alter the native ID are likely to affect the hash code as well!

      Overrides:
      hashCode in class Object
      Returns:
      a 32-bit value for use in hashing
    • toString

      public String toString()
      Represent this instance as a String.
      Overrides:
      toString in class Object
      Returns:
      a descriptive string of text (not null, not empty)