Switch from Nz prefix to namespace Nz

What a huge commit


Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
Lynix
2015-09-25 19:20:05 +02:00
parent c214251ecf
commit df8da275c4
609 changed files with 68265 additions and 66534 deletions

View File

@@ -13,226 +13,229 @@
#include <cstring>
#include <Nazara/Graphics/Debug.hpp>
NzParticleDeclaration::NzParticleDeclaration() :
m_stride(0)
namespace Nz
{
}
NzParticleDeclaration::NzParticleDeclaration(const NzParticleDeclaration& declaration) :
NzRefCounted(),
m_stride(declaration.m_stride)
{
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(nzParticleComponent_Max+1));
}
NzParticleDeclaration::~NzParticleDeclaration()
{
OnParticleDeclarationRelease(this);
}
void NzParticleDeclaration::DisableComponent(nzParticleComponent component)
{
#ifdef NAZARA_DEBUG
if (component > nzParticleComponent_Max)
ParticleDeclaration::ParticleDeclaration() :
m_stride(0)
{
NazaraError("Vertex component out of enum");
return;
}
#endif
#if NAZARA_GRAPHICS_SAFE
if (component == nzParticleComponent_Unused)
{
NazaraError("Cannot disable \"unused\" component");
return;
}
#endif
Component& vertexComponent = m_components[component];
if (vertexComponent.enabled)
{
vertexComponent.enabled = false;
m_stride -= NzUtility::ComponentStride[vertexComponent.type];
}
}
void NzParticleDeclaration::EnableComponent(nzParticleComponent component, nzComponentType type, unsigned int offset)
{
#ifdef NAZARA_DEBUG
if (component > nzParticleComponent_Max)
{
NazaraError("Vertex component out of enum");
return;
}
#endif
#if NAZARA_GRAPHICS_SAFE
if (!IsTypeSupported(type))
{
NazaraError("Component type 0x" + NzString::Number(type, 16) + " is not supported by particle declarations");
return;
}
#endif
if (component != nzParticleComponent_Unused)
{
Component& particleComponent = m_components[component];
if (particleComponent.enabled)
m_stride -= NzUtility::ComponentStride[particleComponent.type];
else
particleComponent.enabled = true;
particleComponent.offset = offset;
particleComponent.type = type;
}
m_stride += NzUtility::ComponentStride[type];
}
void NzParticleDeclaration::GetComponent(nzParticleComponent component, bool* enabled, nzComponentType* type, unsigned int* offset) const
{
#ifdef NAZARA_DEBUG
if (component > nzParticleComponent_Max)
ParticleDeclaration::ParticleDeclaration(const ParticleDeclaration& declaration) :
RefCounted(),
m_stride(declaration.m_stride)
{
NazaraError("Particle component out of enum");
return;
}
#endif
#if NAZARA_GRAPHICS_SAFE
if (component == nzParticleComponent_Unused)
{
NazaraError("Cannot get \"unused\" component");
return;
}
#endif
const Component& particleComponent = m_components[component];
if (enabled)
*enabled = particleComponent.enabled;
if (type)
*type = particleComponent.type;
if (offset)
*offset = particleComponent.offset;
}
unsigned int NzParticleDeclaration::GetStride() const
{
return m_stride;
}
void NzParticleDeclaration::SetStride(unsigned int stride)
{
m_stride = stride;
}
NzParticleDeclaration& NzParticleDeclaration::operator=(const NzParticleDeclaration& declaration)
{
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(nzParticleComponent_Max+1));
m_stride = declaration.m_stride;
return *this;
}
NzParticleDeclaration* NzParticleDeclaration::Get(nzParticleLayout layout)
{
#ifdef NAZARA_DEBUG
if (layout > nzParticleLayout_Max)
{
NazaraError("Particle layout out of enum");
return nullptr;
}
#endif
return &s_declarations[layout];
}
bool NzParticleDeclaration::IsTypeSupported(nzComponentType type)
{
switch (type)
{
case nzComponentType_Color:
case nzComponentType_Double1:
case nzComponentType_Double2:
case nzComponentType_Double3:
case nzComponentType_Double4:
case nzComponentType_Float1:
case nzComponentType_Float2:
case nzComponentType_Float3:
case nzComponentType_Float4:
case nzComponentType_Int1:
case nzComponentType_Int2:
case nzComponentType_Int3:
case nzComponentType_Int4:
case nzComponentType_Quaternion:
return true;
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(ParticleComponent_Max+1));
}
NazaraError("Component type not handled (0x" + NzString::Number(type, 16) + ')');
return false;
}
bool NzParticleDeclaration::Initialize()
{
if (!NzParticleDeclarationLibrary::Initialize())
ParticleDeclaration::~ParticleDeclaration()
{
NazaraError("Failed to initialise library");
OnParticleDeclarationRelease(this);
}
void ParticleDeclaration::DisableComponent(ParticleComponent component)
{
#ifdef NAZARA_DEBUG
if (component > ParticleComponent_Max)
{
NazaraError("Vertex component out of enum");
return;
}
#endif
#if NAZARA_GRAPHICS_SAFE
if (component == ParticleComponent_Unused)
{
NazaraError("Cannot disable \"unused\" component");
return;
}
#endif
Component& vertexComponent = m_components[component];
if (vertexComponent.enabled)
{
vertexComponent.enabled = false;
m_stride -= Utility::ComponentStride[vertexComponent.type];
}
}
void ParticleDeclaration::EnableComponent(ParticleComponent component, ComponentType type, unsigned int offset)
{
#ifdef NAZARA_DEBUG
if (component > ParticleComponent_Max)
{
NazaraError("Vertex component out of enum");
return;
}
#endif
#if NAZARA_GRAPHICS_SAFE
if (!IsTypeSupported(type))
{
NazaraError("Component type 0x" + String::Number(type, 16) + " is not supported by particle declarations");
return;
}
#endif
if (component != ParticleComponent_Unused)
{
Component& particleComponent = m_components[component];
if (particleComponent.enabled)
m_stride -= Utility::ComponentStride[particleComponent.type];
else
particleComponent.enabled = true;
particleComponent.offset = offset;
particleComponent.type = type;
}
m_stride += Utility::ComponentStride[type];
}
void ParticleDeclaration::GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const
{
#ifdef NAZARA_DEBUG
if (component > ParticleComponent_Max)
{
NazaraError("Particle component out of enum");
return;
}
#endif
#if NAZARA_GRAPHICS_SAFE
if (component == ParticleComponent_Unused)
{
NazaraError("Cannot get \"unused\" component");
return;
}
#endif
const Component& particleComponent = m_components[component];
if (enabled)
*enabled = particleComponent.enabled;
if (type)
*type = particleComponent.type;
if (offset)
*offset = particleComponent.offset;
}
unsigned int ParticleDeclaration::GetStride() const
{
return m_stride;
}
void ParticleDeclaration::SetStride(unsigned int stride)
{
m_stride = stride;
}
ParticleDeclaration& ParticleDeclaration::operator=(const ParticleDeclaration& declaration)
{
std::memcpy(m_components, declaration.m_components, sizeof(Component)*(ParticleComponent_Max+1));
m_stride = declaration.m_stride;
return *this;
}
ParticleDeclaration* ParticleDeclaration::Get(ParticleLayout layout)
{
#ifdef NAZARA_DEBUG
if (layout > ParticleLayout_Max)
{
NazaraError("Particle layout out of enum");
return nullptr;
}
#endif
return &s_declarations[layout];
}
bool ParticleDeclaration::IsTypeSupported(ComponentType type)
{
switch (type)
{
case ComponentType_Color:
case ComponentType_Double1:
case ComponentType_Double2:
case ComponentType_Double3:
case ComponentType_Double4:
case ComponentType_Float1:
case ComponentType_Float2:
case ComponentType_Float3:
case ComponentType_Float4:
case ComponentType_Int1:
case ComponentType_Int2:
case ComponentType_Int3:
case ComponentType_Int4:
case ComponentType_Quaternion:
return true;
}
NazaraError("Component type not handled (0x" + String::Number(type, 16) + ')');
return false;
}
try
bool ParticleDeclaration::Initialize()
{
NzErrorFlags flags(nzErrorFlag_Silent | nzErrorFlag_ThrowException);
if (!ParticleDeclarationLibrary::Initialize())
{
NazaraError("Failed to initialise library");
return false;
}
// Layout : Type
NzParticleDeclaration* declaration;
try
{
ErrorFlags flags(ErrorFlag_Silent | ErrorFlag_ThrowException);
// nzParticleLayout_Billboard : NzParticleStruct_Billboard
declaration = &s_declarations[nzParticleLayout_Billboard];
declaration->EnableComponent(nzParticleComponent_Color, nzComponentType_Color, NzOffsetOf(NzParticleStruct_Billboard, color));
declaration->EnableComponent(nzParticleComponent_Life, nzComponentType_Int1, NzOffsetOf(NzParticleStruct_Billboard, life));
declaration->EnableComponent(nzParticleComponent_Normal, nzComponentType_Float3, NzOffsetOf(NzParticleStruct_Billboard, normal));
declaration->EnableComponent(nzParticleComponent_Position, nzComponentType_Float3, NzOffsetOf(NzParticleStruct_Billboard, position));
declaration->EnableComponent(nzParticleComponent_Rotation, nzComponentType_Float1, NzOffsetOf(NzParticleStruct_Billboard, rotation));
declaration->EnableComponent(nzParticleComponent_Velocity, nzComponentType_Float3, NzOffsetOf(NzParticleStruct_Billboard, velocity));
// Layout : Type
ParticleDeclaration* declaration;
NazaraAssert(declaration->GetStride() == sizeof(NzParticleStruct_Billboard), "Invalid stride for declaration nzParticleLayout_Billboard");
// ParticleLayout_Billboard : ParticleStruct_Billboard
declaration = &s_declarations[ParticleLayout_Billboard];
declaration->EnableComponent(ParticleComponent_Color, ComponentType_Color, NazaraOffsetOf(ParticleStruct_Billboard, color));
declaration->EnableComponent(ParticleComponent_Life, ComponentType_Int1, NazaraOffsetOf(ParticleStruct_Billboard, life));
declaration->EnableComponent(ParticleComponent_Normal, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Billboard, normal));
declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Billboard, position));
declaration->EnableComponent(ParticleComponent_Rotation, ComponentType_Float1, NazaraOffsetOf(ParticleStruct_Billboard, rotation));
declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Billboard, velocity));
// nzParticleLayout_Model : NzParticleStruct_Model
declaration = &s_declarations[nzParticleLayout_Model];
declaration->EnableComponent(nzParticleComponent_Life, nzComponentType_Int1, NzOffsetOf(NzParticleStruct_Model, life));
declaration->EnableComponent(nzParticleComponent_Position, nzComponentType_Float3, NzOffsetOf(NzParticleStruct_Model, position));
declaration->EnableComponent(nzParticleComponent_Rotation, nzComponentType_Quaternion, NzOffsetOf(NzParticleStruct_Model, rotation));
declaration->EnableComponent(nzParticleComponent_Velocity, nzComponentType_Float3, NzOffsetOf(NzParticleStruct_Model, velocity));
NazaraAssert(declaration->GetStride() == sizeof(ParticleStruct_Billboard), "Invalid stride for declaration ParticleLayout_Billboard");
NazaraAssert(declaration->GetStride() == sizeof(NzParticleStruct_Model), "Invalid stride for declaration nzParticleLayout_Model");
// ParticleLayout_Model : ParticleStruct_Model
declaration = &s_declarations[ParticleLayout_Model];
declaration->EnableComponent(ParticleComponent_Life, ComponentType_Int1, NazaraOffsetOf(ParticleStruct_Model, life));
declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Model, position));
declaration->EnableComponent(ParticleComponent_Rotation, ComponentType_Quaternion, NazaraOffsetOf(ParticleStruct_Model, rotation));
declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Model, velocity));
// nzParticleLayout_Sprite : NzParticleStruct_Sprite
declaration = &s_declarations[nzParticleLayout_Sprite];
declaration->EnableComponent(nzParticleComponent_Color, nzComponentType_Color, NzOffsetOf(NzParticleStruct_Sprite, color));
declaration->EnableComponent(nzParticleComponent_Life, nzComponentType_Int1, NzOffsetOf(NzParticleStruct_Sprite, life));
declaration->EnableComponent(nzParticleComponent_Position, nzComponentType_Float2, NzOffsetOf(NzParticleStruct_Sprite, position));
declaration->EnableComponent(nzParticleComponent_Rotation, nzComponentType_Float1, NzOffsetOf(NzParticleStruct_Sprite, rotation));
declaration->EnableComponent(nzParticleComponent_Velocity, nzComponentType_Float2, NzOffsetOf(NzParticleStruct_Sprite, velocity));
NazaraAssert(declaration->GetStride() == sizeof(ParticleStruct_Model), "Invalid stride for declaration ParticleLayout_Model");
NazaraAssert(declaration->GetStride() == sizeof(NzParticleStruct_Sprite), "Invalid stride for declaration nzParticleLayout_Sprite");
}
catch (const std::exception& e)
{
NazaraError("Failed to initialize particle declarations: " + NzString(e.what()));
return false;
// ParticleLayout_Sprite : ParticleStruct_Sprite
declaration = &s_declarations[ParticleLayout_Sprite];
declaration->EnableComponent(ParticleComponent_Color, ComponentType_Color, NazaraOffsetOf(ParticleStruct_Sprite, color));
declaration->EnableComponent(ParticleComponent_Life, ComponentType_Int1, NazaraOffsetOf(ParticleStruct_Sprite, life));
declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Sprite, position));
declaration->EnableComponent(ParticleComponent_Rotation, ComponentType_Float1, NazaraOffsetOf(ParticleStruct_Sprite, rotation));
declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Sprite, velocity));
NazaraAssert(declaration->GetStride() == sizeof(ParticleStruct_Sprite), "Invalid stride for declaration ParticleLayout_Sprite");
}
catch (const std::exception& e)
{
NazaraError("Failed to initialize particle declarations: " + String(e.what()));
return false;
}
return true;
}
return true;
}
void ParticleDeclaration::Uninitialize()
{
ParticleDeclarationLibrary::Uninitialize();
}
void NzParticleDeclaration::Uninitialize()
{
NzParticleDeclarationLibrary::Uninitialize();
ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max+1];
ParticleDeclarationLibrary::LibraryMap ParticleDeclaration::s_library;
}
NzParticleDeclaration NzParticleDeclaration::s_declarations[nzParticleLayout_Max+1];
NzParticleDeclarationLibrary::LibraryMap NzParticleDeclaration::s_library;