Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev-sge
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Mar 26, 2024
2 parents dc92602 + 3d3a258 commit ce826cc
Show file tree
Hide file tree
Showing 64 changed files with 770 additions and 550 deletions.
4 changes: 0 additions & 4 deletions lib/app/include/app/application/_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace VTX::App::Application
{
template<typename T>
class Setting;

class Settings;
class Scene;

namespace Action
Expand Down
17 changes: 15 additions & 2 deletions lib/app/include/app/application/ecs/registry_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,22 @@ namespace VTX::App::Application::ECS
}

template<Core::ECS::ECS_Component Type, Core::ECS::ECS_Component... Other>
Core::ECS::View<Type, Other...> getComponents() const
Type & findComponent()
{
return _registry.getComponents<Type, Other...>();
Core::ECS::View<Type, Other...> view = _registry.findComponents<Type, Other...>();
return getComponent<Type>( *( view.begin() ) );
}
template<Core::ECS::ECS_Component Type, Core::ECS::ECS_Component... Other>
const Type & findComponent() const
{
Core::ECS::View<Type, Other...> view = _registry.findComponents<Type, Other...>();
return getComponent<Type>( *( view.begin() ) );
}

template<Core::ECS::ECS_Component Type, Core::ECS::ECS_Component... Other>
Core::ECS::View<Type, Other...> findComponents() const
{
return _registry.findComponents<Type, Other...>();
}

template<Core::ECS::ECS_Component C>
Expand Down
3 changes: 2 additions & 1 deletion lib/app/include/app/application/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace VTX::App::Application
template<SceneItem T>
Core::ECS::View<Component::Scene::SceneItemComponent, T> getAllSceneItemsOfType() const
{
return MAIN_REGISTRY().getComponents<Component::Scene::SceneItemComponent, T>();
return MAIN_REGISTRY().findComponents<Component::Scene::SceneItemComponent, T>();
}

void referenceItem( Component::Scene::SceneItemComponent & p_item );
Expand Down Expand Up @@ -131,6 +131,7 @@ namespace VTX::App::Application

void _computeAABB();
void _createDefaultPath();
void _createDefaultColorLayout();

private:
Component::Render::Camera * _camera = nullptr;
Expand Down
7 changes: 7 additions & 0 deletions lib/app/include/app/application/settings/_fwd.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace VTX::App::Application::Settings
{
template<typename T>
class Setting;

class Settings;
} // namespace VTX::App::Application::Settings
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#ifndef __VTX_APP_APPLICATION_SETTING__
#define __VTX_APP_APPLICATION_SETTING__
#ifndef __VTX_APP_APPLICATION_SETTINGS_BASE_SETTING__
#define __VTX_APP_APPLICATION_SETTINGS_BASE_SETTING__

#include "app/application/system/serializer.hpp"
#include <concepts>
#include <memory>
#include <optional>
#include <util/json/basic_json.hpp>

namespace VTX::App::Application
namespace VTX::App::Application::Settings
{
class BaseSetting
{
Expand Down Expand Up @@ -71,6 +72,5 @@ namespace VTX::App::Application
T _value;
std::optional<T> _defaultValue;
};

} // namespace VTX::App::Application
} // namespace VTX::App::Application::Settings
#endif
28 changes: 28 additions & 0 deletions lib/app/include/app/application/settings/setting_change_info.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef __VTX_APP_APPLICATION_SETTINGS_SETTINGS_CHANGE_EVENT_INFO__
#define __VTX_APP_APPLICATION_SETTINGS_SETTINGS_CHANGE_EVENT_INFO__

#include <string>

namespace VTX::App::Application::Settings
{
class BaseSettingChangeInfo
{
public:
BaseSettingChangeInfo( const std::string & p_key ) : key( p_key ) {};
const std::string key;
};

template<typename T>
class SettingChangeInfo : public BaseSettingChangeInfo
{
public:
SettingChangeInfo( const std::string & p_key, const T & p_oldValue, const T & p_newValue ) :
BaseSettingChangeInfo( p_key ), oldValue( p_oldValue ), newValue( p_newValue ) {};

const T & oldValue;
const T & newValue;
};

} // namespace VTX::App::Application::Settings

#endif
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
#ifndef __VTX_APP_APPLICATION_SETTINGS__
#define __VTX_APP_APPLICATION_SETTINGS__
#ifndef __VTX_APP_APPLICATION_SETTINGS_SETTINGS__
#define __VTX_APP_APPLICATION_SETTINGS_SETTINGS__

#include "app/application/setting.hpp"
#include "app/core/system/base_system.hpp"
#include "app/application/settings/base_setting.hpp"
#include "app/application/settings/setting_change_info.hpp"
#include <cassert>
#include <map>
#include <memory>
#include <string>
#include <util/callback.hpp>

namespace VTX::App::Application
namespace VTX::App::Application::Settings
{
class BaseSettingChangeEvent
{
public:
BaseSettingChangeEvent( const std::string & p_key ) : key( p_key ) {};
const std::string key;
};

template<typename T>
class SettingChangeEvent : public BaseSettingChangeEvent
{
public:
SettingChangeEvent( const std::string & p_key, const T & p_oldValue, const T & p_newValue ) :
BaseSettingChangeEvent( p_key ), oldValue( p_oldValue ), newValue( p_newValue ) {};

const T & oldValue;
const T & newValue;
};

class Settings : public Core::System::BaseSystem
class Settings
{
public:
using SettingMap = std::map<std::string, std::unique_ptr<BaseSetting>>;
Expand All @@ -47,14 +29,14 @@ namespace VTX::App::Application
}

template<typename T>
const T & get( const std::string p_key ) const
const T & get( const std::string & p_key ) const
{
assert( _settings.contains( p_key ) );
return _getConstSetting<T>( p_key ).get();
}

template<typename T>
void set( const std::string p_key, const T & p_value )
void set( const std::string & p_key, const T & p_value )
{
assert( _settings.contains( p_key ) );

Expand All @@ -63,11 +45,7 @@ namespace VTX::App::Application
if ( previousValue != p_value )
{
_getSetting<T>( p_key ).set( p_value );

const std::unique_ptr<SettingChangeEvent<T>> eventData
= std::make_unique<SettingChangeEvent<T>>( p_key, previousValue, p_value );

onSetting( *eventData );
onSetting( SettingChangeInfo<T>( p_key, previousValue, p_value ) );
}
}

Expand All @@ -80,7 +58,7 @@ namespace VTX::App::Application
friend bool operator==( const Settings & p_lhs, const Settings & p_rhs );
friend bool operator!=( const Settings & p_lhs, const Settings & p_rhs );

Util::Callback<BaseSettingChangeEvent> onSetting;
Util::Callback<BaseSettingChangeInfo> onSetting;

private:
// Mutable to allow bracket access in const functions (contains checked in asserts)
Expand All @@ -98,5 +76,6 @@ namespace VTX::App::Application
}
};

} // namespace VTX::App::Application
} // namespace VTX::App::Application::Settings

#endif
25 changes: 25 additions & 0 deletions lib/app/include/app/application/system/settings_system.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef __VTX_APP_APPLICATION_SYSTEM_SETTINGS_SYSTEM__
#define __VTX_APP_APPLICATION_SYSTEM_SETTINGS_SYSTEM__

#include "app/application/settings/settings.hpp"
#include "app/application/system/system_registration.hpp"
#include "app/core/system/base_system.hpp"

namespace VTX::App::Application::System
{
class Settings : public Core::System::BaseSystem
{
public:
inline static const System::SystemRegistration<Settings> SYSTEM = System::SystemRegistration<Settings>();

public:
Application::Settings::Settings currentSetting;
};
} // namespace VTX::App::Application::System

namespace VTX::App
{
Application::Settings::Settings & SETTINGS();
}

#endif
10 changes: 5 additions & 5 deletions lib/app/include/app/component/chemistry/trajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "_fwd.hpp"
#include "app/application/system/ecs_system.hpp"
#include "app/core/trajectory_player/base_player.hpp"
#include "app/core/player/base_player.hpp"
#include "enum_trajectory.hpp"
#include <util/callback.hpp>

Expand All @@ -28,17 +28,17 @@ namespace VTX::App::Component::Chemistry

size_t getFrameCount() const;

App::Core::TrajectoryPlayer::BasePlayer & getPlayer() const { return *_player; }
void setPlayer( std::unique_ptr<App::Core::TrajectoryPlayer::BasePlayer> & p_player );
App::Core::Player::BasePlayer & getPlayer() const { return *_player; }
void setPlayer( std::unique_ptr<App::Core::Player::BasePlayer> & p_player );

Util::Callback<size_t> onFrameChange;

private:
void _update( const float p_deltaTime );
void _referenceUpdateFunction();

Molecule * _moleculePtr = nullptr;
std::unique_ptr<App::Core::TrajectoryPlayer::BasePlayer> _player = nullptr;
Molecule * _moleculePtr = nullptr;
std::unique_ptr<App::Core::Player::BasePlayer> _player = nullptr;
};
} // namespace VTX::App::Component::Chemistry
#endif
29 changes: 29 additions & 0 deletions lib/app/include/app/component/render/proxy_color_layout.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __VTX_APP_COMPONENT_RENDER_PROXY_COLOR_LAYOUT__
#define __VTX_APP_COMPONENT_RENDER_PROXY_COLOR_LAYOUT__

#include "app/application/renderer/proxy_wrapper.hpp"
#include <renderer/facade.hpp>
#include <renderer/proxy/color_layout.hpp>
#include <util/types.hpp>
#include <vector>

namespace VTX::App::Component::Render
{
class ProxyColorLayout
{
public:
ProxyColorLayout();
~ProxyColorLayout();

void setup( Renderer::Facade & p_renderer );
Application::Renderer::ProxyWrapper<VTX::Renderer::Proxy::ColorLayout> & getProxy() { return _proxyWrapper; };

private:
void _addInRenderer( Renderer::Facade & p_renderer );
void _setupCallbacks();

Application::Renderer::ProxyWrapper<VTX::Renderer::Proxy::ColorLayout> _proxyWrapper;
};

} // namespace VTX::App::Component::Render
#endif
29 changes: 29 additions & 0 deletions lib/app/include/app/component/representation/color_layout.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __VTX_APP_COMPONENT_REPRESENTATION_COLOR_LAYOUT__
#define __VTX_APP_COMPONENT_REPRESENTATION_COLOR_LAYOUT__

#include "app/core/ecs/base_component.hpp"
#include <core/struct/color_layout.hpp>
#include <util/callback.hpp>

namespace VTX::App::Component::Representation
{

class ColorLayout : public Core::ECS::BaseComponent
{
public:
ColorLayout() = default;

const VTX::Core::Struct::ColorLayout & getLayout() const { return _layout; }

void setColor( const size_t p_index, const Util::Color::Rgba & p_color );
void setColors( const std::vector<Util::Color::Rgba> & p_colors );

Util::Callback<> onColorChange;

private:
VTX::Core::Struct::ColorLayout _layout;
};

} // namespace VTX::App::Component::Representation

#endif
1 change: 1 addition & 0 deletions lib/app/include/app/component/scene/aabb_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __VTX_APP_COMPONENT_SCENE_AABB__

#include "app/application/system/ecs_system.hpp"
#include "app/component/scene/transform_component.hpp"
#include "app/core/ecs/base_component.hpp"
#include <functional>
#include <util/math/aabb.hpp>
Expand Down
8 changes: 4 additions & 4 deletions lib/app/include/app/core/ecs/registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace VTX::App::Core::ECS
}

template<ECS_Component Type, ECS_Component... Other>
View<Type, Other...> getComponents() const
View<Type, Other...> findComponents() const
{
return View<Type, Other...>( _enttRegistry );
}
Expand Down Expand Up @@ -110,9 +110,9 @@ namespace VTX::App::Core::ECS
{
switch ( p_signal )
{
case SIGNAL::CONSTRUCT: _enttRegistry.on_construct<C>().connect<Func>( p_receiver ); break;
case SIGNAL::UPDATE: _enttRegistry.on_update<C>().connect<Func>( p_receiver ); break;
case SIGNAL::DESTROY: _enttRegistry.on_destroy<C>().connect<Func>( p_receiver ); break;
case SIGNAL::CONSTRUCT: _enttRegistry.on_construct<C>().template connect<Func>( p_receiver ); break;
case SIGNAL::UPDATE: _enttRegistry.on_update<C>().template connect<Func>( p_receiver ); break;
case SIGNAL::DESTROY: _enttRegistry.on_destroy<C>().template connect<Func>( p_receiver ); break;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace VTX::App::Core::TrajectoryPlayer
namespace VTX::App::Core::Player
{
class BasePlayer;

Expand All @@ -8,4 +8,4 @@ namespace VTX::App::Core::TrajectoryPlayer
class PingPong;
class RevertLoop;
class RevertOnce;
} // namespace VTX::App::Core::TrajectoryPlayer
} // namespace VTX::App::Core::Player
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#ifndef __VTX_APP_CORE_TRAJECTORY_PLAYER_BASE_PLAYER__
#define __VTX_APP_CORE_TRAJECTORY_PLAYER_BASE_PLAYER__
#ifndef __VTX_APP_CORE_PLAYER_BASE_PLAYER__
#define __VTX_APP_CORE_PLAYER_BASE_PLAYER__

#include "app/component/chemistry/_fwd.hpp"
#include "app/core/collection.hpp"
#include <memory>
#include <string>
#include <util/callback.hpp>
#include <util/types.hpp>

namespace VTX::App::Core::TrajectoryPlayer
namespace VTX::App::Core::Player
{
class BasePlayer
{
Expand Down Expand Up @@ -56,5 +55,5 @@ namespace VTX::App::Core::TrajectoryPlayer
uint _fps = 1u;
float _trajectoryTimer = 0;
};
} // namespace VTX::App::Core::TrajectoryPlayer
} // namespace VTX::App::Core::Player
#endif
Loading

0 comments on commit ce826cc

Please sign in to comment.