Improved declarations
Former-commit-id: 567f98b44eada10ffb797cc19cfcdbca584a2461 [formerly 01826c3bfd8385abd6a47f770c7eba7980ae9199] [formerly 6c54c8e8e6a8515387fc61f665bfa5d2cc2d8cdf [formerly f507b9604c2395a4d1eec0f12a07e3cd8b47e4f6]] Former-commit-id: 1723f76155d68f5aac2006f5ebf5bd96b4ac81e7 [formerly 04f3ed2688c3519923edbb0693e259ee3653256b] Former-commit-id: e37a8744e6756f5eb331881b422d491171adb362
This commit is contained in:
parent
5fa5186480
commit
ca1b9c1988
|
|
@ -15,6 +15,7 @@
|
|||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -46,6 +47,7 @@ namespace Nz
|
|||
|
||||
static ParticleDeclaration* Get(ParticleLayout layout);
|
||||
static bool IsTypeSupported(ComponentType type);
|
||||
template<typename... Args> static ParticleDeclarationRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnParticleDeclarationRelease, const ParticleDeclaration* /*particleDeclaration*/);
|
||||
|
|
@ -68,12 +70,14 @@ namespace Nz
|
|||
*/
|
||||
};
|
||||
|
||||
Component m_components[ParticleComponent_Max + 1];
|
||||
std::array<Component, ParticleComponent_Max + 1> m_components;
|
||||
unsigned int m_stride;
|
||||
|
||||
static ParticleDeclaration s_declarations[ParticleLayout_Max + 1];
|
||||
static std::array<ParticleDeclaration, ParticleLayout_Max + 1> s_declarations;
|
||||
static ParticleDeclarationLibrary::LibraryMap s_library;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/ParticleDeclaration.inl>
|
||||
|
||||
#endif // NAZARA_PARTICLEDECLARATION_HPP
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (C) 2016 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 <memory>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename... Args>
|
||||
ParticleDeclarationRef ParticleDeclaration::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<ParticleDeclaration> object(new ParticleDeclaration(std::forward<Args>(args)...));
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
|
|
@ -69,14 +70,14 @@ namespace Nz
|
|||
*/
|
||||
};
|
||||
|
||||
Component m_components[VertexComponent_Max+1];
|
||||
std::array<Component, VertexComponent_Max + 1> m_components;
|
||||
std::size_t m_stride;
|
||||
|
||||
static VertexDeclaration s_declarations[VertexLayout_Max+1];
|
||||
static std::array<VertexDeclaration, VertexLayout_Max + 1> s_declarations;
|
||||
static VertexDeclarationLibrary::LibraryMap s_library;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.inl>
|
||||
|
||||
#endif // NAZARA_VERTEXDECLARATION_HPP
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ namespace Nz
|
|||
|
||||
ParticleDeclaration::ParticleDeclaration(const ParticleDeclaration& declaration) :
|
||||
RefCounted(),
|
||||
m_components(declaration.m_components),
|
||||
m_stride(declaration.m_stride)
|
||||
{
|
||||
std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -205,7 +205,7 @@ namespace Nz
|
|||
|
||||
ParticleDeclaration& ParticleDeclaration::operator=(const ParticleDeclaration& declaration)
|
||||
{
|
||||
std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1));
|
||||
m_components = declaration.m_components;
|
||||
m_stride = declaration.m_stride;
|
||||
|
||||
return *this;
|
||||
|
|
@ -222,13 +222,7 @@ namespace Nz
|
|||
|
||||
ParticleDeclaration* ParticleDeclaration::Get(ParticleLayout layout)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (layout > ParticleLayout_Max)
|
||||
{
|
||||
NazaraError("Particle layout out of enum");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(layout <= ParticleLayout_Max, "Particle layout out of enum");
|
||||
|
||||
return &s_declarations[layout];
|
||||
}
|
||||
|
|
@ -338,6 +332,6 @@ namespace Nz
|
|||
ParticleDeclarationLibrary::Uninitialize();
|
||||
}
|
||||
|
||||
ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max + 1];
|
||||
std::array<ParticleDeclaration, ParticleLayout_Max + 1> ParticleDeclaration::s_declarations;
|
||||
ParticleDeclarationLibrary::LibraryMap ParticleDeclaration::s_library;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ namespace Nz
|
|||
|
||||
MTLParser::Material* material = mtlFormat.AddMaterial(name);
|
||||
|
||||
bool bValue;
|
||||
String strVal;
|
||||
if (matData.HasParameter(MaterialData::CustomDefined))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ namespace Nz
|
|||
|
||||
VertexDeclaration::VertexDeclaration(const VertexDeclaration& declaration) :
|
||||
RefCounted(),
|
||||
m_components(declaration.m_components),
|
||||
m_stride(declaration.m_stride)
|
||||
{
|
||||
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(VertexComponent_Max+1));
|
||||
}
|
||||
|
||||
VertexDeclaration::~VertexDeclaration()
|
||||
|
|
@ -133,7 +133,7 @@ namespace Nz
|
|||
|
||||
VertexDeclaration& VertexDeclaration::operator=(const VertexDeclaration& declaration)
|
||||
{
|
||||
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(VertexComponent_Max+1));
|
||||
m_components = declaration.m_components;
|
||||
m_stride = declaration.m_stride;
|
||||
|
||||
return *this;
|
||||
|
|
@ -141,13 +141,7 @@ namespace Nz
|
|||
|
||||
VertexDeclaration* VertexDeclaration::Get(VertexLayout layout)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (layout > VertexLayout_Max)
|
||||
{
|
||||
NazaraError("Vertex layout out of enum");
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum");
|
||||
|
||||
return &s_declarations[layout];
|
||||
}
|
||||
|
|
@ -301,6 +295,6 @@ namespace Nz
|
|||
VertexDeclarationLibrary::Uninitialize();
|
||||
}
|
||||
|
||||
VertexDeclaration VertexDeclaration::s_declarations[VertexLayout_Max+1];
|
||||
std::array<VertexDeclaration, VertexLayout_Max + 1> VertexDeclaration::s_declarations;
|
||||
VertexDeclarationLibrary::LibraryMap VertexDeclaration::s_library;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue