Fixed debug-mode compilation
-Also added multiplication operator and equality comparison to Cube and Rect Former-commit-id: b4194a50fbe3025d3be1fc25d48a85d5a05fc5ac
This commit is contained in:
@@ -11,6 +11,12 @@ m_extend(nzExtend_Null)
|
||||
{
|
||||
}
|
||||
|
||||
NzAxisAlignedBox::NzAxisAlignedBox(const NzCubef& cube) :
|
||||
m_extend(nzExtend_Finite),
|
||||
m_cube(cube)
|
||||
{
|
||||
}
|
||||
|
||||
NzAxisAlignedBox::NzAxisAlignedBox(const NzVector3f& vec1, const NzVector3f& vec2) :
|
||||
m_extend(nzExtend_Finite),
|
||||
m_cube(vec1, vec2)
|
||||
@@ -37,7 +43,6 @@ void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
||||
switch (m_extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
{
|
||||
switch (box.m_extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
@@ -50,18 +55,16 @@ void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
||||
|
||||
case nzExtend_Null:
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case nzExtend_Infinite:
|
||||
// Rien à faire
|
||||
break;
|
||||
case nzExtend_Infinite:
|
||||
// Rien à faire
|
||||
break;
|
||||
|
||||
case nzExtend_Null:
|
||||
operator=(box);
|
||||
break;
|
||||
}
|
||||
case nzExtend_Null:
|
||||
operator=(box);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +155,61 @@ NzString NzAxisAlignedBox::ToString() const
|
||||
return "NzAxisAlignedBox(ERROR)";
|
||||
}
|
||||
|
||||
NzAxisAlignedBox NzAxisAlignedBox::Lerp(const NzAxisAlignedBox& from, const NzAxisAlignedBox& to, float interpolation)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (interpolation < 0.f || interpolation > 1.f)
|
||||
{
|
||||
NazaraError("Interpolation must be in range [0..1] (Got " + NzString::Number(interpolation) + ')');
|
||||
return Null;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NzNumberEquals(interpolation, 0.f))
|
||||
return from;
|
||||
|
||||
if (NzNumberEquals(interpolation, 1.f))
|
||||
return to;
|
||||
|
||||
switch (to.m_extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
{
|
||||
switch (from.m_extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
return NzCubef::Lerp(from.m_cube, to.m_cube, interpolation);
|
||||
|
||||
case nzExtend_Infinite:
|
||||
return Infinite;
|
||||
|
||||
case nzExtend_Null:
|
||||
return from.m_cube * interpolation;
|
||||
}
|
||||
}
|
||||
|
||||
case nzExtend_Infinite:
|
||||
return Infinite; // Un petit peu d'infini est infini quand même ;)
|
||||
|
||||
case nzExtend_Null:
|
||||
{
|
||||
switch (from.m_extend)
|
||||
{
|
||||
case nzExtend_Finite:
|
||||
return from.m_cube * (1.f - interpolation);
|
||||
|
||||
case nzExtend_Infinite:
|
||||
return Infinite;
|
||||
|
||||
case nzExtend_Null:
|
||||
return Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Null;
|
||||
}
|
||||
|
||||
const NzAxisAlignedBox NzAxisAlignedBox::Infinite(nzExtend_Infinite);
|
||||
const NzAxisAlignedBox NzAxisAlignedBox::Null(nzExtend_Null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user