Replaced Mesh::Build by BuildSubMesh(es)
Former-commit-id: c5b034aa764cdda0ea0c48182f2562968a10c226
This commit is contained in:
parent
b1d7770570
commit
f74f9e964e
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Core/InputStream.hpp>
|
#include <Nazara/Core/InputStream.hpp>
|
||||||
|
#include <Nazara/Core/Primitive.hpp>
|
||||||
#include <Nazara/Core/Resource.hpp>
|
#include <Nazara/Core/Resource.hpp>
|
||||||
#include <Nazara/Core/ResourceListener.hpp>
|
#include <Nazara/Core/ResourceListener.hpp>
|
||||||
#include <Nazara/Core/ResourceLoader.hpp>
|
#include <Nazara/Core/ResourceLoader.hpp>
|
||||||
|
|
@ -58,7 +59,8 @@ class NAZARA_API NzMesh : public NzResource, NzResourceListener
|
||||||
bool AddSubMesh(NzSubMesh* subMesh);
|
bool AddSubMesh(NzSubMesh* subMesh);
|
||||||
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
bool AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||||
|
|
||||||
void Build(const NzPrimitiveList& list, const NzMeshParams& params = NzMeshParams());
|
void BuildSubMesh(const NzPrimitive& primitive, const NzMeshParams& params = NzMeshParams());
|
||||||
|
void BuildSubMeshes(const NzPrimitiveList& list, const NzMeshParams& params = NzMeshParams());
|
||||||
|
|
||||||
bool CreateSkeletal(unsigned int jointCount);
|
bool CreateSkeletal(unsigned int jointCount);
|
||||||
bool CreateStatic();
|
bool CreateStatic();
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ bool NzMesh::AddSubMesh(const NzString& identifier, NzSubMesh* subMesh)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
void NzMesh::BuildSubMesh(const NzPrimitive& primitive, const NzMeshParams& params)
|
||||||
{
|
{
|
||||||
#if NAZARA_UTILITY_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
|
|
@ -148,16 +148,6 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||||
NazaraError("Mesh must be static");
|
NazaraError("Mesh must be static");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned int primitiveCount = list.GetSize();
|
|
||||||
|
|
||||||
#if NAZARA_UTILITY_SAFE
|
|
||||||
if (primitiveCount == 0)
|
|
||||||
{
|
|
||||||
NazaraError("PrimitiveList must have at least one primitive");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!params.IsValid())
|
if (!params.IsValid())
|
||||||
{
|
{
|
||||||
|
|
@ -166,14 +156,10 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (unsigned int p = 0; p < primitiveCount; ++p)
|
|
||||||
{
|
|
||||||
NzBoxf aabb;
|
NzBoxf aabb;
|
||||||
std::unique_ptr<NzIndexBuffer> indexBuffer;
|
std::unique_ptr<NzIndexBuffer> indexBuffer;
|
||||||
std::unique_ptr<NzVertexBuffer> vertexBuffer;
|
std::unique_ptr<NzVertexBuffer> vertexBuffer;
|
||||||
|
|
||||||
const NzPrimitive& primitive = list.GetPrimitive(p);
|
|
||||||
|
|
||||||
switch (primitive.type)
|
switch (primitive.type)
|
||||||
{
|
{
|
||||||
case nzPrimitiveType_Box:
|
case nzPrimitiveType_Box:
|
||||||
|
|
@ -283,7 +269,7 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||||
if (!subMesh->Create(vertexBuffer.get()))
|
if (!subMesh->Create(vertexBuffer.get()))
|
||||||
{
|
{
|
||||||
NazaraError("Failed to create StaticMesh");
|
NazaraError("Failed to create StaticMesh");
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
vertexBuffer.release();
|
vertexBuffer.release();
|
||||||
|
|
||||||
|
|
@ -298,6 +284,21 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||||
if (AddSubMesh(subMesh.get()))
|
if (AddSubMesh(subMesh.get()))
|
||||||
subMesh.release();
|
subMesh.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzMesh::BuildSubMeshes(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||||
|
{
|
||||||
|
unsigned int primitiveCount = list.GetSize();
|
||||||
|
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (primitiveCount == 0)
|
||||||
|
{
|
||||||
|
NazaraError("PrimitiveList must have at least one primitive");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < primitiveCount; ++i)
|
||||||
|
BuildSubMesh(list.GetPrimitive(i), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzMesh::CreateSkeletal(unsigned int jointCount)
|
bool NzMesh::CreateSkeletal(unsigned int jointCount)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue