// return true iff no segment in env0 intersects any segment in env1 bool environmentIntersectionTest(const Environment& env0, const Environment& env1) const { for (const auto & i : env0) for (const auto & j : env1) if (intersectionTest(i, j)) return false; return true; }
// return true iff env does *not* include a pair of intersecting segments bool selfIntersectionTest(const Environment& env) const { for (unsigned int i = 0; i < env.size(); ++i) for (unsigned int j = i + 1; j < env.size(); ++j) if (intersectionTest(env[i], env[j])) return false; return true; }
HitInfo Sphere::intersectsRay(const glm::vec3 &ori, const glm::vec3 &dir) { float t = 0.0; if (intersectionTest(ori, dir, t)) { HitInfo info; info.x = t; info.objIdx = uid; info.p = ori + t * dir; const float bias = 1e-4; info.n = info.p * (1 + bias); //info.t = ??? return info; } else { return HitInfo::noHit(); } }