Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-10 13:51:34 +0000
committerStijn Buys <ingar@osirion.org>2008-05-10 13:51:34 +0000
commitd3afb677b6ea5942c042b8a83aa5d9ace1dec787 (patch)
tree49dd7ed5d2a5acec035ccdf487833954dfb59eac /src/core
parent58fa27476e4be965d78782a971439e430032d6b0 (diff)
client-side roll interpolation
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gameinterface.cc65
1 files changed, 36 insertions, 29 deletions
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index c3df020..5e2d428 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -148,10 +148,35 @@ void GameInterface::update_clientstate(float seconds)
math::Vector3f n;
math::Vector3f p;
+ // clientstate axis: pitch
+
+ // project entity->axis().up() into the plane with entity->state()->axis()->left() normal
+ n = entity->state()->axis().left();
+ p = entity->axis().up();
+ u = p[0]*n[0] + p[1]*n[1] + p[2]*n[2] / (-n[0]*n[0] - n[1]*n[1] - n[2] * n[2]);
+ p = entity->axis().up() + u * n;
+
+ side = entity->state()->axis().forward().x * p.x +
+ entity->state()->axis().forward().y * p.y +
+ entity->state()->axis().forward().z * p.z;
+
+ if (fabs(side) > 0.00005f) {
+ cosangle = math::dotproduct(p, entity->state()->axis().up());
+
+ if (fabs(cosangle) < 0.99995f) {
+ angle = acos(cosangle) * 180.0f / M_PI;
+ angle = math::sgnf(side) * angle * seconds /
+ (core::game()->serverframetime() - core::game()->clientframetime());
+
+ entity->state()->state_axis.change_pitch(-angle);
+ }
+ }
+
// clientstate axis: direction
// project entity->axis().forward() into the plane with entity->state()->axis().up() normal
n = entity->state()->axis().up();
+ p = entity->axis().forward();
u = p[0]*n[0] + p[1]*n[1] + p[2]*n[2] / (-n[0]*n[0] - n[1]*n[1] - n[2] * n[2]);
p = entity->axis().forward() + u * n;
@@ -170,47 +195,29 @@ void GameInterface::update_clientstate(float seconds)
}
}
- // clientstate axis: pitch
+ // clientstate axis: roll
- // project entity->axis().up() into the plane with entity->state()->axis()->left() normal
- n = entity->state()->axis().left();
+ // project entity->axis().up() into the plane with entity->state()->axis().forward() normal
+ n = entity->state()->axis().forward();
+ p = entity->axis().up();
u = p[0]*n[0] + p[1]*n[1] + p[2]*n[2] / (-n[0]*n[0] - n[1]*n[1] - n[2] * n[2]);
p = entity->axis().up() + u * n;
-
- side = entity->state()->axis().forward().x * p.x +
- entity->state()->axis().forward().y * p.y +
- entity->state()->axis().forward().z * p.z;
+
+ side = entity->state()->axis().left().x * p.x +
+ entity->state()->axis().left().y * p.y +
+ entity->state()->axis().left().z * p.z;
if (fabs(side) > 0.00005f) {
cosangle = math::dotproduct(p, entity->state()->axis().up());
-
- if (fabs(cosangle) < 0.99995f) {
- angle = acos(cosangle) * 180.0f / M_PI;
+ angle = acos(cosangle) * 180.0f / M_PI;
+ if (fabs(cosangle) < 0.99995f) {
angle = math::sgnf(side) * angle * seconds /
(core::game()->serverframetime() - core::game()->clientframetime());
- entity->state()->state_axis.change_pitch(-angle);
+ entity->state()->state_axis.change_roll(angle);
}
}
-
- /*
- // clientstate axis: roll
- side = entity->state()->axis().left().x * entity->axis().up().x +
- entity->state()->axis().left().y * entity->axis().up().y +
- entity->state()->axis().left().z * entity->axis().up().z;
-
- if (fabs(side) < 0.9999) {
- float cosangle = math::dotproduct(entity->axis().up(), entity->state()->axis().up());
- float angle = acos(cosangle) * 180.0f / M_PI;
- angle = math::sgnf(side) * angle * seconds /
- (core::game()->serverframetime() - core::game()->clientframetime());
-
- if (angle > 0.001)
- entity->state()->state_axis.change_roll(-angle);
- }
- */
-
}
}