summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/ArrowEntity.cpp5
-rw-r--r--src/Vector3.h24
2 files changed, 19 insertions, 10 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index c76c710ef..2d6683f0a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -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
diff --git a/src/Vector3.h b/src/Vector3.h
index 762fdfd71..b5ddc705a 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -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;