1
0

Implemented Vector3<>::Floor()

This commit is contained in:
Tiger Wang 2014-06-30 19:21:21 +01:00
parent 428cfb5c21
commit 85fae0e521
2 changed files with 19 additions and 10 deletions

View File

@ -74,8 +74,9 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
Hit += SinkMovement; // Make arrow sink into block a little
super::OnHitSolidBlock(Hit, a_HitFace);
int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z);
Hit.Floor();
int X = Hit.x, Y = Hit.y, Z = Hit.z;
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound

View File

@ -134,6 +134,22 @@ public:
z += a_Diff.z;
}
/** Runs each value of the vector through std::floor() */
inline void Floor(void)
{
x = (T)floor(x);
y = (T)floor(y);
z = (T)floor(z);
}
/** Clamps each value in the vector to within a specified range */
inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ)
{
x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x));
y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y));
z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z));
}
// tolua_end
inline bool operator != (const Vector3<T> & a_Rhs) const
@ -274,14 +290,6 @@ public:
return (a_X - x) / (a_OtherEnd.x - x);
}
/** Clamps each value in the vector to within a specified range */
inline void Clamp(T a_MinX, T a_MinY, T a_MinZ, T a_MaxX, T a_MaxY, T a_MaxZ)
{
x = Clamp(x, (T)copysign(a_MinX, x), (T)copysign(a_MaxX, x));
y = Clamp(y, (T)copysign(a_MinY, y), (T)copysign(a_MaxY, y));
z = Clamp(z, (T)copysign(a_MinZ, z), (T)copysign(a_MaxZ, z));
}
/** The max difference between two coords for which the coords are assumed equal. */
static const double EPS;