SteeringSystem.ixx File
System for updating entity heading and rotation. More...
Included Headers
#include <algorithm>
#include <cassert>
#include <cmath>
#include <helios.engine.mechanics.lifecycle.components.Active>
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.engine.common.tags.SystemRole>
#include <helios.engine.modules.spatial.transform.components.RotationStateComponent>
#include <helios.engine.modules.physics.motion.components.DirectionComponent>
#include <helios.engine.modules.physics.motion.components.SteeringComponent>
#include <helios.engine.runtime.world.GameWorld>
#include <helios.engine.modules.spatial.transform.components.ComposeTransformComponent>
#include <helios.math>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | modules |
|
Domain-specific components and systems. More... | |
| namespace | physics |
|
Physics simulation and collision detection subsystem for the game engine. More... | |
| namespace | motion |
|
Motion physics components and systems. More... | |
| namespace | systems |
Classes Index
| class | SteeringSystem |
|
System that processes heading and rotation physics. More... | |
Description
System for updating entity heading and rotation.
File Listing
The file content with the documentation metadata removed is:
30export namespace helios::engine::modules::physics::motion::systems {
40 class SteeringSystem {
65 float currentRotationSpeed = cmp->currentRotationSpeed();
66 float currentRotationAngle = cmp->currentRotationAngle();
67 float rotationAngleDelta = cmp->rotationAngleDelta();
68 bool headingStateChanged = cmp->stateChanged();
72 currentRotationSpeed *= std::pow(cmp->rotationDampening(), deltaTime);
78 cmp->setCurrentRotationSpeed(currentRotationSpeed);
84 if (cmp->useInstantRotation()) {
85 currentRotationAngle = cmp->targetRotationAngle();
98 rotationAngleDelta = std::fmod((cmp->targetRotationAngle() - currentRotationAngle) + 540.0f, 360.0f) - 180.0f;
102 currentRotationAngle = cmp->targetRotationAngle();
107 cmp->setCurrentRotationAngle(currentRotationAngle);
108 cmp->setRotationAngleDelta(rotationAngleDelta);
109 cmp->setCurrentRotationSpeed(currentRotationSpeed);
124 void update(helios::engine::runtime::world::UpdateContext& updateContext) noexcept {
137 auto targetRotationAngle = helios::math::degrees(std::atan2(direction[1], direction[0]));
138 auto rotationAngleDelta = std::fmod((targetRotationAngle - hc->currentRotationAngle()) + 540.0f, 360.0f) - 180.0f;
141 float turnBoost = 1.0f + turnBoostFactor * std::clamp((abs(rotationAngleDelta))/180.f, 0.0f, 1.0f);
156 float rad = helios::math::radians(rotationAngle);
159 dc->setDirection(helios::math::vec3f{cos(rad), sin(rad), 0.0f});
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.