float MapTree::getIntersectionTime(const Ray& pRay, float pMaxDist, bool pStopAtFirstHit) { double firstDistance = inf(); const IT end = iTree->endRayIntersection(); IT obj = iTree->beginRayIntersection(pRay, pMaxDist); for ( ;obj != end; ++obj) // (preincrement is *much* faster than postincrement!) { /* Call your accurate intersection test here. It is guaranteed that the ray hits the bounding box of obj. (*obj) has type T, so you can call methods directly using the "->" operator. */ ModelContainer *model = (ModelContainer *) (*obj); float t = model->getIntersectionTime(pRay, pStopAtFirstHit, pMaxDist); // just for visual debugging with an external debug class #ifdef _DEBUG_VMAPS if(gCount3 == gCount1) { AABox testBox; testBox = model->getAABoxBounds(); gBoxArray.append(testBox); } ++gCount3; #endif if(t > 0 && t < inf()) { obj.markBreakNode(); if(firstDistance > t && pMaxDist >= t) { firstDistance = t; if(pStopAtFirstHit) break; } } } return firstDistance; }