1 | #include "Intersectable.h"
|
---|
2 | #include "SimpleRay.h"
|
---|
3 |
|
---|
4 | using namespace std;
|
---|
5 |
|
---|
6 | #if _WIN32
|
---|
7 | #define ALIGN16 __declspec(align(16))
|
---|
8 | #else
|
---|
9 | #ifdef USE_HAVRAN_RAYCASTER
|
---|
10 | #include "ktbconf.h"
|
---|
11 | #define ALIGN16 GALIGN16
|
---|
12 | #else
|
---|
13 | #define ALIGN16
|
---|
14 | #endif
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | namespace GtpVisibilityPreprocessor
|
---|
18 | {
|
---|
19 |
|
---|
20 |
|
---|
21 | int Intersectable::sMailId = 10000;//2147483647;
|
---|
22 | int Intersectable::sReservedMailboxes = 1;
|
---|
23 |
|
---|
24 | int Intersectable::sMailId2 = 10000;//2147483647;
|
---|
25 | int Intersectable::sReservedMailboxes2 = 1;
|
---|
26 |
|
---|
27 |
|
---|
28 | // This is the result of computing intersection
|
---|
29 | // static data member
|
---|
30 | ALIGN16 IntersectionStr
|
---|
31 | SimpleRay::IntersectionRes[32];
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 | Intersectable::Intersectable():
|
---|
36 | mMailbox(0),
|
---|
37 | mBvhLeaf(0),
|
---|
38 | mVssRays(NULL),
|
---|
39 | mRenderedFrame(0)
|
---|
40 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
41 | , mViewCells(NULL)
|
---|
42 | #endif
|
---|
43 | {}
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | Intersectable::~Intersectable()
|
---|
48 | {
|
---|
49 | DEL_PTR(mVssRays);
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | string Intersectable::GetTypeName(Intersectable *obj)
|
---|
54 | {
|
---|
55 | switch(obj->Type())
|
---|
56 | {
|
---|
57 | case MESH_INSTANCE:
|
---|
58 | return "mesh instance";
|
---|
59 | case TRANSFORMED_MESH_INSTANCE:
|
---|
60 | return "transformed mesh instance";
|
---|
61 | case SPHERE:
|
---|
62 | return "sphere";
|
---|
63 | case VIEW_CELL:
|
---|
64 | return "view cell";
|
---|
65 | case OGRE_MESH_INSTANCE:
|
---|
66 | return "ogre_mesh_instance";
|
---|
67 | case KD_INTERSECTABLE:
|
---|
68 | return "kd";
|
---|
69 | case TRIANGLE_INTERSECTABLE:
|
---|
70 | return "triangle";
|
---|
71 | case BVH_INTERSECTABLE:
|
---|
72 | return "bvh";
|
---|
73 | default:
|
---|
74 | return "unknown";
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 | Vector3 Intersectable::GetNormal(const int idx) const
|
---|
80 | {
|
---|
81 | return Vector3(0, 0, 0);
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | VssRayContainer *Intersectable::GetOrCreateRays()
|
---|
86 | {
|
---|
87 | if (!mVssRays)
|
---|
88 | mVssRays = new VssRayContainer();
|
---|
89 |
|
---|
90 | return mVssRays;
|
---|
91 | }
|
---|
92 |
|
---|
93 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
94 |
|
---|
95 | ViewCellContainer *Intersectable::GetOrCreateViewCells()
|
---|
96 | {
|
---|
97 | if (!mViewCells)
|
---|
98 | mViewCells = new ViewCellContainer();
|
---|
99 |
|
---|
100 | return mViewCells;
|
---|
101 | }
|
---|
102 |
|
---|
103 |
|
---|
104 | void Intersectable::DelViewCells()
|
---|
105 | {
|
---|
106 | DEL_PTR(mViewCells);
|
---|
107 | }
|
---|
108 |
|
---|
109 | #endif
|
---|
110 |
|
---|
111 |
|
---|
112 | void Intersectable::DelRayRefs()
|
---|
113 | {
|
---|
114 | DEL_PTR(mVssRays);
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | int Intersectable::GenerateSilhouetteRays(const int nrays,
|
---|
119 | const AxisAlignedBox3 &originBox,
|
---|
120 | const AxisAlignedBox3 &directionBox,
|
---|
121 | VssRayContainer &rays)
|
---|
122 | {
|
---|
123 | return 0;
|
---|
124 | }
|
---|
125 |
|
---|
126 |
|
---|
127 | int Intersectable::GetRandomSurfacePoint(const float u,
|
---|
128 | const float v,
|
---|
129 | Vector3 &point,
|
---|
130 | Vector3 &normal)
|
---|
131 | {
|
---|
132 | cerr << "GetRandomSurfacePoint(u,v...) not yet implemented for type " << Type() << endl;
|
---|
133 | return 1;
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | bool Intersectable::GreaterCounter(const Intersectable *a,
|
---|
138 | const Intersectable *b)
|
---|
139 | {
|
---|
140 | return a->mCounter > b->mCounter;
|
---|
141 | }
|
---|
142 |
|
---|
143 |
|
---|
144 | float Intersectable::GetArea() const
|
---|
145 | {
|
---|
146 | cerr << "GetArea not implemented yet for this type" << endl;
|
---|
147 | return 0;
|
---|
148 | }
|
---|
149 |
|
---|
150 |
|
---|
151 | }
|
---|