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