CollisionStateComponent Class
Stores per-frame collision state for a GameObject. More...
Declaration
Public Constructors Index
| CollisionStateComponent ()=default | |
|
Default constructor. More... | |
| CollisionStateComponent (const CollisionStateComponent &other) | |
|
Copy constructor (creates empty state). More... | |
| CollisionStateComponent (CollisionStateComponent &&) noexcept=default | |
Public Operators Index
| CollisionStateComponent & | operator= (const CollisionStateComponent &)=default |
| CollisionStateComponent & | operator= (CollisionStateComponent &&) noexcept=default |
Public Member Functions Index
| bool | isEnabled () const noexcept |
|
Checks whether this component is enabled. More... | |
| void | enable () noexcept |
|
Enables this component. More... | |
| void | disable () noexcept |
|
Disables this component. More... | |
| bool | setState (helios::engine::ecs::GameObject gameObject, helios::math::vec3f contact, const bool isSolid, const bool isTrigger, const helios::engine::modules::physics::collision::types::CollisionBehavior collisionBehavior, const bool isCollisionReporter, std::optional< helios::engine::ecs::EntityHandle > other=std::nullopt, const uint32_t collisionLayer=0, const uint32_t otherCollisionLayer=0) |
|
Sets the collision state for this frame. More... | |
| void | reset () noexcept |
|
Resets the collision state for a new frame. More... | |
| void | onAcquire () noexcept |
|
Called when the owning GameObject is acquired from a pool. More... | |
| const types::CollisionContext & | collisionContext () const noexcept |
|
Returns the full collision context data. More... | |
| bool | hasCollision () const noexcept |
|
Checks whether a collision was detected this frame. More... | |
| std::optional< helios::engine::ecs::EntityHandle > | other () const noexcept |
|
Returns the handle of the other entity involved in the collision. More... | |
| bool | isCollisionReporter () const noexcept |
|
Checks whether this entity is the collision reporter. More... | |
| bool | isSolid () const noexcept |
|
Checks whether this is a solid (physical) collision. More... | |
| bool | isTrigger () const noexcept |
|
Checks whether this is a trigger (non-physical) collision. More... | |
| helios::engine::modules::physics::collision::types::CollisionBehavior | collisionBehavior () const noexcept |
|
Returns the collision behavior for this collision. More... | |
| helios::math::vec3f | contact () const noexcept |
|
Returns the world-space contact point of the collision. More... | |
| uint32_t | collisionLayer () const noexcept |
|
Returns the collision layer ID of this entity. More... | |
| uint32_t | otherCollisionLayer () const noexcept |
|
Returns the collision layer ID of the other entity. More... | |
Private Member Attributes Index
| helios::math::vec3f | contact_ |
|
World-space contact point of the collision. More... | |
| bool | isSolid_ = false |
|
Whether this collision is a solid (physical) collision. More... | |
| bool | isTrigger_ = false |
|
Whether this collision is a trigger (non-physical) collision. More... | |
| bool | isCollisionReporter_ = false |
|
Whether this entity is the collision reporter. More... | |
| std::optional< helios::engine::ecs::EntityHandle > | other_ |
|
Handle of the other entity involved in the collision. More... | |
| helios::engine::modules::physics::collision::types::CollisionBehavior | collisionBehavior_ = types::CollisionBehavior::None |
|
The collision behavior to apply. More... | |
| bool | hasCollision_ = false |
|
Flag indicating whether a collision was detected this frame. More... | |
| helios::engine::modules::physics::collision::types::CollisionContext | collisionContext_ {} |
|
Full collision context data for event publishing. More... | |
| uint32_t | collisionLayer_ = 0 |
|
Collision layer ID of this entity. More... | |
| uint32_t | otherCollisionLayer_ = 0 |
|
Collision layer ID of the other entity. More... | |
| bool | isEnabled_ = true |
|
Whether this component is enabled. More... | |
Description
Stores per-frame collision state for a GameObject.
This component is written by the collision detection system each frame to record whether a collision occurred and provide details about the collision. Game logic can query this component to react to collisions.
The state should be reset at the start of each frame by the collision system or when the owning GameObject is acquired from a pool.
Definition at line 35 of file CollisionStateComponent.ixx.
Public Constructors
CollisionStateComponent()
| default |
Default constructor.
Definition at line 119 of file CollisionStateComponent.ixx.
Referenced by CollisionStateComponent, CollisionStateComponent, operator= and operator=.
CollisionStateComponent()
| inline |
Copy constructor (creates empty state).
- Parameters
-
other The component to copy from (state is not copied).
Definition at line 126 of file CollisionStateComponent.ixx.
References CollisionStateComponent and other.
CollisionStateComponent()
| noexcept default |
Definition at line 129 of file CollisionStateComponent.ixx.
Reference CollisionStateComponent.
Public Operators
operator=()
| default |
Definition at line 128 of file CollisionStateComponent.ixx.
Reference CollisionStateComponent.
operator=()
| noexcept default |
Definition at line 130 of file CollisionStateComponent.ixx.
Reference CollisionStateComponent.
Public Member Functions
collisionBehavior()
| inline nodiscard noexcept |
Returns the collision behavior for this collision.
- Returns
The CollisionBehavior enum value.
Definition at line 285 of file CollisionStateComponent.ixx.
Referenced by setState.
collisionContext()
| inline nodiscard noexcept |
Returns the full collision context data.
- Returns
Reference to the CollisionContext struct containing all collision details.
Definition at line 230 of file CollisionStateComponent.ixx.
collisionLayer()
| inline nodiscard noexcept |
Returns the collision layer ID of this entity.
- Returns
The collision layer ID.
Definition at line 303 of file CollisionStateComponent.ixx.
Referenced by setState.
contact()
| inline nodiscard noexcept |
Returns the world-space contact point of the collision.
- Returns
The contact point as a 3D vector.
Definition at line 294 of file CollisionStateComponent.ixx.
Referenced by setState.
disable()
| inline noexcept |
Disables this component.
Definition at line 112 of file CollisionStateComponent.ixx.
enable()
| inline noexcept |
Enables this component.
Definition at line 105 of file CollisionStateComponent.ixx.
hasCollision()
| inline nodiscard noexcept |
Checks whether a collision was detected this frame.
- Returns
True if a collision occurred, false otherwise.
Definition at line 240 of file CollisionStateComponent.ixx.
Referenced by helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::solveCell.
isCollisionReporter()
| inline nodiscard noexcept |
Checks whether this entity is the collision reporter.
- Returns
True if this entity reported the collision.
Definition at line 258 of file CollisionStateComponent.ixx.
Referenced by setState.
isEnabled()
| inline nodiscard noexcept |
Checks whether this component is enabled.
- Returns
True if enabled, false otherwise.
Definition at line 98 of file CollisionStateComponent.ixx.
isSolid()
| inline nodiscard noexcept |
Checks whether this is a solid (physical) collision.
- Returns
True if the collision is solid.
Definition at line 267 of file CollisionStateComponent.ixx.
Referenced by setState.
isTrigger()
| inline nodiscard noexcept |
Checks whether this is a trigger (non-physical) collision.
- Returns
True if the collision is a trigger.
Definition at line 276 of file CollisionStateComponent.ixx.
Referenced by setState.
onAcquire()
| inline noexcept |
other()
| inline nodiscard noexcept |
Returns the handle of the other entity involved in the collision.
- Returns
Optional handle of the other entity, or nullopt if not set.
Definition at line 249 of file CollisionStateComponent.ixx.
Referenced by CollisionStateComponent and setState.
otherCollisionLayer()
| inline nodiscard noexcept |
Returns the collision layer ID of the other entity.
- Returns
The other entity's collision layer ID.
Definition at line 312 of file CollisionStateComponent.ixx.
Referenced by setState.
reset()
| inline noexcept |
Resets the collision state for a new frame.
Clears all collision flags and data. Called at the start of each frame or when the owning GameObject is acquired from a pool.
Definition at line 198 of file CollisionStateComponent.ixx.
Reference helios::engine::modules::physics::collision::types::None.
Referenced by onAcquire.
setState()
| inline |
Sets the collision state for this frame.
This method is called by the collision detection system when a collision is detected. Only the first collision per frame is recorded.
- Parameters
-
contact World-space contact point.
isSolid Whether this is a solid collision.
isTrigger Whether this is a trigger collision.
collisionBehavior The behavior to apply for this collision.
isCollisionReporter Whether this entity reports the collision.
other GUID of the other entity (optional).
collisionLayer Collision layer ID of this entity.
otherCollisionLayer Collision layer ID of the other entity.
- Returns
True if the state was set, false if a collision was already recorded.
Definition at line 149 of file CollisionStateComponent.ixx.
References collisionBehavior, collisionLayer, contact, isCollisionReporter, isSolid, isTrigger, other, otherCollisionLayer and setState.
Referenced by setState.
Private Member Attributes
collisionBehavior_
|
The collision behavior to apply.
Definition at line 64 of file CollisionStateComponent.ixx.
collisionContext_
|
Full collision context data for event publishing.
Definition at line 74 of file CollisionStateComponent.ixx.
collisionLayer_
|
Collision layer ID of this entity.
Definition at line 79 of file CollisionStateComponent.ixx.
contact_
|
World-space contact point of the collision.
Definition at line 39 of file CollisionStateComponent.ixx.
hasCollision_
|
Flag indicating whether a collision was detected this frame.
Definition at line 69 of file CollisionStateComponent.ixx.
isCollisionReporter_
|
Whether this entity is the collision reporter.
Definition at line 54 of file CollisionStateComponent.ixx.
isEnabled_
|
Whether this component is enabled.
Definition at line 89 of file CollisionStateComponent.ixx.
isSolid_
|
Whether this collision is a solid (physical) collision.
Definition at line 44 of file CollisionStateComponent.ixx.
isTrigger_
|
Whether this collision is a trigger (non-physical) collision.
Definition at line 49 of file CollisionStateComponent.ixx.
other_
|
Handle of the other entity involved in the collision.
Definition at line 59 of file CollisionStateComponent.ixx.
otherCollisionLayer_
|
Collision layer ID of the other entity.
Definition at line 84 of file CollisionStateComponent.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.