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_;
278 currentRotationAngle_ = 0.0f;
279 targetRotationAngle_ = 0.0f;
280 rotationAngleDelta_ = 0.0f;
281 currentRotationSpeed_ = 0.0f;
282 stateChanged_ = true;
283 turnIntensity_ = 0.0f;
284 steeringInput_ = {0.0f, 0.0f, 0.0f};
292 void setCurrentRotationSpeed(float speed) noexcept {
293 currentRotationSpeed_ = speed;
301 [[nodiscard]] float currentRotationSpeed() const noexcept {
302 return currentRotationSpeed_;
310 [[nodiscard]] float rotationAngleDelta() const noexcept {
311 return rotationAngleDelta_;
319 [[nodiscard]] float currentRotationAngle() const noexcept {
320 return currentRotationAngle_;
328 [[nodiscard]] float targetRotationAngle() const noexcept {
329 return targetRotationAngle_;
337 void setTargetRotationAngle(float angle) noexcept {
338 targetRotationAngle_ = angle;
346 void setCurrentRotationAngle(float angle) noexcept {
347 currentRotationAngle_ = angle;
355 void setRotationAngleDelta(float delta) noexcept {
356 rotationAngleDelta_ = delta;
364 [[nodiscard]] bool stateChanged() const noexcept {
365 return stateChanged_;
373 [[nodiscard]] const helios::math::vec3f& steeringInput() const noexcept {
374 return steeringInput_;
382 [[nodiscard]] const helios::math::vec3f& steeringIntent() const noexcept {
383 return steeringInput_;
391 [[nodiscard]] float rotationSpeed() const noexcept { return rotationSpeed_; }
398 [[nodiscard]] float rotationSpeedThreshold() const noexcept { return rotationSpeedThreshold_; }
405 [[nodiscard]] float rotationDampening() const noexcept { return rotationDampening_; }
412 void setRotationSpeed(float value) noexcept { rotationSpeed_ = value; }
421 void setRotationSpeedThreshold(float value) noexcept {
422 rotationSpeedThreshold_ = value;
430 void setRotationDampening(float value) noexcept {
431 rotationDampening_ = value;
439 [[nodiscard]] float turnIntensity() const noexcept {
440 return turnIntensity_;
450 void resetToDefaults() noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.