SteeringComponent.ixx File
Component for managing entity heading and rotation physics. More...
Included Headers
#include <algorithm>
#include <cassert>
#include <cmath>
#include <memory>
#include <helios.engine.modules.scene.components.SceneNodeComponent>
#include <helios.engine.ecs.GameObject>
#include <helios.core.units.Unit>
#include <helios.math>
#include <helios.core.spatial.Transform>
#include <helios.util.Guid>
#include <helios.scene.SceneNode>
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 | components |
|
Physics and movement components for game entities. More... | |
Classes Index
| class | SteeringComponent |
|
Component that manages the heading (orientation) of an entity. More... | |
Description
Component for managing entity heading and rotation physics.
File Listing
The file content with the documentation metadata removed is:
24export namespace helios::engine::modules::physics::motion::components {
35 class SteeringComponent {
42 static constexpr float DEFAULT_ROTATION_SPEED = 560.0f;
47 static constexpr float DEFAULT_ROTATION_SPEED_THRESHOLD = 0.1f;
52 static constexpr float DEFAULT_ROTATION_DAMPENING = 0.0001f;
57 float rotationSpeed_ = DEFAULT_ROTATION_SPEED;
72 float currentRotationAngle_ = 0;
77 float targetRotationAngle_ = 0;
82 float rotationAngleDelta_ = 0;
87 float currentRotationSpeed_ = 0.0f;
92 bool stateChanged_ = true;
100 float turnIntensity_ = 0.0f;
120 bool useInstantRotation_ = false;
128 bool directionFromSteering_ = false;
133 bool isEnabled_ = true;
143 return isEnabled_;
150 isEnabled_ = true;
157 isEnabled_ = false;
163 SteeringComponent() = default;
171 explicit SteeringComponent(bool useInstantRotation, bool directionFromSteering = false) :
179 SteeringComponent(const SteeringComponent& other) :
180 useInstantRotation_(other.useInstantRotation_),
181 rotationSpeed_(other.rotationSpeed_),
182 directionFromSteering_(other.directionFromSteering_),
183 rotationSpeedThreshold_(other.rotationSpeedThreshold_),
184 rotationDampening_(other.rotationDampening_),
185 rotationAxis_(other.rotationAxis_) {}
187 SteeringComponent& operator=(const SteeringComponent&) = default;
188 SteeringComponent(SteeringComponent&&) noexcept = default;
189 SteeringComponent& operator=(SteeringComponent&&) noexcept = default;
194 void setHeading(helios::math::vec3f direction, float turnIntensity) {
195 setSteeringIntent(direction, turnIntensity);
203 void setDirectionFromSteering(const bool directionFromSteering) noexcept {
212 bool directionFromSteering() const noexcept {
213 return directionFromSteering_;
221 [[nodiscard]] bool useInstantRotation() const noexcept {
222 return useInstantRotation_;
230 void setUseInstantRotation(const bool useInstantRotation) noexcept {
247 void setSteeringIntent(helios::math::vec3f direction, float turnIntensity) {
249 steeringInput_ = direction;
250 turnIntensity_ = turnIntensity;
251 stateChanged_ = true;
253 if (turnIntensity_ <= helios::math::EPSILON_LENGTH) {
254 steeringInput_ = {0.0f, 0.0f, 0.0f};
255 stateChanged_ = false;
256 turnIntensity_ = 0.0f;
260 assert(direction.isNormalized() && "Unexpected direction vector - not normalized");
270 [[nodiscard]] helios::math::vec3f rotationAxis() const noexcept {
271 return rotationAxis_;
279 void setCurrentRotationSpeed(float speed) noexcept {
280 currentRotationSpeed_ = speed;
288 [[nodiscard]] float currentRotationSpeed() const noexcept {
289 return currentRotationSpeed_;
297 [[nodiscard]] float rotationAngleDelta() const noexcept {
298 return rotationAngleDelta_;
306 [[nodiscard]] float currentRotationAngle() const noexcept {
307 return currentRotationAngle_;
315 [[nodiscard]] float targetRotationAngle() const noexcept {
316 return targetRotationAngle_;
324 void setTargetRotationAngle(float angle) noexcept {
325 targetRotationAngle_ = angle;
333 void setCurrentRotationAngle(float angle) noexcept {
334 currentRotationAngle_ = angle;
342 void setRotationAngleDelta(float delta) noexcept {
343 rotationAngleDelta_ = delta;
351 [[nodiscard]] bool stateChanged() const noexcept {
352 return stateChanged_;
360 [[nodiscard]] const helios::math::vec3f& steeringInput() const noexcept {
361 return steeringInput_;
369 [[nodiscard]] const helios::math::vec3f& steeringIntent() const noexcept {
370 return steeringInput_;
378 [[nodiscard]] float rotationSpeed() const noexcept { return rotationSpeed_; }
385 [[nodiscard]] float rotationSpeedThreshold() const noexcept { return rotationSpeedThreshold_; }
392 [[nodiscard]] float rotationDampening() const noexcept { return rotationDampening_; }
399 void setRotationSpeed(float value) noexcept { rotationSpeed_ = value; }
408 void setRotationSpeedThreshold(float value) noexcept {
409 rotationSpeedThreshold_ = value;
417 void setRotationDampening(float value) noexcept {
418 rotationDampening_ = value;
426 [[nodiscard]] float turnIntensity() const noexcept {
427 return turnIntensity_;
437 void resetToDefaults() noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.