Add world based axis modification to rotations
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user