whoopsie
authorhgn <hgodden00@gmail.com>
Fri, 31 Mar 2023 12:08:58 +0000 (13:08 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 31 Mar 2023 12:08:58 +0000 (13:08 +0100)
blender_export.py
maps_src/mp_gridmap.mdl
player_audio.h [deleted file]
player_ragdoll.h
player_walk.c
player_walk.h
rigidbody.h
skaterift.c
skeleton.h
world.h
world_routes.h

index 3b3f5cd9393f28fc995c555944426b0d2bdb3266..8b04a208082673c2c483e4dea8146937b3d700f7 100644 (file)
@@ -430,6 +430,8 @@ def sr_compile_material( mat ):
    if mat.name in sr_compile.material_cache: 
       return sr_compile.material_cache[mat.name]
 
+   print( "\n"+ mat.name+"\n" )
+
    index = (len(sr_compile.material_data)//sizeof(mdl_material))+1
    sr_compile.material_cache[mat.name] = index
 
index 2f44b2153fcbaeeb307db0492f562e060a2bc498..f20740e41ecf73329e5bb8a195f135ca7e82a996 100644 (file)
Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ
diff --git a/player_audio.h b/player_audio.h
deleted file mode 100644 (file)
index bfd93c4..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
- */
-
-#ifndef PLAYER_AUDIO_H
-#define PLAYER_AUDIO_H
-
-#include "player.h"
-
-/* 
- * Audio
- */
-VG_STATIC void player_audio(void)
-{
-#if 0
-   struct player_phys *phys = &player.phys;
-
-   static int _air = 0;
-
-   int l2 = _air;
-   _air = player_skate.activity == k_skate_activity_air;
-
-   static double last_revert = -2000.0;
-
-
-
-
-   audio_lock();
-
-   double revert_delta = vg.time - last_revert;
-   if( (phys->controller == k_player_controller_skate) && 
-         (!_air && l2) && (revert_delta > 0.7) &&
-       (player.air_time > 0.5f) )
-   {
-      audio_player_set_position( &audio_player_extra, phys->rb.co );
-      audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
-      audio_player_set_vol( &audio_player_extra, 2.0f );
-
-      if( (fabsf(phys->slip) > 0.75f) )
-      {
-         audio_player_playclip( &audio_player_extra, &audio_lands[rand()%2+3] );
-      }
-      else
-      {
-         audio_player_playclip( &audio_player_extra, &audio_lands[rand()%3] );
-      }
-
-      last_revert = vg.time;
-   }
-
-   static float air = 0.0f;
-   air = vg_lerpf( air, player_skate.activity == k_skate_activity_air, 
-                        5.0f*vg.time_delta );
-
-   /* Spacial info */
-   v3f ears = { 1.0f,0.0f,0.0f };
-   v3f delta;
-
-   float *cam = main_camera.transform[3],
-         *pos = phys->rb.co;
-   
-   audio_player_set_position( &audio_player0, phys->rb.co );
-   audio_player_set_position( &audio_player1, phys->rb.co );
-   audio_player_set_position( &audio_player2, phys->rb.co );
-   audio_player_set_position( &audio_player4, phys->rb.co );
-   audio_player_set_position( &audio_player_gate, world.render_gate_pos );
-   audio_player_set_vol( &audio_player_gate, 5.0f );
-
-   v3_sub( phys->rb.co, main_camera.transform[3], delta );
-   v3_normalize( delta );
-   m3x3_mulv( main_camera.transform, ears, ears );
-
-   /* TODO, Make function */
-   v3_copy( ears, vg_audio.listener_ears );
-   v3_copy( main_camera.transform[3], vg_audio.listener_pos );
-
-   /* Tunnel / occlusion */
-   audio_sample_occlusion( main_camera.transform[3] );
-
-   int sprite_avail = -1;
-   for( int i=0; i<vg_list_size(ambient_sprites); i++ )
-   {
-      if( !audio_player_is_playing( &ambient_sprites[i] ) )
-      {
-         sprite_avail = i;
-         break;
-      }
-   }
-   
-   if( sprite_avail != -1 )
-   {
-      v3f waterpos;
-      enum audio_sprite_type sprite_type = 
-         audio_sample_sprite_random( phys->rb.co, waterpos );
-
-      if( sprite_type != k_audio_sprite_type_none )
-      {
-         audio_player *avail = &ambient_sprites[ sprite_avail ];
-
-         audio_player_set_vol( avail, 20.0f );
-         audio_player_set_flags( avail, AUDIO_FLAG_SPACIAL_3D );
-         audio_player_set_position( avail, waterpos );
-
-         if( sprite_type == k_audio_sprite_type_grass )
-         {
-            audio_player_playclip( avail, &audio_grass[rand()%4] );
-         }
-         else if( sprite_type == k_audio_sprite_type_water )
-         {
-            if( world.water.enabled )
-               audio_player_playclip( avail, &audio_water[rand()%6] );
-         }
-      }
-   }
-   
-   if( freecam || player.is_dead || 
-         !(phys->controller != k_player_controller_skate))
-   {
-      audio_player_set_vol( &audio_player0, 0.0f );
-      audio_player_set_vol( &audio_player1, 0.0f );
-      audio_player_set_vol( &audio_player2, 0.0f );
-      audio_player_set_vol( &audio_player3, 0.0f );
-      audio_player_set_vol( &audio_player4, 0.0f );
-
-      int walk_phase = 0;
-      if( vg_fractf(player.walk_timer) > 0.5f )
-         walk_phase = 1;
-      else
-         walk_phase = 0;
-
-      if( (player.step_phase != walk_phase) && 
-            !(player_walk.activity == k_walk_activity_air) )
-      {
-         audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
-         audio_player_set_position( &audio_player_extra, phys->rb.co );
-         audio_player_set_vol( &audio_player_extra, 6.0f );
-
-         if( player.surface_prop == k_surface_prop_concrete )
-         {
-            audio_player_playclip( 
-              &audio_player_extra, 
-              &audio_footsteps[rand()%vg_list_size(audio_footsteps)] 
-            );
-         }
-         else if( player.surface_prop == k_surface_prop_grass )
-         {
-            audio_player_playclip( 
-              &audio_player_extra, 
-              &audio_footsteps_grass[rand()%vg_list_size(audio_footsteps_grass)]
-            );
-         }
-         else if( player.surface_prop == k_surface_prop_wood )
-         {
-            audio_player_playclip( 
-              &audio_player_extra, 
-              &audio_footsteps_wood[rand()%vg_list_size(audio_footsteps_wood)]
-            );
-         }
-      }
-
-      player.step_phase = walk_phase;
-   }
-   else
-   {
-      /* Composite */
-      float speed = vg_minf(v3_length( phys->rb.v )*0.1f,1.0f),
-            attn  = speed,
-            slide = vg_clampf( fabsf(phys->slip), 0.0f, 1.0f ),
-            grind = player_skate.activity == k_skate_activity_grind,
-            vol0  = (1.0f-air)*attn*(1.0f-slide)*(1.0f-grind),
-            vol1  =       air *attn*(1.0f-grind),
-            vol2  = (1.0f-air)*attn*slide*(1.0f-grind),
-            vol4  = grind*2.0f;
-      
-      audio_player_set_vol( &audio_player0, vol0*vg.time_rate );
-      audio_player_set_vol( &audio_player1, vol1*vg.time_rate );
-      audio_player_set_vol( &audio_player2, vol2*vg.time_rate );
-      audio_player_set_vol( &audio_player4, vol4*vg.time_rate );
-
-      float reverb_amt = vol0 * audio_occlusion_current * 0.5f;
-
-      audio_player_set_pan( &audio_player3, 0.0f );
-      audio_player_set_vol( &audio_player3, reverb_amt*vg.time_rate );
-   }
-   
-#if 0
-   world_audio_update( cam, ears );
-#endif
-   audio_unlock();
-
-   if( player_skate.activity == k_skate_activity_air )
-      player.air_time += vg.time_delta;
-   else
-      player.air_time = 0.0f;
-#endif
-}
-
-#endif /* PLAYER_AUDIO_H */
index 497aedd09b87b349b5e29113864033074fd6620e..e4711634a218e6f3e79c60a105c4165ed070777c 100644 (file)
@@ -90,8 +90,10 @@ VG_STATIC void player_init_ragdoll_bone_collider( struct skeleton_bone *bone,
 
       rp->colour = 0xff000000 | (0xff << (major_axis*8));
    }
-   else
+   else{
+      vg_warn( "type: %u\n", bone->collider );
       vg_fatal_exit_loop( "Invalid bone collider type" );
+   }
 
    m4x3_invert_affine( rp->collider_mtx, rp->inv_collider_mtx );
 
@@ -130,7 +132,7 @@ VG_STATIC void player_setup_ragdoll_from_avatar( struct player_ragdoll *rd,
    rd->position_constraints_count = 0;
    rd->cone_constraints_count = 0;
 
-   for( u32 i=0; i<av->sk.bone_count; i ++ ){
+   for( u32 i=1; i<av->sk.bone_count; i ++ ){
       struct skeleton_bone *bone = &av->sk.bones[i];
 
       /*
index 6d020523d0cc1bb57451dc6dc3fb992b080bb291..75e3a379261e5ac7b1a8b0e44d9f94aa51e6ca14 100644 (file)
@@ -408,6 +408,8 @@ VG_STATIC void player__walk_update( player_instance *player )
    if( w->state.activity != k_walk_activity_lockedmove )
       w->state.activity = k_walk_activity_air;
 
+   w->surface = k_surface_prop_concrete;
+
    for( int i=0; i<len; i++ )
    {
       struct contact *ct = &manifold[i];
@@ -419,6 +421,10 @@ VG_STATIC void player__walk_update( player_instance *player )
             w->state.activity = k_walk_activity_ground;
 
          v3_add( surface_avg, ct->n, surface_avg );
+
+         struct world_surface *surf = world_contact_surface( world, ct );
+         if( surf->info.surface_prop > w->surface )
+            w->surface = surf->info.surface_prop;
       }
 
       rb_prepare_contact( ct, k_rb_delta );
@@ -456,9 +462,6 @@ VG_STATIC void player__walk_update( player_instance *player )
       }
       else{
          player_friction( player->rb.v );
-
-         struct world_surface *surf = world_contact_surface( world, manifold );
-         w->surface = surf->info.surface_prop;
       }
    }
    else{
@@ -633,6 +636,40 @@ VG_STATIC void player__walk_post_update( player_instance *player )
 
    v3_add( player->rb.co, p1, p1 );
    vg_line( player->rb.co, p1, VG__PINK );
+
+
+   int walk_phase = 0;
+   if( vg_fractf(w->walk_timer) > 0.5f )
+      walk_phase = 1;
+   else
+      walk_phase = 0;
+
+   if( (w->step_phase != walk_phase) && 
+       (w->state.activity == k_walk_activity_ground ) )
+   {
+      audio_lock();
+      if( w->surface == k_surface_prop_concrete ){
+         audio_oneshot_3d( 
+               &audio_footsteps[rand()%vg_list_size(audio_footsteps)], 
+               player->rb.co, 40.0f, 1.0f 
+         );
+      }
+      else if( w->surface == k_surface_prop_grass ){
+         audio_oneshot_3d( 
+           &audio_footsteps_grass[rand()%vg_list_size(audio_footsteps_grass)],
+            player->rb.co, 40.0f, 1.0f 
+         );
+      }
+      else if( w->surface == k_surface_prop_wood ){
+         audio_oneshot_3d( 
+           &audio_footsteps_wood[rand()%vg_list_size(audio_footsteps_wood)],
+            player->rb.co, 40.0f, 1.0f 
+         );
+      }
+      audio_unlock();
+   }
+
+   w->step_phase = walk_phase;
 }
 
 VG_STATIC void player__walk_animate( player_instance *player, 
@@ -659,8 +696,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
 
    player_pose apose, bpose;
 
-   if( w->move_speed > 0.025f )
-   {
+   if( w->move_speed > 0.025f ){
       /* TODO move */
       float walk_norm = 30.0f/(float)w->anim_walk->length,
             run_norm  = 30.0f/(float)w->anim_run->length,
@@ -668,8 +704,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
 
       w->walk_timer += walk_adv * vg.time_delta;
    }
-   else
-   {
+   else{
       w->walk_timer = 0.0f;
    }
 
@@ -812,6 +847,13 @@ VG_STATIC void player__walk_im_gui( player_instance *player )
                                              "k_walk_activity_immobile",
                                              "k_walk_activity_lockedmove" }
                                              [w->state.activity] );
+   player__debugtext( 1, "surface: %s\n",
+                           (const char *[]){ "concrete",
+                                             "wood",
+                                             "grass",
+                                             "tiles",
+                                             "metal" }
+                                             [w->surface] );
 
    if( w->state.outro_anim )
    {
index beb87d25e476cab9f0595fd2e75f4e1d92234761..fc26280fd3a187cdf42d7423fceb3b85f44c88b3 100644 (file)
@@ -53,6 +53,8 @@ struct player_walk
 
          move_speed,
          walk_timer;
+
+   int step_phase;
 };
 
 VG_STATIC void player__walk_pre_update  ( player_instance *player );
index 0fcb894d089bd0204dc839df1f6cff263c06a7a2..398791341b592459f3b1e922ebfdb46a2fcf88a5 100644 (file)
@@ -1509,8 +1509,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b,
    v3_sub( mtxA[3], (v3f){ r,r,r }, box[0] );
    v3_add( mtxA[3], (v3f){ r,r,r }, box[1] );
    
-   while( bh_next( s->bh_scene, &it, box, &idx ) )
-   {
+   while( bh_next( s->bh_scene, &it, box, &idx ) ){
       u32 *ptri = &sc->arrindices[ idx*3 ];
       v3f tri[3];
 
@@ -1526,8 +1525,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b,
       int contact = rb_sphere__triangle( mtxA, b, tri, &buf[count] );
       count += contact;
 
-      if( count == 16 )
-      {
+      if( count == 16 ){
          vg_warn( "Exceeding sphere_vs_scene capacity. Geometry too dense!\n" );
          return count;
       }
@@ -1999,8 +1997,7 @@ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c,
    
    scene *sc = s->bh_scene->user;
    
-   while( bh_next( s->bh_scene, &it, bbx, &idx ) )
-   {
+   while( bh_next( s->bh_scene, &it, bbx, &idx ) ){
       u32 *ptri = &sc->arrindices[ idx*3 ];
       v3f tri[3];
 
@@ -2012,8 +2009,7 @@ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c,
       int contact = rb_capsule__triangle( mtxA, c, tri, &buf[count] );
       count += contact;
 
-      if( count >= 16 )
-      {
+      if( count >= 16 ){
          vg_warn("Exceeding capsule_vs_scene capacity. Geometry too dense!\n");
          return count;
       }
index 4b7323776dd406550ccc28e13caed317fb4da0f0..8e7b738776f7dfccd4104ca9ad69701c76e20983 100644 (file)
@@ -45,7 +45,7 @@ static int cl_ui      = 1,
 
 int main( int argc, char *argv[] )
 {
-   vg_mem.use_libc_malloc = 0;
+   vg_mem.use_libc_malloc = 1;
    vg_set_mem_quota( 160*1024*1024 );
    vg_enter( argc, argv, "Voyager Game Engine" ); 
 
index 2595cda8c6476254700f6da43eac496dd4ffbd24..0332a6051e02faaf0ce79ad6fb8ebeb4f8282a70 100644 (file)
@@ -475,6 +475,8 @@ VG_STATIC void skeleton_setup( struct skeleton *skele,
       sb->collider = bone->collider;
       sb->orig_bone = bone;
 
+      vg_info( "orig: %u\n", bone->collider );
+
       if( sb->flags & k_bone_flag_ik ){
          skele->bones[ sb->parent ].flags |= k_bone_flag_ik;
          
diff --git a/world.h b/world.h
index ff2c2e3610b4bb79b809bbd1be2e289d641b8d92..9883b295d6916bb06b3466f057301b29cf2fe08e 100644 (file)
--- a/world.h
+++ b/world.h
@@ -731,16 +731,14 @@ VG_STATIC int spherecast_world( world_instance *world,
    float min_t = 1.0f;
 
    int idx;
-   while( bh_next( world->geo_bh, &it, region, &idx ) )
-   {
+   while( bh_next( world->geo_bh, &it, region, &idx ) ){
       u32 *ptri = &world->scene_geo->arrindices[ idx*3 ];
       v3f tri[3];
 
       boxf box;
       box_init_inf( box );
 
-      for( int j=0; j<3; j++ )
-      {
+      for( int j=0; j<3; j++ ){
          v3_copy( world->scene_geo->arrvertices[ptri[j]].co, tri[j] );
          box_addpt( box, tri[j] );
       }
@@ -753,10 +751,8 @@ VG_STATIC int spherecast_world( world_instance *world,
       
       float t;
       v3f n1;
-      if( spherecast_triangle( tri, pa, dir, r, &t, n1 ) )
-      {
-         if( t < min_t )
-         {
+      if( spherecast_triangle( tri, pa, dir, r, &t, n1 ) ){
+         if( t < min_t ){
             min_t = t;
             hit = idx;
             v3_copy( n1, n );
@@ -772,18 +768,16 @@ VG_STATIC
 struct world_surface *world_tri_index_surface( world_instance *world, 
                                                  u32 index )
 {
-   for( int i=1; i<world->surface_count; i++ )
-   {
-      struct world_surface *mat = &world->surfaces[i];
+   for( int i=1; i<world->surface_count; i++ ){
+      struct world_surface *surf = &world->surfaces[i];
 
-      if( (index >= mat->sm_geo.vertex_start) &&
-          (index  < mat->sm_geo.vertex_start+mat->sm_geo.vertex_count ) )
+      if( (index >= surf->sm_geo.vertex_start) &&
+          (index  < surf->sm_geo.vertex_start+surf->sm_geo.vertex_count ) )
       {
-         return mat;
+         return surf;
       }
    }
 
-   /* error surface */
    return &world->surfaces[0];
 }
 
index 91456aa0afdbde6bb4f42937aceaab8399a06a79..5862657bdb808a544aabd37bf7b9f3a885f18064 100644 (file)
@@ -196,7 +196,7 @@ VG_STATIC void world_routes_debug( world_instance *world )
 }
 
 VG_STATIC void world_routes_place_curve( world_instance *world,
-                                         v4f h[4], v3f n0, v3f n2 )
+                                         v4f h[3], v3f n0, v3f n2 )
 {
    float t;
    v3f p, pd;
@@ -422,7 +422,7 @@ VG_STATIC void world_routes_generate( world_instance *world )
    }
 
    for( u32 i=0; i<mdl_arrcount(&world->ent_route_node); i++ ){
-      ent_route_node *rn = mdl_arritm( &world->ent_route, i );
+      ent_route_node *rn = mdl_arritm( &world->ent_route_node, i );
       rn->ref_count = 0;
       rn->ref_total = 0;
    }