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