From 7e07f19a259d975756e52e9f35498c05c6745767 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 17 Jun 1997 04:19:16 +0000 Subject: [PATCH] More timer related tweaks with respect to view direction changes. --- Main/GLmain.c | 70 ++++++++++++++++++++++++++++---------------------- Main/mesh2GL.c | 9 ++++--- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/Main/GLmain.c b/Main/GLmain.c index 26c56120b..d17c2f77c 100644 --- a/Main/GLmain.c +++ b/Main/GLmain.c @@ -77,7 +77,7 @@ double goal_view_offset = 0.0; double Simtime; /* Another hack */ -int use_signals = 0; +int use_signals = 1; /************************************************************************** @@ -215,39 +215,42 @@ static void fgUpdateVisuals( void ) { void fgUpdateTimeDepCalcs(int multi_loop) { struct flight_params *f; + int i; f = ¤t_aircraft.flight; /* update the flight model */ if ( multi_loop < 0 ) { - printf("updating flight model with default = %d\n", DEFAULT_MULTILOOP); - fgFlightModelUpdate(FG_LARCSIM, f, DEFAULT_MULTILOOP); - } else { - printf("updating flight model with dynamic = %d\n", multi_loop); - fgFlightModelUpdate(FG_LARCSIM, f, multi_loop); + multi_loop = DEFAULT_MULTILOOP; } - if ( fabs(goal_view_offset - view_offset) < 0.09 ) { - view_offset = goal_view_offset; - } else { - /* move view_offset towards goal_view_offset */ - if ( goal_view_offset > view_offset ) { - if ( goal_view_offset - view_offset < M_PI ) { - view_offset += 0.05; - } else { - view_offset -= 0.05; - } + /* printf("updating flight model x %d\n", multi_loop); */ + fgFlightModelUpdate(FG_LARCSIM, f, multi_loop); + + for ( i = 0; i < multi_loop; i++ ) { + if ( fabs(goal_view_offset - view_offset) < 0.05 ) { + view_offset = goal_view_offset; + break; } else { - if ( view_offset - goal_view_offset < M_PI ) { - view_offset -= 0.05; + /* move view_offset towards goal_view_offset */ + if ( goal_view_offset > view_offset ) { + if ( goal_view_offset - view_offset < M_PI ) { + view_offset += 0.01; + } else { + view_offset -= 0.01; + } } else { - view_offset += 0.05; + if ( view_offset - goal_view_offset < M_PI ) { + view_offset -= 0.01; + } else { + view_offset += 0.01; + } + } + if ( view_offset > PI2 ) { + view_offset -= PI2; + } else if ( view_offset < 0 ) { + view_offset += PI2; } - } - if ( view_offset > PI2 ) { - view_offset -= PI2; - } else if ( view_offset < 0 ) { - view_offset += PI2; } } } @@ -292,13 +295,15 @@ static void fgMainLoop( void ) { int elapsed, multi_loop; elapsed = fgGetTimeInterval(); - printf("Time interval is = %d, previous remainder is = %d\n", elapsed, - remainder); + /* printf("Time interval is = %d, previous remainder is = %d\n", elapsed, + remainder); */ + printf("--> Frame rate is = %.2f\n", 1000.0 / (float)elapsed); + elapsed += remainder; multi_loop = ((float)elapsed * 0.001) * DEFAULT_MODEL_HZ; remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ); - printf("Model iterations needed = %d, new remainder = %d\n", multi_loop, - remainder); + /* printf("Model iterations needed = %d, new remainder = %d\n", multi_loop, + remainder); */ aircraft_debug(1); fgUpdateVisuals(); @@ -470,10 +475,13 @@ int main( int argc, char *argv[] ) { /* $Log$ -/* Revision 1.15 1997/06/17 03:41:10 curt -/* Nonsignal based interval timing is now working. -/* This would be a good time to look at cleaning up the code structure a bit. +/* Revision 1.16 1997/06/17 04:19:16 curt +/* More timer related tweaks with respect to view direction changes. /* + * Revision 1.15 1997/06/17 03:41:10 curt + * Nonsignal based interval timing is now working. + * This would be a good time to look at cleaning up the code structure a bit. + * * Revision 1.14 1997/06/16 19:32:51 curt * Starting to add general timer support. * diff --git a/Main/mesh2GL.c b/Main/mesh2GL.c index ebbd5ce50..ce5f5d749 100644 --- a/Main/mesh2GL.c +++ b/Main/mesh2GL.c @@ -44,7 +44,7 @@ GLint mesh2GL(struct mesh *m) { int i, j, istep, jstep, iend, jend; float temp; - istep = jstep = 15; /* Detail level 1 -- 1200 ... */ + istep = jstep = 16; /* Detail level 1 -- 1200 ... */ mesh = glGenLists(1); glNewList(mesh, GL_COMPILE); @@ -104,9 +104,12 @@ GLint mesh2GL(struct mesh *m) { /* $Log$ -/* Revision 1.17 1997/06/16 19:32:52 curt -/* Starting to add general timer support. +/* Revision 1.18 1997/06/17 04:19:17 curt +/* More timer related tweaks with respect to view direction changes. /* + * Revision 1.17 1997/06/16 19:32:52 curt + * Starting to add general timer support. + * * Revision 1.16 1997/06/02 03:40:07 curt * A tiny bit more view tweaking. * -- 2.39.2