1 | #ifndef __INTERSECTABLE_H
|
---|
2 | #define __INTERSECTABLE_H
|
---|
3 |
|
---|
4 | #include "AxisAlignedBox3.h"
|
---|
5 | #include "Pvs.h"
|
---|
6 |
|
---|
7 |
|
---|
8 | class Intersectable {
|
---|
9 | public:
|
---|
10 | // last mail id -> warning not thread safe!
|
---|
11 | // both mailId and mailbox should be unique for each thread!!!
|
---|
12 | static int sMailId;
|
---|
13 | static int sReservedMailboxes;
|
---|
14 | int mMailbox;
|
---|
15 |
|
---|
16 | // unique object Id
|
---|
17 | int mId;
|
---|
18 |
|
---|
19 | // universal counter
|
---|
20 | int mCounter;
|
---|
21 |
|
---|
22 | // object based pvs
|
---|
23 | KdPvs mKdPvs;
|
---|
24 |
|
---|
25 | enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL };
|
---|
26 |
|
---|
27 | Intersectable():mMailbox(0) {}
|
---|
28 |
|
---|
29 | void SetId(const int id) { mId = id; }
|
---|
30 | int GetId() { return mId; }
|
---|
31 |
|
---|
32 |
|
---|
33 | static void NewMail(const int reserve = 1) {
|
---|
34 | sMailId += sReservedMailboxes;
|
---|
35 | sReservedMailboxes = reserve;
|
---|
36 | }
|
---|
37 |
|
---|
38 | void Mail() { mMailbox = sMailId; }
|
---|
39 | bool Mailed() const { return mMailbox == sMailId; }
|
---|
40 |
|
---|
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 |
|
---|
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 |
|
---|
56 | virtual int NumberOfFaces() const = 0;
|
---|
57 |
|
---|
58 | virtual int Type() const = 0;
|
---|
59 |
|
---|
60 | virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
|
---|
61 |
|
---|
62 | virtual int
|
---|
63 | GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
64 | Vector3 &normal,
|
---|
65 | const Vector3 &viewpoint,
|
---|
66 | const int maxTries
|
---|
67 | ) = 0;
|
---|
68 |
|
---|
69 | virtual ostream &Describe(ostream &s) = 0;
|
---|
70 |
|
---|
71 | };
|
---|
72 |
|
---|
73 |
|
---|
74 | #endif
|
---|