diff --git a/include/Nazara/Graphics/Light.hpp b/include/Nazara/Graphics/Light.hpp index c14cdd075..cff58da44 100644 --- a/include/Nazara/Graphics/Light.hpp +++ b/include/Nazara/Graphics/Light.hpp @@ -9,12 +9,19 @@ #include #include +#include +#include #include #include +class NzLight; class NzShader; struct NzLightUniforms; +using NzLightConstRef = NzObjectRef; +using NzLightLibrary = NzObjectLibrary; +using NzLightRef = NzObjectRef; + class NAZARA_API NzLight : public NzRenderable { public: @@ -55,6 +62,8 @@ class NAZARA_API NzLight : public NzRenderable NzLight& operator=(const NzLight& light) = default; + template static NzLightRef New(Args&&... args); + private: void MakeBoundingVolume() const override; @@ -70,6 +79,8 @@ class NAZARA_API NzLight : public NzRenderable float m_outerAngleCosine; float m_outerAngleTangent; float m_radius; + + static NzLightLibrary::LibraryMap s_library; }; struct NzLightUniforms diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index a46a8e5c0..e82a5f2fd 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -2,6 +2,9 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include +#include + inline float NzLight::GetAmbientFactor() const { return m_ambientFactor; @@ -90,3 +93,14 @@ inline void NzLight::SetRadius(float radius) InvalidateBoundingVolume(); } + +template +NzLightRef NzLight::New(Args&&... args) +{ + std::unique_ptr object(new NzLight(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); +} + +#include diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index d0de7cb6f..44167ab38 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -27,7 +27,9 @@ struct NAZARA_API NzModelParameters class NzModel; +using NzModelConstRef = NzObjectRef; using NzModelLoader = NzResourceLoader; +using NzModelRef = NzObjectRef; class NAZARA_API NzModel : public NzRenderable, public NzResource { @@ -42,9 +44,6 @@ class NAZARA_API NzModel : public NzRenderable, public NzResource void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatrix4f& transformMatrix) const override; - NzModel* Clone() const; - NzModel* Create() const; - NzMaterial* GetMaterial(const NzString& subMeshName) const; NzMaterial* GetMaterial(unsigned int matIndex) const; NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const; @@ -75,6 +74,8 @@ class NAZARA_API NzModel : public NzRenderable, public NzResource NzModel& operator=(const NzModel& node) = default; NzModel& operator=(NzModel&& node) = default; + template static NzModelRef New(Args&&... args); + protected: void MakeBoundingVolume() const override; @@ -87,4 +88,6 @@ class NAZARA_API NzModel : public NzRenderable, public NzResource static NzModelLoader::LoaderList s_loaders; }; +#include + #endif // NAZARA_MODEL_HPP diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl new file mode 100644 index 000000000..007ad23d0 --- /dev/null +++ b/include/Nazara/Graphics/Model.inl @@ -0,0 +1,17 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +template +NzModelRef NzModel::New(Args&&... args) +{ + std::unique_ptr object(new NzModel(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); +} + +#include diff --git a/src/Nazara/Graphics/Light.cpp b/src/Nazara/Graphics/Light.cpp index 7ebe3249f..fd9d4ef61 100644 --- a/src/Nazara/Graphics/Light.cpp +++ b/src/Nazara/Graphics/Light.cpp @@ -179,3 +179,5 @@ void NzLight::MakeBoundingVolume() const break; } } + +NzLightLibrary::LibraryMap NzLight::s_library; diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index fb08b4984..abf8a36a5 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -53,16 +53,6 @@ void NzModel::AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatri } } -NzModel* NzModel::Clone() const -{ - return new NzModel(*this); -} - -NzModel* NzModel::Create() const -{ - return new NzModel; -} - NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const { #if NAZARA_GRAPHICS_SAFE