diff --git a/syncoverrides.cc b/syncoverrides.cc index 81435f5..47fa7a1 100644 --- a/syncoverrides.cc +++ b/syncoverrides.cc @@ -1125,26 +1125,29 @@ void T_CamOverride::makeEditWidgets( T_StringBuilder& sb ) noexcept { auto& sinp( Globals::Sync( ).inputs( ) ); - - // Set field of view / near plane auto const& fc( *fovConfig_ ); - if ( fc.mode == FM_FOV ) { - camera_.fieldOfView( sinp[ inputPos_[ fc.inputIndex ] ] ); - } else { - camera_.nearPlane( sinp[ inputPos_[ fc.inputIndex ] ] ); - } - // Set camera parameters - const glm::vec3 lookAt{ vectorFromInputs( *target_ ) }; - if ( camMode_ == CM_ANGLES ) { - const glm::vec3 angles{ vectorFromInputs( *angles_ ) }; - const float distance{ sinp[ inputPos_[ *distance_ ] ] }; - camera_.camera( lookAt , angles , distance ); - } else { - const glm::vec3 position{ vectorFromInputs( *position_ ) }; - const glm::vec3 up{ vectorFromInputs( *upVector_ ) }; - camera_.camera( lookAt , position , up ); + if ( !enabled( ) || !prevEnabled_ ) { + // Set field of view / near plane + if ( fc.mode == FM_FOV ) { + camera_.fieldOfView( sinp[ inputPos_[ fc.inputIndex ] ] ); + } else { + camera_.nearPlane( sinp[ inputPos_[ fc.inputIndex ] ] ); + } + + // Set camera parameters + const glm::vec3 lookAt{ vectorFromInputs( *target_ ) }; + if ( camMode_ == CM_ANGLES ) { + const glm::vec3 angles{ vectorFromInputs( *angles_ ) }; + const float distance{ sinp[ inputPos_[ *distance_ ] ] }; + camera_.camera( lookAt , angles , distance ); + } else { + const glm::vec3 position{ vectorFromInputs( *position_ ) }; + const glm::vec3 up{ vectorFromInputs( *upVector_ ) }; + camera_.camera( lookAt , position , up ); + } } + prevEnabled_ = enabled( ); // Draw UI char const* const name( buildLabel( counter , sb ) ); diff --git a/syncoverrides.hh b/syncoverrides.hh index 8c7f234..0674cad 100644 --- a/syncoverrides.hh +++ b/syncoverrides.hh @@ -267,6 +267,8 @@ class T_CamOverride : public A_SyncOverride E_CamMode_ camMode_; T_Camera camera_; + bool prevEnabled_{ false }; + public: T_CamOverride( T_String const& title ) noexcept;