right hand yellow
authorhgn <hgodden00@gmail.com>
Sun, 2 Apr 2023 14:57:21 +0000 (15:57 +0100)
committerhgn <hgodden00@gmail.com>
Sun, 2 Apr 2023 14:57:21 +0000 (15:57 +0100)
blender_export.py
bvh.h
maps_src/mp_gridmap.mdl
player_skate.c
scene.h
skaterift.c
sound_src/docks_generic.ogg
sound_src/field_generic.ogg
sound_src/town_generic.ogg
world.h
world_gen.h

index 0d4c63ac0aba6786a5325c98f9b9d1dee1fb4360..dcab66f51953ffbf08fa2b2d080b4e34328995ab 100644 (file)
@@ -1249,6 +1249,7 @@ def sr_compile( collection ):
             compile_obj_transform( obj, audio.transform )
             audio.clip_start = audio_clip_count
             audio.clip_count = len(obj_data.files)
+            audio_clip_count += audio.clip_count
             audio.max_channels = obj_data.max_channels
             audio.volume = obj_data.volume
 
@@ -2801,7 +2802,8 @@ def cv_draw():
             cv_ent_volume( obj )
          #}
          elif ent_type == 'ent_audio':#{
-            cv_draw_sphere( obj.location, obj.scale[0], (1,1,0) )
+            if obj.SR_data.ent_audio[0].flag_3d:
+               cv_draw_sphere( obj.location, obj.scale[0], (1,1,0) )
          #}
       #}
    #}
diff --git a/bvh.h b/bvh.h
index 23f8a564d54cd7ce1b7830457da97ce15ad790d7..b054741facdcfbac6d80ee5f6d36dfaac24a5e09 100644 (file)
--- a/bvh.h
+++ b/bvh.h
@@ -68,8 +68,7 @@ VG_STATIC void bh_update_bounds( bh_tree *bh, u32 inode )
    bh_node *node = &bh->nodes[ inode ];
 
    box_init_inf( node->bbx );
-   for( u32 i=0; i<node->count; i++ )
-   {
+   for( u32 i=0; i<node->count; i++ ){
       u32 idx = node->start+i;
       bh->system->expand_bound( bh->user, node->bbx, idx );
    }
@@ -103,12 +102,10 @@ VG_STATIC void bh_subdivide( bh_tree *bh, u32 inode )
    i32 i = node->start,
        j = i + node->count-1;
    
-   while( i <= j )
-   {
+   while( i <= j ){
       if( bh->system->item_centroid( bh->user, i, axis ) < split )
          i ++;
-      else
-      {
+      else{
          bh->system->item_swap( bh->user, i, j );
          j --;
       }
@@ -164,7 +161,7 @@ VG_STATIC bh_tree *bh_create( void *lin_alloc, bh_system *system,
    if( item_count > 2 )
       bh_subdivide( bh, 0 );
 
-   totsize = sizeof(bh_tree) + sizeof(bh_node) * bh->node_count;
+   totsize = vg_align8(sizeof(bh_tree) + sizeof(bh_node) * bh->node_count);
    bh = vg_linear_resize( lin_alloc, bh, totsize );
 
    vg_success( "BVH done, size: %u/%u\n", bh->node_count, (alloc_count*2-1) );
@@ -179,10 +176,8 @@ VG_STATIC void bh_debug_leaf( bh_tree *bh, bh_node *node )
 {
    vg_line_boxf( node->bbx, 0xff00ff00 );
 
-   if( bh->system->item_debug )
-   {
-      for( u32 i=0; i<node->count; i++ )
-      {
+   if( bh->system->item_debug ){
+      for( u32 i=0; i<node->count; i++ ){
          u32 idx = node->start+i;
          bh->system->item_debug( bh->user, idx );
       }
@@ -199,15 +194,13 @@ VG_STATIC void bh_debug_trace( bh_tree *bh, u32 inode, v3f pos, u32 colour )
    if( (pos[0] >= node->bbx[0][0] && pos[0] <= node->bbx[1][0]) &&
        (pos[2] >= node->bbx[0][2] && pos[2] <= node->bbx[1][2]) )
    {
-      if( !node->count )
-      {
+      if( !node->count ){
          vg_line_boxf( node->bbx, colour );
 
          bh_debug_trace( bh, node->il, pos, colour );
          bh_debug_trace( bh, node->ir, pos, colour );
       }
-      else
-      {
+      else{
          if( bh->system->item_debug )
             bh_debug_leaf( bh, node );
       }
@@ -232,15 +225,11 @@ VG_STATIC int bh_ray( bh_tree *bh, v3f co, v3f dir, ray_hit *hit )
    dir_inv[1] = 1.0f/dir[1];
    dir_inv[2] = 1.0f/dir[2];
    
-   while(depth)
-   {
+   while(depth){
       bh_node *inode = &bh->nodes[ stack[depth] ];
-      if( ray_aabb1( inode->bbx, co, dir_inv, hit->dist ) )
-      {
-         if( inode->count )
-         {
-            for( u32 i=0; i<inode->count; i++ )
-            {
+      if( ray_aabb1( inode->bbx, co, dir_inv, hit->dist ) ){
+         if( inode->count ){
+            for( u32 i=0; i<inode->count; i++ ){
                u32 idx = inode->start+i;
 
                if( bh->system->cast_ray )
@@ -251,10 +240,8 @@ VG_STATIC int bh_ray( bh_tree *bh, v3f co, v3f dir, ray_hit *hit )
 
             depth --;
          }
-         else
-         {
-            if( depth+1 >= vg_list_size(stack) )
-            {
+         else{
+            if( depth+1 >= vg_list_size(stack) ){
                vg_error( "Maximum stack reached!\n" );
                return count;
             }
@@ -264,8 +251,7 @@ VG_STATIC int bh_ray( bh_tree *bh, v3f co, v3f dir, ray_hit *hit )
             depth ++;
          }
       }
-      else
-      {
+      else{
          depth --;
       }
    }
@@ -295,35 +281,28 @@ VG_STATIC void bh_iter_init( int root, bh_iter *it )
 
 VG_STATIC int bh_next( bh_tree *bh, bh_iter *it, boxf box, int *em )
 {
-   while( it->depth >= 0 )
-   {
+   while( it->depth >= 0 ){
       bh_node *inode = &bh->nodes[ it->stack[it->depth].id ];
       
       /* Only process overlapping nodes */
-      if( !box_overlap( inode->bbx, box ) )
-      {
+      if( !box_overlap( inode->bbx, box ) ){
          it->depth --;
          continue;
       }
 
-      if( inode->count )
-      {
-         if( it->i < inode->count )
-         {
+      if( inode->count ){
+         if( it->i < inode->count ){
             *em = inode->start+it->i;
             it->i ++;
             return 1;
          }
-         else
-         {
+         else{
             it->depth --;
             it->i = 0;
          }
       }
-      else
-      {
-         if( it->depth+1 >= vg_list_size(it->stack) )
-         {
+      else{
+         if( it->depth+1 >= vg_list_size(it->stack) ){
             vg_error( "Maximum stack reached!\n" );
             return 0;
          }
@@ -352,8 +331,7 @@ VG_STATIC int bh_closest_point( bh_tree *bh, v3f pos,
 
    queue[0] = 0;
 
-   while( depth >= 0 )
-   {
+   while( depth >= 0 ){
       bh_node *inode = &bh->nodes[ queue[depth] ];
 
       v3f p1;
@@ -361,18 +339,14 @@ VG_STATIC int bh_closest_point( bh_tree *bh, v3f pos,
 
       /* branch into node if its closer than current best */
       float node_dist = v3_dist2( pos, p1 );
-      if( node_dist < max_dist )
-      {
-         if( inode->count )
-         {
-            for( int i=0; i<inode->count; i++ )
-            {
+      if( node_dist < max_dist ){
+         if( inode->count ){
+            for( int i=0; i<inode->count; i++ ){
                v3f p2;
                bh->system->item_closest( bh->user, inode->start+i, pos, p2 );
 
                float item_dist = v3_dist2( pos, p2 );
-               if( item_dist < max_dist )
-               {
+               if( item_dist < max_dist ){
                   max_dist = item_dist;
                   v3_copy( p2, closest );
                   best_item = inode->start+i;
@@ -381,8 +355,7 @@ VG_STATIC int bh_closest_point( bh_tree *bh, v3f pos,
 
             depth --;
          }
-         else
-         {
+         else{
             queue[depth] = inode->il;
             queue[depth+1] = inode->ir;
 
index 18f438ebad6d3016753facecffebaeb0ac33d0ef..a1c0ef40200ff32cea2981e2149de3df5ae65a08 100644 (file)
Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ
index 0362386289b361901505252bf19f8f37e16b39a3..c18df219f4f8f9475d91ae6ac5e3e569fa58c95b 100644 (file)
@@ -302,7 +302,7 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player,
    m3x3_mulv( player->invbasis, player->rb.v, v_local );
 
    v2f d = { v3_dot( ax, v0 ),           v0[1] },
-       v = { v3_dot( ax, player->rb.v ), v_local[1] };
+       v = { v3_dot( ax, v_local ), v_local[1] };
 
    float a = atan2f( v[1], v[0] ),
          m = v2_length( v ),
@@ -1279,7 +1279,8 @@ VG_STATIC void player__skate_post_update( player_instance *player )
    if( s->aud_main ){
       s->aud_main->colour = 0x00103efe;
       audio_channel_set_spacial( s->aud_main, player->rb.co, 40.0f );
-      audio_channel_slope_volume( s->aud_main, 0.05f, vol_main );
+      //audio_channel_slope_volume( s->aud_main, 0.05f, vol_main );
+      audio_channel_edit_volume( s->aud_main, vol_main, 1 );
       audio_channel_sidechain_lfo( s->aud_main, 0, sidechain_amt );
 
       float rate = 1.0f + (attn-0.5f)*0.2f;
@@ -1289,14 +1290,16 @@ VG_STATIC void player__skate_post_update( player_instance *player )
    if( s->aud_slide ){
       s->aud_slide->colour = 0x00103efe;
       audio_channel_set_spacial( s->aud_slide, player->rb.co, 40.0f );
-      audio_channel_slope_volume( s->aud_slide, 0.05f, vol_slide );
+      //audio_channel_slope_volume( s->aud_slide, 0.05f, vol_slide );
+      audio_channel_edit_volume( s->aud_slide, vol_slide, 1 );
       audio_channel_sidechain_lfo( s->aud_slide, 0, sidechain_amt );
    }
 
    if( s->aud_air ){
       s->aud_air->colour = 0x00103efe;
       audio_channel_set_spacial( s->aud_air, player->rb.co, 40.0f );
-      audio_channel_slope_volume( s->aud_air, 0.05f, vol_air );
+      //audio_channel_slope_volume( s->aud_air, 0.05f, vol_air );
+      audio_channel_edit_volume( s->aud_air, vol_air, 1 );
    }
 
    audio_unlock();
diff --git a/scene.h b/scene.h
index 81d00c3f5c94c06f15ea1be92e80fbb69038a42f..74c4ea61a10476c4af5de918d2a07c066621521a 100644 (file)
--- a/scene.h
+++ b/scene.h
@@ -184,7 +184,7 @@ VG_STATIC scene *scene_fix( void *lin_alloc, scene *pscene )
        indice_count  = pscene->indice_count,
        vertex_length = vertex_count * sizeof(scene_vert),
        index_length  = indice_count * sizeof(u32),
-       tot_size      = sizeof(scene) + vertex_length + index_length;
+       tot_size      = vg_align8(sizeof(scene) + vertex_length + index_length);
 
    /* copy down index data */
    void *dst_indices = pscene->arrvertices + vertex_count;
index 67e87cc5fa3015d418f57650b8ae55ce88356714..795ca58fdf38b7c0f06745606c64ecbfa6f971db 100644 (file)
@@ -45,7 +45,7 @@ static int cl_ui      = 1,
 
 int main( int argc, char *argv[] )
 {
-   vg_mem.use_libc_malloc = 1;
+   vg_mem.use_libc_malloc = 0;
    vg_set_mem_quota( 160*1024*1024 );
    vg_enter( argc, argv, "Voyager Game Engine" ); 
 
index e223c7219e0b821fd01c8a9296ad76f24ad96b5c..526f21329b278f2d8a934b352e3904e7fc4dbb57 100644 (file)
Binary files a/sound_src/docks_generic.ogg and b/sound_src/docks_generic.ogg differ
index ed6165d5dd35d123e33c71a392e635af9a04d122..79b02ab766a622ec85c2ed0136a3be3ce6738942 100644 (file)
Binary files a/sound_src/field_generic.ogg and b/sound_src/field_generic.ogg differ
index 6f72ccc1747434cc6a353261849e098978c5ea80..a0f565bf2664fc73d3ccfb588c903bae61e669bc 100644 (file)
Binary files a/sound_src/town_generic.ogg and b/sound_src/town_generic.ogg differ
diff --git a/world.h b/world.h
index 997ff312b03fc0a28377aab2515810671b398c78..e23ae219e3abca7e8d610fbf53b0db6f3deb57ef 100644 (file)
--- a/world.h
+++ b/world.h
@@ -498,12 +498,10 @@ VG_STATIC void ent_volume_call( world_instance *world, ent_call *call )
 
          call->function = k_ent_function_particle_spawn;
          call->data = co;
-         
          entity_call( world, call );
       }
-      else if( volume->type == k_volume_subtype_trigger ){
-         /* TODO */
-      }
+      else
+         entity_call( world, call );
    }
 }
 
@@ -511,51 +509,83 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call )
 {
    ent_audio *audio = mdl_arritm( &world->ent_audio, call->ent.index );
 
+   v3f sound_co;
+
    if( call->function == k_ent_function_particle_spawn ){
-      float chance = vg_randf()*100.0f,
-            bar = 0.0f;
+      v3_copy( call->data, sound_co );
+   }
+   else if( call->function == k_ent_function_trigger ){
+      v3_copy( audio->transform.co, sound_co );
+   }
+   else
+      vg_fatal_exit_loop( "ent_audio_call (invalid function id)" );
+
+   float chance = vg_randf()*100.0f,
+         bar = 0.0f;
 
-      for( u32 i=0; i<audio->clip_count; i++ ){
-         ent_audio_clip *clip = mdl_arritm( &world->ent_audio_clip, 
-                                             audio->clip_start+i );
+   for( u32 i=0; i<audio->clip_count; i++ ){
+      ent_audio_clip *clip = mdl_arritm( &world->ent_audio_clip, 
+                                          audio->clip_start+i );
 
-         float mod = world->probabilities[ audio->probability_curve ],
-               p   = clip->probability * mod;
+      float mod = world->probabilities[ audio->probability_curve ],
+            p   = clip->probability * mod;
 
-         bar += p;
+      bar += p;
 
-         if( chance < bar ){
-            float *pos = call->data;
+      if( chance < bar ){
 
-            audio_lock();
+         audio_lock();
 
-            if( audio->behaviour == k_channel_behaviour_unlimited ){
-               audio_oneshot_3d( &clip->clip, pos,
-                                 audio->transform.s[0],
-                                 audio->volume );
+         if( audio->behaviour == k_channel_behaviour_unlimited ){
+            audio_oneshot_3d( &clip->clip, sound_co,
+                              audio->transform.s[0],
+                              audio->volume );
+         }
+         else if( audio->behaviour == k_channel_behaviour_discard_if_full ){
+            audio_channel *ch = 
+               audio_get_group_idle_channel( audio->group, 
+                                             audio->max_channels );
+
+            if( ch ){
+               audio_channel_init( ch, &clip->clip, audio->flags );
+               audio_channel_group( ch, audio->group );
+               audio_channel_set_spacial( ch, sound_co, audio->transform.s[0] );
+               audio_channel_edit_volume( ch, audio->volume, 1 );
+               ch = audio_relinquish_channel( ch );
             }
-            else if( audio->behaviour == k_channel_behaviour_discard_if_full ){
-               audio_channel *ch = 
-                  audio_get_group_idle_channel( audio->group, 
-                                                audio->max_channels );
-
-               if( ch ){
-                  audio_channel_init( ch, &clip->clip, audio->flags );
-                  audio_channel_group( ch, audio->group );
-                  audio_channel_set_spacial( ch, pos, audio->transform.s[0] );
-                  audio_channel_edit_volume( ch, audio->volume, 1 );
-                  ch = audio_relinquish_channel( ch );
+         }
+         else if( audio->behaviour == k_channel_behaviour_crossfade_if_full){
+            audio_channel *ch =
+               audio_get_group_idle_channel( audio->group,
+                                             audio->max_channels );
+
+            /* group is full */
+            if( !ch ){
+               audio_channel *existing = 
+                  audio_get_group_first_active_channel( audio->group );
+
+               if( existing ){
+                  if( existing->source == &clip->clip ){
+                     audio_unlock();
+                     return;
+                  }
+                 
+                  existing = audio_channel_fadeout( existing, audio->crossfade);
                }
-            }
-            else if( audio->behaviour == k_channel_behaviour_crossfade_if_full){
-               
-            }
 
-            
+               ch = audio_get_first_idle_channel();
+            }
 
-            audio_unlock();
-            break;
+            if( ch ){
+               audio_channel_init( ch, &clip->clip, audio->flags );
+               audio_channel_group( ch, audio->group );
+               audio_channel_fadein( ch, audio->crossfade );
+               ch = audio_relinquish_channel( ch );
+            }
          }
+
+         audio_unlock();
+         return;
       }
    }
 }
@@ -692,13 +722,13 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
       if( volume->type == k_volume_subtype_trigger ){
          v3f local;
          m4x3_mulv( volume->to_local, pos, local );
-         vg_line_boxf_transformed( volume->to_world, cube, 0xff00ff00 );
 
          if( (fabsf(local[0]) <= 1.0f) &&
              (fabsf(local[1]) <= 1.0f) &&
              (fabsf(local[2]) <= 1.0f) )
          {
             in_volume = 1;
+            vg_line_boxf_transformed( volume->to_world, cube, 0xff00ff00 );
 
             if( !world_global.in_volume ){
                ent_call basecall;
@@ -710,6 +740,8 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
                entity_call( world, &basecall );
             }
          }
+         else
+            vg_line_boxf_transformed( volume->to_world, cube, 0xff0000ff );
       }
       else if( volume->type == k_volume_subtype_particle ){
          vg_line_boxf_transformed( volume->to_world, cube, 0xff00c0ff );
index fac1fe7ebb602dbffac6088bb4101d2a3474e075..500592d27eec550986eaab15d2e39cfc11893149 100644 (file)
@@ -356,7 +356,7 @@ VG_STATIC void world_compute_light_indices( world_instance *world )
    int total_cubes = icubes_count[0]*icubes_count[1]*icubes_count[2];
 
    u32 *cubes_index = vg_linear_alloc( world_global.generic_heap, 
-                                       total_cubes * sizeof(u32) * 2.0f );
+                                       vg_align8(total_cubes*sizeof(u32)*2) );
                                        
    vg_info( "Computing light cubes (%d) [%f %f %f] -> [%f %f %f]\n", 
              total_cubes, cubes_min[0], -cubes_min[2], cubes_min[1],
@@ -626,7 +626,7 @@ VG_STATIC void world_process_resources( world_instance *world )
 
    world->texture_count = world->meta.textures.count+1;
    world->textures = vg_linear_alloc( world_global.generic_heap,
-                                      sizeof(GLuint)*world->texture_count );
+                              vg_align8(sizeof(GLuint)*world->texture_count) );
 
    vg_acquire_thread_sync();
    {
@@ -660,7 +660,7 @@ VG_STATIC void world_process_resources( world_instance *world )
 
    world->surface_count = world->meta.materials.count+1;
    world->surfaces = vg_linear_alloc( world_global.generic_heap,
-                           sizeof(struct world_surface)*world->surface_count );
+               vg_align8(sizeof(struct world_surface)*world->surface_count) );
 
    /* error material */
    struct world_surface *errmat = &world->surfaces[0];
@@ -796,7 +796,7 @@ VG_STATIC void world_entities_init( world_instance *world )
    for( u32 j=0; j<mdl_arrcount(&world->ent_volume); j++ ){
       ent_volume *volume = mdl_arritm( &world->ent_volume, j );
       mdl_transform_m4x3( &volume->transform, volume->to_world );
-      m4x3_invert_affine( volume->to_world, volume->to_local );
+      m4x3_invert_full( volume->to_world, volume->to_local );
    }
 
    /* audio packs */