From 08a97e2f39961a79dd57e7310626408b20c5d9e8 Mon Sep 17 00:00:00 2001 From: taw27 Date: Thu, 7 Aug 2008 23:13:07 +0000 Subject: Measure and subtract physics time from the wait git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@233 84d2e878-0bd5-11dd-ad15-13eda11d74c5 --- src/physics.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/physics.c') diff --git a/src/physics.c b/src/physics.c index 3472cc5..91505b9 100644 --- a/src/physics.c +++ b/src/physics.c @@ -15,6 +15,8 @@ #include #include +#include +#include #include "types.h" #include "model.h" @@ -403,9 +405,14 @@ static void physics_process(ModelInstance *obj, Uint32 dt, Game *game) { void physics_step(Game *game, Uint32 t) { Uint32 dt; + struct timeval tv; + suseconds_t us; dt = t - game->tlast; + gettimeofday(&tv, NULL); + us = tv.tv_usec; + /* Handle things specific to the lander craft */ if ( game->thrusting ) { if ( game->fuel > 0.0 ) { @@ -454,6 +461,12 @@ void physics_step(Game *game, Uint32 t) { game_check_handoff(game); game->tlast = t; + + gettimeofday(&tv, NULL); + us = tv.tv_usec - us; + + game->time_physics = us; + } -- cgit v1.2.3