Renamed (Oriented)Cube to (Oriented)Box

Also renamed BoundingBox to BoundingVolume


Former-commit-id: 795c70c265ba17f6b96fc30799e89f140c52852b
This commit is contained in:
Lynix
2013-06-03 14:18:31 +02:00
parent 7e9dd26991
commit fb839de33e
46 changed files with 1008 additions and 1007 deletions

View File

@@ -6,20 +6,20 @@
#include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Debug.hpp>
void NzPrimitiveList::AddCube(const NzCubef& cube, const NzVector3ui& subdivision, const NzMatrix4f& matrix)
void NzPrimitiveList::AddBox(const NzBoxf& box, const NzVector3ui& subdivision, const NzMatrix4f& matrix)
{
NzPrimitive primitive;
primitive.type = nzPrimitiveType_Cube;
primitive.cube.cube = cube; // cube.cube = cube, parce que je le vaux bien
primitive.cube.matrix = matrix;
primitive.cube.subdivision = subdivision;
primitive.type = nzPrimitiveType_Box;
primitive.box.box = box; // box.box = box, parce que je le vaux bien
primitive.box.matrix = matrix;
primitive.box.subdivision = subdivision;
m_primitives.push_back(primitive);
}
void NzPrimitiveList::AddCube(const NzCubef& cube, const NzVector3ui& subdivision, const NzVector3f& position, const NzQuaternionf& rotation)
void NzPrimitiveList::AddBox(const NzBoxf& box, const NzVector3ui& subdivision, const NzVector3f& position, const NzQuaternionf& rotation)
{
AddCube(cube, subdivision, NzMatrix4f::Transform(position, rotation));
AddBox(box, subdivision, NzMatrix4f::Transform(position, rotation));
}
void NzPrimitiveList::AddCubicSphere(float size, unsigned int subdivision, const NzMatrix4f& matrix)

View File

@@ -93,10 +93,10 @@ float NzCamera::GetAspectRatio() const
return m_aspectRatio;
}
const NzBoundingBoxf& NzCamera::GetBoundingBox() const
const NzBoundingVolumef& NzCamera::GetBoundingVolume() const
{
///TODO: Remplacer par la bounding box du Frustum ?
static NzBoundingBoxf dummy(nzExtend_Null);
///TODO: Remplacer par le bounding volume du Frustum ?
static NzBoundingVolumef dummy(nzExtend_Null);
return dummy;
}

View File

@@ -19,7 +19,7 @@ m_type(type),
m_ambientColor((type == nzLightType_Directional) ? NzColor(50, 50, 50) : NzColor::Black),
m_diffuseColor(NzColor::White),
m_specularColor(NzColor::White),
m_boundingBoxUpdated(false),
m_boundingVolumeUpdated(false),
m_attenuation(0.9f),
m_innerAngle(15.f),
m_outerAngle(45.f),
@@ -116,12 +116,12 @@ void NzLight::Apply(const NzShader* shader, unsigned int lightUnit) const
}
}
const NzBoundingBoxf& NzLight::GetBoundingBox() const
const NzBoundingVolumef& NzLight::GetBoundingVolume() const
{
if (!m_boundingBoxUpdated)
UpdateBoundingBox();
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
return m_boundingBox;
return m_boundingVolume;
}
NzColor NzLight::GetAmbientColor() const
@@ -193,16 +193,16 @@ void NzLight::SetOuterAngle(float outerAngle)
{
m_outerAngle = outerAngle;
m_boundingBox.MakeNull();
m_boundingBoxUpdated = false;
m_boundingVolume.MakeNull();
m_boundingVolumeUpdated = false;
}
void NzLight::SetRadius(float radius)
{
m_radius = radius;
m_boundingBox.MakeNull();
m_boundingBoxUpdated = false;
m_boundingVolume.MakeNull();
m_boundingVolumeUpdated = false;
}
void NzLight::SetSpecularColor(const NzColor& specular)
@@ -221,7 +221,7 @@ void NzLight::Invalidate()
{
NzSceneNode::Invalidate();
m_boundingBoxUpdated = false;
m_boundingVolumeUpdated = false;
}
void NzLight::Register()
@@ -232,28 +232,28 @@ void NzLight::Unregister()
{
}
void NzLight::UpdateBoundingBox() const
void NzLight::UpdateBoundingVolume() const
{
if (m_boundingBox.IsNull())
if (m_boundingVolume.IsNull())
{
switch (m_type)
{
case nzLightType_Directional:
m_boundingBox.MakeInfinite();
m_boundingBoxUpdated = true;
m_boundingVolume.MakeInfinite();
m_boundingVolumeUpdated = true;
return; // Rien d'autre à faire
case nzLightType_Point:
{
NzVector3f radius(m_radius);
m_boundingBox.Set(-radius, radius);
m_boundingVolume.Set(-radius, radius);
break;
}
case nzLightType_Spot:
{
// On forme un cube sur l'origine
NzCubef cube(NzVector3f::Zero());
// On forme une boite sur l'origine
NzBoxf box(NzVector3f::Zero());
// On calcule le reste des points
float height = m_radius;
@@ -265,13 +265,13 @@ void NzLight::UpdateBoundingBox() const
NzVector3f lExtend = NzVector3f::Left()*radius;
NzVector3f uExtend = NzVector3f::Up()*radius;
// Et on ajoute ensuite les quatres extrêmités de la pyramide
cube.ExtendTo(base + lExtend + uExtend);
cube.ExtendTo(base + lExtend - uExtend);
cube.ExtendTo(base - lExtend + uExtend);
cube.ExtendTo(base - lExtend - uExtend);
// Et on ajoute ensuite les quatres extrémités de la pyramide
box.ExtendTo(base + lExtend + uExtend);
box.ExtendTo(base + lExtend - uExtend);
box.ExtendTo(base - lExtend + uExtend);
box.ExtendTo(base - lExtend - uExtend);
m_boundingBox.Set(cube);
m_boundingVolume.Set(box);
break;
}
}
@@ -286,18 +286,18 @@ void NzLight::UpdateBoundingBox() const
if (!m_derivedUpdated)
UpdateDerived();
m_boundingBox.Update(NzMatrix4f::Translate(m_derivedPosition)); // Notre BoundingBox ne changera que selon la position
m_boundingVolume.Update(NzMatrix4f::Translate(m_derivedPosition)); // Notre BoundingBox ne changera que selon la position
break;
case nzLightType_Spot:
if (!m_transformMatrixUpdated)
UpdateTransformMatrix();
m_boundingBox.Update(m_transformMatrix);
m_boundingVolume.Update(m_transformMatrix);
break;
}
m_boundingBoxUpdated = true;
m_boundingVolumeUpdated = true;
}
bool NzLight::VisibilityTest(const NzFrustumf& frustum)
@@ -315,10 +315,10 @@ bool NzLight::VisibilityTest(const NzFrustumf& frustum)
return frustum.Contains(NzSpheref(m_derivedPosition, m_radius));
case nzLightType_Spot:
if (!m_boundingBoxUpdated)
UpdateBoundingBox();
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
return frustum.Contains(m_boundingBox);
return frustum.Contains(m_boundingVolume);
}
NazaraError("Invalid light type (0x" + NzString::Number(m_type, 16) + ')');

View File

@@ -25,7 +25,7 @@ bool NzModelParameters::IsValid() const
NzModel::NzModel() :
m_currentSequence(nullptr),
m_animationEnabled(true),
m_boundingBoxUpdated(true),
m_boundingVolumeUpdated(true),
m_drawEnabled(true),
m_matCount(0),
m_skin(0),
@@ -36,10 +36,10 @@ m_skinCount(1)
NzModel::NzModel(const NzModel& model) :
NzSceneNode(model),
m_materials(model.m_materials),
m_boundingBox(model.m_boundingBox),
m_boundingVolume(model.m_boundingVolume),
m_currentSequence(model.m_currentSequence),
m_animationEnabled(model.m_animationEnabled),
m_boundingBoxUpdated(model.m_boundingBoxUpdated),
m_boundingVolumeUpdated(model.m_boundingVolumeUpdated),
m_drawEnabled(model.m_drawEnabled),
m_interpolation(model.m_interpolation),
m_currentFrame(model.m_currentFrame),
@@ -107,8 +107,8 @@ void NzModel::AdvanceAnimation(float elapsedTime)
}
m_animation->AnimateSkeleton(&m_skeleton, m_currentFrame, m_nextFrame, m_interpolation);
m_boundingBox.MakeNull();
m_boundingBoxUpdated = false;
m_boundingVolume.MakeNull();
m_boundingVolumeUpdated = false;
}
void NzModel::EnableAnimation(bool animation)
@@ -126,22 +126,22 @@ NzAnimation* NzModel::GetAnimation() const
return m_animation;
}
const NzBoundingBoxf& NzModel::GetBoundingBox() const
const NzBoundingVolumef& NzModel::GetBoundingVolume() const
{
#if NAZARA_GRAPHICS_SAFE
if (!m_mesh)
{
NazaraError("Model has no mesh");
static NzBoundingBoxf dummy(nzExtend_Null);
static NzBoundingVolumef dummy(nzExtend_Null);
return dummy;
}
#endif
if (!m_boundingBoxUpdated)
UpdateBoundingBox();
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
return m_boundingBox;
return m_boundingVolume;
}
NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const
@@ -474,7 +474,7 @@ void NzModel::SetMesh(NzMesh* mesh)
if (m_mesh)
{
m_boundingBoxUpdated = false;
m_boundingVolumeUpdated = false;
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
m_skeleton = *mesh->GetSkeleton(); // Copie du squelette template
@@ -494,8 +494,8 @@ void NzModel::SetMesh(NzMesh* mesh)
}
else
{
m_boundingBox.MakeNull();
m_boundingBoxUpdated = true;
m_boundingVolume.MakeNull();
m_boundingVolumeUpdated = true;
m_matCount = 0;
m_skinCount = 0;
m_materials.clear();
@@ -584,8 +584,8 @@ NzModel& NzModel::operator=(const NzModel& node)
m_animation = node.m_animation;
m_animationEnabled = node.m_animationEnabled;
m_boundingBox = node.m_boundingBox;
m_boundingBoxUpdated = node.m_boundingBoxUpdated;
m_boundingVolume = node.m_boundingVolume;
m_boundingVolumeUpdated = node.m_boundingVolumeUpdated;
m_currentFrame = node.m_currentFrame;
m_currentSequence = node.m_currentSequence;
m_drawEnabled = node.m_drawEnabled;
@@ -609,8 +609,8 @@ NzModel& NzModel::operator=(NzModel&& node)
m_animation = std::move(node.m_animation);
m_animationEnabled = node.m_animationEnabled;
m_boundingBox = node.m_boundingBox;
m_boundingBoxUpdated = node.m_boundingBoxUpdated;
m_boundingVolume = node.m_boundingVolume;
m_boundingVolumeUpdated = node.m_boundingVolumeUpdated;
m_currentFrame = node.m_currentFrame;
m_currentSequence = node.m_currentSequence;
m_drawEnabled = node.m_drawEnabled;
@@ -632,7 +632,7 @@ void NzModel::Invalidate()
{
NzSceneNode::Invalidate();
m_boundingBoxUpdated = false;
m_boundingVolumeUpdated = false;
}
void NzModel::Register()
@@ -652,21 +652,21 @@ void NzModel::Update()
AdvanceAnimation(m_scene->GetUpdateTime());
}
void NzModel::UpdateBoundingBox() const
void NzModel::UpdateBoundingVolume() const
{
if (m_boundingBox.IsNull())
if (m_boundingVolume.IsNull())
{
if (m_mesh->GetAnimationType() == nzAnimationType_Skeletal)
m_boundingBox.Set(m_skeleton.GetAABB());
m_boundingVolume.Set(m_skeleton.GetAABB());
else
m_boundingBox.Set(m_mesh->GetAABB());
m_boundingVolume.Set(m_mesh->GetAABB());
}
if (!m_transformMatrixUpdated)
UpdateTransformMatrix();
m_boundingBox.Update(m_transformMatrix);
m_boundingBoxUpdated = true;
m_boundingVolume.Update(m_transformMatrix);
m_boundingVolumeUpdated = true;
}
bool NzModel::VisibilityTest(const NzFrustumf& frustum)
@@ -682,10 +682,10 @@ bool NzModel::VisibilityTest(const NzFrustumf& frustum)
if (!m_drawEnabled)
return false;
if (!m_boundingBoxUpdated)
UpdateBoundingBox();
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
return frustum.Contains(m_boundingBox);
return frustum.Contains(m_boundingVolume);
}
NzModelLoader::LoaderList NzModel::s_loaders;

View File

@@ -20,9 +20,9 @@ void NzSceneRoot::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
NazaraInternalError("SceneNode::AddToRenderQueue() called on SceneRoot");
}
const NzBoundingBoxf& NzSceneRoot::GetBoundingBox() const
const NzBoundingVolumef& NzSceneRoot::GetBoundingVolume() const
{
static NzBoundingBoxf infinite(nzExtend_Infinite);
static NzBoundingVolumef infinite(nzExtend_Infinite);
return infinite;
}

View File

@@ -32,9 +32,9 @@ void NzPhysWorld::SetGravity(const NzVector3f& gravity)
m_gravity = gravity;
}
void NzPhysWorld::SetSize(const NzCubef& cube)
void NzPhysWorld::SetSize(const NzBoxf& box)
{
NewtonSetWorldSize(m_world, cube.GetPosition(), cube.GetPosition()+cube.GetSize());
NewtonSetWorldSize(m_world, box.GetPosition(), box.GetPosition()+box.GetSize());
}
void NzPhysWorld::SetSize(const NzVector3f& min, const NzVector3f& max)

View File

@@ -31,27 +31,27 @@ namespace
static int colorLocation = -1;
}
void NzDebugDrawer::Draw(const NzBoundingBoxf& box)
void NzDebugDrawer::Draw(const NzBoundingVolumef& volume)
{
if (!box.IsFinite())
if (!volume.IsFinite())
return;
NzColor oldPrimaryColor = primaryColor;
Draw(box.aabb);
Draw(volume.aabb);
primaryColor = secondaryColor;
Draw(box.obb);
Draw(volume.obb);
primaryColor = oldPrimaryColor;
}
void NzDebugDrawer::Draw(const NzCubei& cube)
void NzDebugDrawer::Draw(const NzBoxi& box)
{
Draw(NzCubef(cube));
Draw(NzBoxf(box));
}
void NzDebugDrawer::Draw(const NzCubef& cube)
void NzDebugDrawer::Draw(const NzBoxf& box)
{
if (!initialized)
{
@@ -63,8 +63,8 @@ void NzDebugDrawer::Draw(const NzCubef& cube)
NzVertexStruct_XYZ* vertex = reinterpret_cast<NzVertexStruct_XYZ*>(mapper.GetPointer());
NzVector3f max, min;
max = cube.GetPosition() + cube.GetSize();
min = cube.GetPosition();
max = box.GetPosition() + box.GetSize();
min = box.GetPosition();
vertex->position.Set(min.x, min.y, min.z);
vertex++;
@@ -138,9 +138,9 @@ void NzDebugDrawer::Draw(const NzCubef& cube)
NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
}
void NzDebugDrawer::Draw(const NzCubeui& cube)
void NzDebugDrawer::Draw(const NzBoxui& box)
{
Draw(NzCubef(cube));
Draw(NzBoxf(box));
}
void NzDebugDrawer::Draw(const NzFrustumf& frustum)
@@ -226,7 +226,7 @@ void NzDebugDrawer::Draw(const NzFrustumf& frustum)
NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
}
void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube)
void NzDebugDrawer::Draw(const NzOrientedBoxf& orientedBox)
{
if (!initialized)
{
@@ -237,64 +237,64 @@ void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube)
NzBufferMapper<NzVertexBuffer> mapper(vertexBuffer, nzBufferAccess_DiscardAndWrite, 0, 24);
NzVertexStruct_XYZ* vertex = reinterpret_cast<NzVertexStruct_XYZ*>(mapper.GetPointer());
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearLeftBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearRightBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearLeftBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearLeftTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearLeftBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarLeftBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarRightTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarLeftTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarRightTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarRightBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarRightTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearRightTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarLeftBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarRightBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarLeftBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarLeftTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearLeftTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearRightTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearLeftTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearLeftTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarLeftTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarLeftTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearRightBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearRightTop));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightTop));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_NearRightBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_NearRightBottom));
vertex++;
vertex->position.Set(orientedCube.GetCorner(nzCorner_FarRightBottom));
vertex->position.Set(orientedBox.GetCorner(nzCorner_FarRightBottom));
vertex++;
mapper.Unmap();

View File

@@ -944,6 +944,32 @@ bool NzTexture::Update(const NzImage& image, nzUInt8 level)
return Update(pixels, image.GetWidth(level), image.GetHeight(level), level);
}
bool NzTexture::Update(const NzImage& image, const NzBoxui& box, nzUInt8 level)
{
#if NAZARA_RENDERER_SAFE
if (!image.IsValid())
{
NazaraError("Image must be valid");
return false;
}
if (image.GetFormat() != m_impl->format)
{
NazaraError("Image format does not match texture format");
return false;
}
#endif
const nzUInt8* pixels = image.GetConstPixels(box.x, box.y, box.z, level);
if (!pixels)
{
NazaraError("Failed to access image's pixels");
return false;
}
return Update(pixels, box, image.GetWidth(level), image.GetHeight(level), level);
}
bool NzTexture::Update(const NzImage& image, const NzRectui& rect, unsigned int z, nzUInt8 level)
{
#if NAZARA_RENDERER_SAFE
@@ -970,32 +996,6 @@ bool NzTexture::Update(const NzImage& image, const NzRectui& rect, unsigned int
return Update(pixels, rect, z, image.GetWidth(level), image.GetHeight(level), level);
}
bool NzTexture::Update(const NzImage& image, const NzCubeui& cube, nzUInt8 level)
{
#if NAZARA_RENDERER_SAFE
if (!image.IsValid())
{
NazaraError("Image must be valid");
return false;
}
if (image.GetFormat() != m_impl->format)
{
NazaraError("Image format does not match texture format");
return false;
}
#endif
const nzUInt8* pixels = image.GetConstPixels(cube.x, cube.y, cube.z, level);
if (!pixels)
{
NazaraError("Failed to access image's pixels");
return false;
}
return Update(pixels, cube, image.GetWidth(level), image.GetHeight(level), level);
}
bool NzTexture::Update(const nzUInt8* pixels, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
{
#if NAZARA_RENDERER_SAFE
@@ -1006,15 +1006,10 @@ bool NzTexture::Update(const nzUInt8* pixels, unsigned int srcWidth, unsigned in
}
#endif
return Update(pixels, NzCubeui(0, 0, 0, std::max(m_impl->width >> level, 1U), std::max(m_impl->height >> level, 1U), std::max(m_impl->depth >> level, 1U)), srcWidth, srcHeight, level);
return Update(pixels, NzBoxui(std::max(m_impl->width >> level, 1U), std::max(m_impl->height >> level, 1U), std::max(m_impl->depth >> level, 1U)), srcWidth, srcHeight, level);
}
bool NzTexture::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
{
return Update(pixels, NzCubeui(rect.x, rect.y, z, rect.width, rect.height, 1), srcWidth, srcHeight, level);
}
bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
bool NzTexture::Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
{
#if NAZARA_RENDERER_SAFE
if (!m_impl)
@@ -1041,9 +1036,9 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int
return false;
}
if (!cube.IsValid())
if (!box.IsValid())
{
NazaraError("Invalid rectangle");
NazaraError("Invalid box");
return false;
}
#endif
@@ -1051,9 +1046,9 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int
unsigned int height = std::max(m_impl->height >> level, 1U);
#if NAZARA_RENDERER_SAFE
if (cube.x+cube.width > std::max(m_impl->width >> level, 1U) ||
cube.y+cube.height > height ||
cube.z+cube.depth > std::max(m_impl->depth >> level, 1U))
if (box.x+box.width > std::max(m_impl->width >> level, 1U) ||
box.y+box.height > height ||
box.z+box.depth > std::max(m_impl->depth >> level, 1U))
{
NazaraError("Cube dimensions are out of bounds");
return false;
@@ -1075,12 +1070,12 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int
nzUInt8 bpp = NzPixelFormat::GetBytesPerPixel(m_impl->format);
unsigned int size = cube.width*cube.height*cube.depth*bpp;
unsigned int size = box.width*box.height*box.depth*bpp;
std::unique_ptr<nzUInt8[]> flipped(new nzUInt8[size]);
NzImage::Copy(flipped.get(), pixels, bpp, cube.width, cube.height, cube.depth, 0, 0, srcWidth, srcHeight);
NzImage::Copy(flipped.get(), pixels, bpp, box.width, box.height, box.depth, 0, 0, srcWidth, srcHeight);
// Inversion de la texture pour le repère d'OpenGL
if (!NzPixelFormat::Flip(nzPixelFlipping_Horizontally, m_impl->format, cube.width, cube.height, cube.depth, flipped.get(), flipped.get()))
if (!NzPixelFormat::Flip(nzPixelFlipping_Horizontally, m_impl->format, box.width, box.height, box.depth, flipped.get(), flipped.get()))
NazaraWarning("Failed to flip image");
SetUnpackAlignement(bpp);
@@ -1089,17 +1084,17 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int
switch (m_impl->type)
{
case nzImageType_1D:
glTexSubImage1D(GL_TEXTURE_1D, level, cube.x, cube.width, format.dataFormat, format.dataType, flipped.get());
glTexSubImage1D(GL_TEXTURE_1D, level, box.x, box.width, format.dataFormat, format.dataType, flipped.get());
break;
case nzImageType_1D_Array:
case nzImageType_2D:
glTexSubImage2D(NzOpenGL::TextureTarget[m_impl->type], level, cube.x, height-cube.height-cube.y, cube.width, cube.height, format.dataFormat, format.dataType, flipped.get());
glTexSubImage2D(NzOpenGL::TextureTarget[m_impl->type], level, box.x, height-box.height-box.y, box.width, box.height, format.dataFormat, format.dataType, flipped.get());
break;
case nzImageType_2D_Array:
case nzImageType_3D:
glTexSubImage3D(NzOpenGL::TextureTarget[m_impl->type], level, cube.x, height-cube.height-cube.y, cube.z, cube.width, cube.height, cube.depth, format.dataFormat, format.dataType, flipped.get());
glTexSubImage3D(NzOpenGL::TextureTarget[m_impl->type], level, box.x, height-box.height-box.y, box.z, box.width, box.height, box.depth, format.dataFormat, format.dataType, flipped.get());
break;
case nzImageType_Cubemap:
@@ -1110,6 +1105,11 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzCubeui& cube, unsigned int
return true;
}
bool NzTexture::Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z, unsigned int srcWidth, unsigned int srcHeight, nzUInt8 level)
{
return Update(pixels, NzBoxui(rect.x, rect.y, z, rect.width, rect.height, 1), srcWidth, srcHeight, level);
}
bool NzTexture::UpdateFace(nzCubemapFace face, const NzImage& image, nzUInt8 level)
{
#if NAZARA_RENDERER_SAFE

View File

@@ -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);

View File

@@ -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();

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}