Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
Collider3D Class Referenceabstract

Base class for 3D collider components. More...

#include <Collider3D.h>

Public Types

enum class  Type {
  UNKNOWN = 0 , BOX , SPHERE , CYLINDER ,
  CAPSULE , CONVEX , MESH , HEIGHT_FIELD ,
  COMPOUND
}
 Collider shape category. More...
using TriggerCallback = std::function<void(Component* other)>
 Callback type used by trigger-style collider notifications.

Public Member Functions

 ~Collider3D () override
 Destroys the collider and releases the native shape/body resources.
void setEnabled (bool enabled) override
 Enables or disables the collider component.
bool isValid () const
 Returns whether the native collision shape has been created.
bool hasOwnBody () const
 Returns whether this collider owns a standalone native body.
bool isAttached () const
 Returns whether the collider is attached to either a world or rigid body.
bool isAttachedToWorld () const
 Returns whether the collider is attached to a world.
PhysicsWorld3D * getWorld () const
 Returns the physics world that owns this collider, or nullptr when detached.
Type getType () const
 Returns this collider's shape category.
JPH::BodyID internalBody () const
 Returns the native body ID for standalone colliders.
JPH::Ref< JPH::Shape > & internalShape ()
 Returns the native Jolt shape reference.
void setTransformInPhysics (const Vec3 &translateInPhysics, const Quat &rotInPhysics)
 Sets the relative transform from the node to the physics representation.
void syncNodeToPhysics () override
 Synchronizes the owner node transform to the native physics body.
void syncPhysicsToNode () override
 Synchronizes the native physics transform back to the owner node.
Mat4 getWorldTransform () const override
 Returns the collider's current world transform.
void setSensor (bool bval)
 Enables or disables sensor behavior.
bool isSensor () const
 Returns whether this collider is configured as a sensor.
const PhysicsMaterial & getMaterial () const
 Returns the collider material settings.
void setMaterial (const PhysicsMaterial &mat)
 Sets the collider material and applies it to the native shape/body when possible.
void setUserData (void *userData)
 Stores opaque caller-owned user data on this collider.
void * getUserData () const
 Returns the opaque user data pointer assigned to this collider.

Detailed Description

Base class for 3D collider components.

Provides common functionality and virtual shape creation.

Member Enumeration Documentation

◆ Type

enum class Type
strong

Collider shape category.

Enumerator
UNKNOWN 

Unknown or uninitialized shape.

BOX 

Box shape.

SPHERE 

Sphere shape.

CYLINDER 

Cylinder shape.

CAPSULE 

Capsule shape.

CONVEX 

Convex hull shape.

MESH 

Triangle mesh shape.

HEIGHT_FIELD 

Height-field terrain shape.

COMPOUND 

Compound shape made from child colliders.

Member Function Documentation

◆ setEnabled()

void setEnabled ( bool enabled)
override

Enables or disables the collider component.

Parameters
enabledTrue to attach or keep the collider active, false to detach it.

◆ internalBody()

JPH::BodyID internalBody ( ) const
inline

Returns the native body ID for standalone colliders.

Returns
Native Jolt body ID, or an invalid ID when this collider is body-owned or detached.

◆ internalShape()

JPH::Ref< JPH::Shape > & internalShape ( )
inline

Returns the native Jolt shape reference.

Returns
Mutable native shape reference.

◆ setTransformInPhysics()

void setTransformInPhysics ( const Vec3 & translateInPhysics,
const Quat & rotInPhysics )

Sets the relative transform from the node to the physics representation.

Parameters
translateInPhysicsTranslation offset in local physics space.
rotInPhysicsRotation offset in local physics space.

◆ getWorldTransform()

Mat4 getWorldTransform ( ) const
override

Returns the collider's current world transform.

Returns
World transform including the physics transform offset.

◆ setSensor()

void setSensor ( bool bval)

Enables or disables sensor behavior.

Parameters
bvalTrue to make the collider report contacts without physical collision response.

◆ setMaterial()

void setMaterial ( const PhysicsMaterial & mat)

Sets the collider material and applies it to the native shape/body when possible.

Parameters
matMaterial settings to use for this collider.

◆ setUserData()

void setUserData ( void * userData)
inline

Stores opaque caller-owned user data on this collider.

Parameters
userDataPointer value to associate with the collider.

The documentation for this class was generated from the following file:
  • Collider3D.h