[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;
|
---|
[382] | 13 | static int sReservedMailboxes;
|
---|
[339] | 14 | int mMailbox;
|
---|
| 15 |
|
---|
| 16 | // unique object Id
|
---|
| 17 | int mId;
|
---|
[176] | 18 |
|
---|
[387] | 19 | // universal counter
|
---|
| 20 | int mCounter;
|
---|
| 21 |
|
---|
[339] | 22 | // object based pvs
|
---|
| 23 | KdPvs mKdPvs;
|
---|
[162] | 24 |
|
---|
[308] | 25 | enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL };
|
---|
[162] | 26 |
|
---|
[339] | 27 | Intersectable():mMailbox(0) {}
|
---|
[245] | 28 |
|
---|
[339] | 29 | void SetId(const int id) { mId = id; }
|
---|
| 30 | int GetId() { return mId; }
|
---|
| 31 |
|
---|
[382] | 32 |
|
---|
| 33 | static void NewMail(const int reserve = 1) {
|
---|
| 34 | sMailId += sReservedMailboxes;
|
---|
| 35 | sReservedMailboxes = reserve;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[339] | 38 | void Mail() { mMailbox = sMailId; }
|
---|
| 39 | bool Mailed() const { return mMailbox == sMailId; }
|
---|
| 40 |
|
---|
[382] | 41 | void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
|
---|
| 42 | bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
|
---|
| 43 |
|
---|
| 44 | int IncMail() { return ++mMailbox - sMailId; }
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 |
|
---|
[176] | 48 | virtual AxisAlignedBox3 GetBox() = 0;
|
---|
| 49 |
|
---|
| 50 | virtual int CastRay(Ray &ray) = 0;
|
---|
| 51 |
|
---|
| 52 | virtual bool IsConvex() = 0;
|
---|
| 53 | virtual bool IsWatertight() = 0;
|
---|
| 54 | virtual float IntersectionComplexity() = 0;
|
---|
| 55 |
|
---|
[387] | 56 | virtual int NumberOfFaces() const = 0;
|
---|
[176] | 57 |
|
---|
[387] | 58 | virtual int Type() const = 0;
|
---|
| 59 |
|
---|
[349] | 60 | virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
|
---|
[176] | 61 |
|
---|
[354] | 62 | virtual int
|
---|
| 63 | GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
| 64 | Vector3 &normal,
|
---|
| 65 | const Vector3 &viewpoint,
|
---|
| 66 | const int maxTries
|
---|
| 67 | ) = 0;
|
---|
| 68 |
|
---|
[340] | 69 | virtual ostream &Describe(ostream &s) = 0;
|
---|
| 70 |
|
---|
[162] | 71 | };
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | #endif
|
---|