[162] | 1 | #ifndef __INTERSECTABLE_H
|
---|
| 2 | #define __INTERSECTABLE_H
|
---|
| 3 |
|
---|
[176] | 4 | #include "AxisAlignedBox3.h"
|
---|
| 5 | #include "Pvs.h"
|
---|
[162] | 6 |
|
---|
[860] | 7 | namespace GtpVisibilityPreprocessor {
|
---|
| 8 |
|
---|
[497] | 9 | struct VssRayContainer;
|
---|
[176] | 10 |
|
---|
[162] | 11 | class Intersectable {
|
---|
[176] | 12 | public:
|
---|
[811] | 13 | // last mail id -> warning not thread safe!
|
---|
| 14 | // both mailId and mailbox should be unique for each thread!!!
|
---|
| 15 | static int sMailId;
|
---|
| 16 | static int sReservedMailboxes;
|
---|
| 17 | int mMailbox;
|
---|
| 18 |
|
---|
| 19 | // unique object Id
|
---|
| 20 | int mId;
|
---|
| 21 |
|
---|
| 22 | // universal counter
|
---|
| 23 | int mCounter;
|
---|
[339] | 24 |
|
---|
[811] | 25 | // object based pvs
|
---|
| 26 | KdPvs mKdPvs;
|
---|
[162] | 27 |
|
---|
[837] | 28 | enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL, OGRE_MESH_INSTANCE };
|
---|
[162] | 29 |
|
---|
[339] | 30 | Intersectable():mMailbox(0) {}
|
---|
[245] | 31 |
|
---|
[339] | 32 | void SetId(const int id) { mId = id; }
|
---|
| 33 | int GetId() { return mId; }
|
---|
| 34 |
|
---|
[382] | 35 |
|
---|
| 36 | static void NewMail(const int reserve = 1) {
|
---|
| 37 | sMailId += sReservedMailboxes;
|
---|
| 38 | sReservedMailboxes = reserve;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
[339] | 41 | void Mail() { mMailbox = sMailId; }
|
---|
[837] | 42 | bool Mailed() const { return mMailbox == sMailId; }
|
---|
[339] | 43 |
|
---|
[382] | 44 | void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
|
---|
| 45 | bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
|
---|
| 46 |
|
---|
| 47 | int IncMail() { return ++mMailbox - sMailId; }
|
---|
| 48 |
|
---|
| 49 |
|
---|
[850] | 50 | virtual AxisAlignedBox3 GetBox() = 0;
|
---|
[870] | 51 | virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0;
|
---|
[382] | 52 |
|
---|
[850] | 53 | virtual bool IsConvex() = 0;
|
---|
| 54 | virtual bool IsWatertight() = 0;
|
---|
| 55 | virtual float IntersectionComplexity() = 0;
|
---|
[176] | 56 |
|
---|
[850] | 57 | virtual int NumberOfFaces() const = 0;
|
---|
| 58 | virtual int Type() const = 0;
|
---|
[176] | 59 |
|
---|
[850] | 60 | virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
|
---|
| 61 |
|
---|
| 62 | virtual int GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
| 63 | Vector3 &normal,
|
---|
| 64 | const Vector3 &viewpoint,
|
---|
| 65 | const int maxTries) = 0;
|
---|
[492] | 66 |
|
---|
[850] | 67 | virtual ostream &Describe(ostream &s) = 0;
|
---|
| 68 |
|
---|
| 69 | virtual int GenerateSilhouetteRays(const int nrays,
|
---|
| 70 | const AxisAlignedBox3 &originBox,
|
---|
| 71 | const AxisAlignedBox3 &directionBox, VssRayContainer &rays)
|
---|
| 72 | {
|
---|
| 73 | return 0;
|
---|
| 74 | }
|
---|
[556] | 75 |
|
---|
[850] | 76 | static bool GreaterCounter(const Intersectable *a,
|
---|
| 77 | const Intersectable *b)
|
---|
| 78 | {
|
---|
| 79 | return a->mCounter > b->mCounter;
|
---|
| 80 | }
|
---|
[162] | 81 | };
|
---|
| 82 |
|
---|
[860] | 83 | }
|
---|
[162] | 84 |
|
---|
| 85 | #endif
|
---|