Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/camera.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc
index c35cb3c..74eb674 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -191,26 +191,33 @@ void Camera::frame(float seconds)
float angle; // angle in radians
math::Vector3f n; // normal of a plane
- // camera axis: pitch & direction
-
n.assign(math::crossproduct(camera_axis.forward(), target_axis.forward()));
- if (n.lengthsquared() > MIN_DELTA) {
+ if (!(n.length() < MIN_DELTA)) {
n.normalize();
cosangle = math::dotproduct(camera_axis.forward(), target_axis.forward());
- angle = acos(cosangle); // * 180.0f / M_PI;
- camera_axis.rotate(n, -angle * seconds);
+ angle = acos(cosangle) * seconds; // * 180.0f / M_PI;
+ if (angle > MIN_DELTA)
+ camera_axis.rotate(n, -angle);
}
- // camera axis: roll
-
n.assign(math::crossproduct(camera_axis.left(), target_axis.left()));
- if (n.lengthsquared() > MIN_DELTA) {
+ if (!(n.length() < MIN_DELTA)) {
n.normalize();
cosangle = math::dotproduct(camera_axis.left(), target_axis.left());
- angle = acos(cosangle); // * 180.0f / M_PI;
- camera_axis.rotate(n, -angle * seconds);
+ angle = acos(cosangle) * seconds; // * 180.0f / M_PI;
+ if (angle > MIN_DELTA)
+ camera_axis.rotate(n, -angle);
}
+ n.assign(math::crossproduct(camera_axis.up(), target_axis.up()));
+ if (!(n.length() < MIN_DELTA)) {
+ n.normalize();
+ cosangle = math::dotproduct(camera_axis.up(), target_axis.up());
+ angle = acos(cosangle) * seconds; // * 180.0f / M_PI;
+ if (angle > MIN_DELTA)
+ camera_axis.rotate(n, -angle);
+ }
+
if (core::localcontrol()->model()) {
camera_target -= (core::localcontrol()->model()->maxbbox().x + core::localcontrol()->model()->radius() + 0.1f) * 0.5f * camera_axis.forward();
camera_target += (core::localcontrol()->model()->maxbbox().z + core::localcontrol()->model()->radius() + 0.1f) * 0.5f * camera_axis.up();
@@ -231,6 +238,8 @@ void Camera::frame(float seconds)
d = degrees180f(pitch_current - pitch_target);
pitch_current = degrees360f(pitch_current - d * seconds);
camera_axis.change_pitch(pitch_current);
+
+ distance = 1.5f * core::localcontrol()->radius();
} else if (mode() == Cockpit) {