From: Rudolf Polzer Date: Fri, 27 Jan 2012 19:11:40 +0000 (+0100) Subject: fix accelerometer with csqcmodels X-Git-Tag: xonotic-v0.6.0~77 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5c3c652b2dfd2191a415365a7931fc714ec2eacb;p=xonotic%2Fxonotic-data.pk3dir.git fix accelerometer with csqcmodels --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 79185d714..04f3020cb 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4394,14 +4394,16 @@ void HUD_Physics(void) conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h break; } + + vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel); float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 ); if (autocvar__hud_configure) speed = floor( max_speed * 0.65 + 0.5 ); else if(autocvar_hud_panel_physics_speed_vertical) - speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 ); + speed = floor( vlen(vel) * conversion_factor + 0.5 ); else - speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 ); + speed = floor( vlen(vel - vel_z * '0 0 1') * conversion_factor + 0.5 ); //compute acceleration float acceleration, f; @@ -4412,13 +4414,13 @@ void HUD_Physics(void) // 1 m/s = 0.0254 qu/s; 1 g = 9.80665 m/s^2 f = time - acc_prevtime; if(autocvar_hud_panel_physics_acceleration_vertical) - acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)); + acceleration = (vlen(vel) - vlen(acc_prevspeed)); else - acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)); + acceleration = (vlen(vel - '0 0 1' * vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)); acceleration = acceleration * (1 / max(0.0001, f)) * (0.0254 / 9.80665); - acc_prevspeed = pmove_vel; + acc_prevspeed = vel; acc_prevtime = time; f = bound(0, f * 10, 1); diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index 3c75b399f..2ececc6e1 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -31,7 +31,6 @@ float pmove_onground; // weird engine flag we shouldn't really use but have to f #define REFDEFFLAG_TELEPORTED 1 #define REFDEFFLAG_JUMPING 2 -entity csqcplayer; vector csqcplayer_origin, csqcplayer_velocity; float csqcplayer_sequence, player_pmflags; float csqcplayer_moveframe; diff --git a/qcsrc/csqcmodellib/cl_player.qh b/qcsrc/csqcmodellib/cl_player.qh index 0eecabed8..881ad3b32 100644 --- a/qcsrc/csqcmodellib/cl_player.qh +++ b/qcsrc/csqcmodellib/cl_player.qh @@ -20,6 +20,7 @@ * IN THE SOFTWARE. */ +entity csqcplayer; float csqcplayer_status; #define CSQCPLAYERSTATUS_UNPREDICTED 0 #define CSQCPLAYERSTATUS_FROMSERVER 1