#include "InternalRayCaster.h" #include "VssRay.h" #include "KdTree.h" #include "Preprocessor.h" #define DEBUG_RAYCAST 0 namespace GtpVisibilityPreprocessor { InternalRayCaster::InternalRayCaster(const Preprocessor &preprocessor, KdTree *kdTree): RayCaster(preprocessor), mKdTree(kdTree) { } InternalRayCaster::~InternalRayCaster() { } int InternalRayCaster::CastRay( const Vector3 &viewPoint, const Vector3 &direction, const float probability, VssRayContainer &vssRays, const AxisAlignedBox3 &box, const bool castDoubleRay ) { //cout << "internal ray" << endl; int hits = 0; static Ray ray; Intersectable *objectA = NULL, *objectB = NULL; Vector3 pointA, pointB; Vector3 normalA, normalB; #if 0 AxisAlignedBox3 sbox = box; sbox.Enlarge(Vector3(-Limits::Small)); if (!sbox.IsInside(viewPoint)) return 0; #endif mPreprocessor.SetupRay(ray, viewPoint, direction); ray.mFlags &= ~Ray::CULL_BACKFACES; if (mKdTree->CastRay(ray)) { objectA = ray.intersections[0].mObject; pointA = ray.Extrap(ray.intersections[0].mT); normalA = ray.intersections[0].mNormal; } mPreprocessor.SetupRay(ray, viewPoint, -direction); ray.mFlags &= ~Ray::CULL_BACKFACES; if (castDoubleRay && mKdTree->CastRay(ray)) { objectB = ray.intersections[0].mObject; pointB = ray.Extrap(ray.intersections[0].mT); normalB = ray.intersections[0].mNormal; } return ProcessRay( viewPoint, direction, objectA, pointA, normalA, objectB, pointB, normalB, probability, vssRays, box ); } void InternalRayCaster::CastRays16( const int index, SimpleRayContainer &rays, VssRayContainer &vssRays, const AxisAlignedBox3 &sbox, const bool castDoubleRays) { int i; const int num = 16; #if DEBUG_RAYCAST Debug<<"C16 "<