class ColliderShape

Represents a single collider shape that can be assigned to a collider.

Public

Constructors

ColliderShape

ColliderShape()

Methods

~ColliderShape

~ColliderShape() noexcept override = default

GetType

virtual ColliderShapeType GetType() const = 0

Returns the type of the collider shape.

SetPosition

virtual void SetPosition(const Vector3 &position)

Position of the collider shape, relative to the parent collider.

GetPosition

Vector3 GetPosition() const

SetRotation

virtual void SetRotation(const Quaternion &rotation)

Rotation of the collider shape, relative to the parent collider.

GetRotation

Quaternion GetRotation() const

SetScale

virtual void SetScale(const Vector3 &scale)

Scale of the collider shape, relative to the parent collider.

GetScale

Vector3 GetScale() const

SetIsTrigger

virtual void SetIsTrigger(bool value)

Enables/disables a collider as a trigger.

A trigger will not be used for collisions (objects will pass through it), but collision events will still be reported.

GetIsTrigger

bool GetIsTrigger() const

SetMass

virtual void SetMass(float mass)

Determines the mass of the collider shape.

Only relevant if the parent collider is part of a rigidbody. Ultimately this will determine the total mass, center of mass and inertia tensors of the parent rigidbody (if they're being calculated automatically).

GetMass

float GetMass() const

SetMaterial

virtual void SetMaterial(const HPhysicsMaterial &material)

Determines the physical material of the collider shape.

The material determines how objects hitting the collider shape.

GetMaterial

HPhysicsMaterial GetMaterial() const

SetContactOffset

virtual void SetContactOffset(float value)

Determines how far apart do two shapes need to be away from each other before the physics runtime starts generating repelling impulse for them.

This distance will be the sum of contact offsets of the two interacting objects. If objects are moving fast you can increase this value to start generating the impulse earlier and potentially prevent the objects from interpenetrating. This value is in meters. Must be positive and greater than rest offset.

Also see SetRestOffset().

GetContactOffset

float GetContactOffset() const

SetRestOffset

virtual void SetRestOffset(float value)

Determines at what distance should two objects resting on one another come to an equilibrium.

The value used in the runtime will be the sum of rest offsets for both interacting objects. This value is in meters. Cannot be larger than contact offset.

Also see SetContactOffset().

GetRestOffset

float GetRestOffset() const

SetLayer

virtual void SetLayer(u64 layer)

Determines the layer of the collider shape.

Layer controls with which shapes will this shape collide.

GetLayer

u64 GetLayer() const

SetCollisionReportMode

virtual void SetCollisionReportMode(CollisionReportMode mode)

Determines which (if any) collision events are reported.

GetCollisionReportMode

CollisionReportMode GetCollisionReportMode() const

SetShape

virtual void SetShape(const PlaneColliderShapeInformation &information) = 0

Changes or sets the collider shape to a plane.

SetShape

virtual void SetShape(const BoxColliderShapeInformation &information) = 0

Changes or sets the collider shape to a box.

SetShape

virtual void SetShape(const SphereColliderShapeInformation &information) = 0

Changes or sets the collider shape to a sphere.

SetShape

virtual void SetShape(const CapsuleColliderShapeInformation &information) = 0

Changes or sets the collider shape to a capsule.

SetShape

virtual void SetShape(const MeshColliderShapeInformation &information) = 0

Changes or sets the collider shape to a mesh.

GetPlaneShapeInformation

PlaneColliderShapeInformation GetPlaneShapeInformation() const

Returns information about the plane shape.

Will return default shape information if the current shape is not a plane.

GetBoxShapeInformation

BoxColliderShapeInformation GetBoxShapeInformation() const

Returns information about the box shape.

Will return default shape information if the current shape is not a box.

GetSphereShapeInformation

SphereColliderShapeInformation GetSphereShapeInformation() const

Returns information about the sphere shape.

Will return default shape information if the current shape is not a sphere.

GetCapsuleShapeInformation

CapsuleColliderShapeInformation GetCapsuleShapeInformation() const

Returns information about the capsule shape.

Will return default shape information if the current shape is not a capsule.

GetMeshShapeInformation

MeshColliderShapeInformation GetMeshShapeInformation() const

Returns information about the mesh shape.

Will return default shape information if the current shape is not a mesh.

staticCreatePlane

static SPtr<ColliderShape> CreatePlane(const PlaneColliderShapeInformation &information)

Creates a new plane collider shape.

staticCreateBox

static SPtr<ColliderShape> CreateBox(const BoxColliderShapeInformation &information)

Creates a new box collider shape.

staticCreateSphere

static SPtr<ColliderShape> CreateSphere(const SphereColliderShapeInformation &information)

Creates a new sphere collider shape.

staticCreateCapsule

static SPtr<ColliderShape> CreateCapsule(const CapsuleColliderShapeInformation &information)

Creates a new capsule collider shape.

staticCreateMesh

static SPtr<ColliderShape> CreateMesh(const MeshColliderShapeInformation &information)

Creates a new mesh collider shape.

staticCreateEmpty

static SPtr<ColliderShape> CreateEmpty()

Creates a new collider shape without any shape initialized.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Internal

Methods

SetParentCollider

void SetParentCollider(Collider *collider)

Notifies the shape that the provided colliders owns it.

GetParentCollider

Collider *GetParentCollider() const

Returns the collider the shape is currently attached to, if any.

SetShapeIndexInParent

void SetShapeIndexInParent(u32 index)

Index of the shape in the parent collider.

GetShapeIndexInParent

u32 GetShapeIndexInParent() const

SetContinuousCollisionDetection

virtual void SetContinuousCollisionDetection(bool value)

Determines if continuous collision detection is enabled or disabled.

When disabled it prevents fast moving objects from passing through obstacles, at the cost of extra performance.

GetContinuousCollisionDetection

bool GetContinuousCollisionDetection() const

Protected

Methods

UpdateTransform

virtual void UpdateTransform() = 0

Updates the local shape transform based on the requested local transform values, and the object the shape is currently attached to.

Fields

mPosition

Vector3 mPosition

mRotation

Quaternion mRotation

mScale

Vector3 mScale

mShapeIndexInParent

u32 mShapeIndexInParent

mParentCollider

Collider * mParentCollider

mMaterial

HPhysicsMaterial mMaterial

mShapeInformation

ColliderShapeInformation mShapeInformation

mLayer

u64 mLayer

mMass

float mMass

mRestOffset

float mRestOffset

mContactOffset

float mContactOffset

mCollisionReportMode

CollisionReportMode mCollisionReportMode

mContinuousCollisionDetectionEnabled

bool mContinuousCollisionDetectionEnabled

mIsTrigger

bool mIsTrigger