Removed AxisAlignedBox (Replaced by BoundingBox)
Former-commit-id: 931dd6710caf49aeaede51efe209d714f080c44b
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
struct NzKeyframeMeshImpl
|
||||
{
|
||||
NzAxisAlignedBoxf* aabb;
|
||||
NzCubef* aabb;
|
||||
NzVector2f* uv;
|
||||
NzVector3f* normals;
|
||||
NzVector3f* positions;
|
||||
@@ -59,7 +59,7 @@ bool NzKeyframeMesh::Create(NzVertexBuffer* vertexBuffer, unsigned int frameCoun
|
||||
vertexBuffer->AddResourceReference();
|
||||
|
||||
m_impl = new NzKeyframeMeshImpl;
|
||||
m_impl->aabb = new NzAxisAlignedBoxf[frameCount+1]; // La première case représente l'AABB interpolée
|
||||
m_impl->aabb = new NzCubef[frameCount+1]; // La première case représente l'AABB interpolée
|
||||
m_impl->frameCount = frameCount;
|
||||
m_impl->vertexBuffer = vertexBuffer;
|
||||
|
||||
@@ -123,25 +123,23 @@ void NzKeyframeMesh::GenerateAABBs()
|
||||
unsigned int vertexCount = m_impl->vertexBuffer->GetVertexCount();
|
||||
for (unsigned int i = 0; i < m_impl->frameCount; ++i)
|
||||
{
|
||||
NzAxisAlignedBoxf& aabb = m_impl->aabb[i+1]; // l'AABB 0 est celle qui est interpolée
|
||||
if (aabb.IsNull())
|
||||
{
|
||||
// Génération de l'AABB selon la position
|
||||
unsigned int index = i*vertexCount;
|
||||
for (unsigned int j = 0; j < vertexCount; ++j)
|
||||
aabb.ExtendTo(m_impl->positions[index+j]);
|
||||
}
|
||||
NzCubef& aabb = m_impl->aabb[i+1]; // l'AABB 0 est celle qui est interpolée
|
||||
|
||||
// Génération de l'AABB selon la position
|
||||
unsigned int index = i*vertexCount;
|
||||
for (unsigned int j = 0; j < vertexCount; ++j)
|
||||
aabb.ExtendTo(m_impl->positions[index+j]);
|
||||
}
|
||||
}
|
||||
|
||||
const NzAxisAlignedBoxf& NzKeyframeMesh::GetAABB() const
|
||||
const NzCubef& NzKeyframeMesh::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Keyframe mesh not created");
|
||||
|
||||
static NzAxisAlignedBoxf dummy(nzExtend_Null);
|
||||
static NzCubef dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
@@ -404,7 +402,7 @@ bool NzKeyframeMesh::IsValid()
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
void NzKeyframeMesh::SetAABB(unsigned int frameIndex, const NzAxisAlignedBoxf& aabb)
|
||||
void NzKeyframeMesh::SetAABB(unsigned int frameIndex, const NzCubef& aabb)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
@@ -502,7 +500,6 @@ void NzKeyframeMesh::SetPosition(unsigned int frameIndex, unsigned int vertexInd
|
||||
unsigned int index = frameIndex*vertexCount + vertexIndex;
|
||||
|
||||
m_impl->positions[index] = position;
|
||||
m_impl->aabb[frameIndex+1].MakeNull(); // Invalidation de l'AABB
|
||||
}
|
||||
|
||||
void NzKeyframeMesh::SetTangent(unsigned int frameIndex, unsigned int vertexIndex, const NzVector3f& tangent)
|
||||
@@ -566,7 +563,7 @@ void NzKeyframeMesh::InterpolateImpl(unsigned int frameA, unsigned int frameB, f
|
||||
#endif
|
||||
|
||||
// Interpolation de l'AABB
|
||||
m_impl->aabb[0] = NzAxisAlignedBoxf::Lerp(m_impl->aabb[frameA+1], m_impl->aabb[frameB+1], interpolation);
|
||||
m_impl->aabb[0] = NzCubef::Lerp(m_impl->aabb[frameA+1], m_impl->aabb[frameB+1], interpolation);
|
||||
|
||||
NzMeshVertex* vertex = reinterpret_cast<NzMeshVertex*>(m_impl->vertexBuffer->Map(nzBufferAccess_DiscardAndWrite));
|
||||
if (!vertex)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Math/AxisAlignedBox.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
@@ -34,7 +34,7 @@ class NzMD5AnimParser
|
||||
};
|
||||
|
||||
std::vector<Joint> joints;
|
||||
NzAxisAlignedBoxf aabb;
|
||||
NzCubef aabb;
|
||||
};
|
||||
|
||||
struct Joint
|
||||
|
||||
@@ -41,9 +41,10 @@ struct NzMeshImpl
|
||||
std::vector<NzString> materials;
|
||||
std::vector<NzSubMesh*> subMeshes;
|
||||
nzAnimationType animationType;
|
||||
NzAxisAlignedBoxf aabb;
|
||||
NzCubef aabb;
|
||||
NzSkeleton skeleton; // Uniquement pour les meshs squelettiques
|
||||
NzString animationPath;
|
||||
bool aabbUpdated = false;
|
||||
unsigned int jointCount; // Uniquement pour les meshs squelettiques
|
||||
};
|
||||
|
||||
@@ -77,7 +78,7 @@ bool NzMesh::AddSubMesh(NzSubMesh* subMesh)
|
||||
subMesh->AddResourceListener(this, m_impl->subMeshes.size());
|
||||
subMesh->Finish();
|
||||
|
||||
m_impl->aabb.MakeNull(); // On invalide l'AABB
|
||||
m_impl->aabbUpdated = false; // On invalide l'AABB
|
||||
m_impl->subMeshes.push_back(subMesh);
|
||||
|
||||
return true;
|
||||
@@ -123,7 +124,7 @@ bool NzMesh::AddSubMesh(const NzString& identifier, NzSubMesh* subMesh)
|
||||
subMesh->AddResourceListener(this, index);
|
||||
subMesh->Finish();
|
||||
|
||||
m_impl->aabb.MakeNull(); // On invalide l'AABB
|
||||
m_impl->aabbUpdated = false; // On invalide l'AABB
|
||||
m_impl->subMeshes.push_back(subMesh);
|
||||
m_impl->subMeshMap[identifier] = index;
|
||||
|
||||
@@ -206,7 +207,7 @@ void NzMesh::Animate(const NzAnimation* animation, unsigned int frameA, unsigned
|
||||
break;
|
||||
}
|
||||
|
||||
m_impl->aabb.MakeNull(); // On invalide l'AABB
|
||||
m_impl->aabbUpdated = false; // On invalide l'AABB
|
||||
}
|
||||
|
||||
bool NzMesh::CreateKeyframe()
|
||||
@@ -417,22 +418,24 @@ void NzMesh::GenerateTangents()
|
||||
}
|
||||
}
|
||||
|
||||
const NzAxisAlignedBoxf& NzMesh::GetAABB() const
|
||||
const NzCubef& NzMesh::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Mesh not created");
|
||||
|
||||
static NzAxisAlignedBoxf dummy(nzExtend_Null);
|
||||
static NzCubef dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_impl->aabb.IsNull())
|
||||
if (!m_impl->aabbUpdated)
|
||||
{
|
||||
for (NzSubMesh* subMesh : m_impl->subMeshes)
|
||||
m_impl->aabb.ExtendTo(subMesh->GetAABB());
|
||||
|
||||
m_impl->aabbUpdated = true;
|
||||
}
|
||||
|
||||
return m_impl->aabb;
|
||||
@@ -700,7 +703,7 @@ void NzMesh::InvalidateAABB() const
|
||||
}
|
||||
#endif
|
||||
|
||||
m_impl->aabb.MakeNull();
|
||||
m_impl->aabbUpdated = false;
|
||||
}
|
||||
|
||||
bool NzMesh::HasSubMesh(const NzString& identifier) const
|
||||
@@ -791,7 +794,7 @@ void NzMesh::RemoveSubMesh(const NzString& identifier)
|
||||
(*it2)->RemoveResourceListener(this);
|
||||
m_impl->subMeshes.erase(it2);
|
||||
|
||||
m_impl->aabb.MakeNull(); // On invalide l'AABB
|
||||
m_impl->aabbUpdated = false; // On invalide l'AABB
|
||||
}
|
||||
|
||||
void NzMesh::RemoveSubMesh(unsigned int index)
|
||||
@@ -818,7 +821,7 @@ void NzMesh::RemoveSubMesh(unsigned int index)
|
||||
(*it)->RemoveResourceListener(this);
|
||||
m_impl->subMeshes.erase(it);
|
||||
|
||||
m_impl->aabb.MakeNull(); // On invalide l'AABB
|
||||
m_impl->aabbUpdated = false; // On invalide l'AABB
|
||||
}
|
||||
|
||||
void NzMesh::SetAnimation(const NzString& animationPath)
|
||||
|
||||
@@ -132,7 +132,7 @@ struct NzSkeletalMeshImpl
|
||||
{
|
||||
std::vector<NzVertexWeight> vertexWeights;
|
||||
std::vector<NzWeight> weights;
|
||||
NzAxisAlignedBoxf aabb;
|
||||
NzCubef aabb;
|
||||
nzUInt8* bindPoseBuffer;
|
||||
const NzIndexBuffer* indexBuffer = nullptr;
|
||||
NzVertexBuffer* vertexBuffer;
|
||||
@@ -208,14 +208,14 @@ void NzSkeletalMesh::Finish()
|
||||
Skin();
|
||||
}
|
||||
|
||||
const NzAxisAlignedBoxf& NzSkeletalMesh::GetAABB() const
|
||||
const NzCubef& NzSkeletalMesh::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Skeletal mesh not created");
|
||||
|
||||
static NzAxisAlignedBoxf dummy(nzExtend_Null);
|
||||
static NzCubef dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,8 @@ struct NzSkeletonImpl
|
||||
{
|
||||
std::map<NzString, unsigned int> jointMap; ///FIXME: unordered_map
|
||||
std::vector<NzJoint> joints;
|
||||
NzAxisAlignedBoxf aabb;
|
||||
NzCubef aabb;
|
||||
bool aabbUpdated = false;
|
||||
bool jointMapUpdated = false;
|
||||
};
|
||||
|
||||
@@ -50,22 +51,24 @@ void NzSkeleton::Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
const NzAxisAlignedBoxf& NzSkeleton::GetAABB() const
|
||||
const NzCubef& NzSkeleton::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Skeleton not created");
|
||||
|
||||
static NzAxisAlignedBoxf dummy(nzExtend_Null);
|
||||
static NzCubef dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_impl->aabb.IsNull())
|
||||
if (!m_impl->aabbUpdated)
|
||||
{
|
||||
for (unsigned int i = 0; i < m_impl->joints.size(); ++i)
|
||||
m_impl->aabb.ExtendTo(m_impl->joints[i].GetPosition());
|
||||
|
||||
m_impl->aabbUpdated = true;
|
||||
}
|
||||
|
||||
return m_impl->aabb;
|
||||
@@ -95,7 +98,7 @@ NzJoint* NzSkeleton::GetJoint(const NzString& jointName)
|
||||
#endif
|
||||
|
||||
// Invalidation de l'AABB
|
||||
m_impl->aabb.MakeNull();
|
||||
m_impl->aabbUpdated = false;
|
||||
|
||||
return &m_impl->joints[it->second];
|
||||
}
|
||||
@@ -117,7 +120,7 @@ NzJoint* NzSkeleton::GetJoint(unsigned int index)
|
||||
#endif
|
||||
|
||||
// Invalidation de l'AABB
|
||||
m_impl->aabb.MakeNull();
|
||||
m_impl->aabbUpdated = false;
|
||||
|
||||
return &m_impl->joints[index];
|
||||
}
|
||||
@@ -265,7 +268,7 @@ void NzSkeleton::Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skel
|
||||
for (unsigned int i = 0; i < m_impl->joints.size(); ++i)
|
||||
m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation);
|
||||
|
||||
m_impl->aabb.MakeNull();
|
||||
m_impl->aabbUpdated = false;
|
||||
}
|
||||
|
||||
void NzSkeleton::Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount)
|
||||
@@ -313,7 +316,7 @@ void NzSkeleton::Interpolate(const NzSkeleton& skeletonA, const NzSkeleton& skel
|
||||
m_impl->joints[index].Interpolate(jointsA[index], jointsB[index], interpolation);
|
||||
}
|
||||
|
||||
m_impl->aabb.MakeNull();
|
||||
m_impl->aabbUpdated = false;
|
||||
}
|
||||
|
||||
bool NzSkeleton::IsValid() const
|
||||
|
||||
@@ -39,8 +39,6 @@ bool NzStaticMesh::Create(NzVertexBuffer* vertexBuffer)
|
||||
|
||||
void NzStaticMesh::Destroy()
|
||||
{
|
||||
m_aabb.MakeNull();
|
||||
|
||||
if (m_indexBuffer)
|
||||
{
|
||||
m_indexBuffer->RemoveResourceListener(this);
|
||||
@@ -62,9 +60,6 @@ void NzStaticMesh::Finish()
|
||||
|
||||
bool NzStaticMesh::GenerateAABB()
|
||||
{
|
||||
if (!m_aabb.IsNull())
|
||||
return true;
|
||||
|
||||
// On lock le buffer pour itérer sur toutes les positions et composer notre AABB
|
||||
NzBufferMapper<NzVertexBuffer> mapper(m_vertexBuffer, nzBufferAccess_ReadOnly);
|
||||
|
||||
@@ -79,7 +74,7 @@ bool NzStaticMesh::GenerateAABB()
|
||||
return true;
|
||||
}
|
||||
|
||||
const NzAxisAlignedBoxf& NzStaticMesh::GetAABB() const
|
||||
const NzCubef& NzStaticMesh::GetAABB() const
|
||||
{
|
||||
return m_aabb;
|
||||
}
|
||||
@@ -114,7 +109,7 @@ bool NzStaticMesh::IsValid() const
|
||||
return m_vertexBuffer != nullptr;
|
||||
}
|
||||
|
||||
void NzStaticMesh::SetAABB(const NzAxisAlignedBoxf& aabb)
|
||||
void NzStaticMesh::SetAABB(const NzCubef& aabb)
|
||||
{
|
||||
m_aabb = aabb;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user