Renamed (Oriented)Cube to (Oriented)Box
Also renamed BoundingBox to BoundingVolume Former-commit-id: 795c70c265ba17f6b96fc30799e89f140c52852b
This commit is contained in:
@@ -17,7 +17,7 @@ namespace
|
||||
{
|
||||
}
|
||||
|
||||
void Generate(float size, unsigned int recursionLevel, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb, unsigned int indexOffset)
|
||||
void Generate(float size, unsigned int recursionLevel, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
// Grandement inspiré de http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html
|
||||
const float t = (1.f + 2.236067f)/2.f;
|
||||
@@ -139,7 +139,7 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
void NzComputeCubeIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount)
|
||||
void NzComputeBoxIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount)
|
||||
{
|
||||
unsigned int xIndexCount, yIndexCount, zIndexCount;
|
||||
unsigned int xVertexCount, yVertexCount, zVertexCount;
|
||||
@@ -202,7 +202,7 @@ void NzComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int sta
|
||||
*vertexCount = sliceCount * stackCount;
|
||||
}
|
||||
|
||||
void NzGenerateCube(const NzCubef& cube, const NzVector3ui& subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb, unsigned int indexOffset)
|
||||
void NzGenerateBox(const NzBoxf& box, const NzVector3ui& subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
unsigned int xIndexCount, yIndexCount, zIndexCount;
|
||||
unsigned int xVertexCount, yVertexCount, zVertexCount;
|
||||
@@ -214,37 +214,37 @@ void NzGenerateCube(const NzCubef& cube, const NzVector3ui& subdivision, const N
|
||||
NzMeshVertex* oldVertices = vertices;
|
||||
|
||||
// Face +X
|
||||
NzGeneratePlane(NzVector2ui(subdivision.y, subdivision.z), cube.GetPosition() + NzVector3f::UnitX() * cube.width/2.f, NzVector3f::UnitX(), NzVector2f(cube.height, cube.depth), vertices, indices, nullptr, indexOffset);
|
||||
NzGeneratePlane(NzVector2ui(subdivision.y, subdivision.z), box.GetPosition() + NzVector3f::UnitX() * box.width/2.f, NzVector3f::UnitX(), NzVector2f(box.height, box.depth), vertices, indices, nullptr, indexOffset);
|
||||
indexOffset += xVertexCount;
|
||||
indices += xIndexCount;
|
||||
vertices += xVertexCount;
|
||||
|
||||
// Face +Y
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), cube.GetPosition() + NzVector3f::UnitY() * cube.height/2.f, NzVector3f::UnitY(), NzVector2f(cube.width, cube.depth), vertices, indices, nullptr, indexOffset);
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), box.GetPosition() + NzVector3f::UnitY() * box.height/2.f, NzVector3f::UnitY(), NzVector2f(box.width, box.depth), vertices, indices, nullptr, indexOffset);
|
||||
indexOffset += yVertexCount;
|
||||
indices += yIndexCount;
|
||||
vertices += yVertexCount;
|
||||
|
||||
// Face +Z
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), cube.GetPosition() + NzVector3f::UnitZ() * cube.depth/2.f, NzVector3f::UnitZ(), NzVector2f(cube.width, cube.height), vertices, indices, nullptr, indexOffset);
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), box.GetPosition() + NzVector3f::UnitZ() * box.depth/2.f, NzVector3f::UnitZ(), NzVector2f(box.width, box.height), vertices, indices, nullptr, indexOffset);
|
||||
indexOffset += zVertexCount;
|
||||
indices += zIndexCount;
|
||||
vertices += zVertexCount;
|
||||
|
||||
// Face -X
|
||||
NzGeneratePlane(NzVector2ui(subdivision.y, subdivision.z), cube.GetPosition() - NzVector3f::UnitX() * cube.width/2.f, -NzVector3f::UnitX(), NzVector2f(cube.height, cube.depth), vertices, indices, nullptr, indexOffset);
|
||||
NzGeneratePlane(NzVector2ui(subdivision.y, subdivision.z), box.GetPosition() - NzVector3f::UnitX() * box.width/2.f, -NzVector3f::UnitX(), NzVector2f(box.height, box.depth), vertices, indices, nullptr, indexOffset);
|
||||
indexOffset += xVertexCount;
|
||||
indices += xIndexCount;
|
||||
vertices += xVertexCount;
|
||||
|
||||
// Face -Y
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), cube.GetPosition() - NzVector3f::UnitY() * cube.height/2.f, -NzVector3f::UnitY(), NzVector2f(cube.width, cube.depth), vertices, indices, nullptr, indexOffset);
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), box.GetPosition() - NzVector3f::UnitY() * box.height/2.f, -NzVector3f::UnitY(), NzVector2f(box.width, box.depth), vertices, indices, nullptr, indexOffset);
|
||||
indexOffset += yVertexCount;
|
||||
indices += yIndexCount;
|
||||
vertices += yVertexCount;
|
||||
|
||||
// Face -Z
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), cube.GetPosition() - NzVector3f::UnitZ() * cube.depth/2.f, -NzVector3f::UnitZ(), NzVector2f(cube.width, cube.height), vertices, indices, nullptr, indexOffset);
|
||||
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), box.GetPosition() - NzVector3f::UnitZ() * box.depth/2.f, -NzVector3f::UnitZ(), NzVector2f(box.width, box.height), vertices, indices, nullptr, indexOffset);
|
||||
indexOffset += zVertexCount;
|
||||
indices += zIndexCount;
|
||||
vertices += zVertexCount;
|
||||
@@ -258,13 +258,13 @@ void NzGenerateCube(const NzCubef& cube, const NzVector3ui& subdivision, const N
|
||||
}
|
||||
}
|
||||
|
||||
void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb, unsigned int indexOffset)
|
||||
void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
unsigned int vertexCount;
|
||||
NzComputeCubeIndexVertexCount(NzVector3ui(subdivision), nullptr, &vertexCount);
|
||||
NzComputeBoxIndexVertexCount(NzVector3ui(subdivision), nullptr, &vertexCount);
|
||||
|
||||
// On envoie une matrice identité de sorte à ce que le cube ne subisse aucune transformation (rendant plus facile l'étape suivante)
|
||||
NzGenerateCube(NzCubef(size, size, size), NzVector3ui(subdivision), NzMatrix4f::Identity(), vertices, indices, nullptr, indexOffset);
|
||||
// On envoie une matrice identité de sorte à ce que le box ne subisse aucune transformation (rendant plus facile l'étape suivante)
|
||||
NzGenerateBox(NzBoxf(size, size, size), NzVector3ui(subdivision), NzMatrix4f::Identity(), vertices, indices, nullptr, indexOffset);
|
||||
|
||||
if (aabb)
|
||||
{
|
||||
@@ -281,13 +281,13 @@ void NzGenerateCubicSphere(float size, unsigned int subdivision, const NzMatrix4
|
||||
}
|
||||
}
|
||||
|
||||
void NzGenerateIcoSphere(float size, unsigned int recursionLevel, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb, unsigned int indexOffset)
|
||||
void NzGenerateIcoSphere(float size, unsigned int recursionLevel, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
IcoSphereBuilder builder(matrix);
|
||||
builder.Generate(size, recursionLevel, vertices, indices, aabb, indexOffset);
|
||||
}
|
||||
|
||||
void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector3f& position, const NzVector3f& normal, const NzVector2f& size, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb, unsigned int indexOffset)
|
||||
void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector3f& position, const NzVector3f& normal, const NzVector2f& size, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
// Le nombre de faces appartenant à un axe est équivalent à 2 exposant la subdivision (2,3,5,9,17,33,...)
|
||||
unsigned int horizontalFaceCount = (1 << subdivision.x);
|
||||
@@ -344,7 +344,7 @@ void NzGeneratePlane(const NzVector2ui& subdivision, const NzVector3f& position,
|
||||
aabb->Set(rotation * NzVector3f(-halfSizeX, 0.f, -halfSizeY), rotation * NzVector3f(halfSizeX, 0.f, halfSizeY));
|
||||
}
|
||||
|
||||
void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzCubef* aabb, unsigned int indexOffset)
|
||||
void NzGenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const NzMatrix4f& matrix, NzMeshVertex* vertices, nzUInt32* indices, NzBoxf* aabb, unsigned int indexOffset)
|
||||
{
|
||||
// http://stackoverflow.com/questions/14080932/implementing-opengl-sphere-example-code
|
||||
float invSliceCount = 1.f / (sliceCount-1);
|
||||
|
||||
@@ -150,7 +150,7 @@ bool NzImage::Convert(nzPixelFormat format)
|
||||
return true;
|
||||
}
|
||||
|
||||
void NzImage::Copy(const NzImage& source, const NzCubeui& srcCube, const NzVector3ui& dstPos)
|
||||
void NzImage::Copy(const NzImage& source, const NzBoxui& srcBox, const NzVector3ui& dstPos)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
@@ -172,7 +172,7 @@ void NzImage::Copy(const NzImage& source, const NzCubeui& srcCube, const NzVecto
|
||||
}
|
||||
#endif
|
||||
|
||||
const nzUInt8* srcPtr = source.GetConstPixels(srcCube.x, srcCube.y, srcCube.z);
|
||||
const nzUInt8* srcPtr = source.GetConstPixels(srcBox.x, srcBox.y, srcBox.z);
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!srcPtr)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ void NzImage::Copy(const NzImage& source, const NzCubeui& srcCube, const NzVecto
|
||||
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||
nzUInt8* dstPtr = GetPixelPtr(m_sharedImage->pixels[0], bpp, dstPos.x, dstPos.y, dstPos.z, m_sharedImage->width, m_sharedImage->height);
|
||||
|
||||
Copy(dstPtr, srcPtr, bpp, srcCube.width, srcCube.height, srcCube.depth, m_sharedImage->width, m_sharedImage->height, source.GetWidth(), source.GetHeight());
|
||||
Copy(dstPtr, srcPtr, bpp, srcBox.width, srcBox.height, srcBox.depth, m_sharedImage->width, m_sharedImage->height, source.GetWidth(), source.GetHeight());
|
||||
}
|
||||
|
||||
bool NzImage::Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth, nzUInt8 levelCount)
|
||||
@@ -384,6 +384,65 @@ bool NzImage::Fill(const NzColor& color)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzImage::Fill(const NzColor& color, const NzBoxui& box)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!box.IsValid())
|
||||
{
|
||||
NazaraError("Invalid rectangle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (box.x+box.width > m_sharedImage->width || box.y+box.height > m_sharedImage->height || box.z+box.depth > m_sharedImage->depth)
|
||||
{
|
||||
NazaraError("Box dimensions are out of bounds");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
EnsureOwnership();
|
||||
|
||||
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||
std::unique_ptr<nzUInt8[]> colorBuffer(new nzUInt8[bpp]);
|
||||
if (!NzPixelFormat::Convert(nzPixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||
{
|
||||
NazaraError("Failed to convert RGBA8 to " + NzPixelFormat::ToString(m_sharedImage->format));
|
||||
return false;
|
||||
}
|
||||
|
||||
///FIXME: L'algorithme a du mal avec un bpp non multiple de 2
|
||||
nzUInt8* dstPixels = GetPixelPtr(m_sharedImage->pixels[0], bpp, box.x, box.y, box.z, m_sharedImage->width, m_sharedImage->height);
|
||||
unsigned int srcStride = box.width * bpp;
|
||||
unsigned int dstStride = m_sharedImage->width * bpp;
|
||||
unsigned int faceSize = dstStride * m_sharedImage->height;
|
||||
for (unsigned int z = 0; z < box.depth; ++z)
|
||||
{
|
||||
nzUInt8* facePixels = dstPixels;
|
||||
for (unsigned int y = 0; y < box.height; ++y)
|
||||
{
|
||||
nzUInt8* start = facePixels;
|
||||
nzUInt8* end = facePixels + srcStride;
|
||||
while (start < end)
|
||||
{
|
||||
std::memcpy(start, colorBuffer.get(), bpp);
|
||||
start += bpp;
|
||||
}
|
||||
|
||||
facePixels += dstStride;
|
||||
}
|
||||
|
||||
dstPixels += faceSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzImage::Fill(const NzColor& color, const NzRectui& rect, unsigned int z)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
@@ -443,65 +502,6 @@ bool NzImage::Fill(const NzColor& color, const NzRectui& rect, unsigned int z)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzImage::Fill(const NzColor& color, const NzCubeui& cube)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!cube.IsValid())
|
||||
{
|
||||
NazaraError("Invalid rectangle");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cube.x+cube.width > m_sharedImage->width || cube.y+cube.height > m_sharedImage->height || cube.z+cube.depth > m_sharedImage->depth)
|
||||
{
|
||||
NazaraError("Cube dimensions are out of bounds");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
EnsureOwnership();
|
||||
|
||||
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||
std::unique_ptr<nzUInt8[]> colorBuffer(new nzUInt8[bpp]);
|
||||
if (!NzPixelFormat::Convert(nzPixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||
{
|
||||
NazaraError("Failed to convert RGBA8 to " + NzPixelFormat::ToString(m_sharedImage->format));
|
||||
return false;
|
||||
}
|
||||
|
||||
///FIXME: L'algorithme a du mal avec un bpp non multiple de 2
|
||||
nzUInt8* dstPixels = GetPixelPtr(m_sharedImage->pixels[0], bpp, cube.x, cube.y, cube.z, m_sharedImage->width, m_sharedImage->height);
|
||||
unsigned int srcStride = cube.width * bpp;
|
||||
unsigned int dstStride = m_sharedImage->width * bpp;
|
||||
unsigned int faceSize = dstStride * m_sharedImage->height;
|
||||
for (unsigned int z = 0; z < cube.depth; ++z)
|
||||
{
|
||||
nzUInt8* facePixels = dstPixels;
|
||||
for (unsigned int y = 0; y < cube.height; ++y)
|
||||
{
|
||||
nzUInt8* start = facePixels;
|
||||
nzUInt8* end = facePixels + srcStride;
|
||||
while (start < end)
|
||||
{
|
||||
std::memcpy(start, colorBuffer.get(), bpp);
|
||||
start += bpp;
|
||||
}
|
||||
|
||||
facePixels += dstStride;
|
||||
}
|
||||
|
||||
dstPixels += faceSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NzImage::FlipHorizontally()
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
@@ -1102,6 +1102,57 @@ void NzImage::Update(const nzUInt8* pixels, unsigned int srcWidth, unsigned int
|
||||
srcWidth, srcHeight);
|
||||
}
|
||||
|
||||
void NzImage::Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pixels)
|
||||
{
|
||||
NazaraError("Invalid pixel source");
|
||||
return;
|
||||
}
|
||||
|
||||
if (level >= m_sharedImage->levelCount)
|
||||
{
|
||||
NazaraError("Level out of bounds (" + NzString::Number(level) + " >= " + NzString::Number(m_sharedImage->levelCount) + ')');
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int width = GetLevelSize(m_sharedImage->width, level);
|
||||
unsigned int height = GetLevelSize(m_sharedImage->height, level);
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!box.IsValid())
|
||||
{
|
||||
NazaraError("Invalid box");
|
||||
return;
|
||||
}
|
||||
|
||||
// Nous n'autorisons pas de modifier plus d'une face du cubemap à la fois (Nous prenons donc la profondeur de base)
|
||||
if (box.x+box.width > width || box.y+box.height > height || box.z+box.depth > GetLevelSize(m_sharedImage->depth, level))
|
||||
{
|
||||
NazaraError("Box dimensions are out of bounds");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
EnsureOwnership();
|
||||
|
||||
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||
nzUInt8* dstPixels = GetPixelPtr(m_sharedImage->pixels[level], bpp, box.x, box.y, box.z, width, height);
|
||||
|
||||
Copy(dstPixels, pixels, bpp,
|
||||
box.width, box.height, box.depth,
|
||||
width, height,
|
||||
srcWidth, srcHeight);
|
||||
}
|
||||
|
||||
void NzImage::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
@@ -1159,57 +1210,6 @@ void NzImage::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z
|
||||
srcWidth, srcHeight);
|
||||
}
|
||||
|
||||
void NzImage::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (m_sharedImage == &emptyImage)
|
||||
{
|
||||
NazaraError("Image must be valid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pixels)
|
||||
{
|
||||
NazaraError("Invalid pixel source");
|
||||
return;
|
||||
}
|
||||
|
||||
if (level >= m_sharedImage->levelCount)
|
||||
{
|
||||
NazaraError("Level out of bounds (" + NzString::Number(level) + " >= " + NzString::Number(m_sharedImage->levelCount) + ')');
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int width = GetLevelSize(m_sharedImage->width, level);
|
||||
unsigned int height = GetLevelSize(m_sharedImage->height, level);
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!cube.IsValid())
|
||||
{
|
||||
NazaraError("Invalid cube");
|
||||
return;
|
||||
}
|
||||
|
||||
// Nous n'autorisons pas de modifier plus d'une face du cubemap à la fois
|
||||
if (cube.x+cube.width > width || cube.y+cube.height > height || cube.z+cube.depth > GetLevelSize(m_sharedImage->height, level))
|
||||
{
|
||||
NazaraError("Cube dimensions are out of bounds");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
EnsureOwnership();
|
||||
|
||||
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_sharedImage->format);
|
||||
nzUInt8* dstPixels = GetPixelPtr(m_sharedImage->pixels[level], bpp, cube.x, cube.y, cube.z, width, height);
|
||||
|
||||
Copy(dstPixels, pixels, bpp,
|
||||
cube.width, cube.height, cube.depth,
|
||||
width, height,
|
||||
srcWidth, srcHeight);
|
||||
}
|
||||
|
||||
NzImage& NzImage::operator=(const NzImage& image)
|
||||
{
|
||||
ReleaseImage();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/InputStream.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include <Nazara/Math/Box.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;
|
||||
NzCubef aabb;
|
||||
NzBoxf aabb;
|
||||
};
|
||||
|
||||
struct Joint
|
||||
|
||||
@@ -46,7 +46,7 @@ struct NzMeshImpl
|
||||
std::vector<NzString> materials;
|
||||
std::vector<NzSubMesh*> subMeshes;
|
||||
nzAnimationType animationType;
|
||||
NzCubef aabb;
|
||||
NzBoxf aabb;
|
||||
NzSkeleton skeleton; // Uniquement pour les meshs squelettiques
|
||||
NzString animationPath;
|
||||
bool aabbUpdated = false;
|
||||
@@ -168,7 +168,7 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||
|
||||
for (unsigned int p = 0; p < primitiveCount; ++p)
|
||||
{
|
||||
NzCubef aabb;
|
||||
NzBoxf aabb;
|
||||
std::unique_ptr<NzIndexBuffer> indexBuffer;
|
||||
std::unique_ptr<NzVertexBuffer> vertexBuffer;
|
||||
|
||||
@@ -176,11 +176,11 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||
|
||||
switch (primitive.type)
|
||||
{
|
||||
case nzPrimitiveType_Cube:
|
||||
case nzPrimitiveType_Box:
|
||||
{
|
||||
unsigned int indexCount;
|
||||
unsigned int vertexCount;
|
||||
NzComputeCubeIndexVertexCount(primitive.cube.subdivision, &indexCount, &vertexCount);
|
||||
NzComputeBoxIndexVertexCount(primitive.box.subdivision, &indexCount, &vertexCount);
|
||||
|
||||
indexBuffer.reset(new NzIndexBuffer(indexCount, vertexCount > std::numeric_limits<nzUInt16>::max(), params.storage, nzBufferUsage_Static));
|
||||
indexBuffer->SetPersistent(false);
|
||||
@@ -193,7 +193,7 @@ void NzMesh::Build(const NzPrimitiveList& list, const NzMeshParams& params)
|
||||
indices.resize(indexCount);
|
||||
|
||||
NzBufferMapper<NzVertexBuffer> vertexMapper(vertexBuffer.get(), nzBufferAccess_WriteOnly);
|
||||
NzGenerateCube(primitive.cube.cube, primitive.cube.subdivision, primitive.cube.matrix, static_cast<NzMeshVertex*>(vertexMapper.GetPointer()), &indices[0], &aabb);
|
||||
NzGenerateBox(primitive.box.box, primitive.box.subdivision, primitive.box.matrix, static_cast<NzMeshVertex*>(vertexMapper.GetPointer()), &indices[0], &aabb);
|
||||
vertexMapper.Unmap();
|
||||
|
||||
NzIndexMapper indexMapper(indexBuffer.get(), nzBufferAccess_WriteOnly);
|
||||
@@ -432,14 +432,14 @@ void NzMesh::GenerateTangents()
|
||||
subMesh->GenerateTangents();
|
||||
}
|
||||
|
||||
const NzCubef& NzMesh::GetAABB() const
|
||||
const NzBoxf& NzMesh::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Mesh not created");
|
||||
|
||||
static NzCubef dummy;
|
||||
static NzBoxf dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -136,7 +136,7 @@ struct NzSkeletalMeshImpl
|
||||
std::unique_ptr<nzUInt8[]> bindPoseBuffer;
|
||||
std::vector<NzVertexWeight> vertexWeights;
|
||||
std::vector<NzWeight> weights;
|
||||
NzCubef aabb;
|
||||
NzBoxf aabb;
|
||||
NzIndexBufferConstRef indexBuffer;
|
||||
unsigned int vertexCount;
|
||||
};
|
||||
@@ -187,14 +187,14 @@ void NzSkeletalMesh::Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
const NzCubef& NzSkeletalMesh::GetAABB() const
|
||||
const NzBoxf& NzSkeletalMesh::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Skeletal mesh not created");
|
||||
|
||||
static NzCubef dummy;
|
||||
static NzBoxf dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@ struct NzSkeletonImpl
|
||||
{
|
||||
std::map<NzString, unsigned int> jointMap; ///FIXME: unordered_map
|
||||
std::vector<NzJoint> joints;
|
||||
NzCubef aabb;
|
||||
NzBoxf aabb;
|
||||
bool aabbUpdated = false;
|
||||
bool jointMapUpdated = false;
|
||||
};
|
||||
@@ -51,14 +51,14 @@ void NzSkeleton::Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
const NzCubef& NzSkeleton::GetAABB() const
|
||||
const NzBoxf& NzSkeleton::GetAABB() const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Skeleton not created");
|
||||
|
||||
static NzCubef dummy;
|
||||
static NzBoxf dummy;
|
||||
return dummy;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -70,7 +70,7 @@ bool NzStaticMesh::GenerateAABB()
|
||||
return true;
|
||||
}
|
||||
|
||||
const NzCubef& NzStaticMesh::GetAABB() const
|
||||
const NzBoxf& NzStaticMesh::GetAABB() const
|
||||
{
|
||||
return m_aabb;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ bool NzStaticMesh::IsValid() const
|
||||
return m_vertexBuffer != nullptr;
|
||||
}
|
||||
|
||||
void NzStaticMesh::SetAABB(const NzCubef& aabb)
|
||||
void NzStaticMesh::SetAABB(const NzBoxf& aabb)
|
||||
{
|
||||
m_aabb = aabb;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user