2012-06-14 09:06:06 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Vector3i.h"
|
|
|
|
#include "Vector3f.h"
|
|
|
|
|
|
|
|
|
|
|
|
class cWorld;
|
2013-01-11 23:46:01 -05:00
|
|
|
class cTracer // tolua_export
|
|
|
|
{ // tolua_export
|
|
|
|
public: // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
Vector3f DotPos;
|
|
|
|
Vector3f BoxOffset;
|
2013-01-11 23:46:01 -05:00
|
|
|
cTracer( cWorld* a_World); // tolua_export
|
|
|
|
~cTracer(); // tolua_export
|
2013-11-05 11:22:28 -05:00
|
|
|
|
|
|
|
/// Determines if a collision occures along a line.
|
2013-01-11 23:46:01 -05:00
|
|
|
int Trace( const Vector3f & a_Start, const Vector3f & a_Direction, int a_Distance ); // tolua_export
|
2013-11-05 11:22:28 -05:00
|
|
|
|
|
|
|
/// Contains the position of the block that caused the collision
|
2013-01-11 23:46:01 -05:00
|
|
|
Vector3f BlockHitPosition; // tolua_export
|
2013-11-05 11:22:28 -05:00
|
|
|
|
|
|
|
/// Contains which face was hit
|
2013-01-11 23:46:01 -05:00
|
|
|
Vector3f HitNormal; // tolua_export
|
2013-11-05 11:22:28 -05:00
|
|
|
|
|
|
|
/// Contains the exact position where a collision occured. (BlockHitPosition + Offset on block)
|
2013-01-11 23:46:01 -05:00
|
|
|
Vector3f RealHit; // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
private:
|
2013-11-05 11:22:28 -05:00
|
|
|
|
|
|
|
/// Preps Tracer object for call of Trace function. Only used internally
|
|
|
|
void SetValues( const Vector3f & a_Start, const Vector3f & a_Direction );
|
|
|
|
|
|
|
|
/// Calculates where on the block a collision occured, if it does occur
|
2012-06-14 09:06:06 -04:00
|
|
|
int intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f & a_End, const Vector3f & a_PlanePos, const Vector3f & a_PlaneNormal );
|
2013-11-05 11:22:28 -05:00
|
|
|
|
|
|
|
/// Determines which face on the block a collision occured, if it does occur
|
2012-06-14 09:06:06 -04:00
|
|
|
int GetHitNormal( const Vector3f & start, const Vector3f & end, const Vector3i & a_BlockPos);
|
2013-11-05 11:22:28 -05:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
float SigNum( float a_Num );
|
|
|
|
cWorld* m_World;
|
|
|
|
|
|
|
|
Vector3f m_NormalTable[6];
|
|
|
|
|
|
|
|
Vector3f dir;
|
|
|
|
Vector3f tDelta;
|
|
|
|
Vector3i pos;
|
|
|
|
Vector3i end1;
|
|
|
|
Vector3i step;
|
|
|
|
Vector3f tMax;
|
2013-01-11 23:46:01 -05:00
|
|
|
}; // tolua_export
|