#ifndef _RayCaster_H__ #define _RayCaster_H__ #include "Containers.h" #include #include "Vector3.h" using namespace std; namespace GtpVisibilityPreprocessor { class Intersectable; class VssRay; class SimpleRayContainer; class AxisAlignedBox3; //class Vector3; struct VssRayContainer; class Preprocessor; struct SimpleRay; /** This class provides an interface for ray casting. */ class RayCaster { public: enum { INTERNAL_RAYCASTER = 0, INTEL_RAYCASTER }; RayCaster(const Preprocessor &preprocessor); virtual ~RayCaster(); virtual int Type() const = 0; /** Wrapper for casting single ray. @returns ray or NULL if invalid */ VssRay *CastRay( const SimpleRay &simpleRay, const AxisAlignedBox3 &box, const bool castDoubleRay ); virtual int CastRay( const SimpleRay &simpleRay, VssRayContainer &vssRays, const AxisAlignedBox3 &box, const bool castDoubleRay, const bool pruneInvalidRays = true ) = 0; virtual void CastRays16( const int i, SimpleRayContainer &rays, VssRayContainer &vssRays, const AxisAlignedBox3 &sbox, const bool castDoubleRay, const bool pruneInvalidRays = true ) = 0; protected: struct Intersection { Intersection(): mObject(NULL), mFaceId(0) {} Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f): mPoint(p), mNormal(n), mObject(o), mFaceId(f) {} Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0) {} Vector3 mPoint; Vector3 mNormal; Intersectable *mObject; int mFaceId; }; int ProcessRay( const SimpleRay &ray, Intersection &hitA, Intersection &hitB, VssRayContainer &vssRays, const AxisAlignedBox3 &box, const bool castDoubleRay, const bool pruneInvalidRays = true ); /** Checks if ray is valid. I.e., the ray is in valid view space. @note: clamps the ray to valid view space. */ bool ValidateRay(const Vector3 &origin, const Vector3 &direction, const AxisAlignedBox3 &box, Intersection &hit); const Preprocessor &mPreprocessor; }; } #endif