]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
fix accelerometer with csqcmodels
authorRudolf Polzer <divverent@alientrap.org>
Fri, 27 Jan 2012 19:11:40 +0000 (20:11 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 27 Jan 2012 19:11:40 +0000 (20:11 +0100)
qcsrc/client/hud.qc
qcsrc/csqcmodellib/cl_player.qc
qcsrc/csqcmodellib/cl_player.qh

index 79185d7147e016d492d9d42c52a8922869eec243..04f3020cb1e4ff325e63461a4e406940ab8d2465 100644 (file)
@@ -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);
index 3c75b399f7b31a310979443620a048a6c1301655..2ececc6e1781cc26d2b98b92cdc4cdb39a60cdb4 100644 (file)
@@ -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;
index 0eecabed88e05e626d5be5a98799480de7bc4a21..881ad3b329bc30100cc677b0214a72dfeb9454ec 100644 (file)
@@ -20,6 +20,7 @@
  * IN THE SOFTWARE.
  */
 
+entity csqcplayer;
 float csqcplayer_status;
 #define CSQCPLAYERSTATUS_UNPREDICTED 0
 #define CSQCPLAYERSTATUS_FROMSERVER 1