#ifndef __KDINTERSECTABLE_H #define __KDINTERSECTABLE_H #include "AxisAlignedBox3.h" #include "Intersectable.h" namespace GtpVisibilityPreprocessor { struct VssRayContainer; class KdNode; class BvhNode; /** Wrapper used for creating a PVS compliant intersectable. */ template class IntersectableWrapper: public Intersectable { public: IntersectableWrapper(T *item); /** Returns node associated with this instance. */ T *GetItem() const; /** See get. */ void SetItem(T *item); //-- inherited functions from Intersectable AxisAlignedBox3 GetBox() const; int CastRay(Ray &ray); bool IsConvex() const; bool IsWatertight() const; float IntersectionComplexity(); int NumberOfFaces() const; //int Type() const; int GetRandomSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, GtpVisibilityPreprocessor::Vector3 &normal); int GetRandomVisibleSurfacePoint(GtpVisibilityPreprocessor::Vector3 &point, GtpVisibilityPreprocessor::Vector3 &normal, const GtpVisibilityPreprocessor::Vector3 &viewpoint, const int maxTries); ostream &Describe(ostream &s); protected: T *mItem; }; template IntersectableWrapper::IntersectableWrapper(T *item): Intersectable(), mItem(item) { } template void IntersectableWrapper::SetItem(T *item) { mItem = item; } template T *IntersectableWrapper::GetItem() const { return mItem; } template AxisAlignedBox3 IntersectableWrapper::GetBox() const { // TODO matt return AxisAlignedBox3(); } template int IntersectableWrapper::CastRay(Ray &ray) { // TODO matt return 0; } template bool IntersectableWrapper::IsConvex() const { return true; } template bool IntersectableWrapper::IsWatertight() const { return true; } template float IntersectableWrapper::IntersectionComplexity() { return 1.0f; } template int IntersectableWrapper::NumberOfFaces() const { return 0; } template int IntersectableWrapper::GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) { return 0; } template int IntersectableWrapper::GetRandomVisibleSurfacePoint(Vector3 &point, Vector3 &normal, const Vector3 &viewpoint, const int maxTries) { return 0; } template ostream &IntersectableWrapper::Describe(ostream &s) { s << mItem; return s; } class KdIntersectable: public IntersectableWrapper { public: KdIntersectable(KdNode *item): IntersectableWrapper(item) {} int Type() const { return Intersectable::KD_INTERSECTABLE; } }; class BvhIntersectable: public IntersectableWrapper { public: BvhIntersectable(BvhNode *item): IntersectableWrapper(item) {} int Type() const { return Intersectable::BVH_INTERSECTABLE; } }; } #endif