Skip to main content

SpinSystem.ixx File

System for applying continuous spin rotation to entities. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemodules

Domain-specific components and systems. More...

namespacephysics

Physics simulation and collision detection subsystem for the game engine. More...

namespacemotion

Motion physics components and systems. More...

namespacesystems

Classes Index

classSpinSystem

System that updates the spin rotation of entities. More...

Description

System for applying continuous spin rotation to entities.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SpinSystem.ixx
3 * @brief System for applying continuous spin rotation to entities.
4 */
5module;
6
7
8#include <cmath>
9
10export module helios.engine.modules.physics.motion.systems.SpinSystem;
11
12import helios.engine.ecs.System;
13import helios.engine.runtime.world.UpdateContext;
14import helios.engine.runtime.world.GameWorld;
15
16import helios.math;
17
18import helios.engine.modules.effects.gfx.components.SpinComponent;
19import helios.engine.modules.spatial.transform.components.ComposeTransformComponent;
20import helios.engine.modules.spatial.transform.components.RotationStateComponent;
21
22import helios.engine.mechanics.lifecycle.components.Active;
23
25
26 /**
27 * @brief System that updates the spin rotation of entities.
28 *
29 * @details
30 * This system iterates over entities with a SpinComponent and updates their
31 * accumulated rotation angle based on the spin speed and delta time.
32 * The updated rotation state is then written to the RotationStateComponent.
33 */
35
36 /**
37 * @brief Identity matrix constant.
38 */
39 inline static const helios::math::mat4f identity = helios::math::mat4f::identity();
40
41 public:
42
43 /**
44 * @brief Updates spin rotation for all applicable entities.
45 *
46 * @param updateContext Context containing frame timing and game state.
47 */
48 void update(helios::engine::runtime::world::UpdateContext& updateContext) noexcept override {
49
50
51 for (auto [entity, sc, rsc, active] : gameWorld_->view<
55 >().whereEnabled()) {
56
57 float delta = updateContext.deltaTime();
58
59 sc->setRotation(std::fmod(sc->rotation() + sc->speed() * delta, 360.0f));
60
61 rsc->setSpinRotationAxis(sc->axis());
62 rsc->setSpinRotationAngle(sc->rotation());
63 }
64
65
66 }
67 };
68
69
70}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.