Add world based axis modification to rotations

This commit is contained in:
2024-09-29 15:46:59 -04:00
parent 47c15f97bc
commit 79667be458
3 changed files with 26 additions and 2 deletions

View File

@@ -42,12 +42,12 @@ namespace fgl::engine::gui
if ( ImGui::IsKeyDown( ImGuiKey_RightArrow ) )
{
pitch_change.addZ( delta_time * yaw_rate );
pitch_change.addZWorld( delta_time * yaw_rate );
}
if ( ImGui::IsKeyDown( ImGuiKey_LeftArrow ) )
{
pitch_change.addZ( -( delta_time * yaw_rate ) );
pitch_change.addZWorld( -( delta_time * yaw_rate ) );
}
Vector move_dir { 0.0f };

View File

@@ -119,4 +119,22 @@ namespace fgl::engine
*this = *this * q;
}
void Rotation::addXWorld( const float value )
{
const glm::quat q { glm::angleAxis( value, constants::WORLD_X ) };
*this = q * *this;
}
void Rotation::addYWorld( const float value )
{
const glm::quat q { glm::angleAxis( value, constants::WORLD_Y ) };
*this = q * *this;
}
void Rotation::addZWorld( const float value )
{
const glm::quat q { glm::angleAxis( value, constants::WORLD_Z ) };
*this = q * *this;
}
} // namespace fgl::engine

View File

@@ -54,10 +54,16 @@ namespace fgl::engine
void setY( float );
void setZ( float );
// These will add a rotation using the local axis
void addX( float );
void addY( float );
void addZ( float );
// These will add a rotation using the world axis
void addXWorld( float );
void addYWorld( float );
void addZWorld( float );
// internal
inline glm::quat internal_quat() const { return static_cast< glm::quat >( *this ); }