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