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