Skip to main content

YawPitchRollUpdateSystem.ixx File

System that converts yaw/pitch/roll angles to local rotation quaternions. More...

Included Headers​

#include <cmath> #include <numbers> #include <helios.engine.core.types.ComponentTypeTags> #include <helios.math> #include <helios.engine.spatial.components> #include <helios.ecs.components> #include <helios.engine.runtime.world.UpdateContext> #include <helios.engine.runtime.world.tags.SystemRole>

Namespaces Index​

namespacehelios
namespaceengine
namespacescene
namespacesystems

Classes Index​

classYawPitchRollUpdateSystem<TMemberHandle>

Updates Rotation3DComponent<..., Local> from YawPitchRollComponent. More...

Description​

System that converts yaw/pitch/roll angles to local rotation quaternions.

File Listing​

The file content with the documentation metadata removed is:

1
5module;
6
7#include <cmath>
8#include <numbers>
9
10export module helios.engine.spatial.systems.YawPitchRollUpdateSystem;
11
12import helios.engine.runtime.world.tags.SystemRole;
13
14import helios.engine.runtime.world.UpdateContext;
15
16import helios.ecs.components;
17import helios.engine.spatial.components;
18
19
20import helios.math;
21import helios.engine.core.types.ComponentTypeTags;
22
23using namespace helios::engine::core::types;
24using namespace helios::ecs::components;
28export namespace helios::engine::scene::systems {
29
35 template<typename TMemberHandle>
37
44 [[nodiscard]] float wrapRad(float a) const noexcept {
45 constexpr float pi = std::numbers::pi_v<float>;
46 constexpr float twoPi = 2.0f * pi;
47 return std::fmod(std::fmod(a + pi, twoPi) + twoPi, twoPi) - pi;
48 }
49
50 public:
51
56
66
67
72 >().withActive()
73 .template whereAnyDirty<
76 >()) {
77 constexpr auto x = helios::math::X_AXISf;
78 constexpr auto y = helios::math::Y_AXISf;
79 constexpr auto z = helios::math::Z_AXISf;
80
81 const auto yaw = wrapRad(yawPitchRoll->yaw);
82 const auto pitch = wrapRad(yawPitchRoll->pitch);
83 const auto roll = wrapRad(yawPitchRoll->roll);
84
85 const auto qYaw = helios::math::quatf::fromAxisAngle(y, yaw);
86 const auto qPitch = helios::math::quatf::fromAxisAngle(x, pitch);
87 const auto qRoll = helios::math::quatf::fromAxisAngle(z, roll);
88
89 entity.setTrackedValue(localRotation, qYaw * qPitch * qRoll);
90 }
91
92 }
93
94
95 };
96}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.