Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::SphereCollisionComponent Class Reference

Collision component using a sphere shape. More...

#include <SphereCollisionComponent.h>

Inheritance diagram for EngineCore::SphereCollisionComponent:
Collaboration diagram for EngineCore::SphereCollisionComponent:

Public Member Functions

 SphereCollisionComponent (Scene *scene, entt::entity entity, float radius=0.5f)
 Constructs a SphereCollisionComponent.
 ~SphereCollisionComponent () 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 sphere.
float getRadius () const
 Gets the radius of the sphere.
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.
PhysicsBodyComponentgetBodyComponent () 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.
EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Private Attributes

float radius_

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
ScenegetScene () const
 Gets the scene this component belongs to.
SceneManagergetSceneManager () 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>()}
PhysicsBodyComponentbodyComponent_ = nullptr
bool isTrigger_ = false
bool isDirty_ = false

Detailed Description

Collision component using a sphere shape.

Author
Konstantin Passig
Date
2026-01-16

Definition at line 13 of file SphereCollisionComponent.h.

Constructor & Destructor Documentation

◆ SphereCollisionComponent()

EngineCore::SphereCollisionComponent::SphereCollisionComponent ( Scene * scene,
entt::entity entity,
float radius = 0.5f )

Constructs a SphereCollisionComponent.

Parameters
sceneThe owning scene.
entityThe ECS entity associated with this component.
radiusRadius of the sphere (default 0.5 = 1m diameter).

Definition at line 7 of file SphereCollisionComponent.cpp.

References EngineCore::CollisionComponent::CollisionComponent(), radius_, and EngineCore::LogicComponent::scene.

Here is the call graph for this function:

◆ ~SphereCollisionComponent()

EngineCore::SphereCollisionComponent::~SphereCollisionComponent ( )
overridedefault

Member Function Documentation

◆ createShape()

btCollisionShape * EngineCore::SphereCollisionComponent::createShape ( )
overridevirtual

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

Returns
Pointer to the created shape.

Implements EngineCore::CollisionComponent.

Definition at line 14 of file SphereCollisionComponent.cpp.

References radius_.

◆ getRadius()

float EngineCore::SphereCollisionComponent::getRadius ( ) const
inlinenodiscard

Gets the radius of the sphere.

Returns
Radius in meters.

Definition at line 38 of file SphereCollisionComponent.h.

References radius_.

◆ setRadius()

void EngineCore::SphereCollisionComponent::setRadius ( float radius)

Sets the radius of the sphere.

Parameters
radiusRadius in meters.

Definition at line 18 of file SphereCollisionComponent.cpp.

References EngineCore::CollisionComponent::markDirty(), and radius_.

Here is the call graph for this function:

Member Data Documentation

◆ radius_

float EngineCore::SphereCollisionComponent::radius_
private

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