- // get normal and turn towards ray if angle > 90°
- Vec3f n = ray.hit()->GetNormal(ray);
- float cos_theta = n.dot(ray.direction());
- // we just need the sign, no value
- if( cos_theta > 0 ) {
- std::cout << "cos_theta="<<cos_theta <<", flipping normal" <<std::endl;
- n = n * -1;
- }
-
- // shoot secondary rays from intersection
- Ray sec(ray.origin() + ray.direction() * (ray.t() - Epsilon),
- ray.direction() + n * 2);
- sec.setRecursionDepth(ray.recursionDepth() - 1);
+ if(ray.recursionDepth() > 0) {
+ m_scene->Intersect(ray);
+ // intersection, - Epsilon to avoid numerical problems and getting the
+ // reflection on the object's inside ;-)
+ Vec3f i = ray.origin() + ray.direction() * (ray.t() - Epsilon);
+ Vec3f r = ray.direction();
+ Vec3f n = (ray.hit()->GetNormal(ray));