Overrides - Functionality implemented
... with a few leftover bugs and a few missing features. Still, it works nicely.
This commit is contained in:
parent
2b1657ac3a
commit
afe7c43351
11 changed files with 248 additions and 82 deletions
7
TODO
7
TODO
|
@ -26,10 +26,6 @@ Scripting:
|
||||||
* (Output only) Texture / framebuffer re-use
|
* (Output only) Texture / framebuffer re-use
|
||||||
|
|
||||||
Sync / inputs:
|
Sync / inputs:
|
||||||
* Support for overrides
|
|
||||||
* Camera controls
|
|
||||||
* FoV vs near plane
|
|
||||||
* Target/angles/distance vs dir/up/left
|
|
||||||
* Curve / timeline display
|
* Curve / timeline display
|
||||||
* Display selected input values
|
* Display selected input values
|
||||||
* Display selected overrides
|
* Display selected overrides
|
||||||
|
@ -40,3 +36,6 @@ Misc:
|
||||||
* Color grading controls:
|
* Color grading controls:
|
||||||
* White balance control in components tab
|
* White balance control in components tab
|
||||||
* Don't reset when hitting value or saturation 0
|
* Don't reset when hitting value or saturation 0
|
||||||
|
* Camera
|
||||||
|
* Control for up vector - check if something more appropriate exists?
|
||||||
|
* Vector controls are too sensitive
|
||||||
|
|
25
camera.cc
25
camera.cc
|
@ -81,28 +81,27 @@ void T_Camera::cvtVectorsToAngles( ) noexcept
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void T_Camera::handleDND(
|
void T_Camera::handleDragAndDrop(
|
||||||
ImVec2 const& move ,
|
ImVec2 const& move ,
|
||||||
const bool hasCtrl ,
|
T_KeyboardModifiers modifiers ,
|
||||||
const bool hasShift ,
|
T_MouseButtons buttons ) noexcept
|
||||||
const bool lmb ) noexcept
|
|
||||||
{
|
{
|
||||||
if ( move.x == 0 || move.y == 0 ) {
|
if ( move.x == 0 || move.y == 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float fdx( move.x * .1f * ( hasCtrl ? 1.f : .1f ) );
|
const float fdx( move.x * .1f * ( ( modifiers & E_KeyboardModifier::CTRL ) ? 1.f : .1f ) );
|
||||||
const float fdy( move.y * .1f * ( hasCtrl ? 1.f : .1f ) );
|
const float fdy( move.y * .1f * ( ( modifiers & E_KeyboardModifier::CTRL ) ? 1.f : .1f ) );
|
||||||
|
|
||||||
if ( lmb && hasShift ) {
|
if ( ( buttons & E_MouseButton::LEFT ) && ( modifiers & E_KeyboardModifier::SHIFT ) ) {
|
||||||
// Left mouse button, shift - move camera
|
// Left mouse button, shift - move camera
|
||||||
const auto side( glm::normalize( glm::cross( up_ , dir_ ) ) );
|
const auto side( glm::normalize( glm::cross( up_ , dir_ ) ) );
|
||||||
lookAt_ += .1f * ( side * fdx + up_ * fdy );
|
lookAt_ += .1f * ( side * fdx + up_ * fdy );
|
||||||
} else if ( lmb ) {
|
} else if ( buttons & E_MouseButton::LEFT ) {
|
||||||
// Left mouse button, no shift - change yaw/pitch
|
// Left mouse button, no shift - change yaw/pitch
|
||||||
updateAngle( angles_.y , fdx );
|
updateAngle( angles_.y , fdx );
|
||||||
updateAngle( angles_.x , fdy );
|
updateAngle( angles_.x , fdy );
|
||||||
} else {
|
} else if ( buttons & E_MouseButton::RIGHT ) {
|
||||||
// Right mouse button - change roll
|
// Right mouse button - change roll
|
||||||
updateAngle( angles_.z , fdx );
|
updateAngle( angles_.z , fdx );
|
||||||
}
|
}
|
||||||
|
@ -111,11 +110,11 @@ void T_Camera::handleDND(
|
||||||
|
|
||||||
void T_Camera::handleWheel(
|
void T_Camera::handleWheel(
|
||||||
const float wheel ,
|
const float wheel ,
|
||||||
const bool hasCtrl ,
|
T_KeyboardModifiers modifiers ,
|
||||||
const bool hasShift ) noexcept
|
T_MouseButtons /* buttons */ ) noexcept
|
||||||
{
|
{
|
||||||
const float delta( wheel * ( hasCtrl ? 1.f : .1f) );
|
const float delta( wheel * ( ( modifiers & E_KeyboardModifier::CTRL ) ? 1.f : .1f) );
|
||||||
if ( hasShift ) {
|
if ( modifiers & E_KeyboardModifier::SHIFT ) {
|
||||||
fov_ = std::max( 1.f , std::min( 179.f , fov_ + delta ) );
|
fov_ = std::max( 1.f , std::min( 179.f , fov_ + delta ) );
|
||||||
cvtFov2Np( );
|
cvtFov2Np( );
|
||||||
} else {
|
} else {
|
||||||
|
|
21
camera.hh
21
camera.hh
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef REAL_BUILD
|
#include "imousectrl.hh"
|
||||||
# include "externals.hh"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*= T_Camera =================================================================*/
|
/*= T_Camera =================================================================*/
|
||||||
|
@ -17,7 +15,7 @@
|
||||||
* - position, direction and up vectors
|
* - position, direction and up vectors
|
||||||
* Modifying one of the sets updates the other.
|
* Modifying one of the sets updates the other.
|
||||||
*/
|
*/
|
||||||
struct T_Camera
|
struct T_Camera : public virtual A_MouseCtrl
|
||||||
{
|
{
|
||||||
T_Camera( ) noexcept;
|
T_Camera( ) noexcept;
|
||||||
|
|
||||||
|
@ -105,16 +103,13 @@ struct T_Camera
|
||||||
|
|
||||||
T_Changes makeUI( ) noexcept;
|
T_Changes makeUI( ) noexcept;
|
||||||
|
|
||||||
void handleDND(
|
void handleDragAndDrop(
|
||||||
ImVec2 const& move ,
|
ImVec2 const& move ,
|
||||||
const bool hasCtrl ,
|
T_KeyboardModifiers modifiers ,
|
||||||
const bool hasShift ,
|
T_MouseButtons buttons ) noexcept override;
|
||||||
const bool lmb // Left mouse button
|
|
||||||
) noexcept;
|
|
||||||
void handleWheel(
|
void handleWheel(
|
||||||
const float wheel ,
|
float wheel ,
|
||||||
const bool hasCtrl ,
|
T_KeyboardModifiers modifiers ,
|
||||||
const bool hasShift
|
T_MouseButtons buttons ) noexcept override;
|
||||||
) noexcept;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
18
demo.cc
18
demo.cc
|
@ -40,24 +40,6 @@ void T_Demo::render( )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_Demo::handleDND(
|
|
||||||
ImVec2 const& move ,
|
|
||||||
const bool hasCtrl ,
|
|
||||||
const bool hasShift ,
|
|
||||||
const bool lmb // Left mouse button
|
|
||||||
)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void T_Demo::handleWheel(
|
|
||||||
const float wheel ,
|
|
||||||
const bool hasCtrl ,
|
|
||||||
const bool hasShift
|
|
||||||
)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool T_Demo::runInit(
|
bool T_Demo::runInit(
|
||||||
ops::T_OpProgram& p )
|
ops::T_OpProgram& p )
|
||||||
{
|
{
|
||||||
|
|
12
demo.hh
12
demo.hh
|
@ -18,18 +18,6 @@ struct T_Demo
|
||||||
const uint32_t height );
|
const uint32_t height );
|
||||||
void render( );
|
void render( );
|
||||||
|
|
||||||
void handleDND(
|
|
||||||
ImVec2 const& move ,
|
|
||||||
const bool hasCtrl ,
|
|
||||||
const bool hasShift ,
|
|
||||||
const bool lmb // Left mouse button
|
|
||||||
);
|
|
||||||
void handleWheel(
|
|
||||||
const float wheel ,
|
|
||||||
const bool hasCtrl ,
|
|
||||||
const bool hasShift
|
|
||||||
);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
46
imousectrl.hh
Normal file
46
imousectrl.hh
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#pragma once
|
||||||
|
#ifndef REAL_BUILD
|
||||||
|
# include "externals.hh"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*= MOUSE CONTROLS INTERFACE ===================================================*/
|
||||||
|
|
||||||
|
enum class E_MouseButton {
|
||||||
|
LEFT ,
|
||||||
|
MIDDLE ,
|
||||||
|
RIGHT ,
|
||||||
|
};
|
||||||
|
using T_MouseButtons = T_Flags< E_MouseButton >;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
enum class E_KeyboardModifier
|
||||||
|
{
|
||||||
|
CTRL ,
|
||||||
|
SHIFT ,
|
||||||
|
ALT ,
|
||||||
|
};
|
||||||
|
using T_KeyboardModifiers = T_Flags< E_KeyboardModifier >;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class A_MouseCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~A_MouseCtrl( ) = 0;
|
||||||
|
|
||||||
|
virtual void handleDragAndDrop(
|
||||||
|
ImVec2 const& move ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons
|
||||||
|
) noexcept = 0;
|
||||||
|
|
||||||
|
virtual void handleWheel(
|
||||||
|
float wheel ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons
|
||||||
|
) noexcept = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline A_MouseCtrl::~A_MouseCtrl() {}
|
53
main.cc
53
main.cc
|
@ -142,36 +142,57 @@ void T_Main::startIteration( )
|
||||||
|
|
||||||
void T_Main::handleCapture( )
|
void T_Main::handleCapture( )
|
||||||
{
|
{
|
||||||
auto const& io( ImGui::GetIO( ) );
|
using namespace ImGui;
|
||||||
const bool lmb( ImGui::IsMouseDown( 0 ) );
|
auto const& io( GetIO( ) );
|
||||||
const bool mb( lmb || ImGui::IsMouseDown( 1 ) );
|
const T_MouseButtons mb( ([]() {;
|
||||||
|
T_MouseButtons mb;
|
||||||
|
if ( IsMouseDown( 0 ) ) {
|
||||||
|
mb |= E_MouseButton::LEFT;
|
||||||
|
}
|
||||||
|
if ( IsMouseDown( 1 ) ) {
|
||||||
|
mb |= E_MouseButton::RIGHT;
|
||||||
|
}
|
||||||
|
if ( IsMouseDown( 2 ) ) {
|
||||||
|
mb |= E_MouseButton::MIDDLE;
|
||||||
|
}
|
||||||
|
return mb;
|
||||||
|
})() );
|
||||||
|
const T_KeyboardModifiers kb( ([&io]() {
|
||||||
|
T_KeyboardModifiers kb;
|
||||||
|
if ( io.KeyCtrl ) {
|
||||||
|
kb |= E_KeyboardModifier::CTRL;
|
||||||
|
}
|
||||||
|
if ( io.KeyShift ) {
|
||||||
|
kb |= E_KeyboardModifier::SHIFT;
|
||||||
|
}
|
||||||
|
if ( io.KeyAlt ) {
|
||||||
|
kb |= E_KeyboardModifier::ALT;
|
||||||
|
}
|
||||||
|
return kb;
|
||||||
|
})() );
|
||||||
const bool appCanGrab( !( ImGui::IsMouseHoveringAnyWindow( )
|
const bool appCanGrab( !( ImGui::IsMouseHoveringAnyWindow( )
|
||||||
|| io.WantCaptureMouse
|
|| io.WantCaptureMouse
|
||||||
|| io.WantCaptureKeyboard ) );
|
|| io.WantCaptureKeyboard ) );
|
||||||
const bool shift( io.KeyShift );
|
|
||||||
const bool ctrl( io.KeyCtrl );
|
|
||||||
|
|
||||||
if ( capture && !mb ) {
|
if ( capture && !mb ) {
|
||||||
capture = false;
|
capture = false;
|
||||||
ImGui::CaptureMouseFromApp( false );
|
CaptureMouseFromApp( false );
|
||||||
SDL_SetRelativeMouseMode( SDL_FALSE );
|
SDL_SetRelativeMouseMode( SDL_FALSE );
|
||||||
Globals::Window( ).warpMouse( mouseInitial );
|
Globals::Window( ).warpMouse( mouseInitial );
|
||||||
ImGui::SetMouseCursor( ImGuiMouseCursor_Arrow );
|
SetMouseCursor( ImGuiMouseCursor_Arrow );
|
||||||
} else if ( capture ) {
|
} else if ( capture ) {
|
||||||
ImGui::SetMouseCursor( ImGuiMouseCursor_Move );
|
SetMouseCursor( ImGuiMouseCursor_Move );
|
||||||
if ( demo ) {
|
Globals::Sync( ).handleDragAndDrop( mouseMove , kb , mb );
|
||||||
demo->handleDND( mouseMove , ctrl , shift , lmb );
|
|
||||||
}
|
|
||||||
} else if ( appCanGrab && mb ) {
|
} else if ( appCanGrab && mb ) {
|
||||||
capture = true;
|
capture = true;
|
||||||
mouseInitial = ImGui::GetMousePos( );
|
mouseInitial = GetMousePos( );
|
||||||
ImGui::CaptureMouseFromApp( true );
|
CaptureMouseFromApp( true );
|
||||||
SDL_SetRelativeMouseMode( SDL_TRUE );
|
SDL_SetRelativeMouseMode( SDL_TRUE );
|
||||||
ImGui::SetMouseCursor( ImGuiMouseCursor_Move );
|
SetMouseCursor( ImGuiMouseCursor_Move );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( appCanGrab || capture ) && io.MouseWheel && demo ) {
|
if ( ( appCanGrab || capture ) && io.MouseWheel ) {
|
||||||
demo->handleWheel( io.MouseWheel , ctrl , shift );
|
Globals::Sync( ).handleWheel( io.MouseWheel , kb , mb );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
32
sync.cc
32
sync.cc
|
@ -2,6 +2,7 @@
|
||||||
#include "sync.hh"
|
#include "sync.hh"
|
||||||
#include "globals.hh"
|
#include "globals.hh"
|
||||||
|
|
||||||
|
#include <imgui_internal.h>
|
||||||
#include <ebcl/Files.hh>
|
#include <ebcl/Files.hh>
|
||||||
#include <ebcl/SRDText.hh>
|
#include <ebcl/SRDText.hh>
|
||||||
#include <ebcl/SRDParser.hh>
|
#include <ebcl/SRDParser.hh>
|
||||||
|
@ -555,6 +556,14 @@ void T_SyncManager::updateTime( ) noexcept
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void T_SyncManager::clearInputs( ) noexcept
|
||||||
|
{
|
||||||
|
clearOverrides( );
|
||||||
|
values_.clear( );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void T_SyncManager::checkCurveFile( )
|
void T_SyncManager::checkCurveFile( )
|
||||||
{
|
{
|
||||||
if ( watcher_ ) {
|
if ( watcher_ ) {
|
||||||
|
@ -664,6 +673,7 @@ void T_SyncManager::updateValues( )
|
||||||
|
|
||||||
void T_SyncManager::clearOverrides( ) noexcept
|
void T_SyncManager::clearOverrides( ) noexcept
|
||||||
{
|
{
|
||||||
|
mouseDelegate_ = nullptr;
|
||||||
soRoot_.subsections.clear( );
|
soRoot_.subsections.clear( );
|
||||||
soRoot_.overrides.clear( );
|
soRoot_.overrides.clear( );
|
||||||
}
|
}
|
||||||
|
@ -765,3 +775,25 @@ void T_SyncManager::makeOverridesWindow( )
|
||||||
}
|
}
|
||||||
End( );
|
End( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void T_SyncManager::handleDragAndDrop(
|
||||||
|
ImVec2 const& move ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept
|
||||||
|
{
|
||||||
|
if ( mouseDelegate_ ) {
|
||||||
|
mouseDelegate_->handleDragAndDrop( move , modifiers , buttons );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void T_SyncManager::handleWheel(
|
||||||
|
const float wheel ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept
|
||||||
|
{
|
||||||
|
if ( mouseDelegate_ ) {
|
||||||
|
mouseDelegate_->handleWheel( wheel , modifiers , buttons );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
33
sync.hh
33
sync.hh
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "filewatcher.hh"
|
#include "filewatcher.hh"
|
||||||
#include "utilities.hh"
|
#include "utilities.hh"
|
||||||
#include "imgui_internal.h"
|
#include "imousectrl.hh"
|
||||||
|
|
||||||
#include <ebcl/SRDParserConfig.hh>
|
#include <ebcl/SRDParserConfig.hh>
|
||||||
#include <ebcl/Sets.hh>
|
#include <ebcl/Sets.hh>
|
||||||
|
@ -272,10 +272,11 @@ struct T_SyncOverrideVisitor
|
||||||
|
|
||||||
// Synchronisation manager; handles all the synchronization data and makes it
|
// Synchronisation manager; handles all the synchronization data and makes it
|
||||||
// work together.
|
// work together.
|
||||||
struct T_SyncManager
|
struct T_SyncManager : public virtual A_MouseCtrl
|
||||||
{
|
{
|
||||||
T_SyncManager( );
|
T_SyncManager( );
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Duration & time controls
|
// Duration & time controls
|
||||||
|
|
||||||
|
@ -297,11 +298,11 @@ struct T_SyncManager
|
||||||
{ return time_.time >= time_.duration( ); }
|
{ return time_.time >= time_.duration( ); }
|
||||||
void updateTime( ) noexcept;
|
void updateTime( ) noexcept;
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Value access
|
// Value access
|
||||||
|
|
||||||
void clearInputs( )
|
void clearInputs( ) noexcept;
|
||||||
{ values_.clear( ); }
|
|
||||||
bool addInput( T_String const& name ,
|
bool addInput( T_String const& name ,
|
||||||
const float initial = 0.f ) noexcept
|
const float initial = 0.f ) noexcept
|
||||||
{ return values_.addValue( name , initial ); }
|
{ return values_.addValue( name , initial ); }
|
||||||
|
@ -313,6 +314,7 @@ struct T_SyncManager
|
||||||
T_Array< float >& inputs( ) noexcept
|
T_Array< float >& inputs( ) noexcept
|
||||||
{ return values_.values; }
|
{ return values_.values; }
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Curves
|
// Curves
|
||||||
|
|
||||||
|
@ -324,6 +326,7 @@ struct T_SyncManager
|
||||||
void curvesChanged_( );
|
void curvesChanged_( );
|
||||||
bool loadCurves_( bool& missing );
|
bool loadCurves_( bool& missing );
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Overrides
|
// Overrides
|
||||||
|
|
||||||
|
@ -342,6 +345,7 @@ struct T_SyncManager
|
||||||
void updateCurveCaches( );
|
void updateCurveCaches( );
|
||||||
void updateValues( );
|
void updateValues( );
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// User interface
|
// User interface
|
||||||
|
|
||||||
|
@ -353,6 +357,26 @@ struct T_SyncManager
|
||||||
{ return ovWindow_; }
|
{ return ovWindow_; }
|
||||||
void makeOverridesWindow( );
|
void makeOverridesWindow( );
|
||||||
|
|
||||||
|
void delegateMouse( A_MouseCtrl& delegate ) noexcept
|
||||||
|
{ mouseDelegate_ = &delegate; }
|
||||||
|
void clearMouseDelegate( ) noexcept
|
||||||
|
{ mouseDelegate_ = nullptr; }
|
||||||
|
bool isCurrentDelegate( A_MouseCtrl const& delegate ) noexcept
|
||||||
|
{ return mouseDelegate_ == &delegate; }
|
||||||
|
|
||||||
|
void handleDragAndDrop(
|
||||||
|
ImVec2 const& move ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept override;
|
||||||
|
void handleWheel(
|
||||||
|
float wheel ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept override;
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
// Private data
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ebcl::T_SRDParserConfig pConfig_; // Parser config for curves
|
ebcl::T_SRDParserConfig pConfig_; // Parser config for curves
|
||||||
P_WatchedFiles watcher_; // Curves file watcher
|
P_WatchedFiles watcher_; // Curves file watcher
|
||||||
|
@ -366,4 +390,5 @@ struct T_SyncManager
|
||||||
T_Array< P_SyncCurveCache > curveCaches_; // Cache for curve segments
|
T_Array< P_SyncCurveCache > curveCaches_; // Cache for curve segments
|
||||||
bool ovWindow_{ false }; // Overrides window
|
bool ovWindow_{ false }; // Overrides window
|
||||||
T_SyncOverrideSection soRoot_; // Root for overrides
|
T_SyncOverrideSection soRoot_; // Root for overrides
|
||||||
|
A_MouseCtrl* mouseDelegate_{ nullptr }; // Delegate for mouse actions
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "syncoverrides.hh"
|
#include "syncoverrides.hh"
|
||||||
#include "colorgrading.hh"
|
#include "colorgrading.hh"
|
||||||
|
|
||||||
|
#include <imgui_internal.h>
|
||||||
#include <ebcl/SRDParser.hh>
|
#include <ebcl/SRDParser.hh>
|
||||||
|
|
||||||
using namespace sov;
|
using namespace sov;
|
||||||
|
@ -1124,7 +1125,8 @@ void T_CamOverride::makeEditWidgets(
|
||||||
uint32_t& counter ,
|
uint32_t& counter ,
|
||||||
T_StringBuilder& sb ) noexcept
|
T_StringBuilder& sb ) noexcept
|
||||||
{
|
{
|
||||||
auto& sinp( Globals::Sync( ).inputs( ) );
|
auto& sync( Globals::Sync( ) );
|
||||||
|
auto& sinp( sync.inputs( ) );
|
||||||
auto const& fc( *fovConfig_ );
|
auto const& fc( *fovConfig_ );
|
||||||
|
|
||||||
if ( !enabled( ) || !prevEnabled_ ) {
|
if ( !enabled( ) || !prevEnabled_ ) {
|
||||||
|
@ -1151,13 +1153,24 @@ void T_CamOverride::makeEditWidgets(
|
||||||
|
|
||||||
// Draw UI
|
// Draw UI
|
||||||
char const* const name( buildLabel( counter , sb ) );
|
char const* const name( buildLabel( counter , sb ) );
|
||||||
|
bool mouseHandler{ sync.isCurrentDelegate( *this ) };
|
||||||
using namespace ImGui;
|
using namespace ImGui;
|
||||||
PushItemWidth( 0 ); // Compensate for -1
|
PushItemWidth( 0 ); // Compensate for -1
|
||||||
PushID( GetCurrentWindow( )->GetID( name ) );
|
PushID( GetCurrentWindow( )->GetID( name ) );
|
||||||
|
const bool handlerChanged{ Checkbox( "Mouse control" , &mouseHandler ) };
|
||||||
|
Separator( );
|
||||||
const auto changes{ camera_.makeUI( ) };
|
const auto changes{ camera_.makeUI( ) };
|
||||||
PopID( );
|
PopID( );
|
||||||
PopItemWidth( );
|
PopItemWidth( );
|
||||||
|
|
||||||
|
if ( handlerChanged ) {
|
||||||
|
if ( mouseHandler ) {
|
||||||
|
sync.delegateMouse( *this );
|
||||||
|
} else {
|
||||||
|
sync.clearMouseDelegate( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( changes & T_Camera::E_Changes::FOV ) {
|
if ( changes & T_Camera::E_Changes::FOV ) {
|
||||||
if ( fc.mode == FM_FOV ) {
|
if ( fc.mode == FM_FOV ) {
|
||||||
sinp[ inputPos_[ fc.inputIndex ] ] = camera_.fieldOfView( );
|
sinp[ inputPos_[ fc.inputIndex ] ] = camera_.fieldOfView( );
|
||||||
|
@ -1196,3 +1209,60 @@ void T_CamOverride::inputsFromVector(
|
||||||
sinp[ inputPos_[ vc.y ] ] = v.y;
|
sinp[ inputPos_[ vc.y ] ] = v.y;
|
||||||
sinp[ inputPos_[ vc.z ] ] = v.z;
|
sinp[ inputPos_[ vc.z ] ] = v.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void T_CamOverride::handleDragAndDrop(
|
||||||
|
ImVec2 const& move ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept
|
||||||
|
{
|
||||||
|
auto& sync( Globals::Sync( ) );
|
||||||
|
if ( !enabled( ) ) {
|
||||||
|
sync.clearMouseDelegate( );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
camera_.handleDragAndDrop( move , modifiers , buttons );
|
||||||
|
|
||||||
|
auto& sinp( sync.inputs( ) );
|
||||||
|
inputsFromVector( *target_ , camera_.lookAt( ) );
|
||||||
|
if ( camMode_ == CM_ANGLES ) {
|
||||||
|
inputsFromVector( *angles_ , camera_.angles( ) );
|
||||||
|
sinp[ inputPos_[ *distance_ ] ] = camera_.distance( );
|
||||||
|
} else {
|
||||||
|
inputsFromVector( *position_ , camera_.position( ) );
|
||||||
|
inputsFromVector( *upVector_ , camera_.upVector( ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void T_CamOverride::handleWheel(
|
||||||
|
const float wheel ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept
|
||||||
|
{
|
||||||
|
auto& sync( Globals::Sync( ) );
|
||||||
|
if ( !enabled( ) ) {
|
||||||
|
sync.clearMouseDelegate( );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
camera_.handleWheel( wheel , modifiers , buttons );
|
||||||
|
|
||||||
|
auto& sinp( sync.inputs( ) );
|
||||||
|
if ( modifiers & E_KeyboardModifier::SHIFT ) {
|
||||||
|
auto const& fc( *fovConfig_ );
|
||||||
|
if ( fc.mode == FM_FOV ) {
|
||||||
|
sinp[ inputPos_[ fc.inputIndex ] ] = camera_.fieldOfView( );
|
||||||
|
} else {
|
||||||
|
sinp[ inputPos_[ fc.inputIndex ] ] = camera_.nearPlane( );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputsFromVector( *target_ , camera_.lookAt( ) );
|
||||||
|
if ( camMode_ == CM_ANGLES ) {
|
||||||
|
inputsFromVector( *angles_ , camera_.angles( ) );
|
||||||
|
sinp[ inputPos_[ *distance_ ] ] = camera_.distance( );
|
||||||
|
} else {
|
||||||
|
inputsFromVector( *position_ , camera_.position( ) );
|
||||||
|
inputsFromVector( *upVector_ , camera_.upVector( ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ class T_ColorGrading : public A_SyncOverride
|
||||||
|
|
||||||
/*= CAMERA CONTROLS ============================================================*/
|
/*= CAMERA CONTROLS ============================================================*/
|
||||||
|
|
||||||
class T_CamOverride : public A_SyncOverride
|
class T_CamOverride : public A_SyncOverride , public virtual A_MouseCtrl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum E_SetState {
|
enum E_SetState {
|
||||||
|
@ -309,6 +309,15 @@ class T_CamOverride : public A_SyncOverride
|
||||||
T_Camera const& camData( ) const noexcept
|
T_Camera const& camData( ) const noexcept
|
||||||
{ return camera_; }
|
{ return camera_; }
|
||||||
|
|
||||||
|
void handleDragAndDrop(
|
||||||
|
ImVec2 const& move ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept override;
|
||||||
|
void handleWheel(
|
||||||
|
float wheel ,
|
||||||
|
T_KeyboardModifiers modifiers ,
|
||||||
|
T_MouseButtons buttons ) noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
E_SetState setVector(
|
E_SetState setVector(
|
||||||
T_Optional< T_VectorConfig_ >& vector ,
|
T_Optional< T_VectorConfig_ >& vector ,
|
||||||
|
|
Loading…
Reference in a new issue