Overrides - Camera angles problem fixed
Because of fucking numerical instability, updating the UI's input values every frame caused problems. Fixed this by making sure it's set only if the override is disabled or at the first frame after it is enabled.
This commit is contained in:
parent
75af2c15c7
commit
2b1657ac3a
2 changed files with 22 additions and 17 deletions
|
@ -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 ) );
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue