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

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