0ad/source/graphics/HFTracer.h
janwas 0bb0df5b2c # new year's cleanup (reduce dependencies, clean up headers)
- remove headers always included from PCH
- nommgr.h is only included ifdef REDEFINED_NEW (allows leaving out the
mmgr stuff)
- in lib/*.cpp, moved the corresponding include file to right behind the
PCH (catches headers that aren't compilable by themselves)
- byte_order no longer depends on SDL
- add debug_level (another means of filtering debug output; needed for
thesis)
- split posix stuff up into subdirs (lib/posix and sysdep/win/wposix).
makes including only some of the modules (e.g. sockets, time) much
easier.

This was SVN commit r4728.
2007-01-01 21:25:47 +00:00

50 lines
1.5 KiB
C++

///////////////////////////////////////////////////////////////////////////////
//
// Name: HFTracer.h
// Author: Rich Cross
// Contact: rich@wildfiregames.com
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _HFTRACER_H
#define _HFTRACER_H
class CVector3D;
class CTerrain;
///////////////////////////////////////////////////////////////////////////////
// CHFTracer: a class for determining ray intersections with a heightfield
class CHFTracer
{
public:
// constructor; setup data
CHFTracer(CTerrain *pTerrain);
// intersect ray with this heightfield; return true if intersection
// occurs (and fill in grid coordinates and point of intersection), or false otherwise
bool RayIntersect(CVector3D& origin,CVector3D& dir,int& x,int& z,CVector3D& ipt) const;
private:
// intersect a ray with triangle defined by vertices
// v0,v1,v2; return true if ray hits triangle at distance less than dist,
// or false otherwise
bool RayTriIntersect(const CVector3D& v0,const CVector3D& v1,const CVector3D& v2,
const CVector3D& origin,const CVector3D& dir,float& dist) const;
// test if ray intersects either of the triangles in the given
bool CellIntersect(int cx,int cz,CVector3D& origin,CVector3D& dir,float& dist) const;
// The terrain we're operating on
CTerrain *m_pTerrain;
// the heightfield were tracing
const u16* m_Heightfield;
// size of the heightfield
u32 m_MapSize;
// cell size - size of each cell in x and z
float m_CellSize;
// vertical scale - size of each cell in y
float m_HeightScale;
};
#endif