Skip to main content

types Namespace

Type definitions for collision system behavior configuration. More...

Definition

namespace helios::engine::modules::physics::collision::types { ... }

Classes Index

structCollisionContext

Context data describing a collision event. More...

Typedefs Index

usingCollisionLayer = uint32_t

Type alias for collision layer identifiers. More...

Enumerations Index

enum classCollisionBehavior : uint16_t { ... }

Defines how an entity responds to a collision event. More...

enum classCollisionResponse : uint8_t { ... }

Defines how an entity responds to a collision event. More...

enum classHitPolicy { ... }

Specifies how many collision events an entity can receive per frame. More...

Operators Index

constexpr CollisionBehavioroperator| (CollisionBehavior lhs, CollisionBehavior rhs) noexcept

Combines two CollisionBehavior flags using bitwise OR. More...

constexpr CollisionBehavioroperator& (CollisionBehavior lhs, CollisionBehavior rhs) noexcept

Masks two CollisionBehavior flags using bitwise AND. More...

Functions Index

constexpr boolhasFlag (const CollisionBehavior mask, const CollisionBehavior flag) noexcept

Checks if a behavior mask contains a specific flag. More...

Variables Index

constexpr size_tCollisionBehaviorItemSize = 8

Number of distinct CollisionBehavior flags. More...

constexpr std::size_tMAX_COLLISION_LAYERS = std::numeric_limits<CollisionLayer>::digits

Maximum number of distinct collision layers. More...

Description

Type definitions for collision system behavior configuration.

Provides enums and structs that configure collision detection and response behavior, including bitmask-based behavior flags and collision event context data.

Typedefs

CollisionLayer

using helios::engine::modules::physics::collision::types::CollisionLayer = uint32_t

Type alias for collision layer identifiers.

Collision layers are represented as bitmask values where each layer is a single bit. This allows efficient layer masking operations.

Definition at line 22 of file CollisionLayer.ixx.

22 using CollisionLayer = uint32_t;

Enumerations

CollisionBehavior

enum class helios::engine::modules::physics::collision::types::CollisionBehavior : uint16_t
strong

Defines how an entity responds to a collision event.

Enumeration values
NoneNo collision response (= 0)
ReflectReflect the entity's velocity off the collision surface (= 1 << 0)
BounceBounce the entity with restitution applied (= 1 << 1)
StickStick the entity to the collision surface (= 1 << 2)
DespawnDespawn the entity on collision (= 1 << 3)
PassEventEmit an event without physical response (= 1 << 4)
PhaseEventPush collision event to the event bus (= 1 << 5)
FrameEventProcess collision event in the current frame (= 1 << 6)

CollisionBehavior values are used as bitmasks to configure per-layer collision responses in CollisionComponent. Multiple behaviors can be combined using bitwise operations.

The behavior determines what action the collision system takes when two entities collide based on their layer configuration.

info

Not all behaviors are currently fully implemented. Currently supported:

  • `Reflect` - Fully supported
  • `Bounce` - Fully supported
  • `Despawn` - Fully supported

Definition at line 30 of file CollisionBehavior.ixx.

30 enum class CollisionBehavior : uint16_t {
31
32 /**
33 * @brief No collision response.
34 */
35 None = 0,
36
37 /**
38 * @brief Reflect the entity's velocity off the collision surface.
39 *
40 * @details Uses the surface normal to calculate a reflected velocity
41 * vector. Commonly used for projectiles bouncing off walls.
42 */
43 Reflect = 1 << 0,
44
45 /**
46 * @brief Bounce the entity with restitution applied.
47 *
48 * @details Similar to Reflect but applies a restitution coefficient
49 * to reduce velocity. Used for physics-based bouncing.
50 */
51 Bounce = 1 << 1,
52
53 /**
54 * @brief Stick the entity to the collision surface.
55 *
56 * @details Stops the entity's movement and attaches it to the
57 * collided object. Used for projectiles that embed on impact.
58 */
59 Stick = 1 << 2,
60
61 /**
62 * @brief Despawn the entity on collision.
63 *
64 * @details Marks the entity for removal from the game world.
65 * Used for projectiles that are destroyed on impact.
66 */
67 Despawn = 1 << 3,
68
69 /**
70 * @brief Emit an event without physical response.
71 *
72 * @details Generates a collision event for game logic processing
73 * without affecting the entity's physics state.
74 */
75 PassEvent = 1 << 4,
76
77 /**
78 * @brief Push collision event to the event bus.
79 *
80 * @details Pushes the collision event to the double-buffered event bus
81 * for processing in the next frame. Used for deferred collision handling.
82 */
83 PhaseEvent = 1 << 5,
84
85 /**
86 * @brief Process collision event in the current frame.
87 *
88 * @details Sends the collision event to the immediate bus for processing
89 * within the same frame. Used for time-critical collision responses.
90 */
91 FrameEvent = 1 << 6
92 };

CollisionResponse

enum class helios::engine::modules::physics::collision::types::CollisionResponse : uint8_t
strong

Defines how an entity responds to a collision event.

Enumeration values
NoneNo collision response; collision is ignored (= 0)
AlignHeadingToDirectionAligns the entity's heading direction upon collision (= 1 << 0)
size_Sentinel value indicating the number of response types (= 2)

CollisionResponse is a bitmask enum that specifies the behavior when a collision is detected.

See Also

CollisionComponent

Definition at line 23 of file CollisionResponse.ixx.

23 enum class CollisionResponse : uint8_t {
24
25 /**
26 * @brief No collision response; collision is ignored.
27 */
28 None = 0,
29
30 /**
31 * @brief Aligns the entity's heading direction upon collision.
32 *
33 * @details Aligns the heading of the object to the the movement direction, typically used for bouncing or reflecting projectiles off surfaces.
34 */
36
37 /**
38 * @brief Sentinel value indicating the number of response types.
39 */
40 size_ = 2
41 };

HitPolicy

enum class helios::engine::modules::physics::collision::types::HitPolicy
strong

Specifies how many collision events an entity can receive per frame.

Enumeration values
OneHitReports only the first collision per frame
AllReports all collisions with overlapping entities

HitPolicy controls the collision detection behavior when an entity overlaps multiple other entities in the same frame. This affects both performance and gameplay logic.

## Policies

| Policy | Behavior | |--------|----------| | `OneHit` | Reports only the first collision detected (default) | | `All` | Reports all collisions with overlapping entities |

## Use Cases

  • **OneHit:** Projectiles that destroy on first contact, pickups collected once
  • **All:** Area-of-effect damage, entities affecting multiple targets simultaneously

## Usage

```cpp // Projectile: stops after first hit prototype.withCollision([](CollisionBuilder& b) { b.collision() .layer(Layers::PROJECTILE) .hitPolicy(HitPolicy::OneHit); });

// Explosion: damages all entities in range prototype.withCollision([](CollisionBuilder& b) { b.collision() .layer(Layers::EXPLOSION) .hitPolicy(HitPolicy::All); }); ```

See Also

CollisionComponent::setHitPolicy

See Also

GridCollisionDetectionSystem

Definition at line 53 of file HitPolicy.ixx.

53 enum class HitPolicy {
54
55 /**
56 * @brief Reports only the first collision per frame.
57 *
58 * @details Once a collision is detected, the entity skips further
59 * collision checks for the current frame. This is the default policy
60 * and provides optimal performance for typical projectile behavior.
61 */
63
64 /**
65 * @brief Reports all collisions with overlapping entities.
66 *
67 * @details The entity continues collision checks even after detecting
68 * a collision, generating events for every overlapping entity. Use for
69 * area-of-effect or multi-target interactions.
70 */
72
73 };

Operators

operator&()

CollisionBehavior helios::engine::modules::physics::collision::types::operator& (CollisionBehavior lhs, CollisionBehavior rhs)
nodiscard constexpr noexcept

Masks two CollisionBehavior flags using bitwise AND.

Parameters
lhs

Left-hand side behavior.

rhs

Right-hand side behavior.

Returns

Masked behavior flags.

Definition at line 121 of file CollisionBehavior.ixx.

121 [[nodiscard]] constexpr CollisionBehavior operator&(CollisionBehavior lhs, CollisionBehavior rhs) noexcept {
122 return static_cast<CollisionBehavior>(
123 static_cast<uint16_t>(lhs) & static_cast<uint16_t>(rhs)
124 );
125 }

operator|()

CollisionBehavior helios::engine::modules::physics::collision::types::operator| (CollisionBehavior lhs, CollisionBehavior rhs)
nodiscard constexpr noexcept

Combines two CollisionBehavior flags using bitwise OR.

Parameters
lhs

Left-hand side behavior.

rhs

Right-hand side behavior.

Returns

Combined behavior flags.

Definition at line 107 of file CollisionBehavior.ixx.

107 [[nodiscard]] constexpr CollisionBehavior operator|(CollisionBehavior lhs, CollisionBehavior rhs) noexcept {
108 return static_cast<CollisionBehavior>(
109 static_cast<uint16_t>(lhs) | static_cast<uint16_t>(rhs)
110 );
111 }

Functions

hasFlag()

bool helios::engine::modules::physics::collision::types::hasFlag (const CollisionBehavior mask, const CollisionBehavior flag)
nodiscard constexpr noexcept

Checks if a behavior mask contains a specific flag.

Parameters
mask

The behavior mask to check.

flag

The flag to test for.

Returns

True if the mask contains the flag, false otherwise.

Definition at line 135 of file CollisionBehavior.ixx.

135 [[nodiscard]] constexpr bool hasFlag(const CollisionBehavior mask, const CollisionBehavior flag) noexcept {
136 return (mask & flag) == flag;
137 }

Referenced by helios::engine::modules::physics::collision::systems::CollisionStateResponseSystem::update.

Variables

CollisionBehaviorItemSize

size_t helios::engine::modules::physics::collision::types::CollisionBehaviorItemSize = 8
constexpr

Number of distinct CollisionBehavior flags.

Definition at line 97 of file CollisionBehavior.ixx.

97 constexpr size_t CollisionBehaviorItemSize = 8;

MAX_COLLISION_LAYERS

std::size_t helios::engine::modules::physics::collision::types::MAX_COLLISION_LAYERS = std::numeric_limits<CollisionLayer>::digits
constexpr

Maximum number of distinct collision layers.

Derived from the number of bits in CollisionLayer (32 for uint32_t).

Definition at line 29 of file CollisionLayer.ixx.

29 constexpr std::size_t MAX_COLLISION_LAYERS = std::numeric_limits<CollisionLayer>::digits;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.