[1520] | 1 | #ifndef _RayCaster_H__
|
---|
| 2 | #define _RayCaster_H__
|
---|
| 3 |
|
---|
| 4 | #include "Containers.h"
|
---|
| 5 | #include <string>
|
---|
[1528] | 6 | #include "Vector3.h"
|
---|
| 7 |
|
---|
[1520] | 8 | using namespace std;
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | namespace GtpVisibilityPreprocessor {
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | class Intersectable;
|
---|
| 15 | class VssRay;
|
---|
| 16 | class SimpleRayContainer;
|
---|
| 17 | class AxisAlignedBox3;
|
---|
[1528] | 18 | //class Vector3;
|
---|
[1520] | 19 | struct VssRayContainer;
|
---|
| 20 | class Preprocessor;
|
---|
[1528] | 21 | struct SimpleRay;
|
---|
[1520] | 22 |
|
---|
[1528] | 23 |
|
---|
[1520] | 24 | /** This class provides an interface for ray casting.
|
---|
| 25 | */
|
---|
| 26 | class RayCaster
|
---|
| 27 | {
|
---|
[1528] | 28 |
|
---|
[1520] | 29 | public:
|
---|
| 30 |
|
---|
| 31 | enum {
|
---|
| 32 | INTERNAL_RAYCASTER = 0,
|
---|
| 33 | INTEL_RAYCASTER
|
---|
| 34 | };
|
---|
| 35 |
|
---|
| 36 | RayCaster(const Preprocessor &preprocessor);
|
---|
| 37 |
|
---|
[1521] | 38 | virtual ~RayCaster();
|
---|
[1520] | 39 |
|
---|
| 40 | virtual int Type() const = 0;
|
---|
| 41 |
|
---|
[1521] | 42 | /** Wrapper for casting single ray.
|
---|
| 43 | */
|
---|
| 44 | VssRay *CastSingleRay(
|
---|
[1528] | 45 | const SimpleRay &simpleRay,
|
---|
| 46 | const AxisAlignedBox3 &box
|
---|
[1521] | 47 | );
|
---|
| 48 |
|
---|
[1520] | 49 | virtual int CastRay(
|
---|
[1528] | 50 | const SimpleRay &simpleRay,
|
---|
[1520] | 51 | VssRayContainer &vssRays,
|
---|
| 52 | const AxisAlignedBox3 &box,
|
---|
[1528] | 53 | const bool castDoubleRay,
|
---|
| 54 | const bool pruneInvalidRays = true
|
---|
[1520] | 55 | ) = 0;
|
---|
| 56 |
|
---|
| 57 | virtual void CastRays16(
|
---|
| 58 | const int i,
|
---|
| 59 | SimpleRayContainer &rays,
|
---|
| 60 | VssRayContainer &vssRays,
|
---|
| 61 | const AxisAlignedBox3 &sbox,
|
---|
[1528] | 62 | const bool castDoubleRay,
|
---|
| 63 | const bool pruneInvalidRays = true
|
---|
[1520] | 64 | ) = 0;
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 | protected:
|
---|
[1528] | 68 | struct Intersection
|
---|
| 69 | {
|
---|
| 70 | Intersection(): mObject(NULL), mFaceId(0)
|
---|
| 71 | {}
|
---|
[1520] | 72 |
|
---|
[1528] | 73 | Intersection(const Vector3 &p, const Vector3 &n, Intersectable *o, const int f):
|
---|
| 74 | mPoint(p), mNormal(n), mObject(o), mFaceId(f)
|
---|
| 75 | {}
|
---|
| 76 |
|
---|
| 77 | Intersection(const Vector3 &p): mPoint(p), mObject(NULL), mFaceId(0)
|
---|
| 78 | {}
|
---|
| 79 | Vector3 mPoint;
|
---|
| 80 | Vector3 mNormal;
|
---|
| 81 | Intersectable *mObject;
|
---|
| 82 | int mFaceId;
|
---|
| 83 | };
|
---|
| 84 |
|
---|
[1520] | 85 | int ProcessRay(
|
---|
[1528] | 86 | const SimpleRay &ray,
|
---|
| 87 | Intersection &hitA,
|
---|
| 88 | Intersection &hitB,
|
---|
[1520] | 89 | VssRayContainer &vssRays,
|
---|
[1528] | 90 | const AxisAlignedBox3 &box,
|
---|
| 91 | const bool castDoubleRay,
|
---|
| 92 | const bool pruneInvalidRays = true
|
---|
[1520] | 93 | );
|
---|
| 94 |
|
---|
[1528] | 95 | /** Checks if ray is valid.
|
---|
| 96 | I.e., the ray is in valid view space.
|
---|
| 97 | @note: clamps the ray to valid view space.
|
---|
| 98 | */
|
---|
| 99 | bool ValidateRay(const Vector3 &origin,
|
---|
| 100 | const Vector3 &direction,
|
---|
| 101 | const AxisAlignedBox3 &box,
|
---|
| 102 | Intersection &hit);
|
---|
[1520] | 103 |
|
---|
| 104 | const Preprocessor &mPreprocessor;
|
---|
| 105 | };
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | #endif
|
---|