Reworking drawable components

This commit is contained in:
Zoe Roux
2021-06-02 16:18:26 +02:00
parent 1cc6907ff0
commit 09d8b1a90b
15 changed files with 118 additions and 268 deletions
@@ -4,37 +4,37 @@
#pragma once
#include <Models/TypeHolder.hpp>
#include "Component/Component.hpp"
#include "Drawables/ADrawable3D.hpp"
#include "Model/Model.hpp"
namespace BBM
{
template <class T>
class Drawable3DComponent : public WAL::Component
{
public:
//! @brief The type of the component
T member;
std::shared_ptr<RAY::Drawables::ADrawable3D> drawable;
//! @brief ctor
Drawable3DComponent(WAL::Entity &entity, T member)
Drawable3DComponent(WAL::Entity &entity, std::shared_ptr<RAY::Drawables::ADrawable3D> drawable)
: WAL::Component(entity),
member(std::move(member))
drawable(std::move(drawable))
{}
//! ctor
template<typename ...Params>
explicit Drawable3DComponent(WAL::Entity &entity, Params &&...params)
template<typename T, typename ...Params>
explicit Drawable3DComponent(WAL::Entity &entity, WAL::TypeHolder<T>, Params &&...params)
: WAL::Component(entity),
member(std::forward<Params>(params)...)
drawable(new T(std::forward<Params>(params)...))
{}
//! @brief Clone a component for another or the same entity.
//! @param entity The entity that owns the ne component.
WAL::Component *clone(WAL::Entity &entity) const override
{
return new Drawable3DComponent(entity, this->member);
return new Drawable3DComponent(entity, this->drawable);
}
//! @brief Default copy ctor