]> git.tdb.fi Git - r2c2.git/commitdiff
Enforce a lower limit for camera distance
authorMikko Rasa <tdb@tdb.fi>
Mon, 1 Nov 2010 12:08:59 +0000 (12:08 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 1 Nov 2010 12:08:59 +0000 (12:08 +0000)
Adjust depth clip according to distance

source/designer/cameracontroller.cpp

index bd7edbb530d540e73ac32296b80c6c57a3106180..edebff75f375f7911499e38f7edafb3a592217ec 100644 (file)
@@ -83,7 +83,13 @@ void CameraController::adjust_distance(float delta)
 {
        const GL::Vector3 &pos = camera.get_position();
        const GL::Vector3 &look = camera.get_look_direction();
+       float dist = get_distance();
+       float low = designer.get_layout().get_catalogue().get_gauge()*5;
+       if(dist+delta<low)
+               delta = low-dist;
        camera.set_position(GL::Vector3(pos.x-look.x*delta, pos.y-look.y*delta, pos.z-look.z*delta));
+       dist += delta;
+       camera.set_depth_clip(dist*0.02, dist*50);
 }
 
 void CameraController::rotate(float angle)