inline float Exhaustive(const Ray charles, float t, const BVHNode& node, const vector<Sphere> spheres, unsigned int &sphereId) { exhaustives += node.GetPrimitiveRange(); for (unsigned int p = node.GetFirstPrimitive(); p < node.GetFirstPrimitive() + node.GetPrimitiveRange(); ++p) { const Sphere sphere = spheres[p]; const float tSphere = sphere.Intersect(charles); if (0 < tSphere && tSphere < t) { sphereId = p; t = tSphere; } } return t; }
inline void Exhaustive(vector<BoundedRay> &rays, vector<int> &rayIndices, const int indexOffset, const int indexCount, const vector<Sphere> &spheres, vector<int> &sphereIDs, const int sphereOffset, const int sphereCount, vector<Hit> &hits) { for (int i = indexOffset; i < indexOffset + indexCount; ++i) { const int rayID = rayIndices[i]; const Ray charles = rays[rayID].ToRay(); float tHit = rays[rayID].t == 0.0f ? 1e30 : rays[rayID].t; Hit hit = hits[rayID]; for (int s = sphereOffset; s < sphereOffset + sphereCount; ++s) { ++exhaustives; const Sphere sphere = spheres[sphereIDs[s]]; const float t = sphere.Intersect(charles); if (0 < t && t < tHit) { hit = Hit(sphereIDs[s]); tHit = t; } } hits[rayID] = hit; rays[rayID].t = tHit; } }