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 | int mMailbox;
|
---|
14 |
|
---|
15 | // unique object Id
|
---|
16 | int mId;
|
---|
17 |
|
---|
18 | // object based pvs
|
---|
19 | KdPvs mKdPvs;
|
---|
20 |
|
---|
21 | enum { MESH_INSTANCE, TRANSFORMED_MESH_INSTANCE, SPHERE, VIEW_CELL };
|
---|
22 |
|
---|
23 | Intersectable():mMailbox(0) {}
|
---|
24 |
|
---|
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 |
|
---|
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 |
|
---|
43 | virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0;
|
---|
44 |
|
---|
45 | virtual int
|
---|
46 | GetRandomVisibleSurfacePoint(Vector3 &point,
|
---|
47 | Vector3 &normal,
|
---|
48 | const Vector3 &viewpoint,
|
---|
49 | const int maxTries
|
---|
50 | ) = 0;
|
---|
51 |
|
---|
52 | virtual ostream &Describe(ostream &s) = 0;
|
---|
53 |
|
---|
54 | };
|
---|
55 |
|
---|
56 |
|
---|
57 | #endif
|
---|