|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Base class for collision shape components. More...
#include <CollisionComponent.h>
Public Member Functions | |
| 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 btCollisionShape * | createShape ()=0 |
| Creates the Bullet collision shape. Must be implemented by derived classes. | |
| 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::PhysicsBody * | getBodyComponent () const |
| Gets the physics body component this collision is registered with. | |
| virtual void | debugDraw (const glm::mat4 &worldTransform) const |
| Draws debug visualization of the collision shape. | |
| 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::Entity * | getOwningEntity () const |
| Gets the entity this component belongs to. | |
Static Public Member Functions | |
| static void | setDebugDrawEnabled (bool enabled) |
| Enable or disable debug drawing for all collision components. | |
| static bool | isDebugDrawEnabled () |
| Check if debug drawing is enabled globally. | |
Static Public Attributes | |
| 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. | |
Protected Member Functions | |
| glm::vec4 | getDebugDrawColor (const glm::vec4 &fallbackColor) const |
| Protected Member Functions inherited from Engine::Components::Logic | |
| Entities::Scene * | getScene () const |
| Gets the scene this component belongs to. | |
| Core::SceneManager * | getSceneManager () const |
| Helper to get the SceneManager from the owning scene. | |
Protected Attributes | |
| entt::entity | entity_ |
| btCollisionShape * | shape_ = nullptr |
| glm::vec3 | localOffset_ {0.0f} |
| glm::quat | localRotation_ {glm::identity<glm::quat>()} |
| Components::PhysicsBody * | bodyComponent_ = nullptr |
| std::string | debugName_ |
| std::uint64_t | debugColorSeed_ = 0 |
| bool | hasDebugColorSeed_ = false |
| bool | isTrigger_ = false |
| bool | isDirty_ = false |
Static Protected Attributes | |
| static bool | debugDrawEnabled_ |
Private Member Functions | |
| void | registerWithBody () |
| void | unregisterFromBody () |
Base class for collision shape components.
CollisionComponent is the abstract base for all collision shapes. Multiple collision components can be attached to a single entity, and they will be combined into a compound shape by PhysicsBodyComponent.
Derived classes must implement createShape() to create the Bullet shape.
Definition at line 27 of file CollisionComponent.h.
| Engine::Components::Collision::Collision | ( | Engine::Entities::Scene * | scene, |
| entt::entity | entity ) |
Constructs a CollisionComponent.
| scene | The owning scene. |
| entity | The ECS entity associated with this component. |
|
override |
|
overridevirtual |
Called when the component is added to the scene or the game starts.
Reimplemented from Engine::Components::Logic.
|
pure virtual |
Creates the Bullet collision shape. Must be implemented by derived classes.
Implemented in Engine::Components::BoxCollision, and Engine::Components::CapsuleCollision.
|
virtual |
Draws debug visualization of the collision shape.
Override in derived classes to visualize the specific shape type. Uses DebugDraw API to render wireframe representation.
| worldTransform | World transform of the entity. |
Reimplemented in Engine::Components::BoxCollision, and Engine::Components::CapsuleCollision.
|
virtual |
Destroys the current shape.
|
overridevirtual |
Called when the component is removed or the game ends.
Reimplemented from Engine::Components::Logic.
|
inlinenodiscard |
Gets the physics body component this collision is registered with.
Definition at line 154 of file CollisionComponent.h.
References bodyComponent_.
|
nodiscardprotected |
|
inlinenodiscard |
Definition at line 173 of file CollisionComponent.h.
References debugName_.
|
inlinenodiscard |
Gets the local position offset.
Definition at line 92 of file CollisionComponent.h.
References localOffset_.
|
inlinenodiscard |
Gets the local rotation.
Definition at line 104 of file CollisionComponent.h.
References localRotation_.
|
nodiscard |
Gets the local transform matrix.
|
inlinenodiscard |
Gets the current collision shape.
Definition at line 76 of file CollisionComponent.h.
References shape_.
|
staticnodiscard |
Check if debug drawing is enabled globally.
|
inlinenodiscard |
Checks if this collision is a trigger.
Definition at line 126 of file CollisionComponent.h.
References isTrigger_.
| void Engine::Components::Collision::markDirty | ( | ) |
Marks the shape as needing rebuild. Call after changing shape properties (halfExtents, radius, etc.).
|
virtual |
Called when a collision with another object begins.
| other | The other collision component. |
|
virtual |
Called when a collision with another object ends.
| other | The other collision component. |
|
virtual |
Called every frame while colliding with another object.
| other | The other collision component. |
| void Engine::Components::Collision::rebuild | ( | ) |
Rebuilds the shape and notifies PhysicsBodyComponent.
|
private |
| void Engine::Components::Collision::setDebugColorSeed | ( | std::uint64_t | seed | ) |
|
static |
Enable or disable debug drawing for all collision components.
| enabled | True to enable debug drawing. |
| void Engine::Components::Collision::setDebugName | ( | std::string | name | ) |
| void Engine::Components::Collision::setIsTrigger | ( | bool | trigger | ) |
Sets whether this collision is a trigger (overlap only, no physics response).
| trigger | True for trigger mode. |
| void Engine::Components::Collision::setLocalOffset | ( | const glm::vec3 & | offset | ) |
Sets the local position offset relative to the body.
| offset | Position offset in local space. |
| void Engine::Components::Collision::setLocalRotation | ( | const glm::quat & | rotation | ) |
Sets the local rotation relative to the body.
| rotation | Rotation quaternion. |
|
private |
|
protected |
Definition at line 195 of file CollisionComponent.h.
Referenced by getBodyComponent().
|
staticconstexpr |
Definition at line 32 of file CollisionComponent.h.
|
protected |
Definition at line 197 of file CollisionComponent.h.
|
staticprotected |
Definition at line 190 of file CollisionComponent.h.
|
protected |
Definition at line 196 of file CollisionComponent.h.
Referenced by getDebugName().
|
protected |
Definition at line 191 of file CollisionComponent.h.
|
protected |
Definition at line 198 of file CollisionComponent.h.
|
protected |
Definition at line 200 of file CollisionComponent.h.
|
protected |
Definition at line 199 of file CollisionComponent.h.
Referenced by isTrigger().
|
staticconstexpr |
Definition at line 31 of file CollisionComponent.h.
|
protected |
Definition at line 193 of file CollisionComponent.h.
Referenced by getLocalOffset().
|
protected |
Definition at line 194 of file CollisionComponent.h.
Referenced by getLocalRotation().
|
protected |
Definition at line 192 of file CollisionComponent.h.
Referenced by getShape().