summaryrefslogtreecommitdiffstats
path: root/src/Tracer.cpp
diff options
context:
space:
mode:
authorWoazboat <f.kargl@posteo.de>2015-04-28 02:51:21 +0200
committerWoazboat <f.kargl@posteo.de>2015-04-28 02:51:21 +0200
commit496e5b10002900b4fb12b053523f83b943ef3806 (patch)
tree7ec0f5ff2b47d7169a686e3f2fc652b088d898e8 /src/Tracer.cpp
parentCheck for zero length vector in Trace (diff)
downloadcuberite-496e5b10002900b4fb12b053523f83b943ef3806.tar
cuberite-496e5b10002900b4fb12b053523f83b943ef3806.tar.gz
cuberite-496e5b10002900b4fb12b053523f83b943ef3806.tar.bz2
cuberite-496e5b10002900b4fb12b053523f83b943ef3806.tar.lz
cuberite-496e5b10002900b4fb12b053523f83b943ef3806.tar.xz
cuberite-496e5b10002900b4fb12b053523f83b943ef3806.tar.zst
cuberite-496e5b10002900b4fb12b053523f83b943ef3806.zip
Diffstat (limited to 'src/Tracer.cpp')
-rw-r--r--src/Tracer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Tracer.cpp b/src/Tracer.cpp
index 816bc0fe8..aa8689814 100644
--- a/src/Tracer.cpp
+++ b/src/Tracer.cpp
@@ -12,6 +12,8 @@
+const float FLOAT_EPSILON = 0.0001f; //TODO: Stash this in some header where it can be reused
+
cTracer::cTracer(cWorld * a_World):
@@ -37,7 +39,7 @@ cTracer::~cTracer()
-float cTracer::SigNum(float a_Num)
+int cTracer::SigNum(float a_Num)
{
if (a_Num < 0.f)
{
@@ -63,9 +65,10 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
dir = a_Direction;
// decide which direction to start walking in
- step.x = (int) SigNum(dir.x);
- step.y = (int) SigNum(dir.y);
- step.z = (int) SigNum(dir.z);
+ step.x = SigNum(dir.x);
+ step.y = SigNum(dir.y);
+ step.z = SigNum(dir.z);
+
// normalize the direction vector
dir.Normalize();
@@ -302,8 +305,7 @@ int cTracer::intersect3D_SegmentPlane(const Vector3f & a_Origin, const Vector3f
float D = a_PlaneNormal.Dot(u); // dot(Pn.n, u);
float N = -(a_PlaneNormal.Dot(w)); // -dot(a_Plane.n, w);
- const float EPSILON = 0.0001f;
- if (fabs(D) < EPSILON)
+ if (fabs(D) < FLOAT_EPSILON)
{
// segment is parallel to plane
if (N == 0.0)