From 2423fbf2efa39e28cc348acc11b9269e573dcdef Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Jul 2014 22:15:34 +0200 Subject: Normalized comments. This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign. --- src/Tracer.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/Tracer.cpp') diff --git a/src/Tracer.cpp b/src/Tracer.cpp index d788d9e26..54b4716e3 100644 --- a/src/Tracer.cpp +++ b/src/Tracer.cpp @@ -273,36 +273,50 @@ int LinesCross(float x0,float y0,float x1,float y1,float x2,float y2,float x3,fl // 2 = the segment lies in the plane int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal ) { - Vector3f u = a_End - a_Origin;//a_Ray.P1 - S.P0; - Vector3f w = a_Origin - a_PlanePos;//S.P0 - Pn.V0; + Vector3f u = a_End - a_Origin; // a_Ray.P1 - S.P0; + Vector3f w = a_Origin - a_PlanePos; // S.P0 - Pn.V0; - float D = a_PlaneNormal.Dot( u );//dot(Pn.n, u); - float N = -(a_PlaneNormal.Dot( w ) );//-dot(a_Plane.n, w); + 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) { // segment is parallel to plane - if (N == 0) // segment lies in plane + if (fabs(D) < EPSILON) + { + // segment is parallel to plane + if (N == 0) + { + // segment lies in plane return 2; - return 0; // no intersection + } + return 0; // no intersection } + // they are not parallel // compute intersect param float sI = N / D; if (sI < 0 || sI > 1) - return 0; // no intersection + { + return 0; // no intersection + } - // Vector3f I ( a_Ray->GetOrigin() + sI * u );//S.P0 + sI * u; // compute segment intersect point + // Vector3f I ( a_Ray->GetOrigin() + sI * u );// S.P0 + sI * u; // compute segment intersect point RealHit = a_Origin + u * sI; return 1; } + + + + int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos) { Vector3i SmallBlockPos = a_BlockPos; char BlockID = m_World->GetBlock( a_BlockPos.x, a_BlockPos.y, a_BlockPos.z ); if( BlockID == E_BLOCK_AIR || IsBlockWater(BlockID)) + { return 0; + } Vector3f BlockPos; BlockPos = Vector3f(SmallBlockPos); -- cgit v1.2.3