double SearchStructure::findNearestIntersection( const Raycast& raycast, RayHitReport& reportMin, RayHitList& rayHitList) const { Raycast ray(raycast); size_t minId = -1; size_t zId = 0; size_t zoneCount = _searchZones.size(); while(zId < zoneCount) { const SearchZone& zone = _searchZones[zId]; if(zone.bounds == StageZone::UNBOUNDED.get() || zone.bounds->intersects(ray, rayHitList)) { for(size_t s = zone.begSurf; s < zone.endSurf; ++s) { rayHitList.clear(); _searchSurfaces[s]->raycast(ray, rayHitList); RayHitReport* node = rayHitList.head; while(node != nullptr) { if(0.0 < node->length && node->length < ray.limit) { ray.limit = node->length; reportMin = *node; minId = s; } node = node->_next; } } ++zId; } else { zId = zone.endZone; } } if(!_isOptimized && reportMin.length != raycast.limit) { incrementCounter(_searchSurfaces[minId], ray.entropy); } return reportMin.length; }
bool SearchStructure::intersectsScene( const Raycast& raycast, RayHitList& rayHitList, double incomingEntropy) const { rayHitList.clear(); size_t zId = 0; size_t zoneCount = _searchZones.size(); while(zId < zoneCount) { const SearchZone& zone = _searchZones[zId]; if(zone.bounds == StageZone::UNBOUNDED.get() || zone.bounds->intersects(raycast, rayHitList)) { for(size_t s = zone.begSurf; s < zone.endSurf; ++s) { if(_searchSurfaces[s]->intersects(raycast, rayHitList)) { if(!_isOptimized) incrementCounter(_searchSurfaces[s], incomingEntropy); return true; } } ++zId; } else { zId = zone.endZone; } } return false; }