Class PhysicsGhostObject

All Implemented Interfaces:
Comparable<NativePhysicsObject>

public class PhysicsGhostObject extends PhysicsCollisionObject
A collision object for intangibles, based on Bullet's btPairCachingGhostObject. This is useful for creating a character controller, collision sensors/triggers, explosions etc.

Overlap detection skips the narrow-phase collision-detection algorithm and relies entirely on the broad-phase algorithm, which is AABB plus a margin of about 0.06 world units. Precise collision detection is still available via PhysicsSpace.addCollisionListener().

From Bullet manual:
btGhostObject is a special btCollisionObject, useful for fast localized collision queries.

  • Field Details

    • logger2

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

    • PhysicsGhostObject

      public PhysicsGhostObject(CollisionShape shape)
      Instantiate a ghost object with the specified CollisionShape. The new object is not added to any CollisionSpace.
      Parameters:
      shape - the desired shape (not null, alias created)
  • Method Details

    • getOverlapping

      public PhysicsCollisionObject getOverlapping(int index)
      Access an overlapping collision object by its position in the list. Important: getOverlappingObjects() must be invoked first!
      Parameters:
      index - which list position (≥0, <count)
      Returns:
      the pre-existing object
    • getOverlappingCount

      public int getOverlappingCount()
      Count how many collision objects this object overlaps.
      Returns:
      the count (≥0)
    • getOverlappingObjects

      public List<PhysicsCollisionObject> getOverlappingObjects()
      Update and access a list of overlapping objects.
      Returns:
      an internal list which may get reused (not null)
    • setPhysicsLocation

      public void setPhysicsLocation(Vector3f location)
      Directly alter the location of the ghost's center.
      Parameters:
      location - the desired location (in physics-space coordinates, not null, finite, unaffected)
    • setPhysicsLocationDp

      public void setPhysicsLocationDp(Vec3d location)
      Directly alter the location of the ghost's center.
      Parameters:
      location - the desired location (in physics-space coordinates, not null, finite, unaffected)
    • setPhysicsRotation

      public void setPhysicsRotation(Matrix3f orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation matrix in physics-space coordinates, not null, unaffected)
    • setPhysicsRotation

      public void setPhysicsRotation(Quaternion orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation quaternion in physics-space coordinates, not null, not zero, unaffected)
    • setPhysicsRotationDp

      public void setPhysicsRotationDp(Matrix3d orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation matrix in physics-space coordinates, not null, unaffected)
    • setPhysicsRotationDp

      public void setPhysicsRotationDp(Quatd orientation)
      Directly alter the ghost's orientation.
      Parameters:
      orientation - the desired orientation (a rotation quaternion in physics-space coordinates, not null, not zero, unaffected)
    • setCollisionShape

      public void setCollisionShape(CollisionShape collisionShape)
      Apply the specified CollisionShape to this object. Note that the object should not be in any CollisionSpace while changing shape; the object gets rebuilt on the physics side.
      Overrides:
      setCollisionShape in class PhysicsCollisionObject
      Parameters:
      collisionShape - the shape to apply (not null, alias created)