[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 |
|
---|
[2066] | 17 | namespace GtpVisibilityPreprocessor {
|
---|
| 18 |
|
---|
[2660] | 19 |
|
---|
| 20 | int Intersectable::sMailId = 10000;//2147483647;
|
---|
[2643] | 21 | int Intersectable::sReservedMailboxes = 1;
|
---|
[2066] | 22 |
|
---|
[2660] | 23 | int Intersectable::sMailId2 = 10000;//2147483647;
|
---|
[2643] | 24 | int Intersectable::sReservedMailboxes2 = 1;
|
---|
| 25 |
|
---|
[2575] | 26 | // This is the result of computing intersection
|
---|
| 27 | // static data member
|
---|
| 28 | ALIGN16 IntersectionStr
|
---|
| 29 | SimpleRay::IntersectionRes[32];
|
---|
| 30 |
|
---|
[2066] | 31 | Intersectable::Intersectable():
|
---|
| 32 | mMailbox(0),
|
---|
| 33 | mBvhLeaf(0),
|
---|
[2543] | 34 | mVssRays(NULL),
|
---|
| 35 | mRenderedFrame(0)
|
---|
[2198] | 36 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
| 37 | , mViewCells(NULL)
|
---|
| 38 | #endif
|
---|
[2066] | 39 | {}
|
---|
| 40 |
|
---|
| 41 |
|
---|
[2575] | 42 |
|
---|
[2066] | 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:
|
---|
[2538] | 54 | return "mesh instance";
|
---|
[2066] | 55 | case TRANSFORMED_MESH_INSTANCE:
|
---|
[2538] | 56 | return "transformed mesh instance";
|
---|
[2066] | 57 | case SPHERE:
|
---|
[2538] | 58 | return "sphere";
|
---|
[2066] | 59 | case VIEW_CELL:
|
---|
[2538] | 60 | return "view cell";
|
---|
[2066] | 61 | case OGRE_MESH_INSTANCE:
|
---|
[2538] | 62 | return "ogre_mesh_instance";
|
---|
[2066] | 63 | case KD_INTERSECTABLE:
|
---|
[2538] | 64 | return "kd";
|
---|
| 65 | case TRIANGLE_INTERSECTABLE:
|
---|
| 66 | return "triangle";
|
---|
| 67 | case BVH_INTERSECTABLE:
|
---|
| 68 | return "bvh";
|
---|
[2066] | 69 | default:
|
---|
[2538] | 70 | return "unknown";
|
---|
[2066] | 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 |
|
---|
[2198] | 89 | #if STORE_VIEWCELLS_WITH_BVH
|
---|
[2066] | 90 |
|
---|
[2198] | 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 |
|
---|
[2066] | 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 | {
|
---|
[2231] | 128 | cerr << "GetRandomSurfacePoint(u,v...) not yet implemented for type " << Type() << endl;
|
---|
[2066] | 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 | {
|
---|
[2206] | 142 | cerr << "GetArea not implemented yet for this type" << endl;
|
---|
[2066] | 143 | return 0;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | }
|
---|