bool Renderable::anyIntersection(const Ray &ray, real maxLambda) const { Ray modelRay = transformRayWorldToModel(ray); maxLambda = transformRayLambdaWorldToModel(ray, maxLambda); // early out test - do we hit the bounding box of the object? if (!mBoundingBox.anyIntersection(modelRay,maxLambda)) return false; return this->anyIntersectionModel(modelRay,maxLambda); }
bool CollisionGeometry::closestIntersection(const Ray &ray, float maxLambda, RayIntersection& intersection) const { //adapt maximal lambda value relative to transformation properties //(e.g., scaling) Ray modelRay = transformRayWorldToModel(ray); maxLambda = transformRayLambdaWorldToModel(ray, maxLambda); //transform ray from world to model coordinate system RayIntersection isect_local; if (!this->closestIntersectionModel(modelRay,maxLambda,isect_local)) return false; //transform intersection from model to world coordinate system isect_local.transform(mModelMatrix, mModelMatrixInverseTransposed); intersection=isect_local; return true; }
bool Renderable::closestIntersection(const Ray &ray, double maxLambda, RayIntersection& intersection) const { //adapt maximal lambda value relative to transformation properties //(e.g., scaling) Ray modelRay = transformRayWorldToModel(ray); maxLambda = transformRayLambdaWorldToModel(ray, maxLambda); // early out test - do we hit the bounding box of the object? if (!mBoundingBox.anyIntersection(modelRay, maxLambda)) return false; //transform ray from world to model coordinate system RayIntersection isect_local; if (!this->closestIntersectionModel(modelRay,maxLambda,isect_local)) return false; //transform intersection from model to world coordinate system isect_local.transform(mTransform, mTransformInvTransp); intersection=isect_local; return true; }
std::shared_ptr<RayIntersection> Renderable::closestIntersection(const Ray &ray, real maxLambda) const { //adapt maximal lambda value relative to transformation properties //(e.g., scaling) Ray modelRay = transformRayWorldToModel(ray); maxLambda = transformRayLambdaWorldToModel(ray, maxLambda); // early out test - do we hit the bounding box of the object? if (!mBoundingBox.anyIntersection(modelRay, maxLambda)) return nullptr; //transform ray from world to model coordinate system std::shared_ptr<RayIntersection> isect_local = this->closestIntersectionModel(modelRay,maxLambda); if (!isect_local) return nullptr; //transform intersection from model to world coordinate system isect_local->transform(mTransform, mTransformInvTransp); return isect_local; }