[2066] | 1 | #include "Intersectable.h"
|
---|
[2575] | 2 | #include "SimpleRay.h"
|
---|
[2066] | 3 |
|
---|
[2176] | 4 | using namespace std;
|
---|
[2066] | 5 |
|
---|
[2575] | 6 | #if _WIN32
|
---|
| 7 | #define ALIGN16 __declspec(align(16))
|
---|
| 8 | #else
|
---|
[2582] | 9 | #ifdef USE_HAVRAN_RAYCASTER
|
---|
| 10 | #include "ktbconf.h"
|
---|
| 11 | #define ALIGN16 GALIGN16
|
---|
| 12 | #else
|
---|
| 13 | #define ALIGN16
|
---|
[2575] | 14 | #endif
|
---|
[2582] | 15 | #endif
|
---|
[2176] | 16 |
|
---|
[2670] | 17 | namespace GtpVisibilityPreprocessor
|
---|
| 18 | {
|
---|
[2066] | 19 |
|
---|
[2660] | 20 |
|
---|
| 21 | int Intersectable::sMailId = 10000;//2147483647;
|
---|
[2643] | 22 | int Intersectable::sReservedMailboxes = 1;
|
---|
[2066] | 23 |
|
---|
[2660] | 24 | int Intersectable::sMailId2 = 10000;//2147483647;
|
---|
[2643] | 25 | int Intersectable::sReservedMailboxes2 = 1;
|
---|
| 26 |
|
---|
[2670] | 27 |
|
---|
[2575] | 28 | // This is the result of computing intersection
|
---|
| 29 | // static data member
|
---|
[2670] | 30 | ALIGN16 IntersectionStr
|
---|
| 31 | SimpleRay::IntersectionRes[32];
|
---|
[2575] | 32 |
|
---|
[2670] | 33 |
|
---|
| 34 |
|
---|
[2066] | 35 | Intersectable::Intersectable():
|
---|
| 36 | mMailbox(0),
|
---|
| 37 | mBvhLeaf(0),
|
---|
[2543] | 38 | mVssRays(NULL),
|
---|
| 39 | mRenderedFrame(0)
|
---|
[2198] | 40 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
| 41 | , mViewCells(NULL)
|
---|
| 42 | #endif
|
---|
[2066] | 43 | {}
|
---|
| 44 |
|
---|
| 45 |
|
---|
[2575] | 46 |
|
---|
[2066] | 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:
|
---|
[2538] | 58 | return "mesh instance";
|
---|
[2066] | 59 | case TRANSFORMED_MESH_INSTANCE:
|
---|
[2538] | 60 | return "transformed mesh instance";
|
---|
[2066] | 61 | case SPHERE:
|
---|
[2538] | 62 | return "sphere";
|
---|
[2066] | 63 | case VIEW_CELL:
|
---|
[2538] | 64 | return "view cell";
|
---|
[2066] | 65 | case OGRE_MESH_INSTANCE:
|
---|
[2538] | 66 | return "ogre_mesh_instance";
|
---|
[2066] | 67 | case KD_INTERSECTABLE:
|
---|
[2538] | 68 | return "kd";
|
---|
| 69 | case TRIANGLE_INTERSECTABLE:
|
---|
| 70 | return "triangle";
|
---|
| 71 | case BVH_INTERSECTABLE:
|
---|
| 72 | return "bvh";
|
---|
[2066] | 73 | default:
|
---|
[2538] | 74 | return "unknown";
|
---|
[2066] | 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 |
|
---|
[2198] | 93 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
[2066] | 94 |
|
---|
[2198] | 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 |
|
---|
[2066] | 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 | {
|
---|
[2231] | 132 | cerr << "GetRandomSurfacePoint(u,v...) not yet implemented for type " << Type() << endl;
|
---|
[2066] | 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 | {
|
---|
[2206] | 146 | cerr << "GetArea not implemented yet for this type" << endl;
|
---|
[2066] | 147 | return 0;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 | }
|
---|