From bee8b665a9b1b2424bb0b50ce2f5b07389b4ece7 Mon Sep 17 00:00:00 2001 From: sguionni Date: Fri, 6 Sep 2024 03:11:00 +0200 Subject: [PATCH 1/4] Remove old shortcut code --- .../include/app/controller/shortcut/debug.hpp | 31 ---------- .../app/controller/shortcut/global.hpp | 33 ----------- .../app/controller/shortcut/visualization.hpp | 36 ------------ .../app/core/controller/base_controller.hpp | 2 +- .../controller/base_shortcut_controller.hpp | 27 --------- .../include/app/core/controller/concepts.hpp | 12 ++++ .../app/core/init_visualization_mode.hpp | 11 ---- lib/app/include/app/mode/base_mode.hpp | 1 + lib/app/src/app/controller/shortcut/debug.cpp | 21 ------- .../src/app/controller/shortcut/global.cpp | 21 ------- .../app/controller/shortcut/visualization.cpp | 51 ----------------- .../app/core/animation/animation_system.cpp | 8 +-- .../controller/base_shortcut_controller.cpp | 28 --------- .../src/app/core/init_visualization_mode.cpp | 57 ------------------- lib/app/src/app/vtx_app.cpp | 6 +- 15 files changed, 20 insertions(+), 325 deletions(-) delete mode 100644 lib/app/include/app/controller/shortcut/debug.hpp delete mode 100644 lib/app/include/app/controller/shortcut/global.hpp delete mode 100644 lib/app/include/app/controller/shortcut/visualization.hpp delete mode 100644 lib/app/include/app/core/controller/base_shortcut_controller.hpp create mode 100644 lib/app/include/app/core/controller/concepts.hpp delete mode 100644 lib/app/include/app/core/init_visualization_mode.hpp delete mode 100644 lib/app/src/app/controller/shortcut/debug.cpp delete mode 100644 lib/app/src/app/controller/shortcut/global.cpp delete mode 100644 lib/app/src/app/controller/shortcut/visualization.cpp delete mode 100644 lib/app/src/app/core/controller/base_shortcut_controller.cpp delete mode 100644 lib/app/src/app/core/init_visualization_mode.cpp diff --git a/lib/app/include/app/controller/shortcut/debug.hpp b/lib/app/include/app/controller/shortcut/debug.hpp deleted file mode 100644 index 25f3646c7..000000000 --- a/lib/app/include/app/controller/shortcut/debug.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __VTX_UI_INTERNAL_CONTROLLER_DEBUG_SHORTCUT__ -#define __VTX_UI_INTERNAL_CONTROLLER_DEBUG_SHORTCUT__ - -#include "app/core/controller/base_shortcut_controller.hpp" -#include "app/core/controller/controller_manager.hpp" -#include -#include - -namespace VTX::App::Controller::Shortcut -{ - class Debug final : public Core::Controller::BaseShortcutController - { - public: - inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_DEBUG"; - inline static const VTX::Hash HASHED_COLLECTION_ID = Util::hash( COLLECTION_ID ); - - private: - inline static const Core::Controller::ControllerCollection::Registration _reg { COLLECTION_ID }; - - public: - Debug() = default; - Debug( const Debug & p_source ) = default; - ~Debug() = default; - - void init() override; - - inline VTX::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; - }; -} // namespace VTX::App::Controller::Shortcut -#endif diff --git a/lib/app/include/app/controller/shortcut/global.hpp b/lib/app/include/app/controller/shortcut/global.hpp deleted file mode 100644 index 58156e167..000000000 --- a/lib/app/include/app/controller/shortcut/global.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __VTX_UI_INTERNAL_CONTROLLER_GLOBAL_SHORTCUT__ -#define __VTX_UI_INTERNAL_CONTROLLER_GLOBAL_SHORTCUT__ - -#include "app/core/controller/base_controller.hpp" -#include "app/core/controller/base_shortcut_controller.hpp" -#include "app/core/controller/controller_manager.hpp" -#include -#include - -namespace VTX::App::Controller::Shortcut -{ - - class Global final : public Core::Controller::BaseShortcutController - { - public: - inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_GLOBAL"; - inline static const VTX::Hash HASHED_COLLECTION_ID = Util::hash( COLLECTION_ID ); - - private: - inline static const Core::Controller::ControllerCollection::Registration _reg { COLLECTION_ID }; - - public: - Global() = default; - Global( const Global & p_source ) = default; - ~Global() = default; - - void init() override; - - inline VTX::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; - }; -} // namespace VTX::App::Controller::Shortcut -#endif diff --git a/lib/app/include/app/controller/shortcut/visualization.hpp b/lib/app/include/app/controller/shortcut/visualization.hpp deleted file mode 100644 index 9748c6dbb..000000000 --- a/lib/app/include/app/controller/shortcut/visualization.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __VTX_UI_INTERNAL_CONTROLLER_VISUALIZATION_SHORTCUT__ -#define __VTX_UI_INTERNAL_CONTROLLER_VISUALIZATION_SHORTCUT__ - -#include "app/core/controller/base_controller.hpp" -#include "app/core/controller/base_shortcut_controller.hpp" -#include "app/core/controller/controller_manager.hpp" -#include -#include - -namespace VTX::App::Controller::Shortcut -{ - class Visualization final : public Core::Controller::BaseShortcutController - { - public: - inline static const Util::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_VISUALIZATION"; - inline static const VTX::Hash HASHED_COLLECTION_ID = Util::hash( COLLECTION_ID ); - - private: - inline static const Core::Controller::ControllerCollection::Registration _reg { COLLECTION_ID }; - - public: - Visualization() = default; - Visualization( const Visualization & p_source ) = default; - ~Visualization() = default; - - void init() override; - - inline VTX::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; }; - std::unique_ptr clone() const { return std::make_unique( *this ); }; - - private: - void _callOrientOnScene() const; - void _callOrientOnSelection() const; - }; -} // namespace VTX::App::Controller::Shortcut -#endif diff --git a/lib/app/include/app/core/controller/base_controller.hpp b/lib/app/include/app/core/controller/base_controller.hpp index 781597ccb..e3236436f 100644 --- a/lib/app/include/app/core/controller/base_controller.hpp +++ b/lib/app/include/app/core/controller/base_controller.hpp @@ -24,7 +24,7 @@ namespace VTX::App::Core::Controller // inline bool isTargetWidgetFocused() const { return _widgetTarget == nullptr || _widgetTarget->hasFocus(); } - virtual VTX::Hash getHashedCollectionID() const = 0; + virtual VTX::Hash getHashedCollectionID() const = 0; virtual std::unique_ptr clone() const = 0; protected: diff --git a/lib/app/include/app/core/controller/base_shortcut_controller.hpp b/lib/app/include/app/core/controller/base_shortcut_controller.hpp deleted file mode 100644 index 4ec90dfa6..000000000 --- a/lib/app/include/app/core/controller/base_shortcut_controller.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __VTX_UI_QT_CONTROLLER_BASE_SHORTCUT_CONTROLLER__ -#define __VTX_UI_QT_CONTROLLER_BASE_SHORTCUT_CONTROLLER__ - -#include "app/core/input/keys.hpp" -#include "app/core/input/shortcut.hpp" -#include "app/core/input/shortcut_map.hpp" -#include "base_controller.hpp" - -namespace VTX::App::Core::Controller -{ - class BaseShortcutController : public BaseController - { - public: - BaseShortcutController() = default; - BaseShortcutController( const BaseShortcutController & p_source ) = default; - ~BaseShortcutController() = default; - - virtual void init() override; - void referenceShortcut( const Core::Input::Shortcut & p_shortcut ); - - protected: - void _onKeyPressed( Core::Input::Key p_key ) const; - - Core::Input::ShortcutMap _mapShortcuts = Core::Input::ShortcutMap(); - }; -} // namespace VTX::App::Core::Controller -#endif diff --git a/lib/app/include/app/core/controller/concepts.hpp b/lib/app/include/app/core/controller/concepts.hpp new file mode 100644 index 000000000..c95cd6803 --- /dev/null +++ b/lib/app/include/app/core/controller/concepts.hpp @@ -0,0 +1,12 @@ +#ifndef __VTX_APP_CORE_CONTROLLER_CONCEPT__ +#define __VTX_APP_CORE_CONTROLLER_CONCEPT__ + +#include + +template +concept Concept = requires( C p_controller, const float p_deltaTime ) { + { p_controller.init() } -> std::same_as; + { p_controller.update( p_deltaTime ) } -> std::same_as; +}; + +#endif diff --git a/lib/app/include/app/core/init_visualization_mode.hpp b/lib/app/include/app/core/init_visualization_mode.hpp deleted file mode 100644 index 1de6d43b6..000000000 --- a/lib/app/include/app/core/init_visualization_mode.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __VTX_UI_INTERNAL_INIT_VISUALIZATION_MODE__ -#define __VTX_UI_INTERNAL_INIT_VISUALIZATION_MODE__ - -#include "app/mode/visualization.hpp" - -namespace VTX::App::Core -{ - void init( Mode::Visualization & p_visualization ); -} // namespace VTX::App::Core - -#endif diff --git a/lib/app/include/app/mode/base_mode.hpp b/lib/app/include/app/mode/base_mode.hpp index abe0dca8c..5a4dd0995 100644 --- a/lib/app/include/app/mode/base_mode.hpp +++ b/lib/app/include/app/mode/base_mode.hpp @@ -15,6 +15,7 @@ namespace VTX::App::Mode virtual const std::string & getName() const = 0; virtual void enter() {} + // TODO: use concept to avoid virtual call in main loop. virtual void update( const float p_deltaTime ) {}; virtual void exit() {}; }; diff --git a/lib/app/src/app/controller/shortcut/debug.cpp b/lib/app/src/app/controller/shortcut/debug.cpp deleted file mode 100644 index ef8ee7a70..000000000 --- a/lib/app/src/app/controller/shortcut/debug.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "app/controller/shortcut/debug.hpp" -#include "app/action/debug.hpp" -#include "app/core/input/keys.hpp" - -namespace VTX::App::Controller::Shortcut -{ - void Debug::init() - { - BaseShortcutController::init(); - - referenceShortcut( { { Core::Input::Key::Key_F9 }, - Core::Input::Shortcut::callAction() } ); - referenceShortcut( { { Core::Input::Key::Key_F10 }, - Core::Input::Shortcut::callAction() } ); - referenceShortcut( { { Core::Input::Key::Key_F7 }, - Core::Input::Shortcut::callAction() } ); - referenceShortcut( { { Core::Input::Key::Key_Space }, - Core::Input::Shortcut::callAction() } ); - } - -} // namespace VTX::App::Controller::Shortcut diff --git a/lib/app/src/app/controller/shortcut/global.cpp b/lib/app/src/app/controller/shortcut/global.cpp deleted file mode 100644 index 13d1562a5..000000000 --- a/lib/app/src/app/controller/shortcut/global.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "app/controller/shortcut/global.hpp" -#include "app/core/input/keys.hpp" -#include - -namespace VTX::App::Controller::Shortcut -{ - void Global::init() - { - BaseShortcutController::init(); - - referenceShortcut( { { Core::Input::Key::Key_N, ( Core::Input::ModifierEnum::Ctrl ) }, - Core::Input::Shortcut::callAction() } ); - - referenceShortcut( { { Core::Input::Key::Key_S, Core::Input::ModifierEnum::Ctrl }, - Core::Input::Shortcut::callAction() } ); - - referenceShortcut( { { Core::Input::Key::Key_S, ( Core::Input::ModifierEnum::Ctrl_Shift ) }, - Core::Input::Shortcut::callAction() } ); - } - -} // namespace VTX::App::Controller::Shortcut diff --git a/lib/app/src/app/controller/shortcut/visualization.cpp b/lib/app/src/app/controller/shortcut/visualization.cpp deleted file mode 100644 index 4797740ff..000000000 --- a/lib/app/src/app/controller/shortcut/visualization.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "app/action/visualization.hpp" -#include "app/action/animation.hpp" -#include "app/controller/shortcut/visualization.hpp" -#include "app/core/animation/animation_system.hpp" -#include -#include -#include - -namespace VTX::App::Controller::Shortcut -{ - void Visualization::init() - { - BaseShortcutController::init(); - - referenceShortcut( { { Core::Input::Key::Key_F1 }, - Core::Input::Shortcut::callAction() } ); - - referenceShortcut( { { Core::Input::Key::Key_F1, Core::Input::ModifierEnum::Ctrl }, - Core::Input::Shortcut::callAction() } ); - - referenceShortcut( { { Core::Input::Key::Key_O }, - [ this ]() - { - if ( App::CURRENT_SELECTION().isEmpty() ) - _callOrientOnScene(); - else - _callOrientOnSelection(); - } } ); - - // TODO Maybe move that in a controller dedicated for the animator which activate / deactivate itself when the - // Animator Play / Stop - referenceShortcut( { { Core::Input::Key::Key_Escape }, - [ this ]() - { - if ( ANIMATION_SYSTEM().isPlaying() ) - { - ANIMATION_SYSTEM().stop(); - } - } } ); - } - - void Visualization::_callOrientOnScene() const - { - App::VTX_ACTION().execute( App::SCENE().getAABB() ); - } - void Visualization::_callOrientOnSelection() const - { - App::VTX_ACTION().execute( App::CURRENT_SELECTION().getAABB() ); - } - -} // namespace VTX::App::Controller::Shortcut diff --git a/lib/app/src/app/core/animation/animation_system.cpp b/lib/app/src/app/core/animation/animation_system.cpp index b7b943c4b..583baf44f 100644 --- a/lib/app/src/app/core/animation/animation_system.cpp +++ b/lib/app/src/app/core/animation/animation_system.cpp @@ -4,13 +4,7 @@ namespace VTX::App::Core::Animation { - AnimationSystem::AnimationSystem() - { - _currentAnimationIt = _animationSequence.end(); - - // TODO: call from app::update(). - // APP::onUpdate += [ this ]( const float p_deltaTime, const float p_elapsedTime ) { update( p_deltaTime ); }; - } + AnimationSystem::AnimationSystem() { _currentAnimationIt = _animationSequence.end(); } void AnimationSystem::play() { diff --git a/lib/app/src/app/core/controller/base_shortcut_controller.cpp b/lib/app/src/app/core/controller/base_shortcut_controller.cpp deleted file mode 100644 index e36f674c6..000000000 --- a/lib/app/src/app/core/controller/base_shortcut_controller.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "app/core/controller/base_shortcut_controller.hpp" -#include "app/core/input/input_manager.hpp" - -namespace VTX::App::Core::Controller -{ - void BaseShortcutController::init() - { - INPUT_MANAGER().onKeyPressed += [ this ]( Core::Input::Key p_key ) { _onKeyPressed( p_key ); }; - } - - void BaseShortcutController::referenceShortcut( const Core::Input::Shortcut & p_shortcut ) - { - _mapShortcuts.referenceShortcut( p_shortcut ); - } - - void BaseShortcutController::_onKeyPressed( Input::Key p_key ) const - { - if ( not isActive() /* || !isTargetWidgetFocused() */ ) - return; - - const Core::Input::Shortcut * const shortcutPtr - = _mapShortcuts.tryGet( p_key, INPUT_MANAGER().getCurrentModifiers() ); - - if ( shortcutPtr ) - shortcutPtr->trigger(); - } - -} // namespace VTX::App::Core::Controller diff --git a/lib/app/src/app/core/init_visualization_mode.cpp b/lib/app/src/app/core/init_visualization_mode.cpp deleted file mode 100644 index 9127692f5..000000000 --- a/lib/app/src/app/core/init_visualization_mode.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "app/core/init_visualization_mode.hpp" -#include "app/controller/camera/freefly.hpp" -#include "app/controller/camera/trackball.hpp" -#include "app/controller/picker/selection.hpp" -#include "app/controller/shortcut/debug.hpp" -#include "app/controller/shortcut/global.hpp" -#include "app/controller/shortcut/visualization.hpp" -#include "app/core/controller/controller_manager.hpp" - -namespace VTX::App::Core -{ - void init( Mode::Visualization & p_visualization ) - { - // TODO replace that with an initialisation with custom data. - std::unique_ptr ptr - = Util::Singleton::get().instantiateItem( - App::Controller::Camera::Freefly::HASHED_COLLECTION_ID - ); - ptr->init(); - p_visualization.addCameraController( ptr ); - - ptr = Util::Singleton::get().instantiateItem( - App::Controller::Camera::Trackball::HASHED_COLLECTION_ID - ); - ptr->init(); - p_visualization.addCameraController( ptr ); - - ptr = Util::Singleton::get().instantiateItem( - App::Controller::Picker::Selection::HASHED_COLLECTION_ID - ); - ptr->init(); - p_visualization.addPickerController( ptr ); - - ptr = Util::Singleton::get().instantiateItem( - App::Controller::Shortcut::Global::HASHED_COLLECTION_ID - ); - ptr->init(); - p_visualization.addController( ptr ); - - ptr = Util::Singleton::get().instantiateItem( - App::Controller::Shortcut::Visualization::HASHED_COLLECTION_ID - ); - ptr->init(); - p_visualization.addController( ptr ); - -#ifndef VTX_PRODUCTION - ptr = Util::Singleton::get().instantiateItem( - App::Controller::Shortcut::Debug::HASHED_COLLECTION_ID - ); - ptr->init(); - p_visualization.addController( ptr ); -#endif - - p_visualization.setCameraController( App::Controller::Camera::Trackball::HASHED_COLLECTION_ID ); - p_visualization.setPickerController( App::Controller::Picker::Selection::HASHED_COLLECTION_ID ); - } -} // namespace VTX::App::Core diff --git a/lib/app/src/app/vtx_app.cpp b/lib/app/src/app/vtx_app.cpp index cf7c5a8ef..905e7f9c4 100644 --- a/lib/app/src/app/vtx_app.cpp +++ b/lib/app/src/app/vtx_app.cpp @@ -16,6 +16,7 @@ #include "app/component/render/proxy_color_layout.hpp" #include "app/component/render/proxy_molecule.hpp" #include "app/controller/camera/trackball.hpp" +#include "app/core/animation/animation_system.hpp" #include "app/core/ecs/registry.hpp" #include "app/core/serialization/serialization.hpp" #include "app/core/worker/worker_manager.hpp" @@ -58,8 +59,11 @@ namespace VTX::App tool->init(); } - // Register loop events + // Register loop events. + // TODO: call in main loop? onUpdate += []( const float p_deltaTime, const float p_elapsedTime ) { SCENE().update( p_elapsedTime ); }; + onUpdate += + []( const float p_deltaTime, const float p_elapsedTime ) { ANIMATION_SYSTEM().update( p_deltaTime ); }; onPostUpdate += []( const float p_elapsedTime ) { THREADING().lateUpdate(); }; //// Create Databases From 4a76fc3dde63127affaf5c21d809b57203c0c7cf Mon Sep 17 00:00:00 2001 From: sguionni Date: Tue, 10 Sep 2024 15:19:19 +0200 Subject: [PATCH 2/4] Bench: center molecule --- app/bench/src/scene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/bench/src/scene.cpp b/app/bench/src/scene.cpp index b4ccefb9d..4aa34c088 100644 --- a/app/bench/src/scene.cpp +++ b/app/bench/src/scene.cpp @@ -43,8 +43,8 @@ namespace VTX::Bench _molecules.emplace_back( std::make_unique( downloadMolecule( p_name ) ) ); } - _molecules.back()->transform - = Math::translate( _molecules.back()->transform, Math::randomVec3f() * 200.f - 100.f ); + //_molecules.back()->transform + // = Math::translate( _molecules.back()->transform, Math::randomVec3f() * 200.f - 100.f ); IO::Util::SecondaryStructure::computeStride( *_molecules.back() ); _proxyMolecules.emplace_back( _proxify( *_molecules.back() ) ); _directions.emplace_back( Math::randomVec3f() * 2.f - 1.f ); From 6c054739390b683a8d74c23fee98b0212d379947 Mon Sep 17 00:00:00 2001 From: sguionni Date: Tue, 10 Sep 2024 15:22:09 +0200 Subject: [PATCH 3/4] Disable picking --- lib/renderer/include/renderer/renderer.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/renderer/include/renderer/renderer.hpp b/lib/renderer/include/renderer/renderer.hpp index ef0e459e1..9a3d126da 100644 --- a/lib/renderer/include/renderer/renderer.hpp +++ b/lib/renderer/include/renderer/renderer.hpp @@ -120,9 +120,10 @@ namespace VTX::Renderer inline Vec2i getPickedIds( const size_t p_x, const size_t p_y ) const { - std::any idsAny = std::make_any(); - _context->getTextureData( idsAny, p_x, height - p_y, "Geometric", E_CHAN_OUT::COLOR_2 ); - return std::any_cast( idsAny ); + // std::any idsAny = std::make_any(); + //_context->getTextureData( idsAny, p_x, height - p_y, "Geometric", E_CHAN_OUT::COLOR_2 ); + return Vec2i(); + // std::any_cast( idsAny ); } inline void setNeedUpdate( const bool p_value ) From 660a0edbd985cdff30d2a9f28166e7c60f1abdd6 Mon Sep 17 00:00:00 2001 From: sguionni Date: Tue, 10 Sep 2024 16:35:13 +0200 Subject: [PATCH 4/4] Remove enum inheritance --- lib/renderer/include/renderer/enums.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/renderer/include/renderer/enums.hpp b/lib/renderer/include/renderer/enums.hpp index ca8a7d5ae..6f19fbb2a 100644 --- a/lib/renderer/include/renderer/enums.hpp +++ b/lib/renderer/include/renderer/enums.hpp @@ -16,7 +16,7 @@ namespace VTX::Renderer _7, }; - enum struct E_CHAN_OUT : unsigned int + enum struct E_CHAN_OUT { COLOR_0, COLOR_1,