Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::CapsuleCollision Class Reference

Collision component using a capsule shape (cylinder with hemispherical ends). More...

#include <CapsuleCollisionComponent.h>

Inheritance diagram for Engine::Components::CapsuleCollision:
Collaboration diagram for Engine::Components::CapsuleCollision:

Public Member Functions

 CapsuleCollision (Entities::Scene *scene, entt::entity entity, float radius=0.5f, float height=1.0f)
 Constructs a CapsuleCollisionComponent.
 ~CapsuleCollision () override=default
btCollisionShape * createShape () override
 Creates the Bullet collision shape. Must be implemented by derived classes.
void debugDraw (const glm::mat4 &worldTransform) const override
 Draws debug visualization of the capsule.
void setRadius (float radius)
 Sets the radius of the capsule.
float getRadius () const
 Gets the radius of the capsule.
void setHeight (float height)
 Sets the height of the cylindrical portion.
float getHeight () const
 Gets the height of the cylindrical portion.
Public Member Functions inherited from Engine::Components::Collision
 Collision (Engine::Entities::Scene *scene, entt::entity entity)
 Constructs a CollisionComponent.
 ~Collision () override
void beginPlay () override
 Called when the component is added to the scene or the game starts.
void endPlay () override
 Called when the component is removed or the game ends.
virtual void destroyShape ()
 Destroys the current shape.
void markDirty ()
 Marks the shape as needing rebuild. Call after changing shape properties (halfExtents, radius, etc.).
void rebuild ()
 Rebuilds the shape and notifies PhysicsBodyComponent.
btCollisionShape * getShape () const
 Gets the current collision shape.
void setLocalOffset (const glm::vec3 &offset)
 Sets the local position offset relative to the body.
glm::vec3 getLocalOffset () const
 Gets the local position offset.
void setLocalRotation (const glm::quat &rotation)
 Sets the local rotation relative to the body.
glm::quat getLocalRotation () const
 Gets the local rotation.
glm::mat4 getLocalTransform () const
 Gets the local transform matrix.
void setIsTrigger (bool trigger)
 Sets whether this collision is a trigger (overlap only, no physics response).
bool isTrigger () const
 Checks if this collision is a trigger.
virtual void onCollisionBegin (Components::Collision *other)
 Called when a collision with another object begins.
virtual void onCollisionEnd (Components::Collision *other)
 Called when a collision with another object ends.
virtual void onCollisionStay (Components::Collision *other)
 Called every frame while colliding with another object.
Components::PhysicsBodygetBodyComponent () const
 Gets the physics body component this collision is registered with.
void setDebugColorSeed (std::uint64_t seed)
void setDebugName (std::string name)
const std::string & getDebugName () const
Public Member Functions inherited from Engine::Components::Logic
 Logic (Entities::Scene *owningScene)
virtual ~Logic ()=default
virtual std::string getComponentName () const
 Gets the component type name for debugging/UI.
virtual void tick (double deltaTime)
 Called every frame if ticking is enabled.
bool hasBegunPlay () const
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Static Public Attributes

static constexpr const char * ComponentName = "CapsuleCollision"
Static Public Attributes inherited from Engine::Components::Collision
static constexpr bool IsUnique = false
static constexpr const char * ComponentName = "Collision"
Static Public Attributes inherited from Engine::Components::Logic
static constexpr bool IsUnique = false
 Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique = true; if needed.
static constexpr const char * ComponentName = "Logic"
 Fallback component type name. Derived classes may override getComponentName() for custom labels.

Private Attributes

float radius_
float height_

Additional Inherited Members

Static Public Member Functions inherited from Engine::Components::Collision
static void setDebugDrawEnabled (bool enabled)
 Enable or disable debug drawing for all collision components.
static bool isDebugDrawEnabled ()
 Check if debug drawing is enabled globally.
Protected Member Functions inherited from Engine::Components::Collision
glm::vec4 getDebugDrawColor (const glm::vec4 &fallbackColor) const
Protected Member Functions inherited from Engine::Components::Logic
Entities::ScenegetScene () const
 Gets the scene this component belongs to.
Core::SceneManagergetSceneManager () const
 Helper to get the SceneManager from the owning scene.
Protected Attributes inherited from Engine::Components::Collision
entt::entity entity_
btCollisionShape * shape_ = nullptr
glm::vec3 localOffset_ {0.0f}
glm::quat localRotation_ {glm::identity<glm::quat>()}
Components::PhysicsBodybodyComponent_ = nullptr
std::string debugName_
std::uint64_t debugColorSeed_ = 0
bool hasDebugColorSeed_ = false
bool isTrigger_ = false
bool isDirty_ = false
Static Protected Attributes inherited from Engine::Components::Collision
static bool debugDrawEnabled_

Detailed Description

Collision component using a capsule shape (cylinder with hemispherical ends).

The capsule is aligned along the Y axis by default.

Definition at line 12 of file CapsuleCollisionComponent.h.

Constructor & Destructor Documentation

◆ CapsuleCollision()

Engine::Components::CapsuleCollision::CapsuleCollision ( Entities::Scene * scene,
entt::entity entity,
float radius = 0.5f,
float height = 1.0f )

Constructs a CapsuleCollisionComponent.

Parameters
sceneThe owning scene.
entityThe ECS entity associated with this component.
radiusRadius of the capsule (default 0.5).
heightHeight of the cylindrical portion (default 1.0).

◆ ~CapsuleCollision()

Engine::Components::CapsuleCollision::~CapsuleCollision ( )
overridedefault

Member Function Documentation

◆ createShape()

btCollisionShape * Engine::Components::CapsuleCollision::createShape ( )
overridevirtual

Creates the Bullet collision shape. Must be implemented by derived classes.

Returns
Pointer to the created shape.

Implements Engine::Components::Collision.

◆ debugDraw()

void Engine::Components::CapsuleCollision::debugDraw ( const glm::mat4 & worldTransform) const
overridevirtual

Draws debug visualization of the capsule.

Parameters
worldTransformWorld transform of the entity.

Reimplemented from Engine::Components::Collision.

◆ getHeight()

float Engine::Components::CapsuleCollision::getHeight ( ) const
inlinenodiscard

Gets the height of the cylindrical portion.

Returns
Height in meters.

Definition at line 57 of file CapsuleCollisionComponent.h.

References height_.

◆ getRadius()

float Engine::Components::CapsuleCollision::getRadius ( ) const
inlinenodiscard

Gets the radius of the capsule.

Returns
Radius in meters.

Definition at line 45 of file CapsuleCollisionComponent.h.

References radius_.

◆ setHeight()

void Engine::Components::CapsuleCollision::setHeight ( float height)

Sets the height of the cylindrical portion.

Parameters
heightHeight in meters.

◆ setRadius()

void Engine::Components::CapsuleCollision::setRadius ( float radius)

Sets the radius of the capsule.

Parameters
radiusRadius in meters.

Member Data Documentation

◆ ComponentName

const char* Engine::Components::CapsuleCollision::ComponentName = "CapsuleCollision"
staticconstexpr

Definition at line 14 of file CapsuleCollisionComponent.h.

◆ height_

float Engine::Components::CapsuleCollision::height_
private

Definition at line 61 of file CapsuleCollisionComponent.h.

Referenced by getHeight().

◆ radius_

float Engine::Components::CapsuleCollision::radius_
private

Definition at line 60 of file CapsuleCollisionComponent.h.

Referenced by getRadius().


The documentation for this class was generated from the following file: