[162] | 1 | #ifndef __INTERSECTABLE_H
|
---|
| 2 | #define __INTERSECTABLE_H
|
---|
| 3 |
|
---|
[176] | 4 | #include "AxisAlignedBox3.h"
|
---|
| 5 | #include "Pvs.h"
|
---|
[162] | 6 |
|
---|
[176] | 7 |
|
---|
[162] | 8 | class Intersectable {
|
---|
[176] | 9 | public:
|
---|
[339] | 10 | // last mail id -> warning not thread safe!
|
---|
| 11 | // both mailId and mailbox should be unique for each thread!!!
|
---|
| 12 | static int sMailId;
|
---|
| 13 | int mMailbox;
|
---|
| 14 |
|
---|
| 15 | // unique object Id
|
---|
| 16 | int mId;
|
---|
[176] | 17 |
|
---|
[339] | 18 | // object based pvs
|
---|
| 19 | KdPvs mKdPvs;
|
---|
[162] | 20 |
|
---|
[308] | 21 | enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL };
|
---|
[162] | 22 |
|
---|
[339] | 23 | Intersectable():mMailbox(0) {}
|
---|
[245] | 24 |
|
---|
[339] | 25 | void SetId(const int id) { mId = id; }
|
---|
| 26 | int GetId() { return mId; }
|
---|
| 27 |
|
---|
| 28 | void Mail() { mMailbox = sMailId; }
|
---|
| 29 | static void NewMail() { sMailId++; }
|
---|
| 30 | bool Mailed() const { return mMailbox == sMailId; }
|
---|
| 31 | int IncMail() { return ++mMailbox - sMailId; }
|
---|
| 32 |
|
---|
[176] | 33 | virtual AxisAlignedBox3 GetBox() = 0;
|
---|
| 34 |
|
---|
| 35 | virtual int CastRay(Ray &ray) = 0;
|
---|
| 36 |
|
---|
| 37 | virtual bool IsConvex() = 0;
|
---|
| 38 | virtual bool IsWatertight() = 0;
|
---|
| 39 | virtual float IntersectionComplexity() = 0;
|
---|
| 40 |
|
---|
| 41 | virtual int Type() const = 0;
|
---|
| 42 |
|
---|
[349] | 43 | virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
|
---|
[176] | 44 |
|
---|
[354] | 45 | virtual int
|
---|
| 46 | GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
| 47 | Vector3 &normal,
|
---|
| 48 | const Vector3 &viewpoint,
|
---|
| 49 | const int maxTries
|
---|
| 50 | ) = 0;
|
---|
| 51 |
|
---|
[340] | 52 | virtual ostream &Describe(ostream &s) = 0;
|
---|
| 53 |
|
---|
[162] | 54 | };
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | #endif
|
---|