|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Collision component using a capsule shape (cylinder with hemispherical ends). More...
#include <CapsuleCollisionComponent.h>
Public Member Functions | |
| CapsuleCollisionComponent (Scene *scene, entt::entity entity, float radius=0.5f, float height=1.0f) | |
| Constructs a CapsuleCollisionComponent. | |
| ~CapsuleCollisionComponent () override=default | |
| btCollisionShape * | createShape () override |
| Creates the Bullet collision shape. Must be implemented by derived classes. | |
| 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 EngineCore::CollisionComponent | |
| CollisionComponent (Scene *scene, entt::entity entity) | |
| Constructs a CollisionComponent. | |
| ~CollisionComponent () 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 (CollisionComponent *other) |
| Called when a collision with another object begins. | |
| virtual void | onCollisionEnd (CollisionComponent *other) |
| Called when a collision with another object ends. | |
| virtual void | onCollisionStay (CollisionComponent *other) |
| Called every frame while colliding with another object. | |
| PhysicsBodyComponent * | getBodyComponent () const |
| Gets the physics body component this collision is registered with. | |
| Public Member Functions inherited from EngineCore::LogicComponent | |
| LogicComponent (Scene *owningScene) | |
| virtual | ~LogicComponent ()=default |
| virtual void | tick (double deltaTime) |
| Called every frame if ticking is enabled. | |
| bool | canTick () const |
| Checks if the component is currently set to tick. | |
| void | setCanTick (bool enable) |
| Enables or disables ticking for this component. | |
| Entity * | getOwningEntity () const |
| Gets the entity this component belongs to. | |
Private Attributes | |
| float | radius_ |
| float | height_ |
Additional Inherited Members | |
| Static Public Attributes inherited from EngineCore::CollisionComponent | |
| static constexpr bool | IsUnique = false |
| Static Public Attributes inherited from EngineCore::LogicComponent | |
| 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. | |
| Protected Member Functions inherited from EngineCore::LogicComponent | |
| Scene * | getScene () const |
| Gets the scene this component belongs to. | |
| SceneManager * | getSceneManager () const |
| Helper to get the SceneManager from the owning scene. | |
| Protected Attributes inherited from EngineCore::CollisionComponent | |
| entt::entity | entity_ |
| btCollisionShape * | shape_ = nullptr |
| glm::vec3 | localOffset_ {0.0f} |
| glm::quat | localRotation_ {glm::identity<glm::quat>()} |
| PhysicsBodyComponent * | bodyComponent_ = nullptr |
| bool | isTrigger_ = false |
| bool | isDirty_ = false |
Collision component using a capsule shape (cylinder with hemispherical ends).
The capsule is aligned along the Y axis by default.
Definition at line 15 of file CapsuleCollisionComponent.h.
| EngineCore::CapsuleCollisionComponent::CapsuleCollisionComponent | ( | Scene * | scene, |
| entt::entity | entity, | ||
| float | radius = 0.5f, | ||
| float | height = 1.0f ) |
Constructs a CapsuleCollisionComponent.
| scene | The owning scene. |
| entity | The ECS entity associated with this component. |
| radius | Radius of the capsule (default 0.5). |
| height | Height of the cylindrical portion (default 1.0). |
Definition at line 7 of file CapsuleCollisionComponent.cpp.
References EngineCore::CollisionComponent::CollisionComponent(), height_, radius_, and EngineCore::LogicComponent::scene.
|
overridedefault |
|
overridevirtual |
Creates the Bullet collision shape. Must be implemented by derived classes.
Implements EngineCore::CollisionComponent.
Definition at line 15 of file CapsuleCollisionComponent.cpp.
|
inlinenodiscard |
Gets the height of the cylindrical portion.
Definition at line 53 of file CapsuleCollisionComponent.h.
References height_.
|
inlinenodiscard |
Gets the radius of the capsule.
Definition at line 41 of file CapsuleCollisionComponent.h.
References radius_.
| void EngineCore::CapsuleCollisionComponent::setHeight | ( | float | height | ) |
Sets the height of the cylindrical portion.
| height | Height in meters. |
Definition at line 24 of file CapsuleCollisionComponent.cpp.
References height_, and EngineCore::CollisionComponent::markDirty().
| void EngineCore::CapsuleCollisionComponent::setRadius | ( | float | radius | ) |
Sets the radius of the capsule.
| radius | Radius in meters. |
Definition at line 19 of file CapsuleCollisionComponent.cpp.
References EngineCore::CollisionComponent::markDirty(), and radius_.
|
private |
Definition at line 57 of file CapsuleCollisionComponent.h.
Referenced by CapsuleCollisionComponent(), createShape(), getHeight(), and setHeight().
|
private |
Definition at line 56 of file CapsuleCollisionComponent.h.
Referenced by CapsuleCollisionComponent(), createShape(), getRadius(), and setRadius().