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