ray operator *(const tmat &l, ray r) { r.origin = transformPt(l, r.origin); r.direction = transformVec(l, r.direction); return r; }
Vector Instance::getRandomPoint(Vector n,double t) { auto m = makeMatrices(t); auto n_ = transformVec(m.second, n); n_.normalize(); auto p = i->getRandomPoint(n_,t); return transformLoc(m.first, p); }
std::pair<boost::optional<double>,HitRecord> Instance::hit(Ray r) { auto m = makeMatrices(r.time); Ray tr; tr.time = r.time; tr.depth = r.depth; tr.origin = transformLoc(m.second, r.origin); tr.direction = transformVec(m.second, r.direction); tr.direction.normalize(); auto hit = i->hit(tr); if(hit.first) { hit.second.r = r; hit.second.at = transformLoc(m.first, hit.second.at); hit.second.n = transformVec(m.first, hit.second.n); hit.second.n.normalize(); hit.first = (hit.second.at - r.origin).length(); } return hit; }