Renamed (Oriented)Cube to (Oriented)Box
Also renamed BoundingBox to BoundingVolume Former-commit-id: 795c70c265ba17f6b96fc30799e89f140c52852b
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) + ')');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user