]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/view.cpp
Make sure the shadow volume does not have zero size
[r2c2.git] / source / 3d / view.cpp
index 69049e0b3e8e2232277ad4d0ee0f93e374424075..9fd5684f6ab50851f82c42c8ba10a25da16b3abc 100644 (file)
@@ -25,6 +25,7 @@ View3D::View3D(Layout3D &l, unsigned w, unsigned h):
        pipeline.add_renderable_for_pass(layout.get_scene(), "translucent");
 
        GL::Pipeline::Pass *pass = &pipeline.add_pass("sky");
+       pass->set_lighting(&layout.get_lighting());
 
        pass = &pipeline.add_pass(0);
        pass->set_lighting(&layout.get_lighting());
@@ -59,7 +60,7 @@ Ray View3D::create_ray(float x, float y) const
 {
        const GL::Vector3 &start = camera.get_position();
        GL::Vector4 ray = camera.unproject(GL::Vector4(x, y, 0, 0));
-       return Ray(start, Vector(ray));
+       return Ray(start, ray.slice<3>(0));
 }
 
 void View3D::compute_bounds(Vector &minp, Vector &maxp)
@@ -98,7 +99,7 @@ void View3D::update_shadow_area()
 {
        Vector minp, maxp;
        compute_bounds(minp, maxp);
-       shadow.set_target((minp+maxp)/2.0f, (maxp-minp).norm()/2.0f);
+       shadow.set_target((minp+maxp)/2.0f, max((maxp-minp).norm()/2.0f, 0.1f));
 }
 
 } // namespace R2C2