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
+++ /dev/null
-/*
- * 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 */
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 );
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];
/*
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];
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 );
}
else{
player_friction( player->rb.v );
-
- struct world_surface *surf = world_contact_surface( world, manifold );
- w->surface = surf->info.surface_prop;
}
}
else{
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,
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,
w->walk_timer += walk_adv * vg.time_delta;
}
- else
- {
+ else{
w->walk_timer = 0.0f;
}
"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 )
{
move_speed,
walk_timer;
+
+ int step_phase;
};
VG_STATIC void player__walk_pre_update ( player_instance *player );
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];
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;
}
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];
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;
}
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" );
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;
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] );
}
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 );
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];
}
}
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;
}
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;
}