sat
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index 1d8e564359ef810e34532e131a876b568f417454..7b1d1d15dbcc723067562329187f0bff4676e56f 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #define SR_NETWORKED
+#define VG_DEVWINDOW
 #include "common.h"
 #include "conf.h"
 #include "steam.h"
@@ -21,7 +22,6 @@
 #include "font.h"
 
 
-
 #include "player.h"
 static player_instance localplayer;
 VG_STATIC struct player_avatar localplayer_avatar;
@@ -40,12 +40,19 @@ player_instance *tmp_localplayer(void)
 static int cl_ui      = 1,
            cl_light_edit = 0;
 
+#define DEV_AARON
+#ifdef DEV_AARON
+static rb_object aaron={
+   .type=k_rb_shape_box,
+   .rb.bbx = {{ -2.0f, -1.0f, -1.0f }, { 2.0f, 1.0f, 1.0f }}
+};
+#endif
+
 int main( int argc, char *argv[] )
 {
    vg_mem.use_libc_malloc = 0;
    vg_set_mem_quota( 160*1024*1024 );
    vg_enter( argc, argv, "Voyager Game Engine" ); 
-
    return 0;
 }
 
@@ -163,6 +170,14 @@ vg_info("            '        ' '--' [] '----- '----- '     ' '---'  "
    steam_init();
    vg_loader_step( NULL, steam_end );
    vg_loader_step( network_init, network_end );
+
+#ifdef DEV_AARON
+   q_identity( aaron.rb.q );
+   v3_zero( aaron.rb.w );
+   v3_zero( aaron.rb.co );
+   v3_zero( aaron.rb.v );
+   rb_init_object( &aaron );
+#endif
 }
 
 VG_STATIC void load_playermodels(void)
@@ -223,7 +238,7 @@ VG_STATIC void vg_load(void)
    font3d_load( &world_global.font, "models/rs_font.mdl", vg_mem.rtmemory );
 
    //vg_loader_step( player_init, NULL );
-   //vg_loader_step( vehicle_init, NULL );
+   vg_loader_step( vehicle_init, NULL );
    //
    //vg_loader_step( player_model_init, NULL );
    
@@ -246,8 +261,8 @@ VG_STATIC void vg_load(void)
    /* 'systems' are completely loaded now */
 
    /* load home world */
-   //world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" );
-   world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" );
+   world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" );
+   //world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" );
 
 #if 0
    world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" );
@@ -279,49 +294,50 @@ VG_STATIC void vg_update(void)
       draw_origin_axis();
       network_update();
       
-#if 0
-      if( !gzoomer.inside )
-         player_update_pre();
-#endif
-
       player__pre_update( &localplayer );
-      world_update( get_active_world(), localplayer.rb.co );
 
-      audio_update();
+      world_update( get_active_world(), localplayer.rb.co );
+      audio_ambient_sprites_update( get_active_world(), localplayer.rb.co );
    }
 }
 
 VG_STATIC void vg_update_fixed(void)
 {
    if( vg.is_loaded ){
-#if 0
-      if( !gzoomer.inside )
-         player_update_fixed();
+      world_routes_fixedupdate( get_active_world() );
 
+      player__update( &localplayer );
       vehicle_update_fixed();
+
+#ifdef DEV_AARON
+      world_instance *world = get_active_world();
+      rb_solver_reset();
+      rb_ct *buf = rb_global_buffer();
+
+      int l = rb_box__scene( aaron.rb.to_world, aaron.rb.bbx,
+                             NULL, &world->rb_geo.inf.scene, buf );
+      for( int j=0; j<l; j++ ){
+         buf[j].rba = &aaron.rb;
+         buf[j].rbb = &world->rb_geo.rb;
+      }
+      rb_contact_count += l;
+      rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
+
+      for( int j=0; j<8; j++ ){
+         rb_solve_contacts( rb_contact_buffer, rb_contact_count );
+      }
+
+      rb_iter( &aaron.rb );
+      rb_update_transform( &aaron.rb );
 #endif
-      world_routes_fixedupdate( get_active_world() );
-      player__update( &localplayer );
+
    }
 }
 
 VG_STATIC void vg_update_post(void)
 {
-   if( vg.is_loaded )
-   {
-#if 0
-      if( gzoomer.inside )
-      {
-         vehicle_camera();
-      }
-      else
-      {
-         player_update_post();
-      }
-#endif
-
+   if( vg.is_loaded ){
       player__post_update( &localplayer );
-
       
       float inr3 = 0.57735027,
             inr2 = 0.70710678118;
@@ -388,7 +404,6 @@ VG_STATIC void vg_update_post(void)
       if( si >= 14 )
          si = 0;
 
-
       /* FIXME: TEMP */
       audio_lock();
       vg_dsp.echo_distances[si] = dist;
@@ -409,8 +424,20 @@ VG_STATIC void vg_update_post(void)
       audio_unlock();
 
       menu_update();
-#if 0
       vehicle_update_post();
+
+#ifdef DEV_AARON
+      SDL_Scancode sc = SDL_GetScancodeFromKey( SDLK_q );
+      if( vg_input.sdl_keys[sc] ){
+         m4x3_mulv( main_camera.transform, (v3f){0.0f,0.0f,-3.0f}, 
+                    aaron.rb.co );
+
+         v3_zero( aaron.rb.v );
+         v3_zero( aaron.rb.w );
+         rb_update_transform( &aaron.rb );
+      }
+
+      rb_object_debug( &aaron, VG__PINK );
 #endif
    }
 }
@@ -605,42 +632,5 @@ VG_STATIC void vg_ui(void)
    world_instance *world = get_active_world();
    menu_crap_ui();
    
-   audio_debug_soundscapes();
    render_view_framebuffer_ui();
-
-#if 0
-   player_physics_gui();
-#endif
-}
-
-VG_STATIC void run_debug_info(void)
-{
-#if 0
-   char buf[40];
-   
-   snprintf( buf, 40, "%.2fm/s", v3_length( player.rb.v ) );
-   ui_text( (ui_px [2]){ 0, 0 }, buf, 1, k_text_align_left );
-   
-   snprintf( buf, 40, "%.2f %.2f %.2f m/s", 
-         player.phys.a[0], player.phys.a[1], player.phys.a[2] );
-   ui_text( (ui_px [2]){ 0, 20 }, buf, 1, k_text_align_left );
-
-   snprintf( buf, 40, "pos %.2f %.2f %.2f", 
-         player.phys.rb.co[0], player.phys.rb.co[1], player.phys.rb.co[2] );
-   ui_text( (ui_px [2]){ 0, 40 }, buf, 1, k_text_align_left );
-
-   if( vg_input.controller_handle )
-   {
-      for( int i=0; i<vg_list_size(vg_input.controller_axises); i++ )
-      {
-         snprintf( buf, 40, "%.2f", vg_input.controller_axises[i] );
-         ui_text( (ui_px [2]){ 0, (i+3)*20 }, buf, 1, k_text_align_left );
-      }
-   }
-   else
-   {
-      ui_text( (ui_px [2]){ 0, 60 }, 
-            "Gamepad not ready", 1, k_text_align_left );
-   }
-#endif
 }