From: hgn Date: Sun, 2 Apr 2023 14:57:21 +0000 (+0100) Subject: right hand yellow X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=8f83be5a31728cd6bf95020e729367cc44308763;hp=5f01e7ab4aad052faad262b55404819dac3d25ce;p=carveJwlIkooP6JGAAIwe30JlM.git right hand yellow --- diff --git a/blender_export.py b/blender_export.py index 0d4c63a..dcab66f 100644 --- a/blender_export.py +++ b/blender_export.py @@ -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 23f8a56..b054741 100644 --- 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; icount; i++ ) - { + for( u32 i=0; icount; 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; icount; i++ ) - { + if( bh->system->item_debug ){ + for( u32 i=0; icount; 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; icount; i++ ) - { + if( ray_aabb1( inode->bbx, co, dir_inv, hit->dist ) ){ + if( inode->count ){ + for( u32 i=0; icount; 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; icount; i++ ) - { + if( node_dist < max_dist ){ + if( inode->count ){ + for( int i=0; icount; 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; diff --git a/maps_src/mp_gridmap.mdl b/maps_src/mp_gridmap.mdl index 18f438e..a1c0ef4 100644 Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ diff --git a/player_skate.c b/player_skate.c index 0362386..c18df21 100644 --- a/player_skate.c +++ b/player_skate.c @@ -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 81d00c3..74c4ea6 100644 --- 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; diff --git a/skaterift.c b/skaterift.c index 67e87cc..795ca58 100644 --- a/skaterift.c +++ b/skaterift.c @@ -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" ); diff --git a/sound_src/docks_generic.ogg b/sound_src/docks_generic.ogg index e223c72..526f213 100644 Binary files a/sound_src/docks_generic.ogg and b/sound_src/docks_generic.ogg differ diff --git a/sound_src/field_generic.ogg b/sound_src/field_generic.ogg index ed6165d..79b02ab 100644 Binary files a/sound_src/field_generic.ogg and b/sound_src/field_generic.ogg differ diff --git a/sound_src/town_generic.ogg b/sound_src/town_generic.ogg index 6f72ccc..a0f565b 100644 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 997ff31..e23ae21 100644 --- 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; iclip_count; i++ ){ - ent_audio_clip *clip = mdl_arritm( &world->ent_audio_clip, - audio->clip_start+i ); + for( u32 i=0; iclip_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 ); diff --git a/world_gen.h b/world_gen.h index fac1fe7..500592d 100644 --- a/world_gen.h +++ b/world_gen.h @@ -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; jent_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 */