From 22f62f001f21d1b91fefd9fc495c122d9ddf205a Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 29 Sep 2023 13:29:11 +0100 Subject: [PATCH] refactor (reduction) --- addon.c | 20 +- addon.h | 8 +- audio.h | 10 +- bvh.h | 26 +- camera.h | 18 +- ent_challenge.c | 6 +- ent_challenge.h | 4 +- ent_objective.c | 8 +- ent_relay.c | 2 +- ent_skateshop.c | 40 +- ent_skateshop.h | 4 +- entity.c | 2 +- entity.h | 4 +- font.h | 20 +- gui.h | 12 +- highscores.c | 42 +- highscores.h | 22 +- menu.h | 6 +- model.h | 56 +- network.c | 33 +- network.h | 18 +- network_msg.h | 2 +- player.c | 182 ++--- player.h | 165 ++-- player_api.h | 2 +- player_common.c | 154 ++-- player_common.h | 14 +- player_dead.c | 72 +- player_dead.h | 29 +- player_drive.c | 64 +- player_drive.h | 36 +- player_ragdoll.c | 16 +- player_ragdoll.h | 20 +- player_render.c | 164 ++-- player_render.h | 16 +- player_replay.c | 52 +- player_replay.h | 22 +- player_skate.c | 1718 ++++++++++++++++++++-------------------- player_skate.h | 93 +-- player_walk.c | 460 ++++++----- player_walk.h | 48 +- render.h | 42 +- respawn.c | 20 +- respawn.h | 4 +- rigidbody.h | 102 +-- scene.h | 38 +- servermonitor_client.c | 18 +- skaterift.c | 59 +- skaterift_imgui_dev.c | 20 +- skeleton.h | 44 +- steam.h | 36 +- vehicle.c | 12 +- vehicle.h | 14 +- workshop.c | 70 +- workshop.h | 8 +- world.c | 2 +- world_audio.c | 6 +- world_audio.h | 6 +- world_entity.c | 36 +- world_entity.h | 34 +- world_gate.c | 20 +- world_gate.h | 18 +- world_gen.c | 18 +- world_gen.h | 10 +- world_load.c | 4 +- world_physics.c | 12 +- world_physics.h | 12 +- world_render.c | 66 +- world_render.h | 18 +- world_routes.c | 48 +- world_routes.h | 18 +- world_sfd.c | 12 +- world_sfd.h | 4 +- world_water.c | 16 +- world_water.h | 8 +- 75 files changed, 2209 insertions(+), 2336 deletions(-) diff --git a/addon.c b/addon.c index 67f2f6b..7e03050 100644 --- a/addon.c +++ b/addon.c @@ -123,7 +123,7 @@ static void addon_system_init( void ){ /* * Reciever for scan completion. copies the registry counts back into main fred */ -VG_STATIC void async_addon_reg_update( void *data, u32 size ) +static void async_addon_reg_update( void *data, u32 size ) { vg_info( "Registry update notify\n" ); @@ -137,7 +137,7 @@ VG_STATIC void async_addon_reg_update( void *data, u32 size ) } } -VG_STATIC void addon_set_foldername( addon_reg *reg, const char name[64] ){ +static void addon_set_foldername( addon_reg *reg, const char name[64] ){ vg_strncpy( name, reg->alias.foldername, 64, k_strncpy_always_add_null ); reg->foldername_hash = vg_strdjb2( reg->alias.foldername ); } @@ -145,7 +145,7 @@ VG_STATIC void addon_set_foldername( addon_reg *reg, const char name[64] ){ /* * Create a new registry */ -VG_STATIC addon_reg *addon_alloc_reg( PublishedFileId_t workshop_id, +static addon_reg *addon_alloc_reg( PublishedFileId_t workshop_id, enum addon_type type ){ if( addon_system.registry_count == ADDON_MOUNTED_MAX ){ vg_error( "You have too many addons installed!\n" ); @@ -171,7 +171,7 @@ VG_STATIC addon_reg *addon_alloc_reg( PublishedFileId_t workshop_id, /* * If the addon.inf exists int the folder, load into the reg */ -VG_STATIC int addon_try_load_metadata( addon_reg *reg, vg_str folder_path ){ +static int addon_try_load_metadata( addon_reg *reg, vg_str folder_path ){ vg_str meta_path = folder_path; vg_strcat( &meta_path, "/addon.inf" ); if( !vg_strgood( &meta_path ) ){ @@ -198,7 +198,7 @@ VG_STATIC int addon_try_load_metadata( addon_reg *reg, vg_str folder_path ){ return 1; } -VG_STATIC void addon_print_info( addon_reg *reg ){ +static void addon_print_info( addon_reg *reg ){ vg_info( "addon_reg #%u{\n", addon_system.registry_count ); vg_info( " type: %d\n", reg->alias.type ); vg_info( " workshop_id: " PRINTF_U64 "\n", reg->alias.workshop_id ); @@ -208,7 +208,7 @@ VG_STATIC void addon_print_info( addon_reg *reg ){ vg_info( "}\n" ); } -VG_STATIC void addon_mount_finish( addon_reg *reg ){ +static void addon_mount_finish( addon_reg *reg ){ #if 0 addon_print_info( reg ); #endif @@ -218,7 +218,7 @@ VG_STATIC void addon_mount_finish( addon_reg *reg ){ /* * Mount a fully packaged addon, one that certainly has a addon.inf */ -VG_STATIC addon_reg *addon_mount_workshop_folder( PublishedFileId_t workshop_id, +static addon_reg *addon_mount_workshop_folder( PublishedFileId_t workshop_id, vg_str folder_path ) { addon_reg *reg = addon_alloc_reg( workshop_id, k_addon_type_none ); @@ -252,7 +252,7 @@ VG_STATIC addon_reg *addon_mount_workshop_folder( PublishedFileId_t workshop_id, /* * Mount a local folder. may or may not have addon.inf */ -VG_STATIC addon_reg *addon_mount_local_addon( const char *folder, +static addon_reg *addon_mount_local_addon( const char *folder, enum addon_type type, const char *content_ext ) { @@ -331,7 +331,7 @@ VG_STATIC addon_reg *addon_mount_local_addon( const char *folder, /* * Check all subscribed items */ -VG_STATIC void addon_mount_workshop_items(void){ +static void addon_mount_workshop_items(void){ if( !steam_ready ) return; /* * Steam workshop scan @@ -383,7 +383,7 @@ next_file_workshop:; * Scan a local content folder for addons. It must find at least one file with * the specified content_ext to be considered. */ -VG_STATIC void addon_mount_content_folder( enum addon_type type, +static void addon_mount_content_folder( enum addon_type type, const char *base_folder, const char *content_ext ) { diff --git a/addon.h b/addon.h index 6dda8a8..6daf8c8 100644 --- a/addon.h +++ b/addon.h @@ -80,12 +80,12 @@ static int addon_get_content_folder( addon_reg *reg, vg_str *folder ); /* scanning routines */ static u32 addon_match( addon_alias *alias ); static void addon_alias_uid( addon_alias *alias, char buf[76] ); -VG_STATIC void addon_mount_content_folder( enum addon_type type, +static void addon_mount_content_folder( enum addon_type type, const char *base_folder, const char *content_ext ); -VG_STATIC void addon_mount_workshop_items(void); -VG_STATIC void async_addon_reg_update( void *data, u32 size ); -VG_STATIC addon_reg *addon_mount_local_addon( const char *folder, +static void addon_mount_workshop_items(void); +static void async_addon_reg_update( void *data, u32 size ); +static addon_reg *addon_mount_local_addon( const char *folder, enum addon_type type, const char *content_ext ); static u16 addon_cache_fetch( enum addon_type type, u32 reg_index ); diff --git a/audio.h b/audio.h index 79fcc58..dbd6fc7 100644 --- a/audio.h +++ b/audio.h @@ -138,7 +138,7 @@ audio_clip audio_challenge[] = { { .path = "sound/objective_fail.ogg" } }; -VG_STATIC void audio_init(void) +static void audio_init(void) { audio_clip_loadn( audio_board, vg_list_size(audio_board), NULL ); audio_clip_loadn( audio_taps, vg_list_size(audio_taps), NULL ); @@ -168,7 +168,7 @@ VG_STATIC void audio_init(void) audio_unlock(); } -VG_STATIC void audio_free(void) +static void audio_free(void) { /* TODO! */ vg_warn( "UNIMPLEMENTED: audio_free()\n" ); @@ -181,7 +181,7 @@ enum audio_sprite_type k_audio_sprite_type_water }; -VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip ) +static void audio_ambient_sprite_play( v3f co, audio_clip *clip ) { audio_lock(); u16 group_id = 0xfff0; @@ -197,9 +197,9 @@ VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip ) audio_unlock(); } -VG_STATIC +static enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output); -VG_STATIC void audio_ambient_sprites_update( world_instance *world, v3f co ) +static void audio_ambient_sprites_update( world_instance *world, v3f co ) { static float accum = 0.0f; accum += vg.time_delta; diff --git a/bvh.h b/bvh.h index 0865ee7..945d3cb 100644 --- a/bvh.h +++ b/bvh.h @@ -21,8 +21,8 @@ * system: the system we created above which will deal with the data * * call bh_create( bh_tree *bh, u32 item_count ) - * VG_STATIC int bh_ray( bh_tree *bh, u32 inode, v3f co, v3f dir, ray_hit *hit ) - * VG_STATIC int bh_select( bh_tree *bh, boxf box, u32 *buffer, int len ) + * static int bh_ray( bh_tree *bh, u32 inode, v3f co, v3f dir, ray_hit *hit ) + * static int bh_select( bh_tree *bh, boxf box, u32 *buffer, int len ) */ typedef struct bh_node bh_node; @@ -71,7 +71,7 @@ struct bh_system{ int (*cast_ray)( void *user, u32 index, v3f co, v3f dir, ray_hit *hit ); }; -VG_STATIC void bh_update_bounds( bh_tree *bh, u32 inode ){ +static void bh_update_bounds( bh_tree *bh, u32 inode ){ bh_node *node = &bh->nodes[ inode ]; box_init_inf( node->bbx ); @@ -81,7 +81,7 @@ VG_STATIC void bh_update_bounds( bh_tree *bh, u32 inode ){ } } -VG_STATIC void bh_subdivide( bh_tree *bh, u32 inode ){ +static void bh_subdivide( bh_tree *bh, u32 inode ){ bh_node *node = &bh->nodes[ inode ]; if( node->count <= bh->max_per_leaf ) @@ -141,7 +141,7 @@ VG_STATIC void bh_subdivide( bh_tree *bh, u32 inode ){ bh_subdivide( bh, ir ); } -VG_STATIC bh_tree *bh_create( void *lin_alloc, bh_system *system, +static bh_tree *bh_create( void *lin_alloc, bh_system *system, void *user, u32 item_count, u32 max_per_leaf ){ assert( max_per_leaf > 0 ); @@ -177,7 +177,7 @@ VG_STATIC bh_tree *bh_create( void *lin_alloc, bh_system *system, * Draw items in this leaf node. * *item_debug() must be set! */ -VG_STATIC void bh_debug_leaf( bh_tree *bh, bh_node *node ){ +static void bh_debug_leaf( bh_tree *bh, bh_node *node ){ vg_line_boxf( node->bbx, 0xff00ff00 ); if( bh->system->item_debug ){ @@ -191,7 +191,7 @@ VG_STATIC void bh_debug_leaf( bh_tree *bh, bh_node *node ){ /* * Trace the bh tree all the way down to the leaf nodes where pos is inside */ -VG_STATIC void bh_debug_trace( bh_tree *bh, u32 inode, v3f pos, u32 colour ){ +static void bh_debug_trace( bh_tree *bh, u32 inode, v3f pos, u32 colour ){ bh_node *node = &bh->nodes[ inode ]; if( (pos[0] >= node->bbx[0][0] && pos[0] <= node->bbx[1][0]) && @@ -246,21 +246,21 @@ struct bh_iter{ i32 depth, i; }; -VG_STATIC void bh_iter_init_generic( i32 root, bh_iter *it ){ +static void bh_iter_init_generic( i32 root, bh_iter *it ){ it->stack[0].id = root; it->stack[0].depth = 0; it->depth = 0; it->i = 0; } -VG_STATIC void bh_iter_init_box( i32 root, bh_iter *it, boxf box ){ +static void bh_iter_init_box( i32 root, bh_iter *it, boxf box ){ bh_iter_init_generic( root, it ); it->query = k_bh_query_box; box_copy( box, it->box.box ); } -VG_STATIC void bh_iter_init_ray( i32 root, bh_iter *it, v3f co, +static void bh_iter_init_ray( i32 root, bh_iter *it, v3f co, v3f dir, f32 max_dist ){ bh_iter_init_generic( root, it ); it->query = k_bh_query_ray; @@ -270,7 +270,7 @@ VG_STATIC void bh_iter_init_ray( i32 root, bh_iter *it, v3f co, it->ray.max_dist = max_dist; } -VG_STATIC void bh_iter_init_range( i32 root, bh_iter *it, v3f co, f32 range ){ +static void bh_iter_init_range( i32 root, bh_iter *it, v3f co, f32 range ){ bh_iter_init_generic( root, it ); it->query = k_bh_query_range; @@ -283,7 +283,7 @@ VG_STATIC void bh_iter_init_range( i32 root, bh_iter *it, v3f co, f32 range ){ * * this is like a 'broad phase only' deal. */ -VG_STATIC i32 bh_next( bh_tree *bh, bh_iter *it, i32 *em ){ +static i32 bh_next( bh_tree *bh, bh_iter *it, i32 *em ){ while( it->depth >= 0 ){ bh_node *inode = &bh->nodes[ it->stack[it->depth].id ]; @@ -339,7 +339,7 @@ VG_STATIC i32 bh_next( bh_tree *bh, bh_iter *it, i32 *em ){ return 0; } -VG_STATIC int bh_closest_point( bh_tree *bh, v3f pos, +static int bh_closest_point( bh_tree *bh, v3f pos, v3f closest, float max_dist ) { if( bh->node_count < 2 ) diff --git a/camera.h b/camera.h index 6374393..c1744d8 100644 --- a/camera.h +++ b/camera.h @@ -23,13 +23,13 @@ struct camera{ mtx_prev; }; -VG_STATIC void camera_lerp_angles( v3f a, v3f b, float t, v3f d ){ +static void camera_lerp_angles( v3f a, v3f b, float t, v3f d ){ d[0] = vg_alerpf( a[0], b[0], t ); d[1] = vg_lerpf( a[1], b[1], t ); d[2] = vg_lerpf( a[2], b[2], t ); } -VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d ){ +static void camera_lerp( camera *a, camera *b, float t, camera *d ){ v3_lerp( a->pos, b->pos, t, d->pos ); d->angles[0] = vg_alerpf( a->angles[0], b->angles[0], t ); d->angles[1] = vg_lerpf( a->angles[1], b->angles[1], t ); @@ -37,7 +37,7 @@ VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d ){ d->fov = vg_lerpf( a->fov, b->fov, t ); } -VG_STATIC void camera_copy( camera *a, camera *d ){ +static void camera_copy( camera *a, camera *d ){ v3_copy( a->pos, d->pos ); v3_copy( a->angles, d->angles ); d->fov = a->fov; @@ -46,7 +46,7 @@ VG_STATIC void camera_copy( camera *a, camera *d ){ /* * 1) [angles, pos] -> transform */ -VG_STATIC void camera_update_transform( camera *cam ) +static void camera_update_transform( camera *cam ) { v4f qyaw, qpitch, qcam; q_axis_angle( qyaw, (v3f){ 0.0f, 1.0f, 0.0f }, -cam->angles[0] ); @@ -60,7 +60,7 @@ VG_STATIC void camera_update_transform( camera *cam ) /* * 2) [transform] -> transform_inverse, view matrix */ -VG_STATIC void camera_update_view( camera *cam ) +static void camera_update_view( camera *cam ) { m4x4_copy( cam->mtx.v, cam->mtx_prev.v ); m4x3_invert_affine( cam->transform, cam->transform_inverse ); @@ -70,7 +70,7 @@ VG_STATIC void camera_update_view( camera *cam ) /* * 3) [fov,nearz,farz] -> projection matrix */ -VG_STATIC void camera_update_projection( camera *cam ) +static void camera_update_projection( camera *cam ) { m4x4_copy( cam->mtx.p, cam->mtx_prev.p ); m4x4_projection( cam->mtx.p, cam->fov, @@ -81,7 +81,7 @@ VG_STATIC void camera_update_projection( camera *cam ) /* * 4) [projection matrix, view matrix] -> previous pv, new pv */ -VG_STATIC void camera_finalize( camera *cam ) +static void camera_finalize( camera *cam ) { m4x4_copy( cam->mtx.pv, cam->mtx_prev.pv ); m4x4_mul( cam->mtx.p, cam->mtx.v, cam->mtx.pv ); @@ -90,7 +90,7 @@ VG_STATIC void camera_finalize( camera *cam ) /* * http://www.terathon.com/lengyel/Lengyel-Oblique.pdf */ -VG_STATIC void m4x4_clip_projection( m4x4f mat, v4f plane ) +static void m4x4_clip_projection( m4x4f mat, v4f plane ) { v4f c = { @@ -111,7 +111,7 @@ VG_STATIC void m4x4_clip_projection( m4x4f mat, v4f plane ) /* * Undoes the above operation */ -VG_STATIC void m4x4_reset_clipping( m4x4f mat, float ffar, float fnear ) +static void m4x4_reset_clipping( m4x4f mat, float ffar, float fnear ) { mat[0][2] = 0.0f; mat[1][2] = 0.0f; diff --git a/ent_challenge.c b/ent_challenge.c index e6c543b..02fac7d 100644 --- a/ent_challenge.c +++ b/ent_challenge.c @@ -6,7 +6,7 @@ #include "gui.h" #include "audio.h" -VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){ +static void ent_challenge_call( world_instance *world, ent_call *call ){ u32 index = mdl_entity_id_id( call->id ); ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index ); @@ -35,7 +35,7 @@ VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){ } } -VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge, int active ){ +static void ent_challenge_preupdate( ent_challenge *challenge, int active ){ world_instance *world = world_current_instance(); /* maximum distance from active challenge */ @@ -119,7 +119,7 @@ VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge, int active ){ } } -VG_STATIC void ent_challenge_render( ent_challenge *challenge ){ +static void ent_challenge_render( ent_challenge *challenge ){ } diff --git a/ent_challenge.h b/ent_challenge.h index 0d185f9..a3cd92a 100644 --- a/ent_challenge.h +++ b/ent_challenge.h @@ -3,7 +3,7 @@ #include "entity.h" -VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge, int active ); -VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ); +static void ent_challenge_preupdate( ent_challenge *challenge, int active ); +static void ent_challenge_call( world_instance *world, ent_call *call ); #endif /* ENT_CHALLENGE_H */ diff --git a/ent_objective.c b/ent_objective.c index d516e27..0cf5790 100644 --- a/ent_objective.c +++ b/ent_objective.c @@ -7,7 +7,7 @@ #include "audio.h" #include "steam.h" -VG_STATIC void ent_objective_pass( world_instance *world, +static void ent_objective_pass( world_instance *world, ent_objective *objective ){ if( objective->id_next ){ world_static.challenge_timer += objective->filter; @@ -60,9 +60,9 @@ VG_STATIC void ent_objective_pass( world_instance *world, } } -VG_STATIC int ent_objective_check_filter( ent_objective *objective ){ +static int ent_objective_check_filter( ent_objective *objective ){ if( objective->filter ){ - struct player_skate_state *s = &localplayer._skate.state; + struct player_skate_state *s = &player_skate.state; enum trick_type trick = s->trick_type; u32 state = 0x00; @@ -93,7 +93,7 @@ VG_STATIC int ent_objective_check_filter( ent_objective *objective ){ } } -VG_STATIC void ent_objective_call( world_instance *world, ent_call *call ){ +static void ent_objective_call( world_instance *world, ent_call *call ){ u32 index = mdl_entity_id_id( call->id ); ent_objective *objective = mdl_arritm( &world->ent_objective, index ); diff --git a/ent_relay.c b/ent_relay.c index 60144ab..357031b 100644 --- a/ent_relay.c +++ b/ent_relay.c @@ -3,7 +3,7 @@ #include "entity.h" -VG_STATIC void ent_relay_call( world_instance *world, ent_call *call ){ +static void ent_relay_call( world_instance *world, ent_call *call ){ u32 index = mdl_entity_id_id( call->id ); ent_relay *relay = mdl_arritm( &world->ent_relay, index ); diff --git a/ent_skateshop.c b/ent_skateshop.c index 2815482..a4cfe22 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -27,7 +27,7 @@ static inline int const_str_eq( u32 hash, const char *str, const char *cmp ) return 0; } -VG_STATIC void skateshop_update_viewpage(void){ +static void skateshop_update_viewpage(void){ u32 page = global_skateshop.selected_board_id/SKATESHOP_VIEW_SLOT_MAX; for( u32 i=0; ient_marker, @@ -645,7 +645,7 @@ VG_STATIC void skateshop_render_worldshop( ent_skateshop *shop ){ /* * World: render event */ -VG_STATIC void skateshop_render( ent_skateshop *shop ){ +static void skateshop_render( ent_skateshop *shop ){ if( shop->type == k_skateshop_type_boardshop ) skateshop_render_boardshop( shop ); else if( shop->type == k_skateshop_type_charshop ) @@ -659,7 +659,7 @@ VG_STATIC void skateshop_render( ent_skateshop *shop ){ /* * Entity logic: entrance event */ -VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ){ +static void ent_skateshop_call( world_instance *world, ent_call *call ){ u32 index = mdl_entity_id_id( call->id ); ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index ); vg_info( "skateshop_call\n" ); diff --git a/ent_skateshop.h b/ent_skateshop.h index e12edb1..3866021 100644 --- a/ent_skateshop.h +++ b/ent_skateshop.h @@ -41,7 +41,7 @@ struct{ } static global_skateshop={.render={.reg_id=0xffffffff,.world_reg=0xffffffff}}; -VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop, int active ); -VG_STATIC void skateshop_render( ent_skateshop *shop ); +static void ent_skateshop_preupdate( ent_skateshop *shop, int active ); +static void skateshop_render( ent_skateshop *shop ); #endif /* ENT_SKATESHOP_H */ diff --git a/entity.c b/entity.c index 82c3ecd..21815f4 100644 --- a/entity.c +++ b/entity.c @@ -12,7 +12,7 @@ typedef void (*fn_entity_call_handler)( world_instance *, ent_call *); -VG_STATIC void entity_call( world_instance *world, ent_call *call ){ +static void entity_call( world_instance *world, ent_call *call ){ u32 type = mdl_entity_id_type( call->id ); fn_entity_call_handler table[] = { diff --git a/entity.h b/entity.h index 06b2c6e..22ee913 100644 --- a/entity.h +++ b/entity.h @@ -370,7 +370,7 @@ struct ent_worldinfo{ f32 timezone; }; -VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl, +static ent_marker *ent_find_marker( mdl_context *mdl, mdl_array_ptr *arr, const char *alias ) { for( u32 i=0; imdl, mdl_path, alloc ); mdl_load_metadata_block( &font->mdl, alloc ); @@ -99,13 +99,13 @@ VG_STATIC void font3d_load( font3d *font, const char *mdl_path, void *alloc ) mdl_close( &font->mdl ); } -VG_STATIC void font3d_init(void) +static void font3d_init(void) { shader_model_font_register(); shader_scene_font_register(); } -VG_STATIC u32 font3d_find_variant( font3d *font, const char *name ) +static u32 font3d_find_variant( font3d *font, const char *name ) { for( u32 i=0; ifont_variants ); i ++ ){ ent_font_variant *variant = mdl_arritm( &font->font_variants, i ); @@ -118,7 +118,7 @@ VG_STATIC u32 font3d_find_variant( font3d *font, const char *name ) return 0; } -VG_STATIC void font3d_bind( font3d *font, camera *cam ) +static void font3d_bind( font3d *font, camera *cam ) { shader_model_font_use(); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); @@ -130,7 +130,7 @@ VG_STATIC void font3d_bind( font3d *font, camera *cam ) mesh_bind( &font->mesh ); } -VG_STATIC ent_glyph *font3d_glyph( font3d *font, u32 variant_id, u32 utf32 ) +static ent_glyph *font3d_glyph( font3d *font, u32 variant_id, u32 utf32 ) { if( utf32 < font->info.glyph_utf32_base ) return NULL; if( utf32 >= font->info.glyph_utf32_base+font->info.glyph_count) return NULL; @@ -154,7 +154,7 @@ struct font3d_render{ shader; }; -VG_STATIC +static void font3d_begin( const char *text, camera *cam, m4x3f transform, struct font3d_render *render ) { @@ -176,14 +176,14 @@ void font3d_begin( const char *text, render->u8pch = (u8*)text; } -VG_STATIC void font3d_setoffset( struct font3d_render *render, v4f offset ){ +static void font3d_setoffset( struct font3d_render *render, v4f offset ){ if( render->shader == k_font_shader_default ) shader_model_font_uOffset( offset ); else if( render->shader == k_font_shader_world ) shader_scene_font_uOffset( offset ); } -VG_STATIC void font3d_draw( struct font3d_render *render ) +static void font3d_draw( struct font3d_render *render ) { u32 max_chars = 512; while( render->u8pch && max_chars ){ @@ -257,7 +257,7 @@ VG_STATIC void font3d_draw( struct font3d_render *render ) render->u8pch = NULL; } -VG_STATIC +static float font3d_simple_draw( font3d *font, u32 variant_id, enum font_shader shader, const char *text, camera *cam, m4x3f transform ) @@ -275,7 +275,7 @@ float font3d_simple_draw( font3d *font, u32 variant_id, enum font_shader shader, return render.offset[0]; } -VG_STATIC +static float font3d_string_width( font3d *font, u32 variant_id, const char *text ) { if( !text ) return 0.0f; diff --git a/gui.h b/gui.h index 433ba83..18b3dbd 100644 --- a/gui.h +++ b/gui.h @@ -54,7 +54,7 @@ struct{ } static gui; -VG_STATIC +static void gui_helper_action( const char *bindstr, const char *text ){ if( gui.helper_count >= vg_list_size(gui.helpers) ){ vg_error( "Too many helpers\n" ); @@ -66,7 +66,7 @@ void gui_helper_action( const char *bindstr, const char *text ){ helper->text = text; } -VG_STATIC +static void gui_draw(void) { if( v3_dist2(localplayer.rb.co,gui.trick_co) > 2.0f ){ @@ -232,7 +232,7 @@ void gui_draw(void) gui.helper_count = 0; } -VG_STATIC +static int gui_location_print_ccmd( int argc, const char *argv[] ){ if( argc > 0 ){ char new_loc[64]; @@ -249,7 +249,7 @@ int gui_location_print_ccmd( int argc, const char *argv[] ){ return 0; } -VG_STATIC int gui_showtrick_ccmd( int argc, const char *argv[] ){ +static int gui_showtrick_ccmd( int argc, const char *argv[] ){ if( argc == 1 ){ enum guitrick_type type = k_guitrick_type_none; if( !strcmp( argv[0], "pump" ) ) type = k_guitrick_type_pump; @@ -265,7 +265,7 @@ VG_STATIC int gui_showtrick_ccmd( int argc, const char *argv[] ){ return 1; } -VG_STATIC void gui_draw_icon( enum gui_icon icon, v2f co, f32 size ){ +static void gui_draw_icon( enum gui_icon icon, v2f co, f32 size ){ if( gui.icon_draw_count == vg_list_size(gui.icon_draw_buffer) ) return; @@ -289,7 +289,7 @@ static mdl_submesh *gui_find_icon( const char *name ){ return NULL; } -VG_STATIC void gui_init(void){ +static void gui_init(void){ font3d_load( &gui.font, "models/rs_font.mdl", vg_mem.rtmemory ); vg_console_reg_cmd( "gui_location", gui_location_print_ccmd, NULL ); vg_console_reg_cmd( "showtrick", gui_showtrick_ccmd, NULL ); diff --git a/highscores.c b/highscores.c index 6593b9a..d1866ae 100644 --- a/highscores.c +++ b/highscores.c @@ -3,13 +3,13 @@ #include "highscores.h" -VG_STATIC int highscore_cmp_points( void *a, void *b ) +static int highscore_cmp_points( void *a, void *b ) { highscore_record *pa = a, *pb = b; return (int)pa->points - (int)pb->points; } -VG_STATIC int highscore_cmp_datetime( void *a, void *b ) +static int highscore_cmp_datetime( void *a, void *b ) { highscore_record *pa = a, *pb = b; @@ -17,27 +17,27 @@ VG_STATIC int highscore_cmp_datetime( void *a, void *b ) return pa->datetime < pb->datetime? 1: -1; } -VG_STATIC int highscore_cmp_time( void *a, void *b ) +static int highscore_cmp_time( void *a, void *b ) { highscore_record *pa = a, *pb = b; return (int)pb->time - (int)pa->time; } -VG_STATIC int highscore_cmp_playerid( void *a, void *b ) +static int highscore_cmp_playerid( void *a, void *b ) { highscore_record *pa = a, *pb = b; if( pa->playerid == pb->playerid ) return 0; return pa->playerid < pb->playerid? -1: 1; } -VG_STATIC int highscore_cmp_playerinfo_playerid( void *a, void *b ) +static int highscore_cmp_playerinfo_playerid( void *a, void *b ) { highscore_playerinfo *pa = a, *pb = b; if( pa->playerid == pb->playerid ) return 0; return pa->playerid < pb->playerid? -1: 1; } -VG_STATIC void highscores_create_db(void) +static void highscores_create_db(void) { struct highscore_system *sys = &highscore_system; @@ -64,7 +64,7 @@ VG_STATIC void highscores_create_db(void) sys->dbheader.playerinfo_root = AATREE_PTR_NIL; } -VG_STATIC int highscores_read(void) +static int highscores_read(void) { struct highscore_system *sys = &highscore_system; @@ -111,7 +111,7 @@ VG_STATIC int highscores_read(void) } } -VG_STATIC void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) +static void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) { struct highscore_system *sys = &highscore_system; @@ -168,7 +168,7 @@ VG_STATIC void highscores_init( u32 pool_size, u32 playerinfo_pool_size ) sys->pool_size = pool_size; } -VG_STATIC int highscores_serialize_all(void) +static int highscores_serialize_all(void) { struct highscore_system *sys = &highscore_system; vg_info( "Serializing database\n" ); @@ -191,7 +191,7 @@ VG_STATIC int highscores_serialize_all(void) return 1; } -VG_STATIC highscore_record *highscore_find_user_record( u64 playerid, +static highscore_record *highscore_find_user_record( u64 playerid, u32 trackid ) { struct highscore_system *sys = &highscore_system; @@ -209,7 +209,7 @@ VG_STATIC highscore_record *highscore_find_user_record( u64 playerid, return aatree_get_data( &sys->aainfo_playerid, find ); } -VG_STATIC aatree_ptr highscores_push_record( highscore_record *record ) +static aatree_ptr highscores_push_record( highscore_record *record ) { struct highscore_system *sys = &highscore_system; @@ -278,7 +278,7 @@ VG_STATIC aatree_ptr highscores_push_record( highscore_record *record ) return index; } -VG_STATIC aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] ) +static aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] ) { char name[17]; for( int i=0; i<16; i++ ) @@ -328,7 +328,7 @@ VG_STATIC aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] ) } /* Get the length of a string, bounded by '\0' or len, whichever is first */ -VG_STATIC int highscore_strlen( const char *str, int len ) +static int highscore_strlen( const char *str, int len ) { int str_length; for( str_length=0; str_lengthfile ); vg_file_print_invalid( mdl->file ); @@ -281,7 +281,7 @@ VG_STATIC void mdl_load_fatal_corrupt( mdl_context *mdl ) * Model implementation */ -VG_STATIC u32 mdl_query_array_size( mdl_array *arr ) +static u32 mdl_query_array_size( mdl_array *arr ) { if( arr->item_count ){ u32 size = arr->item_size*arr->item_count; @@ -290,8 +290,8 @@ VG_STATIC u32 mdl_query_array_size( mdl_array *arr ) else return 0; } -VG_STATIC const char *mdl_pstr( mdl_context *mdl, u32 pstr ); -VG_STATIC +static const char *mdl_pstr( mdl_context *mdl, u32 pstr ); +static void mdl_fread_pack_file( mdl_context *mdl, mdl_file *info, void *dst ) { if( !info->pack_size ){ @@ -306,7 +306,7 @@ void mdl_fread_pack_file( mdl_context *mdl, mdl_file *info, void *dst ) } /* TODO: Rename these */ -VG_STATIC void mdl_load_array_file_buffer( mdl_context *mdl, mdl_array *arr, +static void mdl_load_array_file_buffer( mdl_context *mdl, mdl_array *arr, void *buffer ) { if( arr->item_count ){ @@ -317,7 +317,7 @@ VG_STATIC void mdl_load_array_file_buffer( mdl_context *mdl, mdl_array *arr, } } -VG_STATIC void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, +static void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, mdl_array *arr, void *lin_alloc ) { if( arr->item_count ){ @@ -332,17 +332,17 @@ VG_STATIC void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, ptr->stride = arr->item_size; } -VG_STATIC void *mdl_arritm( mdl_array_ptr *arr, u32 index ) +static void *mdl_arritm( mdl_array_ptr *arr, u32 index ) { return ((u8 *)arr->data) + index*arr->stride; } -VG_STATIC u32 mdl_arrcount( mdl_array_ptr *arr ) +static u32 mdl_arrcount( mdl_array_ptr *arr ) { return arr->count; } -VG_STATIC mdl_array *mdl_find_array( mdl_context *mdl, const char *name ) +static mdl_array *mdl_find_array( mdl_context *mdl, const char *name ) { for( u32 i=0; iindex); i++ ){ mdl_array *arr = mdl_arritm( &mdl->index, i ); @@ -355,7 +355,7 @@ VG_STATIC mdl_array *mdl_find_array( mdl_context *mdl, const char *name ) return NULL; } -VG_STATIC int mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr, +static int mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr, const char *name, void *lin_alloc ) { mdl_array *arr = mdl_find_array( mdl, name ); @@ -372,7 +372,7 @@ VG_STATIC int mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr, } } -VG_STATIC int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ) +static int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ) { int success = 1; @@ -382,7 +382,7 @@ VG_STATIC int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ) return success; } -VG_STATIC int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ) +static int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ) { int success = 1; @@ -398,7 +398,7 @@ VG_STATIC int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ) return success; } -VG_STATIC int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ) +static int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ) { return mdl_load_array( mdl, &mdl->keyframes, "mdl_keyframe", lin_alloc ); } @@ -406,7 +406,7 @@ VG_STATIC int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ) /* * if calling mdl_open, and the file does not exist, the game will fatal quit */ -VG_STATIC void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) +static void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) { memset( mdl, 0, sizeof( mdl_context ) ); mdl->file = fopen( path, "rb" ); @@ -438,7 +438,7 @@ VG_STATIC void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) /* * close file handle */ -VG_STATIC void mdl_close( mdl_context *mdl ) +static void mdl_close( mdl_context *mdl ) { fclose( mdl->file ); mdl->file = NULL; @@ -446,7 +446,7 @@ VG_STATIC void mdl_close( mdl_context *mdl ) /* useful things you can do with the model */ -VG_STATIC void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) +static void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) { q_m3x3( transform->q, mtx ); v3_muls( mtx[0], transform->s[0], mtx[0] ); @@ -455,13 +455,13 @@ VG_STATIC void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) v3_copy( transform->co, mtx[3] ); } -VG_STATIC const char *mdl_pstr( mdl_context *mdl, u32 pstr ) +static const char *mdl_pstr( mdl_context *mdl, u32 pstr ) { return ((char *)mdl_arritm( &mdl->strings, pstr )) + 4; } -VG_STATIC int +static int mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 ) { u32 hash = *((u32 *)mdl_arritm( &mdl->strings, pstr )); @@ -480,7 +480,7 @@ mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 ) * ---------------------------------------------------------------------------- */ -VG_STATIC void mesh_upload( glmesh *mesh, +static void mesh_upload( glmesh *mesh, mdl_vert *verts, u32 vert_count, u32 *indices, u32 indice_count ) { @@ -536,23 +536,23 @@ VG_STATIC void mesh_upload( glmesh *mesh, mesh->loaded = 1; } -VG_STATIC void mesh_bind( glmesh *mesh ) +static void mesh_bind( glmesh *mesh ) { glBindVertexArray( mesh->vao ); } -VG_STATIC void mesh_drawn( u32 start, u32 count ) +static void mesh_drawn( u32 start, u32 count ) { glDrawElements( GL_TRIANGLES, count, GL_UNSIGNED_INT, (void *)(start*sizeof(u32)) ); } -VG_STATIC void mesh_draw( glmesh *mesh ) +static void mesh_draw( glmesh *mesh ) { mesh_drawn( 0, mesh->indice_count ); } -VG_STATIC void mesh_free( glmesh *mesh ) +static void mesh_free( glmesh *mesh ) { if( mesh->loaded ){ glDeleteVertexArrays( 1, &mesh->vao ); @@ -562,12 +562,12 @@ VG_STATIC void mesh_free( glmesh *mesh ) } } -VG_STATIC void mdl_draw_submesh( mdl_submesh *sm ) +static void mdl_draw_submesh( mdl_submesh *sm ) { mesh_drawn( sm->indice_start, sm->indice_count ); } -VG_STATIC mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ) +static mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ) { for( u32 i=0; imeshs ); i++ ){ mdl_mesh *mesh = mdl_arritm( &mdl->meshs, i ); @@ -588,7 +588,7 @@ struct payload_glmesh_load{ glmesh *mesh; }; -VG_STATIC void async_mdl_load_glmesh( void *payload, u32 size ) +static void async_mdl_load_glmesh( void *payload, u32 size ) { struct payload_glmesh_load *job = payload; mesh_upload( job->mesh, job->verts, job->vertex_count, @@ -596,7 +596,7 @@ VG_STATIC void async_mdl_load_glmesh( void *payload, u32 size ) } /* TODO: Find out if this needs deprecating in favour of the new full loader */ -VG_STATIC void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh ) +static void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh ) { mdl_array *arr_vertices = mdl_find_array( mdl, "mdl_vert" ); mdl_array *arr_indices = mdl_find_array( mdl, "mdl_indice" ); @@ -654,7 +654,7 @@ VG_STATIC void mdl_async_load_glmesh( mdl_context *mdl, glmesh *mesh ) } /* uploads the glmesh, and textures. everything is saved into the mdl_context */ -VG_STATIC void mdl_async_full_load_std( mdl_context *mdl ){ +static void mdl_async_full_load_std( mdl_context *mdl ){ mdl_async_load_glmesh( mdl, &mdl->mesh ); for( u32 i=0; itextures ); i ++ ){ diff --git a/network.c b/network.c index ef7dee5..63b70c3 100644 --- a/network.c +++ b/network.c @@ -1,6 +1,9 @@ -VG_STATIC void scores_update(void); +#include "player.h" +#include "network.h" -VG_STATIC void on_auth_ticket_recieved( void *result, void *context ){ +static void scores_update(void); + +static void on_auth_ticket_recieved( void *result, void *context ){ EncryptedAppTicketResponse_t *response = result; if( response->m_eResult == k_EResultOK ){ @@ -23,7 +26,7 @@ VG_STATIC void on_auth_ticket_recieved( void *result, void *context ){ } } -VG_STATIC void request_auth_ticket(void){ +static void request_auth_ticket(void){ /* * TODO Check for one thats cached on the disk and load it. * This might be OK though because steam seems to cache the result @@ -38,7 +41,7 @@ VG_STATIC void request_auth_ticket(void){ SteamAPI_ISteamUser_RequestEncryptedAppTicket( hSteamUser, NULL, 0 ); } -VG_STATIC void send_auth_ticket(void){ +static void send_auth_ticket(void){ u32 size = sizeof(netmsg_auth) + network_client.app_key_length; netmsg_auth *auth = alloca(size); @@ -52,7 +55,7 @@ VG_STATIC void send_auth_ticket(void){ k_nSteamNetworkingSend_Reliable, NULL ); } -VG_STATIC void send_score_request(void){ +static void send_score_request(void){ vg_info( "Requesting scores\n" ); netmsg_scores_request req; req.inetmsg_id = k_inetmsg_scores_request; @@ -63,7 +66,7 @@ VG_STATIC void send_score_request(void){ k_nSteamNetworkingSend_Reliable, NULL ); } -VG_STATIC void send_score_update(void){ +static void send_score_update(void){ vg_info( "Sending scores\n" ); u32 size = sizeof(netmsg_set_score) + vg_list_size(track_infos)*sizeof(struct netmsg_score_record); @@ -104,7 +107,7 @@ VG_STATIC void send_score_update(void){ k_nSteamNetworkingSend_Reliable, NULL ); } -VG_STATIC void send_nickname(void){ +static void send_nickname(void){ netmsg_set_nickname nick; nick.inetmsg_id = k_inetmsg_set_nickname; @@ -131,7 +134,7 @@ static void network_send_playerframe(void){ k_nSteamNetworkingSend_Unreliable, NULL ); } -VG_STATIC void server_routine_update(void){ +static void server_routine_update(void){ if( network_client.name_update ) send_nickname(); @@ -139,7 +142,7 @@ VG_STATIC void server_routine_update(void){ send_score_request(); } -VG_STATIC void on_server_connect_status( CallbackMsg_t *msg ){ +static void on_server_connect_status( CallbackMsg_t *msg ){ SteamNetConnectionStatusChangedCallback_t *info = (void *)msg->m_pubParam; vg_info( " Connection status changed for %lu\n", info->m_hConn ); vg_info( " %s -> %s\n", @@ -158,7 +161,7 @@ VG_STATIC void on_server_connect_status( CallbackMsg_t *msg ){ } } -VG_STATIC void network_connect(void){ +static void network_connect(void){ /* Connect to server if not connected */ SteamNetworkingIPAddr remoteAddr; @@ -177,7 +180,7 @@ VG_STATIC void network_connect(void){ hSteamNetworkingSockets, &remoteAddr, 0, NULL ); } -VG_STATIC void on_inet_scoreboard( SteamNetworkingMessage_t *msg ){ +static void on_inet_scoreboard( SteamNetworkingMessage_t *msg ){ netmsg_scoreboard *sb = msg->m_pData; u32 base_size = sizeof(netmsg_scoreboard)- @@ -209,7 +212,7 @@ VG_STATIC void on_inet_scoreboard( SteamNetworkingMessage_t *msg ){ network_scores_updated = 1; } -VG_STATIC void poll_remote_connection(void){ +static void poll_remote_connection(void){ SteamNetworkingMessage_t *messages[32]; int len; @@ -239,7 +242,7 @@ VG_STATIC void poll_remote_connection(void){ } } -VG_STATIC void network_update(void){ +static void network_update(void){ if( !steam_ready ) return; @@ -276,7 +279,7 @@ VG_STATIC void network_update(void){ } } -VG_STATIC void network_init(void){ +static void network_init(void){ if( steam_ready ){ steam_register_callback( k_iSteamNetConnectionStatusChangedCallBack, on_server_connect_status ); @@ -284,7 +287,7 @@ VG_STATIC void network_init(void){ } } -VG_STATIC void network_end(void){ +static void network_end(void){ /* TODO: Send buffered highscores that were not already */ if( (network_client.state == k_ESteamNetworkingConnectionState_Connected) || (network_client.state == k_ESteamNetworkingConnectionState_Connecting) ) diff --git a/network.h b/network.h index 6121f0f..16594e8 100644 --- a/network.h +++ b/network.h @@ -11,7 +11,7 @@ #include "network_msg.h" #include "highscores.h" -VG_STATIC int network_scores_updated = 0; +static int network_scores_updated = 0; /* * Interface @@ -19,25 +19,24 @@ VG_STATIC int network_scores_updated = 0; //#define SR_USE_LOCALHOST /* Call it at start; Connects us to the gameserver */ -VG_STATIC void network_init(void); +static void network_init(void); /* Run this from main loop */ -VG_STATIC void network_update(void); +static void network_update(void); /* Call it at shutdown */ -VG_STATIC void network_end(void); +static void network_end(void); /* * Can buffer up a bunch of these by calling many times, they will be * sent at the next connection */ -VG_STATIC void network_submit_highscore( u32 trackid, u16 points, u16 time ); +static void network_submit_highscore( u32 trackid, u16 points, u16 time ); /* * Game endpoints are provided with the same names to allow running without a * network connection. */ -#ifdef SR_NETWORKED struct { u8 app_symmetric_key[ 1024 ]; @@ -58,11 +57,4 @@ static network_client = { .name_update = 1 }; -#else /* SR_NETWORKED */ - -VG_STATIC void network_init(void){} -VG_STATIC void network_update(void){} -VG_STATIC void network_end(void){} - -#endif /* SR_NETWORKED */ #endif /* NETWORK_H */ diff --git a/network_msg.h b/network_msg.h index 4b36a3e..495f4ae 100644 --- a/network_msg.h +++ b/network_msg.h @@ -75,7 +75,7 @@ struct netmsg_scoreboard } boards[ vg_list_size(track_infos) ]; } -VG_STATIC scoreboard_client_data = { +static scoreboard_client_data = { .inetmsg_id = k_inetmsg_scoreboard, .board_count = vg_list_size(track_infos) }; diff --git a/player.c b/player.c index c79132f..1cd1bec 100644 --- a/player.c +++ b/player.c @@ -9,8 +9,7 @@ #include "audio.h" #include "player_replay.h" -VG_STATIC int localplayer_cmd_respawn( int argc, const char *argv[] ) -{ +static int localplayer_cmd_respawn( int argc, const char *argv[] ){ ent_spawn *rp = NULL, *r; world_instance *world = localplayer.viewable_world; @@ -24,15 +23,15 @@ VG_STATIC int localplayer_cmd_respawn( int argc, const char *argv[] ) if( !rp ) return 0; - player__spawn( &localplayer, rp ); + player__spawn( rp ); return 1; } -VG_STATIC void player_init(void) -{ - for( u32 i=0; isystem_register ) sys->system_register(); } vg_console_reg_cmd( "respawn", localplayer_cmd_respawn, NULL ); @@ -49,9 +48,7 @@ VG_STATIC void player_init(void) k_var_dtype_i32, VG_VAR_PERSISTENT ); } -PLAYER_API -void player__debugtext( int size, const char *fmt, ... ) -{ +static void player__debugtext( int size, const char *fmt, ... ){ char buffer[ 1024 ]; va_list args; @@ -63,47 +60,26 @@ void player__debugtext( int size, const char *fmt, ... ) g_player_debugger[1] += size*16; } -/* - * Init - */ -PLAYER_API -void player__create( player_instance *inst ) -{ - static int only_once = 0; - assert( only_once == 0 ); - only_once ++; - - v3_zero( inst->rb.co ); - v3_zero( inst->rb.w ); - v3_zero( inst->rb.v ); - q_identity( inst->rb.q ); - m4x3_identity( inst->rb.to_world ); - m4x3_identity( inst->rb.to_local ); -} - /* * Appearence */ -PLAYER_API -void player__use_avatar( player_instance *player, struct player_avatar *av ) -{ - player->playeravatar = av; - player_setup_ragdoll_from_avatar( &player->ragdoll, av ); +static void player__use_avatar( struct player_avatar *av ){ + localplayer.playeravatar = av; + player_setup_ragdoll_from_avatar( &localplayer.ragdoll, av ); } -PLAYER_API -void player__use_model( player_instance *player, u16 reg_id ){ - addon_cache_unwatch( k_addon_type_player, player->playermodel_view_slot ); - player->playermodel_view_slot = +static void player__use_model( u16 reg_id ){ + addon_cache_unwatch( k_addon_type_player, + localplayer.playermodel_view_slot ); + localplayer.playermodel_view_slot = addon_cache_create_viewer( k_addon_type_player, reg_id ); } -PLAYER_API -void player__bind( player_instance *player ) -{ - for( u32 i=0; ibind ) sys->bind(); } } @@ -112,57 +88,52 @@ void player__bind( player_instance *player ) * ---------------------------------------------------------------------------- */ -PLAYER_API -void player__pre_update( player_instance *player ){ - if( button_down( k_srbind_camera ) && !player->immobile ){ - if( player->cam_control.camera_mode == k_cam_firstperson ) - player->cam_control.camera_mode = k_cam_thirdperson; +static void player__pre_update(void){ + if( button_down( k_srbind_camera ) && !localplayer.immobile ){ + if( localplayer.cam_control.camera_mode == k_cam_firstperson ) + localplayer.cam_control.camera_mode = k_cam_thirdperson; else - player->cam_control.camera_mode = k_cam_firstperson; + localplayer.cam_control.camera_mode = k_cam_firstperson; } - if( _player_pre_update[ player->subsystem ] ) - _player_pre_update[ player->subsystem ]( player ); + if( player_subsystems[ localplayer.subsystem ]->pre_update ) + player_subsystems[ localplayer.subsystem ]->pre_update(); } -PLAYER_API -void player__update( player_instance *player ){ - if( _player_update[ player->subsystem ] ) - _player_update[ player->subsystem ]( player ); +static void player__update(void){ + if( player_subsystems[ localplayer.subsystem ]->update ) + player_subsystems[ localplayer.subsystem ]->update(); } -PLAYER_API -void player__post_update( player_instance *player ){ - if( _player_post_update[ player->subsystem ] ) - _player_post_update[ player->subsystem ]( player ); +static void player__post_update(void){ + if( player_subsystems[ localplayer.subsystem ]->post_update ) + player_subsystems[ localplayer.subsystem ]->post_update(); } /* * Applies gate transport to a player_interface */ -PLAYER_API -void player__pass_gate( player_instance *player, ent_gate *gate ) -{ +static void player__pass_gate( ent_gate *gate ){ world_routes_fracture( world_current_instance(), gate, - player->rb.co, player->rb.v ); + localplayer.rb.co, localplayer.rb.v ); - player->gate_waiting = gate; + localplayer.gate_waiting = gate; world_routes_activate_entry_gate( world_current_instance(), gate ); - struct player_cam_controller *cc = &player->cam_control; + struct player_cam_controller *cc = &localplayer.cam_control; m4x3_mulv( gate->transport, cc->tpv_lpf, cc->tpv_lpf ); m3x3_mulv( gate->transport, cc->cam_velocity_smooth, cc->cam_velocity_smooth ); - m3x3_copy( player->basis, player->basis_gate ); + m3x3_copy( localplayer.basis, localplayer.basis_gate ); v4f q; m3x3_q( gate->transport, q ); - q_mul( q, player->qbasis, player->qbasis ); - q_normalize( player->qbasis ); - q_m3x3( player->qbasis, player->basis ); - m3x3_transpose( player->basis, player->invbasis ); + q_mul( q, localplayer.qbasis, localplayer.qbasis ); + q_normalize( localplayer.qbasis ); + q_m3x3( localplayer.qbasis, localplayer.basis ); + m3x3_transpose( localplayer.basis, localplayer.invbasis ); - m4x3_mulv( gate->transport, player->cam.pos, player->cam.pos ); + m4x3_mulv( gate->transport, localplayer.cam.pos, localplayer.cam.pos ); if( gate->flags & k_ent_gate_nonlocal ) world_set_active_instance( gate->target ); @@ -174,8 +145,7 @@ void player__pass_gate( player_instance *player, ent_gate *gate ) replay_clear( &skaterift.replay ); } -VG_STATIC void player_apply_transport_to_cam( m4x3f transport ) -{ +static void player_apply_transport_to_cam( m4x3f transport ){ /* FIXME: Applies to skaterift.cam directly! */ /* Pre-emptively edit the camera matrices so that the motion vectors @@ -193,8 +163,9 @@ VG_STATIC void player_apply_transport_to_cam( m4x3f transport ) m4x4_mul( world_gates.cam.mtx.v, transport_4, world_gates.cam.mtx.v ); } +#if 0 __attribute__ ((deprecated)) -VG_STATIC void gate_rotate_angles( ent_gate *gate, v3f angles, v3f d ) +static void gate_rotate_angles( ent_gate *gate, v3f angles, v3f d ) { v3_copy( angles, d ); return; @@ -207,8 +178,9 @@ VG_STATIC void gate_rotate_angles( ent_gate *gate, v3f angles, v3f d ) v3_copy( angles, d ); d[0] = atan2f( fwd_dir[2], fwd_dir[0] ); } +#endif -PLAYER_API void player__im_gui( player_instance *player ){ +static void player__im_gui(void){ if( !k_player_debug_info ) return; ui_rect box = { @@ -251,55 +223,55 @@ PLAYER_API void player__im_gui( player_instance *player ){ } [skaterift.activity] ); player__debugtext( 1, "time_rate: %.4f", skaterift.time_rate ); - player__debugtext( 2, "player_instance[%p]", player ); - player__debugtext( 1, "angles: " PRINTF_v3f( player->cam.angles ) ); - player__debugtext( 1, "basis: " PRINTF_v4f( player->qbasis ) ); + player__debugtext( 2, "player" ); + player__debugtext( 1, "angles: " PRINTF_v3f( localplayer.cam.angles ) ); + player__debugtext( 1, "basis: " PRINTF_v4f( localplayer.qbasis ) ); - if( _player_im_gui[ player->subsystem ] ) - _player_im_gui[ player->subsystem ]( player ); + if( player_subsystems[ localplayer.subsystem ]->im_gui ) + player_subsystems[ localplayer.subsystem ]->im_gui(); skaterift_replay_debug_info(); } -PLAYER_API void player__setpos( player_instance *player, v3f pos ){ - v3_copy( pos, player->rb.co ); - v3_zero( player->rb.v ); - rb_update_transform( &player->rb ); +static void player__setpos( v3f pos ){ + v3_copy( pos, localplayer.rb.co ); + v3_zero( localplayer.rb.v ); + rb_update_transform( &localplayer.rb ); } -PLAYER_API void player__spawn( player_instance *player, ent_spawn *rp ){ +static void player__spawn( ent_spawn *rp ){ replay_clear( &skaterift.replay ); - player__setpos( player, rp->transform.co ); - v3_zero( player->rb.w ); - q_identity( player->rb.q ); - rb_update_transform( &player->rb ); - - q_identity( player->qbasis ); - m3x3_identity( player->basis ); - m3x3_identity( player->invbasis ); - - player->subsystem = k_player_subsystem_walk; - player->immobile = 0; - player->gate_waiting = NULL; + player__setpos( rp->transform.co ); + v3_zero( localplayer.rb.w ); + q_identity( localplayer.rb.q ); + rb_update_transform( &localplayer.rb ); + + q_identity( localplayer.qbasis ); + m3x3_identity( localplayer.basis ); + m3x3_identity( localplayer.invbasis ); + + localplayer.subsystem = k_player_subsystem_walk; + localplayer.immobile = 0; + localplayer.gate_waiting = NULL; world_static.last_use = 0.0; world_static.focused_entity = 0; world_static.challenge_target = NULL; world_static.challenge_timer = 0.0f; world_entity_unfocus(); - if( _player_reset[ player->subsystem ] ) - _player_reset[ player->subsystem ]( player, rp ); + if( player_subsystems[ localplayer.subsystem ]->reset ) + player_subsystems[ localplayer.subsystem ]->reset( rp ); } -PLAYER_API void player__kill( player_instance *player ){ - +static void player__kill(void){ } -PLAYER_API void player__begin_holdout( player_instance *player ){ - memcpy( &player->holdout_pose, &player->pose, sizeof(player->pose) ); - player->holdout_time = 1.0f; +static void player__begin_holdout(void){ + memcpy( &localplayer.holdout_pose, &localplayer.pose, + sizeof(localplayer.pose) ); + localplayer.holdout_time = 1.0f; } /* implementation */ diff --git a/player.h b/player.h index 2d31e46..dedae18 100644 --- a/player.h +++ b/player.h @@ -2,6 +2,7 @@ #define PLAYER_H #include "skaterift.h" +#include "player_common.h" enum player_subsystem{ k_player_subsystem_walk = 0, @@ -29,10 +30,25 @@ struct player_cam_controller { cam_velocity_smooth; }; +struct player_subsystem_interface{ + void(*system_register)(void); + void(*bind)(void); + void(*reset)( ent_spawn *rp ); + void(*pre_update)(void); + void(*update)(void); + void(*post_update)(void); + void(*im_gui)(void); + void(*animate)(void); + void(*pose)( void *animator, player_pose *pose ); + void(*post_animate)(void); + + void *animator_data; + u32 animator_size; +}; + #include "player_ragdoll.h" #include "player_render.h" #include "player_model.h" -#include "player_common.h" #include "player_walk.h" #include "player_skate.h" #include "player_dead.h" @@ -46,7 +62,7 @@ static i32 k_cinema_fixed = 0; static f32 k_cinema = 0.0f; static i32 k_invert_y = 0; -struct player_instance{ +struct { /* transform definition */ rigidbody rb; v3f angles; @@ -96,120 +112,49 @@ struct player_instance{ */ enum player_subsystem subsystem; /* .. prev */ - - struct player_skate _skate; - struct player_walk _walk; - struct player_dead _dead; - struct player_drive _drive; } -static localplayer; +static localplayer = { + .rb = { + .co = { 0,0,0 }, + .w = { 0,0,0 }, + .v = { 0,0,0 }, + .q = { 0,0,0,1 }, + .to_world = M4X3_IDENTITY, + .to_local = M4X3_IDENTITY + } +}; + +struct player_subsystem_interface static *player_subsystems[] = { + [k_player_subsystem_walk] = &player_subsystem_walk, + [k_player_subsystem_dead] = &player_subsystem_dead, + [k_player_subsystem_drive] = &player_subsystem_drive, + [k_player_subsystem_skate] = &player_subsystem_skate +}; /* * Gameloop tables * --------------------------------------------------------- */ -VG_STATIC -void (*_player_system_register[])(void) = { - player__walk_register, - player__skate_register, - NULL, - NULL -}; - -VG_STATIC -void (*_player_bind[])( player_instance *player ) = { - player__walk_bind, - player__skate_bind, - NULL, - player__drive_bind -}; - -VG_STATIC -void (*_player_reset[])( player_instance *player, ent_spawn *rp ) = { - player__walk_reset, - player__skate_reset, - NULL, - player__drive_reset -}; - -VG_STATIC -void (*_player_pre_update[])( player_instance *player ) = { - player__walk_pre_update, - player__skate_pre_update, - NULL, - player__drive_pre_update -}; - -VG_STATIC -void( *_player_update[])( player_instance *player ) = { - player__walk_update, - player__skate_update, - player__dead_update, - player__drive_update -}; - -VG_STATIC -void( *_player_post_update[])( player_instance *player ) = { - player__walk_post_update, - player__skate_post_update, - player__dead_post_update, - player__drive_post_update -}; - -VG_STATIC -void( *_player_im_gui[])( player_instance *player ) = { - player__walk_im_gui, - player__skate_im_gui, - NULL, - player__drive_im_gui -}; - -VG_STATIC -void( *_player_animate[])( player_instance *player ) = { - player__walk_animate, - player__skate_animate, - player__dead_animate, - player__drive_animate -}; - -VG_STATIC -void( *_player_pose[] )( player_instance *player, player_pose *pose ) = { - player__walk_pose, - player__skate_pose, - player__dead_pose, - player__drive_pose, -}; - -VG_STATIC -void( *_player_post_animate[])( player_instance *player ) = { - player__walk_post_animate, - player__skate_post_animate, - player__dead_post_animate, - player__drive_post_animate -}; - -PLAYER_API void player__debugtext( int size, const char *fmt, ... ); -PLAYER_API void player__create( player_instance *inst ); -PLAYER_API void player__use_avatar( player_instance *player, - struct player_avatar *av ); -PLAYER_API void player__use_mesh( player_instance *player, glmesh *mesh ); -PLAYER_API void player__use_texture( player_instance *player, vg_tex2d *tex ); -PLAYER_API void player__use_model( player_instance *player, u16 reg_id ); - -PLAYER_API void player__bind( player_instance *player ); -PLAYER_API void player__pre_update( player_instance *player ); -PLAYER_API void player__update( player_instance *player ); -PLAYER_API void player__post_update( player_instance *player ); - -PLAYER_API void player__pass_gate( player_instance *player, ent_gate *gate ); -PLAYER_API void player__im_gui( player_instance *player ); -PLAYER_API void player__setpos( player_instance *player, v3f pos ); -PLAYER_API void player__spawn( player_instance *player, ent_spawn *rp ); -PLAYER_API void player__kill( player_instance *player ); -PLAYER_API void player__begin_holdout( player_instance *player ); - -VG_STATIC int localplayer_cmd_respawn( int argc, const char *argv[] ); -VG_STATIC void player_apply_transport_to_cam( m4x3f transport ); +static void player__debugtext( int size, const char *fmt, ... ); +static void player__use_avatar( struct player_avatar *av ); +static void player__use_mesh( glmesh *mesh ); +static void player__use_texture( vg_tex2d *tex ); +static void player__use_model( u16 reg_id ); + +static void player__bind(void); +static void player__pre_update(void); +static void player__update(void); +static void player__post_update(void); + +static void player__pass_gate( ent_gate *gate ); +static void player__im_gui(void); +static void player__setpos( v3f pos ); +static void player__spawn( ent_spawn *rp ); +static void player__kill(void); +static void player__begin_holdout(void); + +static int localplayer_cmd_respawn( int argc, const char *argv[] ); +static void player_apply_transport_to_cam( m4x3f transport ); #endif /* PLAYER_H */ diff --git a/player_api.h b/player_api.h index 2c2d18e..b3b6907 100644 --- a/player_api.h +++ b/player_api.h @@ -5,7 +5,7 @@ #include "camera.h" #include "entity.h" -#define PLAYER_API VG_STATIC +#define PLAYER_API static typedef struct player_instance player_instance; typedef struct player_pose player_pose; diff --git a/player_common.c b/player_common.c index e0a7776..7daa399 100644 --- a/player_common.c +++ b/player_common.c @@ -7,8 +7,7 @@ #include "menu.h" #include "vg/vg_perlin.h" -VG_STATIC void player_vector_angles( v3f angles, v3f v, float C, float k ) -{ +static void player_vector_angles( v3f angles, v3f v, float C, float k ){ float yaw = atan2f( v[0], -v[2] ), pitch = atan2f ( @@ -24,48 +23,46 @@ VG_STATIC void player_vector_angles( v3f angles, v3f v, float C, float k ) angles[2] = 0.0f; } -VG_STATIC float player_get_heading_yaw( player_instance *player ) -{ +static float player_get_heading_yaw(void){ v3f xz; - q_mulv( player->rb.q, (v3f){ 0.0f,0.0f,1.0f }, xz ); - m3x3_mulv( player->invbasis, xz, xz ); + q_mulv( localplayer.rb.q, (v3f){ 0.0f,0.0f,1.0f }, xz ); + m3x3_mulv( localplayer.invbasis, xz, xz ); return atan2f( xz[0], xz[2] ); } -VG_STATIC void player_camera_portal_correction( player_instance *player ) -{ - if( player->gate_waiting ){ +static void player_camera_portal_correction(void){ + if( localplayer.gate_waiting ){ /* construct plane equation for reciever gate */ v4f plane; - q_mulv( player->gate_waiting->q[1], (v3f){0.0f,0.0f,1.0f}, plane ); - plane[3] = v3_dot( plane, player->gate_waiting->co[1] ); + q_mulv( localplayer.gate_waiting->q[1], (v3f){0.0f,0.0f,1.0f}, plane ); + plane[3] = v3_dot( plane, localplayer.gate_waiting->co[1] ); - f32 pol = v3_dot( player->cam.pos, plane ) - plane[3]; + f32 pol = v3_dot( localplayer.cam.pos, plane ) - plane[3]; /* check camera polarity */ if( (pol < 0.0f) || (pol > 5.0f) ) { vg_success( "Plane cleared\n" ); - player_apply_transport_to_cam( player->gate_waiting->transport ); - player->gate_waiting = NULL; - player->viewable_world = world_current_instance(); + player_apply_transport_to_cam( localplayer.gate_waiting->transport ); + localplayer.gate_waiting = NULL; + localplayer.viewable_world = world_current_instance(); } else{ /* de-transform camera and player back */ m4x3f inverse; - m4x3_invert_affine( player->gate_waiting->transport, inverse ); - m4x3_mulv( inverse, player->cam.pos, player->cam.pos ); + m4x3_invert_affine( localplayer.gate_waiting->transport, inverse ); + m4x3_mulv( inverse, localplayer.cam.pos, localplayer.cam.pos ); - struct skeleton *sk = &player->playeravatar->sk; + struct skeleton *sk = &localplayer.playeravatar->sk; skeleton_apply_transform( sk, inverse ); } } } -VG_STATIC void player__cam_iterate( player_instance *player ){ - struct player_avatar *av = player->playeravatar; - struct player_cam_controller *cc = &player->cam_control; +static void player__cam_iterate(void){ + struct player_avatar *av = localplayer.playeravatar; + struct player_cam_controller *cc = &localplayer.cam_control; - if( player->subsystem == k_player_subsystem_walk ){ + if( localplayer.subsystem == k_player_subsystem_walk ){ v3_copy( (v3f){-0.1f,1.8f,0.0f}, cc->fpv_viewpoint ); v3_copy( (v3f){0.0f,0.0f,0.0f}, cc->fpv_offset ); v3_copy( (v3f){0.0f,1.4f,0.0f}, cc->tpv_offset ); @@ -79,29 +76,29 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ v3_add( cc->tpv_offset_extra, cc->tpv_offset, cc->tpv_offset ); } - player->cam_velocity_constant = 0.25f; - player->cam_velocity_coefficient = 0.7f; + localplayer.cam_velocity_constant = 0.25f; + localplayer.cam_velocity_coefficient = 0.7f; /* lerping */ - player->cam_velocity_influence_smooth = vg_lerpf( - player->cam_velocity_influence_smooth, - player->cam_velocity_influence, + localplayer.cam_velocity_influence_smooth = vg_lerpf( + localplayer.cam_velocity_influence_smooth, + localplayer.cam_velocity_influence, vg.time_frame_delta * 8.0f ); - player->cam_velocity_coefficient_smooth = vg_lerpf( - player->cam_velocity_coefficient_smooth, - player->cam_velocity_coefficient, + localplayer.cam_velocity_coefficient_smooth = vg_lerpf( + localplayer.cam_velocity_coefficient_smooth, + localplayer.cam_velocity_coefficient, vg.time_frame_delta * 8.0f ); - player->cam_velocity_constant_smooth = vg_lerpf( - player->cam_velocity_constant_smooth, - player->cam_velocity_constant, + localplayer.cam_velocity_constant_smooth = vg_lerpf( + localplayer.cam_velocity_constant_smooth, + localplayer.cam_velocity_constant, vg.time_frame_delta * 8.0f ); enum camera_mode target_mode = cc->camera_mode; - if( player->subsystem == k_player_subsystem_dead ) + if( localplayer.subsystem == k_player_subsystem_dead ) target_mode = k_cam_thirdperson; cc->camera_type_blend = @@ -122,7 +119,7 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ float fov_skate = vg_lerpf( 97.0f, 135.0f, k_fov ), fov_walk = vg_lerpf( 90.0f, 110.0f, k_fov ); - player->cam.fov = vg_lerpf( fov_walk, fov_skate, cc->camera_type_blend ); + localplayer.cam.fov = vg_lerpf( fov_walk, fov_skate, cc->camera_type_blend ); /* * first person camera @@ -132,27 +129,28 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ v3f fpv_pos, fpv_offset; m4x3_mulv( av->sk.final_mtx[ av->id_head-1 ], cc->fpv_viewpoint_smooth, fpv_pos ); - m3x3_mulv( player->rb.to_world, cc->fpv_offset_smooth, fpv_offset ); + m3x3_mulv( localplayer.rb.to_world, cc->fpv_offset_smooth, fpv_offset ); v3_add( fpv_offset, fpv_pos, fpv_pos ); /* angles */ v3f velocity_angles; - v3_lerp( cc->cam_velocity_smooth, player->rb.v, 4.0f*vg.time_frame_delta, + v3_lerp( cc->cam_velocity_smooth, localplayer.rb.v, 4.0f*vg.time_frame_delta, cc->cam_velocity_smooth ); v3f velocity_local; - m3x3_mulv( player->invbasis, cc->cam_velocity_smooth, velocity_local ); + m3x3_mulv( localplayer.invbasis, cc->cam_velocity_smooth, velocity_local ); player_vector_angles( velocity_angles, velocity_local, - player->cam_velocity_coefficient_smooth, - player->cam_velocity_constant_smooth ); + localplayer.cam_velocity_coefficient_smooth, + localplayer.cam_velocity_constant_smooth ); - float inf_fpv = player->cam_velocity_influence_smooth * cc->camera_type_blend, - inf_tpv = player->cam_velocity_influence_smooth * + float inf_fpv = localplayer.cam_velocity_influence_smooth * + cc->camera_type_blend, + inf_tpv = localplayer.cam_velocity_influence_smooth * (1.0f-cc->camera_type_blend); - camera_lerp_angles( player->angles, velocity_angles, + camera_lerp_angles( localplayer.angles, velocity_angles, inf_fpv, - player->angles ); + localplayer.angles ); /* * Third person camera @@ -164,32 +162,32 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ * it is done in the local basis then transformed back */ v3f future; - v3_muls( player->rb.v, 0.4f*vg.time_frame_delta, future ); - m3x3_mulv( player->invbasis, future, future ); + v3_muls( localplayer.rb.v, 0.4f*vg.time_frame_delta, future ); + m3x3_mulv( localplayer.invbasis, future, future ); v3f camera_follow_dir = - { -sinf( player->angles[0] ) * cosf( player->angles[1] ), - sinf( player->angles[1] ), - cosf( player->angles[0] ) * cosf( player->angles[1] ) }; + { -sinf( localplayer.angles[0] ) * cosf( localplayer.angles[1] ), + sinf( localplayer.angles[1] ), + cosf( localplayer.angles[0] ) * cosf( localplayer.angles[1] ) }; v3f v0; v3_sub( camera_follow_dir, future, v0 ); v3f follow_angles; - v3_copy( player->angles, follow_angles ); + v3_copy( localplayer.angles, follow_angles ); follow_angles[0] = atan2f( -v0[0], v0[2] ); follow_angles[1] = 0.3f + velocity_angles[1] * 0.2f; float ya = atan2f( -velocity_local[1], 30.0f ); follow_angles[1] = 0.3f + ya; - camera_lerp_angles( player->angles, follow_angles, + camera_lerp_angles( localplayer.angles, follow_angles, inf_tpv, - player->angles ); + localplayer.angles ); v3f pco; v4f pq; - rb_extrapolate( &player->rb, pco, pq ); + rb_extrapolate( &localplayer.rb, pco, pq ); v3_lerp( cc->tpv_lpf, pco, 20.0f*vg.time_frame_delta, cc->tpv_lpf ); /* now move into world */ @@ -200,7 +198,7 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ v3_add( tpv_origin, cc->tpv_lpf, tpv_origin ); /* offset */ - m3x3_mulv( player->basis, camera_follow_dir, camera_follow_dir ); + m3x3_mulv( localplayer.basis, camera_follow_dir, camera_follow_dir ); v3_muls( camera_follow_dir, 1.8f, tpv_offset ); v3_muladds( tpv_offset, cc->cam_velocity_smooth, -0.025f, tpv_offset ); @@ -216,37 +214,39 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ /* * Blend cameras */ - v3_lerp( tpv_pos, fpv_pos, cc->camera_type_blend, player->cam.pos ); - v3_copy( player->angles, player->cam.angles ); + v3_lerp( tpv_pos, fpv_pos, cc->camera_type_blend, localplayer.cam.pos ); + v3_copy( localplayer.angles, localplayer.cam.angles ); /* Camera shake */ - f32 speed = v3_length(player->rb.v), + f32 speed = v3_length(localplayer.rb.v), strength = k_cam_shake_strength * speed; - player->cam_trackshake += speed*k_cam_shake_trackspeed*vg.time_frame_delta; + localplayer.cam_trackshake += + speed*k_cam_shake_trackspeed*vg.time_frame_delta; - v2f rnd = {perlin1d( player->cam_trackshake, 1.0f, 4, 20 ), - perlin1d( player->cam_trackshake, 1.0f, 4, 63 ) }; - v2_muladds( player->cam.angles, rnd, strength, player->cam.angles ); + v2f rnd = {perlin1d( localplayer.cam_trackshake, 1.0f, 4, 20 ), + perlin1d( localplayer.cam_trackshake, 1.0f, 4, 63 ) }; + v2_muladds( localplayer.cam.angles, rnd, strength, localplayer.cam.angles ); v3f Fd, Fs, F; - v3_muls( player->cam_land_punch_v, -k_cam_damp, Fd ); - v3_muls( player->cam_land_punch, -k_cam_spring, Fs ); - v3_muladds( player->cam_land_punch, player->cam_land_punch_v, - vg.time_frame_delta, player->cam_land_punch ); + v3_muls( localplayer.cam_land_punch_v, -k_cam_damp, Fd ); + v3_muls( localplayer.cam_land_punch, -k_cam_spring, Fs ); + v3_muladds( localplayer.cam_land_punch, localplayer.cam_land_punch_v, + vg.time_frame_delta, localplayer.cam_land_punch ); v3_add( Fd, Fs, F ); - v3_muladds( player->cam_land_punch_v, F, vg.time_frame_delta, - player->cam_land_punch_v ); - v3_add( player->cam_land_punch, player->cam.pos, player->cam.pos ); + v3_muladds( localplayer.cam_land_punch_v, F, vg.time_frame_delta, + localplayer.cam_land_punch_v ); + v3_add( localplayer.cam_land_punch, localplayer.cam.pos, + localplayer.cam.pos ); if( k_cinema >= 0.0001f ){ ent_camera *cam = NULL; f32 min_dist = k_cinema; - world_instance *world = player->viewable_world; + world_instance *world = localplayer.viewable_world; for( u32 i=0; ient_camera); i++ ){ ent_camera *c = mdl_arritm(&world->ent_camera,i); - f32 dist = v3_dist( c->transform.co, player->rb.co ); + f32 dist = v3_dist( c->transform.co, localplayer.rb.co ); if( dist < min_dist ){ min_dist = dist; @@ -255,22 +255,22 @@ VG_STATIC void player__cam_iterate( player_instance *player ){ } if( cam ){ - player->cam.fov = cam->fov; - v3_copy( cam->transform.co, player->cam.pos ); + localplayer.cam.fov = cam->fov; + v3_copy( cam->transform.co, localplayer.cam.pos ); v3f v0; if( k_cinema_fixed ) mdl_transform_vector( &cam->transform, (v3f){0.0f,-1.0f,0.0f}, v0 ); - else v3_sub( player->rb.co, cam->transform.co, v0 ); - m3x3_mulv( player->invbasis, v0, v0 ); - player_vector_angles( player->cam.angles, v0, 1.0f, 0.0f ); + else v3_sub( localplayer.rb.co, cam->transform.co, v0 ); + m3x3_mulv( localplayer.invbasis, v0, v0 ); + player_vector_angles( localplayer.cam.angles, v0, 1.0f, 0.0f ); } } /* portal transitions */ - player_camera_portal_correction( player ); + player_camera_portal_correction(); } -VG_STATIC void player_look( v3f angles, float speed ){ +static void player_look( v3f angles, float speed ){ if( vg_ui.wants_mouse ) return; angles[2] = 0.0f; diff --git a/player_common.h b/player_common.h index 529fc84..d119827 100644 --- a/player_common.h +++ b/player_common.h @@ -13,11 +13,13 @@ static float static i32 k_player_debug_info = 0; static ui_rect g_player_debugger; -VG_STATIC void player_look( v3f angles, float speed ); -VG_STATIC void player__cam_iterate( player_instance *player ); -VG_STATIC void player_vector_angles( v3f angles, v3f v, float C, float k ); -struct player_board *player_get_player_board( struct player_instance *player ); -struct player_model *player_get_player_model( struct player_instance *player ); -VG_STATIC float player_get_heading_yaw( player_instance *player ); +static void player_look( v3f angles, float speed ); +static void player__cam_iterate(void); +static void player_vector_angles( v3f angles, v3f v, float C, float k ); +static struct player_board + *player_get_player_board( struct player_instance *player ); +static struct player_model + *player_get_player_model( struct player_instance *player ); +static f32 player_get_heading_yaw(void); #endif /* PLAYER_COMMON_H */ diff --git a/player_dead.c b/player_dead.c index 78cce2f..957f38d 100644 --- a/player_dead.c +++ b/player_dead.c @@ -3,15 +3,14 @@ #include "player.h" -VG_STATIC void player__dead_update ( player_instance *player ) -{ - player_ragdoll_iter( &player->ragdoll ); +static void player__dead_update(void){ + player_ragdoll_iter( &localplayer.ragdoll ); } -VG_STATIC void player__dead_post_update( player_instance *player ){ - struct player_dead *d = &player->_dead; - struct player_avatar *av = player->playeravatar; - struct ragdoll_part *part = &player->ragdoll.parts[ av->id_hip-1 ]; +static void player__dead_post_update(void){ + struct player_avatar *av = localplayer.playeravatar; + struct ragdoll_part *part = &localplayer.ragdoll.parts[ av->id_hip-1 ]; + struct player_dead *d = &player_dead; v3f ext_co; v4f ext_q; @@ -21,26 +20,26 @@ VG_STATIC void player__dead_post_update( player_instance *player ){ v3_lerp( d->v_lpf, part->obj.rb.v, vg.time_frame_delta*4.0f, d->v_lpf ); v3_lerp( d->w_lpf, part->obj.rb.w, vg.time_frame_delta*4.0f, d->w_lpf ); - v3_copy( d->co_lpf, player->rb.co ); - v3_zero( player->rb.v ); - v3_zero( player->rb.w ); + v3_copy( d->co_lpf, localplayer.rb.co ); + v3_zero( localplayer.rb.v ); + v3_zero( localplayer.rb.w ); } -VG_STATIC void player__dead_animate( player_instance *player ){ - struct player_dead *d = &player->_dead; +static void player__dead_animate(void){ + struct player_dead *d = &player_dead; struct player_dead_animator *animator = &d->animator; - struct player_ragdoll *rd = &player->ragdoll; - struct player_avatar *av = player->playeravatar; + struct player_ragdoll *rd = &localplayer.ragdoll; + struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &av->sk; m4x3f transforms[ 32 ]; /* root transform */ - q_m3x3( player->rb.q, transforms[0] ); - v3_copy( player->rb.co, transforms[0][3] ); + q_m3x3( localplayer.rb.q, transforms[0] ); + v3_copy( localplayer.rb.co, transforms[0][3] ); - v4_copy( player->rb.q, animator->transforms[0].q ); - v3_copy( player->rb.co, animator->transforms[0].co ); + v4_copy( localplayer.rb.q, animator->transforms[0].q ); + v3_copy( localplayer.rb.co, animator->transforms[0].co ); /* colliders with bones transforms */ for( int i=0; ipart_count; i++ ){ @@ -99,11 +98,10 @@ VG_STATIC void player__dead_animate( player_instance *player ){ } } -VG_STATIC void player__dead_pose( player_instance *player, player_pose *pose ){ - struct player_dead *d = &player->_dead; - struct player_dead_animator *animator = &d->animator; - struct player_ragdoll *rd = &player->ragdoll; - struct player_avatar *av = player->playeravatar; +static void player__dead_pose( void *_animator, player_pose *pose ){ + struct player_dead_animator *animator = _animator; + struct player_ragdoll *rd = &localplayer.ragdoll; + struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &av->sk; pose->type = k_player_pose_type_fk_2; @@ -119,25 +117,23 @@ VG_STATIC void player__dead_pose( player_instance *player, player_pose *pose ){ } } -VG_STATIC void player__dead_post_animate( player_instance *player ){ - player->cam_velocity_influence = 1.0f; +static void player__dead_post_animate(void){ + localplayer.cam_velocity_influence = 1.0f; } -VG_STATIC void player__dead_im_gui ( player_instance *player ){ - +static void player__dead_im_gui(void){ } -VG_STATIC void player__dead_transition ( player_instance *player ){ - player->subsystem = k_player_subsystem_dead; - copy_avatar_pose_to_ragdoll( player->playeravatar, &player->ragdoll, - player->rb.v ); - - struct player_avatar *av = player->playeravatar; - struct ragdoll_part *part = &player->ragdoll.parts[ av->id_hip-1 ]; - struct player_dead *d = &player->_dead; - v3_copy( part->obj.rb.co, d->co_lpf ); - v3_copy( part->obj.rb.v, d->v_lpf ); - v3_copy( part->obj.rb.w, d->w_lpf ); +static void player__dead_transition(void){ + localplayer.subsystem = k_player_subsystem_dead; + copy_avatar_pose_to_ragdoll( localplayer.playeravatar, &localplayer.ragdoll, + localplayer.rb.v ); + + struct player_avatar *av = localplayer.playeravatar; + struct ragdoll_part *part = &localplayer.ragdoll.parts[ av->id_hip-1 ]; + v3_copy( part->obj.rb.co, player_dead.co_lpf ); + v3_copy( part->obj.rb.v, player_dead.v_lpf ); + v3_copy( part->obj.rb.w, player_dead.w_lpf ); } #endif /* PLAYER_DEAD_C */ diff --git a/player_dead.h b/player_dead.h index 6a10bea..03c9326 100644 --- a/player_dead.h +++ b/player_dead.h @@ -1,6 +1,7 @@ #ifndef PLAYER_DEAD_H #define PLAYER_DEAD_H +#include "player.h" #include "player_api.h" struct player_dead{ @@ -14,15 +15,27 @@ struct player_dead{ transforms[ 32 ]; } animator; -}; +} +static player_dead; + +static void player__dead_update (void); +static void player__dead_post_update (void); +static void player__dead_animate (void); +static void player__dead_pose (void *animator, player_pose *pose); +static void player__dead_post_animate(void); +static void player__dead_im_gui (void); +static void player__dead_transition (void); -VG_STATIC void player__dead_update ( player_instance *player ); -VG_STATIC void player__dead_post_update ( player_instance *player ); -VG_STATIC void player__dead_animate ( player_instance *player ); -VG_STATIC void player__dead_pose( player_instance *player, player_pose *pose ); +struct player_subsystem_interface static player_subsystem_dead = { + .update = player__dead_update, + .post_update = player__dead_post_update, + .animate = player__dead_animate, + .pose = player__dead_pose, + .post_animate = player__dead_post_animate, + .im_gui = player__dead_im_gui, -VG_STATIC void player__dead_post_animate( player_instance *player ); -VG_STATIC void player__dead_im_gui ( player_instance *player ); -VG_STATIC void player__dead_transition ( player_instance *player ); + .animator_data = &player_dead.animator, + .animator_size = sizeof(player_dead.animator) +}; #endif /* PLAYER_DEAD_H */ diff --git a/player_drive.c b/player_drive.c index 1c83205..90036a6 100644 --- a/player_drive.c +++ b/player_drive.c @@ -4,10 +4,8 @@ #include "player.h" #include "input.h" -VG_STATIC void player__drive_pre_update( player_instance *player ) -{ - struct player_drive *drive = &player->_drive; - drivable_vehicle *vehc = drive->vehicle; +static void player__drive_pre_update(void){ + drivable_vehicle *vehc = player_drive.vehicle; v2f steer; joystick_state( k_srjoystick_steer, steer ); @@ -16,36 +14,30 @@ VG_STATIC void player__drive_pre_update( player_instance *player ) vehc->drive = steer[1]; } -VG_STATIC void player__drive_update( player_instance *player ) -{ -} +static void player__drive_update(void){} -VG_STATIC void player__drive_post_update( player_instance *player ) -{ - struct player_drive *drive = &player->_drive; - v3_copy( drive->vehicle->obj.rb.co, player->rb.co ); - v3_copy( drive->vehicle->obj.rb.v, player->rb.v ); - v4_copy( drive->vehicle->obj.rb.q, player->rb.q ); - v3_copy( drive->vehicle->obj.rb.w, player->rb.w ); +static void player__drive_post_update(void){ + v3_copy( player_drive.vehicle->obj.rb.co,localplayer.rb.co ); + v3_copy( player_drive.vehicle->obj.rb.v, localplayer.rb.v ); + v4_copy( player_drive.vehicle->obj.rb.q, localplayer.rb.q ); + v3_copy( player_drive.vehicle->obj.rb.w, localplayer.rb.w ); } -VG_STATIC void player__drive_animate( player_instance *player ){} +static void player__drive_animate(void){} -VG_STATIC void player__drive_pose( player_instance *player, player_pose *pose ){ - struct player_drive *drive = &player->_drive; - struct skeleton *sk = &player->playeravatar->sk; +static void player__drive_pose( void *animator, player_pose *pose ){ + struct skeleton *sk = &localplayer.playeravatar->sk; - skeleton_sample_anim( sk, drive->anim_drive, 0.0f, pose->keyframes ); - v3_copy( player->rb.co, pose->root_co ); - v4_copy( player->rb.q, pose->root_q ); + skeleton_sample_anim( sk, player_drive.anim_drive, 0.0f, pose->keyframes ); + v3_copy( localplayer.rb.co, pose->root_co ); + v4_copy( localplayer.rb.q, pose->root_q ); } -VG_STATIC void player__drive_post_animate( player_instance *player ) -{ - if( player->cam_control.camera_mode == k_cam_firstperson ) - player->cam_velocity_influence = 0.0f; +static void player__drive_post_animate(void){ + if( localplayer.cam_control.camera_mode == k_cam_firstperson ) + localplayer.cam_velocity_influence = 0.0f; else - player->cam_velocity_influence = 1.0f; + localplayer.cam_velocity_influence = 1.0f; rigidbody *rb = &gzoomer.obj.rb; float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ), @@ -59,27 +51,23 @@ VG_STATIC void player__drive_post_animate( player_instance *player ) ) ); - player->angles[0] = yaw; - player->angles[1] = pitch; + localplayer.angles[0] = yaw; + localplayer.angles[1] = pitch; } -VG_STATIC void player__drive_im_gui( player_instance *player ) -{ +static void player__drive_im_gui(void){ player__debugtext( 1, "Nothing here" ); } -VG_STATIC void player__drive_bind( player_instance *player ) -{ - struct player_drive *drive = &player->_drive; - struct player_avatar *av = player->playeravatar; +static void player__drive_bind(void){ + struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &av->sk; - drive->vehicle = &gzoomer; - drive->anim_drive = skeleton_get_anim( sk, "idle_cycle+y" ); + player_drive.vehicle = &gzoomer; + player_drive.anim_drive = skeleton_get_anim( sk, "idle_cycle+y" ); } -VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp ) -{ +static void player__drive_reset( ent_spawn *rp ){ } #endif /* PLAYER_DRIVE_C */ diff --git a/player_drive.h b/player_drive.h index 7e1bb98..071fef4 100644 --- a/player_drive.h +++ b/player_drive.h @@ -7,17 +7,33 @@ struct player_drive { drivable_vehicle *vehicle; struct skeleton_anim *anim_drive; -}; +} +static player_drive; + +static void player__drive_pre_update(void); +static void player__drive_update(void); +static void player__drive_post_update(void); +static void player__drive_animate(void); +static void player__drive_pose( void *animator, player_pose *pose ); -VG_STATIC void player__drive_pre_update( player_instance *player ); -VG_STATIC void player__drive_update( player_instance *player ); -VG_STATIC void player__drive_post_update( player_instance *player ); -VG_STATIC void player__drive_animate( player_instance *player ); -VG_STATIC void player__drive_pose( player_instance *player, player_pose *pose ); +static void player__drive_post_animate(void); +static void player__drive_im_gui(void); +static void player__drive_bind(void); +static void player__drive_reset( ent_spawn *rp ); -VG_STATIC void player__drive_post_animate( player_instance *player ); -VG_STATIC void player__drive_im_gui( player_instance *player ); -VG_STATIC void player__drive_bind( player_instance *player ); -VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp ); +struct player_subsystem_interface static player_subsystem_drive = { + .pre_update = player__drive_pre_update, + .update = player__drive_update, + .post_update = player__drive_post_update, + .animate = player__drive_animate, + .pose = player__drive_pose, + .post_animate = player__drive_post_animate, + .im_gui = player__drive_im_gui, + .bind = player__drive_bind, + .reset = player__drive_reset, + + .animator_data = NULL, + .animator_size = 0 +}; #endif /* PLAYER_DRIVE_H */ diff --git a/player_ragdoll.c b/player_ragdoll.c index 3dc7ba6..d36bec4 100644 --- a/player_ragdoll.c +++ b/player_ragdoll.c @@ -4,7 +4,7 @@ #include "player.h" #include "audio.h" -VG_STATIC void player_ragdoll_init(void) +static void player_ragdoll_init(void) { VG_VAR_F32( k_ragdoll_limit_scale ); VG_VAR_I32( k_ragdoll_div ); @@ -12,7 +12,7 @@ VG_STATIC void player_ragdoll_init(void) VG_VAR_I32( k_ragdoll_debug_constraints ); } -VG_STATIC void player_init_ragdoll_bone_collider( struct skeleton_bone *bone, +static void player_init_ragdoll_bone_collider( struct skeleton_bone *bone, struct ragdoll_part *rp ) { m4x3_identity( rp->collider_mtx ); @@ -82,7 +82,7 @@ VG_STATIC void player_init_ragdoll_bone_collider( struct skeleton_bone *bone, /* * Get parent index in the ragdoll */ -VG_STATIC u32 ragdoll_bone_parent( struct player_ragdoll *rd, +static u32 ragdoll_bone_parent( struct player_ragdoll *rd, struct player_avatar *av, u32 bone_id ) { for( u32 j=0; jpart_count; j++ ) @@ -96,7 +96,7 @@ VG_STATIC u32 ragdoll_bone_parent( struct player_ragdoll *rd, /* * Setup ragdoll colliders */ -VG_STATIC void player_setup_ragdoll_from_avatar( struct player_ragdoll *rd, +static void player_setup_ragdoll_from_avatar( struct player_ragdoll *rd, struct player_avatar *av ) { rd->part_count = 0; @@ -186,7 +186,7 @@ VG_STATIC void player_setup_ragdoll_from_avatar( struct player_ragdoll *rd, /* * Make avatar copy the ragdoll */ -VG_STATIC void copy_ragdoll_pose_to_avatar( struct player_ragdoll *rd, +static void copy_ragdoll_pose_to_avatar( struct player_ragdoll *rd, struct player_avatar *av ) { for( int i=0; ipart_count; i++ ){ @@ -229,7 +229,7 @@ VG_STATIC void copy_ragdoll_pose_to_avatar( struct player_ragdoll *rd, /* * Make the ragdoll copy the player model */ -VG_STATIC void copy_avatar_pose_to_ragdoll( struct player_avatar *av, +static void copy_avatar_pose_to_ragdoll( struct player_avatar *av, struct player_ragdoll *rd, v3f velocity ) { @@ -260,14 +260,14 @@ VG_STATIC void copy_avatar_pose_to_ragdoll( struct player_avatar *av, /* * Draw rigidbody colliders for ragdoll */ -VG_STATIC void player_debug_ragdoll(void) +static void player_debug_ragdoll(void) { } /* * Ragdoll physics step */ -VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd ) +static void player_ragdoll_iter( struct player_ragdoll *rd ) { world_instance *world = world_current_instance(); diff --git a/player_ragdoll.h b/player_ragdoll.h index 789db4c..52c2ec9 100644 --- a/player_ragdoll.h +++ b/player_ragdoll.h @@ -36,28 +36,28 @@ struct player_ragdoll{ int shoes[2]; }; -VG_STATIC float k_ragdoll_floatyiness = 20.0f, +static float k_ragdoll_floatyiness = 20.0f, k_ragdoll_floatydrag = 1.0f, k_ragdoll_limit_scale = 1.0f; -VG_STATIC int k_ragdoll_div = 1, +static int k_ragdoll_div = 1, ragdoll_frame = 0, k_ragdoll_debug_collider = 1, k_ragdoll_debug_constraints = 0; -VG_STATIC void player_ragdoll_init(void); -VG_STATIC void player_init_ragdoll_bone_collider( struct skeleton_bone *bone, +static void player_ragdoll_init(void); +static void player_init_ragdoll_bone_collider( struct skeleton_bone *bone, struct ragdoll_part *rp ); -VG_STATIC u32 ragdoll_bone_parent( struct player_ragdoll *rd, +static u32 ragdoll_bone_parent( struct player_ragdoll *rd, struct player_avatar *av, u32 bone_id ); -VG_STATIC void player_setup_ragdoll_from_avatar( struct player_ragdoll *rd, +static void player_setup_ragdoll_from_avatar( struct player_ragdoll *rd, struct player_avatar *av ); -VG_STATIC void copy_ragdoll_pose_to_avatar( struct player_ragdoll *rd, +static void copy_ragdoll_pose_to_avatar( struct player_ragdoll *rd, struct player_avatar *av ); -VG_STATIC void copy_avatar_pose_to_ragdoll( struct player_avatar *av, +static void copy_avatar_pose_to_ragdoll( struct player_avatar *av, struct player_ragdoll *rd, v3f velocity ); -VG_STATIC void player_debug_ragdoll(void); -VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd ); +static void player_debug_ragdoll(void); +static void player_ragdoll_iter( struct player_ragdoll *rd ); #endif /* PLAYER_RAGDOLL_H */ diff --git a/player_render.c b/player_render.c index 0d7e922..93786b3 100644 --- a/player_render.c +++ b/player_render.c @@ -13,8 +13,7 @@ #include "shaders/model_board_view.h" #include "shaders/model_entity.h" -VG_STATIC void player_avatar_load( struct player_avatar *av, const char *path ) -{ +static void player_avatar_load( struct player_avatar *av, const char *path ){ mdl_open( &av->meta, path, vg_mem.rtmemory ); mdl_load_metadata_block( &av->meta, vg_mem.rtmemory ); mdl_load_animation_block( &av->meta, vg_mem.rtmemory ); @@ -40,10 +39,9 @@ VG_STATIC void player_avatar_load( struct player_avatar *av, const char *path ) /* TODO: Standard model load */ -VG_STATIC void dynamic_model_load( mdl_context *ctx, +static void dynamic_model_load( mdl_context *ctx, struct dynamic_model_1texture *mdl, - const char *path ) -{ + const char *path ){ if( !mdl_arrcount( &ctx->textures ) ) vg_fatal_error( "No texture in model" ); @@ -58,13 +56,13 @@ VG_STATIC void dynamic_model_load( mdl_context *ctx, mdl_async_load_glmesh( ctx, &mdl->mesh ); } -VG_STATIC void dynamic_model_unload( struct dynamic_model_1texture *mdl ){ +static void dynamic_model_unload( struct dynamic_model_1texture *mdl ){ mesh_free( &mdl->mesh ); glDeleteTextures( 1, &mdl->texture ); } /* TODO: allow error handling */ -VG_STATIC void player_board_load( struct player_board *board, +static void player_board_load( struct player_board *board, const char *path ){ vg_linear_clear( vg_mem.scratch ); @@ -118,11 +116,11 @@ VG_STATIC void player_board_load( struct player_board *board, mdl_close( &ctx ); } -VG_STATIC void player_board_unload( struct player_board *board ){ +static void player_board_unload( struct player_board *board ){ dynamic_model_unload( &board->mdl ); } -VG_STATIC void player_model_load( struct player_model *board, const char *path){ +static void player_model_load( struct player_model *board, const char *path){ vg_linear_clear( vg_mem.scratch ); mdl_context ctx; @@ -134,13 +132,13 @@ VG_STATIC void player_model_load( struct player_model *board, const char *path){ mdl_close( &ctx ); } -VG_STATIC void player_model_unload( struct player_model *board ){ +static void player_model_unload( struct player_model *board ){ dynamic_model_unload( &board->mdl ); } -VG_STATIC void player_apply_pose_to_skeleton( player_instance *player ){ - struct skeleton *sk = &player->playeravatar->sk; - player_pose *pose = &player->pose; +static void player_apply_pose_to_skeleton(void){ + struct skeleton *sk = &localplayer.playeravatar->sk; + player_pose *pose = &localplayer.pose; m4x3f transform; q_m3x3( pose->root_q, transform ); @@ -160,56 +158,49 @@ VG_STATIC void player_apply_pose_to_skeleton( player_instance *player ){ } } -VG_STATIC void player__animate( player_instance *player ){ - if( _player_animate[ player->subsystem ] && - _player_pose[ player->subsystem ] ){ - _player_animate[ player->subsystem ]( player ); - _player_pose[ player->subsystem ]( player, &player->pose ); +static void player__animate(void){ + struct player_subsystem_interface *sys = + player_subsystems[localplayer.subsystem]; + assert( sys->animate ); + assert( sys->pose ); + assert( sys->animator_data ); - struct skeleton *sk = &player->playeravatar->sk; + sys->animate(); + sys->pose( sys->animator_data, &localplayer.pose ); - if( player->holdout_time > 0.0f ){ - player_pose *pose = &player->pose; - skeleton_lerp_pose( sk, - pose->keyframes, player->holdout_pose.keyframes, - player->holdout_time, pose->keyframes ); - q_nlerp( pose->root_q, player->holdout_pose.root_q, - player->holdout_time, pose->root_q ); - player->holdout_time -= vg.time_frame_delta * 2.0f; - } + struct skeleton *sk = &localplayer.playeravatar->sk; - player_apply_pose_to_skeleton( player ); - skeleton_debug( sk ); + if( localplayer.holdout_time > 0.0f ){ + player_pose *pose = &localplayer.pose; + skeleton_lerp_pose( sk, + pose->keyframes,localplayer.holdout_pose.keyframes, + localplayer.holdout_time, pose->keyframes ); + q_nlerp( pose->root_q, localplayer.holdout_pose.root_q, + localplayer.holdout_time, pose->root_q ); + localplayer.holdout_time -= vg.time_frame_delta * 2.0f; } - if( _player_post_animate[ player->subsystem ] ) - _player_post_animate[ player->subsystem ]( player ); + player_apply_pose_to_skeleton(); + skeleton_debug( sk ); - player__cam_iterate( player ); + if( sys->post_animate ) + sys->post_animate(); + + player__cam_iterate(); } -VG_STATIC void player_copy_frame_animator( player_instance *player, - replay_frame *frame ){ - void *animator_src = replay_frame_data( frame, k_replay_framedata_animator ); - u16 animator_size = frame->data_table[ k_replay_framedata_animator ][1]; +static void player_copy_frame_animator( replay_frame *frame ){ + struct player_subsystem_interface *sys = + player_subsystems[localplayer.subsystem]; - if( frame->system == k_player_subsystem_walk ){ - memcpy( &player->_walk.animator, animator_src, animator_size ); - } - else if( frame->system == k_player_subsystem_dead ){ - memcpy( &player->_dead.animator, animator_src, animator_size ); - } - else if( frame->system == k_player_subsystem_skate ){ - memcpy( &player->_skate.animator, animator_src, animator_size ); - } - else if( frame->system == k_player_subsystem_drive ){ - + if( sys->animator_size ){ + void *src = replay_frame_data( frame, k_replay_framedata_animator ); + memcpy( sys->animator_data, src, sys->animator_size ); } } -VG_STATIC void player__animate_from_replay( player_instance *player, - replay_buffer *replay ){ +static void player__animate_from_replay( replay_buffer *replay ){ replay_frame *frame = replay->cursor_frame, *next = NULL; if( frame ){ @@ -220,44 +211,51 @@ VG_STATIC void player__animate_from_replay( player_instance *player, player_pose pose0, pose1; - player_copy_frame_animator( player, frame ); - _player_pose[ frame->system ]( player, &pose0 ); + struct player_subsystem_interface + *sys0 = player_subsystems[frame->system], + *sys1 = player_subsystems[next->system]; + + void *a0 = replay_frame_data( frame, k_replay_framedata_animator ), + *a1 = replay_frame_data( next, k_replay_framedata_animator ); - player_copy_frame_animator( player, next ); - _player_pose[ next->system ]( player, &pose1 ); + sys0->pose( a0, &pose0 ); + sys1->pose( a1, &pose1 ); - v3_lerp( pose0.root_co, pose1.root_co, t, player->pose.root_co ); - q_nlerp( pose0.root_q, pose1.root_q, t, player->pose.root_q ); - player->pose.type = pose0.type; - player->pose.board.lean = vg_lerpf( pose0.board.lean, + v3_lerp( pose0.root_co, pose1.root_co, t, localplayer.pose.root_co ); + q_nlerp( pose0.root_q, pose1.root_q, t, localplayer.pose.root_q ); + localplayer.pose.type = pose0.type; + localplayer.pose.board.lean = vg_lerpf( pose0.board.lean, pose1.board.lean, t ); - struct skeleton *sk = &player->playeravatar->sk; + struct skeleton *sk = &localplayer.playeravatar->sk; if( pose0.type != pose1.type ){ /* it would be nice to apply IK pass in-keyframes. TOO BAD! */ - skeleton_copy_pose( sk, pose0.keyframes, player->pose.keyframes ); + skeleton_copy_pose( sk, pose0.keyframes, + localplayer.pose.keyframes ); } else { skeleton_lerp_pose( sk, pose0.keyframes, pose1.keyframes, - t, player->pose.keyframes ); + t, localplayer.pose.keyframes ); } } else{ - player_copy_frame_animator( player, frame ); - _player_pose[ frame->system ]( player, &player->pose ); + struct player_subsystem_interface + *sys = player_subsystems[frame->system]; + sys->pose( replay_frame_data( frame, k_replay_framedata_animator ), + &localplayer.pose ); } } else return; - player_apply_pose_to_skeleton( player ); + player_apply_pose_to_skeleton(); } -VG_STATIC void player__pre_render( player_instance *player ){ +static void player__pre_render(void){ /* shadowing/ao info */ - struct player_avatar *av = player->playeravatar; + struct player_avatar *av = localplayer.playeravatar; struct player_board *board = addon_cache_item_if_loaded( k_addon_type_board, - player->board_view_slot ); + localplayer.board_view_slot ); v3f vp0, vp1; if( board ){ v3_copy((v3f){0.0f,0.1f, board->truck_positions[0][2]}, vp0 ); @@ -273,10 +271,10 @@ VG_STATIC void player__pre_render( player_instance *player ){ m4x3_mulv( av->sk.final_mtx[ av->id_board ], vp1, ubo->g_board_1 ); } -VG_STATIC void render_board( camera *cam, world_instance *world, - struct player_board *board, m4x3f root, - struct player_board_pose *pose, - enum board_shader shader ) +static void render_board( camera *cam, world_instance *world, + struct player_board *board, m4x3f root, + struct player_board_pose *pose, + enum board_shader shader ) { if( !board ) return; @@ -404,10 +402,10 @@ VG_STATIC void render_board( camera *cam, world_instance *world, } } -VG_STATIC void render_playermodel( camera *cam, world_instance *world, - int depth_compare, - struct player_model *model, - struct skeleton *skeleton ){ +static void render_playermodel( camera *cam, world_instance *world, + int depth_compare, + struct player_model *model, + struct skeleton *skeleton ){ if( !model ) return; shader_model_character_view_use(); @@ -449,24 +447,24 @@ VG_STATIC void render_playermodel( camera *cam, world_instance *world, mesh_draw( &model->mdl.mesh ); } -PLAYER_API void player__render( camera *cam, player_instance *player ){ +static void player__render( camera *cam ){ world_instance *world = world_current_instance(); SDL_AtomicLock( &addon_system.sl_cache_using_resources ); struct player_model *model = addon_cache_item_if_loaded( k_addon_type_player, - player->playermodel_view_slot ); + localplayer.playermodel_view_slot ); - if( !model ) model = &player->fallback_model; - render_playermodel( cam, world, 1, model, &player->playeravatar->sk ); + if( !model ) model = &localplayer.fallback_model; + render_playermodel( cam, world, 1, model, &localplayer.playeravatar->sk ); struct player_board *board = addon_cache_item_if_loaded( k_addon_type_board, - player->board_view_slot ); + localplayer.board_view_slot ); - render_board( cam, world, board, player->playeravatar->sk.final_mtx[ - player->playeravatar->id_board], - &player->pose.board, + render_board( cam, world, board, localplayer.playeravatar->sk.final_mtx[ + localplayer.playeravatar->id_board], + &localplayer.pose.board, k_board_shader_player ); SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); diff --git a/player_render.h b/player_render.h index 5a11bea..be12d68 100644 --- a/player_render.h +++ b/player_render.h @@ -66,23 +66,23 @@ enum board_shader{ k_board_shader_entity }; -VG_STATIC void dynamic_model_load( mdl_context *ctx, +static void dynamic_model_load( mdl_context *ctx, struct dynamic_model_1texture *mdl, const char *path ); -VG_STATIC void dynamic_model_unload( struct dynamic_model_1texture *mdl ); +static void dynamic_model_unload( struct dynamic_model_1texture *mdl ); -VG_STATIC void player_board_load( struct player_board *mdl, const char *path ); -VG_STATIC void player_board_unload( struct player_board *mdl ); +static void player_board_load( struct player_board *mdl, const char *path ); +static void player_board_unload( struct player_board *mdl ); -VG_STATIC void player_model_load( struct player_model *board, const char *path); -VG_STATIC void player_model_unload( struct player_model *board ); +static void player_model_load( struct player_model *board, const char *path); +static void player_model_unload( struct player_model *board ); -VG_STATIC void render_board( camera *cam, world_instance *world, +static void render_board( camera *cam, world_instance *world, struct player_board *board, m4x3f root, struct player_board_pose *pose, enum board_shader shader ); -VG_STATIC void render_playermodel( camera *cam, world_instance *world, +static void render_playermodel( camera *cam, world_instance *world, int depth_compare, struct player_model *model, struct skeleton *skeleton ); diff --git a/player_replay.c b/player_replay.c index 5237e5f..cd947dd 100644 --- a/player_replay.c +++ b/player_replay.c @@ -5,7 +5,7 @@ #include "input.h" #include "gui.h" -VG_STATIC void replay_clear( replay_buffer *replay ){ +static void replay_clear( replay_buffer *replay ){ replay->head = NULL; replay->tail = NULL; replay->cursor_frame = NULL; @@ -13,13 +13,13 @@ VG_STATIC void replay_clear( replay_buffer *replay ){ replay->cursor = -99999.9; } -VG_STATIC void * -replay_frame_data( replay_frame *frame, enum replay_framedata type ){ +static +void * replay_frame_data( replay_frame *frame, enum replay_framedata type ){ void *baseptr = frame; return baseptr + frame->data_table[type][0]; } -VG_STATIC u16 +static u16 replay_frame_calculate_data_offsets( u16 data_table[4][2] ){ u32 total = vg_align8( sizeof(replay_frame) ); for( u32 i=0; i<4; i++ ){ @@ -32,7 +32,7 @@ replay_frame_calculate_data_offsets( u16 data_table[4][2] ){ return total; } -VG_STATIC void replay_tailpop( replay_buffer *replay ){ +static void replay_tailpop( replay_buffer *replay ){ if( replay->cursor_frame == replay->tail ) replay->cursor_frame = NULL; if( replay->statehead == replay->tail ) @@ -46,7 +46,7 @@ VG_STATIC void replay_tailpop( replay_buffer *replay ){ replay->head = NULL; } -VG_STATIC replay_frame *replay_newframe( replay_buffer *replay, +static replay_frame *replay_newframe( replay_buffer *replay, u16 animator_size, u16 gamestate_size, u16 sfx_count ){ @@ -120,7 +120,7 @@ check_again:; return frame; } -VG_STATIC void replay_seek( replay_buffer *replay, f64 t ){ +static void replay_seek( replay_buffer *replay, f64 t ){ if( !replay->head ) return; assert( replay->tail ); @@ -164,7 +164,7 @@ VG_STATIC void replay_seek( replay_buffer *replay, f64 t ){ replay->cursor = t; } -VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay ){ +static replay_frame *replay_find_recent_stateframe( replay_buffer *replay ){ replay_frame *frame = replay->cursor_frame; u32 i=4096; while( i --> 0 ){ @@ -176,7 +176,7 @@ VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay ){ return NULL; } -VG_STATIC f32 replay_subframe_time( replay_buffer *replay ){ +static f32 replay_subframe_time( replay_buffer *replay ){ replay_frame *frame = replay->cursor_frame; if( !frame ) return 0.0f; replay_frame *next = frame->r; @@ -189,13 +189,13 @@ VG_STATIC f32 replay_subframe_time( replay_buffer *replay ){ return 0.0f; } -VG_STATIC void replay_get_frame_camera( replay_frame *frame, camera *cam ){ +static void replay_get_frame_camera( replay_frame *frame, camera *cam ){ cam->fov = frame->cam_fov; v3_copy( frame->cam_pos, cam->pos ); v3_copy( frame->cam_angles, cam->angles ); } -VG_STATIC void replay_get_camera( replay_buffer *replay, camera *cam ){ +static void replay_get_camera( replay_buffer *replay, camera *cam ){ cam->nearz = 0.1f; cam->farz = 100.0f; if( replay->cursor_frame ){ @@ -224,7 +224,7 @@ struct replay_rb{ v4f q; }; -VG_STATIC +static void skaterift_record_frame( replay_buffer *replay, int force_gamestate ){ f64 delta = 9999999.9, statedelta = 9999999.9; @@ -284,9 +284,9 @@ void skaterift_record_frame( replay_buffer *replay, int force_gamestate ){ /* subsytem/dynamic block */ if( localplayer.subsystem == k_player_subsystem_walk ) - memcpy( dst, &localplayer._walk.state, gamestate_size ); + memcpy( dst, &player_walk.state, gamestate_size ); else if( localplayer.subsystem == k_player_subsystem_skate ) - memcpy( dst, &localplayer._skate.state, gamestate_size ); + memcpy( dst, &player_skate.state, gamestate_size ); else if( localplayer.subsystem == k_player_subsystem_dead ){ struct replay_rb *arr = dst; for( u32 i=0; isystem == k_player_subsystem_walk ){ - memcpy( &localplayer._walk.state, src, src_size ); + memcpy( &player_walk.state, src, src_size ); } else if( frame->system == k_player_subsystem_skate ){ - memcpy( &localplayer._skate.state, src, src_size ); + memcpy( &player_skate.state, src, src_size ); } else if( frame->system == k_player_subsystem_dead ){ - player__dead_transition( &localplayer ); + player__dead_transition(); struct replay_rb *arr = src; for( u32 i=0; itime; } -VG_STATIC void skaterift_replay_resume(void){ +static void skaterift_replay_resume(void){ replay_frame *prev = replay_find_recent_stateframe(&skaterift.replay); if( prev ){ @@ -390,7 +390,7 @@ VG_STATIC void skaterift_replay_resume(void){ } } -VG_STATIC void skaterift_replay_pre_update(void){ +static void skaterift_replay_pre_update(void){ if( skaterift.activity != k_skaterift_replay ) return; if( skaterift.replay_control == k_replay_control_resume ){ @@ -508,7 +508,7 @@ VG_STATIC void skaterift_replay_pre_update(void){ } } -VG_STATIC void skaterift_get_replay_camera( camera *cam ){ +static void skaterift_get_replay_camera( camera *cam ){ if( skaterift.freecam ){ cam->nearz = 0.1f; cam->farz = 100.0f; @@ -521,7 +521,7 @@ VG_STATIC void skaterift_get_replay_camera( camera *cam ){ } } -VG_STATIC void skaterift_replay_debug_info(void){ +static void skaterift_replay_debug_info(void){ player__debugtext( 2, "replay info" ); replay_buffer *replay = &skaterift.replay; @@ -558,7 +558,7 @@ VG_STATIC void skaterift_replay_debug_info(void){ player__debugtext( 1, "cursor: %.2fs / %.2fs\n", cur, len ); } -VG_STATIC void skaterift_replay_imgui(void){ +static void skaterift_replay_imgui(void){ if( skaterift.activity != k_skaterift_replay ) return; replay_buffer *replay = &skaterift.replay; diff --git a/player_replay.h b/player_replay.h index 9890be0..cd9bd84 100644 --- a/player_replay.h +++ b/player_replay.h @@ -49,22 +49,22 @@ struct replay_sfx { u32 none; }; -VG_STATIC replay_frame *replay_newframe( replay_buffer *replay, +static replay_frame *replay_newframe( replay_buffer *replay, u16 animator_size, u16 gamestate_size, u16 sfx_count ); -VG_STATIC void replay_seek( replay_buffer *replay, f64 t ); +static void replay_seek( replay_buffer *replay, f64 t ); -VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay ); -VG_STATIC void replay_get_camera( replay_buffer *replay, camera *cam ); -VG_STATIC void replay_get_frame_camera( replay_frame *frame, camera *cam ); -VG_STATIC f32 replay_subframe_time( replay_buffer *replay ); -VG_STATIC void replay_clear( replay_buffer *replay ); -VG_STATIC void * +static replay_frame *replay_find_recent_stateframe( replay_buffer *replay ); +static void replay_get_camera( replay_buffer *replay, camera *cam ); +static void replay_get_frame_camera( replay_frame *frame, camera *cam ); +static f32 replay_subframe_time( replay_buffer *replay ); +static void replay_clear( replay_buffer *replay ); +static void * replay_frame_data( replay_frame *frame, enum replay_framedata type ); -VG_STATIC void skaterift_replay_pre_update(void); -VG_STATIC void skaterift_replay_imgui(void); -VG_STATIC void skaterift_replay_debug_info(void); +static void skaterift_replay_pre_update(void); +static void skaterift_replay_imgui(void); +static void skaterift_replay_debug_info(void); #endif /* PLAYER_REPLAY_H */ diff --git a/player_skate.c b/player_skate.c index 7da738e..1ea632a 100644 --- a/player_skate.c +++ b/player_skate.c @@ -8,37 +8,45 @@ #include "ent_skateshop.h" #include "addon.h" -VG_STATIC void player__skate_bind( player_instance *player ) -{ - struct player_skate *s = &player->_skate; - struct player_avatar *av = player->playeravatar; +static void player__skate_bind(void){ + struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &av->sk; - rb_update_transform( &player->rb ); - s->anim_grind = skeleton_get_anim( sk, "pose_grind" ); - s->anim_grind_jump = skeleton_get_anim( sk, "pose_grind_jump" ); - s->anim_stand = skeleton_get_anim( sk, "pose_stand" ); - s->anim_highg = skeleton_get_anim( sk, "pose_highg" ); - s->anim_air = skeleton_get_anim( sk, "pose_air" ); - s->anim_slide = skeleton_get_anim( sk, "pose_slide" ); - s->anim_push = skeleton_get_anim( sk, "push" ); - s->anim_push_reverse = skeleton_get_anim( sk, "push_reverse" ); - s->anim_ollie = skeleton_get_anim( sk, "ollie" ); - s->anim_ollie_reverse = skeleton_get_anim( sk, "ollie_reverse" ); - s->anim_grabs = skeleton_get_anim( sk, "grabs" ); -} + rb_update_transform( &localplayer.rb ); + + struct { struct skeleton_anim **anim; const char *name; } + bindings[] = { + { &player_skate.anim_grind, "pose_grind" }, + { &player_skate.anim_grind_jump, "pose_grind_jump" }, + { &player_skate.anim_stand, "pose_stand" }, + { &player_skate.anim_highg, "pose_highg" }, + { &player_skate.anim_air, "pose_air" }, + { &player_skate.anim_slide, "pose_slide" }, + { &player_skate.anim_push, "push" }, + { &player_skate.anim_push_reverse, "push_reverse" }, + { &player_skate.anim_ollie, "ollie" }, + { &player_skate.anim_ollie_reverse,"ollie_reverse" }, + { &player_skate.anim_grabs, "grabs" } + }; -VG_STATIC void player__skate_kill_audio( player_instance *player ) -{ - struct player_skate *s = &player->_skate; + for( u32 i=0; iaud_main ) - s->aud_main = audio_channel_fadeout( s->aud_main, 0.1f ); - if( s->aud_air ) - s->aud_air = audio_channel_fadeout( s->aud_air, 0.1f ); - if( s->aud_slide ) - s->aud_slide = audio_channel_fadeout( s->aud_slide, 0.1f ); + if( player_skate.aud_main ){ + player_skate.aud_main = + audio_channel_fadeout( player_skate.aud_main, 0.1f ); + } + if( player_skate.aud_air ){ + player_skate.aud_air = + audio_channel_fadeout( player_skate.aud_air, 0.1f ); + } + if( player_skate.aud_slide ){ + player_skate.aud_slide = + audio_channel_fadeout( player_skate.aud_slide, 0.1f ); + } audio_unlock(); } @@ -52,10 +60,7 @@ VG_STATIC void player__skate_kill_audio( player_instance *player ) * Does collision detection on a sphere vs world, and applies some smoothing * filters to the manifold afterwards */ -VG_STATIC int skate_collide_smooth( player_instance *player, - m4x3f mtx, rb_sphere *sphere, - rb_ct *man ) -{ +static int skate_collide_smooth( m4x3f mtx, rb_sphere *sphere, rb_ct *man ){ world_instance *world = world_current_instance(); int len = 0; @@ -63,7 +68,7 @@ VG_STATIC int skate_collide_smooth( player_instance *player, k_material_flag_walking ); for( int i=0; irb; + man[i].rba = &localplayer.rb; man[i].rbb = NULL; } @@ -88,10 +93,8 @@ struct grind_info v3f co, dir, n; }; -VG_STATIC int skate_grind_scansq( player_instance *player, - v3f pos, v3f dir, float r, - struct grind_info *inf ) -{ +static int skate_grind_scansq( v3f pos, v3f dir, float r, + struct grind_info *inf ){ world_instance *world = world_current_instance(); v4f plane; @@ -116,7 +119,7 @@ VG_STATIC int skate_grind_scansq( player_instance *player, support_max; v3f support_axis; - v3_cross( plane, player->basis[1], support_axis ); + v3_cross( plane, localplayer.basis[1], support_axis ); v3_normalize( support_axis ); bh_iter it; @@ -153,9 +156,9 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3_cross( va, vb, normal ); sample->normal[0] = v3_dot( support_axis, normal ); - sample->normal[1] = v3_dot( player->basis[1], normal ); + sample->normal[1] = v3_dot( localplayer.basis[1], normal ); sample->co[0] = v3_dot( support_axis, d ); - sample->co[1] = v3_dot( player->basis[1], d ); + sample->co[1] = v3_dot( localplayer.basis[1], d ); v3_copy( normal, sample->normal3 ); /* normalize later if we want to us it */ @@ -230,8 +233,8 @@ too_many_samples: v3_muls( dir, vg_signf(v3_dot(dir,plane)), dir ); v3_add( average_direction, dir, average_direction ); - float yi = v3_dot( player->basis[1], si->normal3 ), - yj = v3_dot( player->basis[1], sj->normal3 ); + float yi = v3_dot( localplayer.basis[1], si->normal3 ), + yj = v3_dot( localplayer.basis[1], sj->normal3 ); if( yi > yj ) v3_add( si->normal3, average_normal, average_normal ); else v3_add( sj->normal3, average_normal, average_normal ); @@ -268,8 +271,7 @@ too_many_samples: return passed_samples; } -VG_STATIC void reset_jump_info( jump_info *inf ) -{ +static void reset_jump_info( jump_info *inf ){ inf->log_length = 0; inf->land_dist = 0.0f; inf->score = 0.0f; @@ -277,18 +279,14 @@ VG_STATIC void reset_jump_info( jump_info *inf ) v3_zero( inf->apex ); } -VG_STATIC int create_jumps_to_hit_target( player_instance *player, - jump_info *jumps, +static int create_jumps_to_hit_target( jump_info *jumps, v3f target, float max_angle_delta, - float gravity ) -{ - struct player_skate *s = &player->_skate; - + float gravity ){ /* calculate the exact 2 solutions to jump onto that grind spot */ v3f v0; - v3_sub( target, player->rb.co, v0 ); - m3x3_mulv( player->invbasis, v0, v0 ); + v3_sub( target, localplayer.rb.co, v0 ); + m3x3_mulv( localplayer.invbasis, v0, v0 ); v3f ax; v3_copy( v0, ax ); @@ -296,7 +294,7 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player, v3_normalize( ax ); v3f v_local; - m3x3_mulv( player->invbasis, player->rb.v, v_local ); + m3x3_mulv( localplayer.invbasis, localplayer.rb.v, v_local ); v2f d = { v3_dot( ax, v0 ), v0[1] }, v = { v3_dot( ax, v_local ), v_local[1] }; @@ -318,7 +316,7 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player, v3_muls( ax, cosf( a0 ) * m, inf->v ); inf->v[1] += sinf( a0 ) * m; - m3x3_mulv( player->basis, inf->v, inf->v ); + m3x3_mulv( localplayer.basis, inf->v, inf->v ); inf->land_dist = d[0] / (cosf(a0)*m); inf->gravity = gravity; @@ -331,7 +329,7 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player, v3_muls( ax, cosf( a1 ) * m, inf->v ); inf->v[1] += sinf( a1 ) * m; - m3x3_mulv( player->basis, inf->v, inf->v ); + m3x3_mulv( localplayer.basis, inf->v, inf->v ); inf->land_dist = d[0] / (cosf(a1)*m); inf->gravity = gravity; @@ -342,26 +340,24 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player, return valid_count; } -VG_STATIC -void player__approximate_best_trajectory( player_instance *player ) -{ +static void player__approximate_best_trajectory(void){ world_instance *world0 = world_current_instance(); - struct player_skate *s = &player->_skate; float k_trace_delta = k_rb_delta * 10.0f; + struct player_skate_state *state = &player_skate.state; - s->state.air_start = vg.time; - v3_copy( player->rb.v, s->state.air_init_v ); - v3_copy( player->rb.co, s->state.air_init_co ); + state->air_start = vg.time; + v3_copy( localplayer.rb.v, state->air_init_v ); + v3_copy( localplayer.rb.co, state->air_init_co ); - s->possible_jump_count = 0; + player_skate.possible_jump_count = 0; v3f axis; - v3_cross( player->rb.v, player->rb.to_world[1], axis ); + v3_cross( localplayer.rb.v, localplayer.rb.to_world[1], axis ); v3_normalize( axis ); /* at high slopes, Y component is low */ - float upness = v3_dot( player->rb.to_world[1], player->basis[1] ), + float upness = v3_dot( localplayer.rb.to_world[1], localplayer.basis[1] ), angle_begin = -(1.0f-fabsf( upness )), angle_end = 1.0f; @@ -373,7 +369,7 @@ void player__approximate_best_trajectory( player_instance *player ) v3f launch_v_bounds[2]; for( int i=0; i<2; i++ ){ - v3_copy( player->rb.v, launch_v_bounds[i] ); + v3_copy( localplayer.rb.v, launch_v_bounds[i] ); float ang = (float[]){ angle_begin, angle_end }[ i ]; ang *= 0.15f; @@ -383,12 +379,13 @@ void player__approximate_best_trajectory( player_instance *player ) } for( int m=0;m<=30; m++ ){ - jump_info *inf = &s->possible_jumps[ s->possible_jump_count ++ ]; + jump_info *inf = + &player_skate.possible_jumps[ player_skate.possible_jump_count ++ ]; reset_jump_info( inf ); v3f launch_co, launch_v, co0, co1; - v3_copy( player->rb.co, launch_co ); - v3_copy( player->rb.v, launch_v ); + v3_copy( localplayer.rb.co, launch_co ); + v3_copy( localplayer.rb.v, launch_v ); v3_copy( launch_co, co0 ); world_instance *trace_world = world0; @@ -402,7 +399,7 @@ void player__approximate_best_trajectory( player_instance *player ) float yaw_sketch = 1.0f-fabsf(upness); float yaw_bias = ((float)(m%3) - 1.0f) * 0.08f * yaw_sketch; - q_axis_angle( qbias, player->rb.to_world[1], yaw_bias ); + q_axis_angle( qbias, localplayer.rb.to_world[1], yaw_bias ); q_mulv( qbias, launch_v, launch_v ); float gravity_bias = vg_lerpf( 0.85f, 1.4f, vt ), @@ -411,7 +408,7 @@ void player__approximate_best_trajectory( player_instance *player ) v3_copy( launch_v, inf->v ); m3x3f basis; - m3x3_copy( player->basis, basis ); + m3x3_copy( localplayer.basis, basis ); for( int i=1; i<=50; i++ ){ float t = (float)i * k_trace_delta; @@ -462,7 +459,7 @@ void player__approximate_best_trajectory( player_instance *player ) v3_copy( launch_v, ve ); v3_muladds( ve, basis[1], -gravity * t, ve ); - if( skate_grind_scansq( player, closest, ve, 0.5f, &grind ) ){ + if( skate_grind_scansq( closest, ve, 0.5f, &grind ) ){ /* check alignment */ v2f v0 = { v3_dot( ve, basis[0] ), v3_dot( ve, basis[2] ) }, @@ -475,7 +472,7 @@ void player__approximate_best_trajectory( player_instance *player ) float a = v2_dot( v0, v1 ); float a_min = cosf( VG_PIf * 0.185f ); - if( s->state.grind_cooldown ) + if( state->grind_cooldown ) a_min = cosf( VG_PIf * 0.05f ); /* check speed */ @@ -526,7 +523,7 @@ void player__approximate_best_trajectory( player_instance *player ) v3f ve; v3_copy( launch_v, ve ); - v3_muladds( ve, player->basis[1], -gravity * t, ve ); + v3_muladds( ve, localplayer.basis[1], -gravity * t, ve ); inf->score = -v3_dot( ve, inf->n ); inf->land_dist = t + k_trace_delta * t1; @@ -536,31 +533,30 @@ void player__approximate_best_trajectory( player_instance *player ) inf->score *= 10.0f; if( surf->info.flags & k_material_flag_boundary ) - s->possible_jump_count --; + player_skate.possible_jump_count --; break; } if( i % 3 == 0 ) v3_copy( co1, inf->log[ inf->log_length ++ ] ); - v3_copy( co1, co0 ); } if( inf->type == k_prediction_unset ) - s->possible_jump_count --; + player_skate.possible_jump_count --; } if( grind_located ){ jump_info grind_jumps[2]; int valid_count = - create_jumps_to_hit_target( player, grind_jumps, grind.co, + create_jumps_to_hit_target( grind_jumps, grind.co, 0.175f*VG_PIf, grind_located_gravity ); /* knock out original landing points in the 1m area */ - for( u32 j=0; jpossible_jump_count; j++ ){ - jump_info *jump = &s->possible_jumps[ j ]; + for( u32 j=0; jlog[jump->log_length-1], grind.co ); float descale = 1.0f-vg_minf(1.0f,dist); jump->score += descale*3.0f; @@ -573,10 +569,10 @@ void player__approximate_best_trajectory( player_instance *player ) v3f launch_v, launch_co, co0, co1; v3_copy( jump->v, launch_v ); - v3_copy( player->rb.co, launch_co ); + v3_copy( localplayer.rb.co, launch_co ); m3x3f basis; - m3x3_copy( player->basis, basis ); + m3x3_copy( localplayer.basis, basis ); float t = 0.05f * jump->land_dist; v3_muls( launch_v, t, co0 ); @@ -612,10 +608,12 @@ void player__approximate_best_trajectory( player_instance *player ) /* determine score */ v3f ve; v3_copy( jump->v, ve ); - v3_muladds( ve, player->basis[1], -jump->gravity*jump->land_dist, ve ); + v3_muladds( ve, localplayer.basis[1], + -jump->gravity*jump->land_dist, ve ); jump->score = -v3_dot( ve, grind.n ) * 0.9f; - s->possible_jumps[ s->possible_jump_count ++ ] = *jump; + player_skate.possible_jumps[ player_skate.possible_jump_count ++ ] = + *jump; continue; invalidated_grind:; @@ -628,8 +626,8 @@ invalidated_grind:; jump_info *best = NULL; - for( int i=0; ipossible_jump_count; i ++ ){ - jump_info *jump = &s->possible_jumps[i]; + for( int i=0; iscore < score_min ) best = jump; @@ -638,8 +636,8 @@ invalidated_grind:; score_max = vg_maxf( score_max, jump->score ); } - for( int i=0; ipossible_jump_count; i ++ ){ - jump_info *jump = &s->possible_jumps[i]; + for( int i=0; iscore; s -= score_min; @@ -658,33 +656,32 @@ invalidated_grind:; } if( best ){ - v3_copy( best->n, s->state.land_normal ); - v3_copy( best->v, player->rb.v ); - s->state.land_dist = best->land_dist; - - s->state.gravity_bias = best->gravity; + v3_copy( best->n, state->land_normal ); + v3_copy( best->v, localplayer.rb.v ); + state->land_dist = best->land_dist; + state->gravity_bias = best->gravity; if( best->type == k_prediction_grind ){ - s->state.activity = k_skate_activity_air_to_grind; + state->activity = k_skate_activity_air_to_grind; } v2f steer; joystick_state( k_srjoystick_steer, steer ); v2_normalize_clamp( steer ); - if( (fabsf(steer[1]) > 0.5f) && (s->state.land_dist >= 1.5f) ){ - s->state.flip_rate = (1.0f/s->state.land_dist) * vg_signf(steer[1]) * - s->state.reverse ; - s->state.flip_time = 0.0f; - v3_copy( player->rb.to_world[0], s->state.flip_axis ); + if( (fabsf(steer[1]) > 0.5f) && (state->land_dist >= 1.5f) ){ + state->flip_rate = (1.0f/state->land_dist) * vg_signf(steer[1]) * + state->reverse ; + state->flip_time = 0.0f; + v3_copy( localplayer.rb.to_world[0], state->flip_axis ); } else{ - s->state.flip_rate = 0.0f; - v3_zero( s->state.flip_axis ); + state->flip_rate = 0.0f; + v3_zero( state->flip_axis ); } } else{ - v3_copy( player->basis[1], s->state.land_normal ); + v3_copy( localplayer.basis[1], state->land_normal ); } } @@ -697,47 +694,45 @@ invalidated_grind:; /* * Air control, no real physics */ -VG_STATIC void skate_apply_air_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void skate_apply_air_model(void){ + struct player_skate_state *state = &player_skate.state; - if( s->state.activity_prev > k_skate_activity_air_to_grind ) - player__approximate_best_trajectory( player ); + if( state->activity_prev > k_skate_activity_air_to_grind ) + player__approximate_best_trajectory(); - float angle = v3_dot( player->rb.to_world[1], s->state.land_normal ); + float angle = v3_dot( localplayer.rb.to_world[1], state->land_normal ); angle = vg_clampf( angle, -1.0f, 1.0f ); v3f axis; - v3_cross( player->rb.to_world[1], s->state.land_normal, axis ); + v3_cross( localplayer.rb.to_world[1], state->land_normal, axis ); v4f correction; q_axis_angle( correction, axis, acosf(angle)*2.0f*VG_TIMESTEP_FIXED ); - q_mul( correction, player->rb.q, player->rb.q ); + q_mul( correction, localplayer.rb.q, localplayer.rb.q ); } -VG_STATIC enum trick_type player_skate_trick_input( player_instance *player ); -VG_STATIC void skate_apply_trick_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static enum trick_type player_skate_trick_input(void); +static void skate_apply_trick_model(void){ + struct player_skate_state *state = &player_skate.state; v3f Fd, Fs, F; v3f strength = { 3.7f, 3.6f, 8.0f }; - v3_muls( s->state.trick_residualv, -4.0f , Fd ); - v3_muls( s->state.trick_residuald, -10.0f, Fs ); + v3_muls( state->trick_residualv, -4.0f , Fd ); + v3_muls( state->trick_residuald, -10.0f, Fs ); v3_add( Fd, Fs, F ); v3_mul( strength, F, F ); - v3_muladds( s->state.trick_residualv, F, k_rb_delta, - s->state.trick_residualv ); - v3_muladds( s->state.trick_residuald, s->state.trick_residualv, - k_rb_delta, s->state.trick_residuald ); + v3_muladds( state->trick_residualv, F, k_rb_delta, + state->trick_residualv ); + v3_muladds( state->trick_residuald, state->trick_residualv, + k_rb_delta, state->trick_residuald ); - if( s->state.activity <= k_skate_activity_air_to_grind ){ - if( v3_length2( s->state.trick_vel ) < 0.0001f ) + if( state->activity <= k_skate_activity_air_to_grind ){ + if( v3_length2( state->trick_vel ) < 0.0001f ) return; - int carry_on = player_skate_trick_input( player ); + int carry_on = player_skate_trick_input(); /* we assume velocities share a common divisor, in which case the * interval is the minimum value (if not zero) */ @@ -745,68 +740,66 @@ VG_STATIC void skate_apply_trick_model( player_instance *player ) float min_rate = 99999.0f; for( int i=0; i<3; i++ ){ - float v = s->state.trick_vel[i]; + float v = state->trick_vel[i]; if( (v > 0.0f) && (v < min_rate) ) min_rate = v; } float interval = 1.0f / min_rate, - current = floorf( s->state.trick_time / interval ), + current = floorf( state->trick_time / interval ), next_end = (current+1.0f) * interval; /* integrate trick velocities */ - v3_muladds( s->state.trick_euler, s->state.trick_vel, k_rb_delta, - s->state.trick_euler ); - - if( !carry_on && (s->state.trick_time + k_rb_delta >= next_end) ){ - s->state.trick_time = 0.0f; - s->state.trick_euler[0] = roundf( s->state.trick_euler[0] ); - s->state.trick_euler[1] = roundf( s->state.trick_euler[1] ); - s->state.trick_euler[2] = roundf( s->state.trick_euler[2] ); - v3_copy( s->state.trick_vel, s->state.trick_residualv ); - v3_zero( s->state.trick_vel ); + v3_muladds( state->trick_euler, state->trick_vel, k_rb_delta, + state->trick_euler ); + + if( !carry_on && (state->trick_time + k_rb_delta >= next_end) ){ + state->trick_time = 0.0f; + state->trick_euler[0] = roundf( state->trick_euler[0] ); + state->trick_euler[1] = roundf( state->trick_euler[1] ); + state->trick_euler[2] = roundf( state->trick_euler[2] ); + v3_copy( state->trick_vel, state->trick_residualv ); + v3_zero( state->trick_vel ); } - s->state.trick_time += k_rb_delta; + state->trick_time += k_rb_delta; } else{ - if( (v3_length2(s->state.trick_vel) >= 0.0001f ) && - s->state.trick_time > 0.2f) + if( (v3_length2(state->trick_vel) >= 0.0001f ) && + state->trick_time > 0.2f) { - player__skate_kill_audio( player ); - player__dead_transition( player ); + player__skate_kill_audio(); + player__dead_transition(); } - s->state.trick_euler[0] = roundf( s->state.trick_euler[0] ); - s->state.trick_euler[1] = roundf( s->state.trick_euler[1] ); - s->state.trick_euler[2] = roundf( s->state.trick_euler[2] ); - s->state.trick_time = 0.0f; - v3_zero( s->state.trick_vel ); + state->trick_euler[0] = roundf( state->trick_euler[0] ); + state->trick_euler[1] = roundf( state->trick_euler[1] ); + state->trick_euler[2] = roundf( state->trick_euler[2] ); + state->trick_time = 0.0f; + v3_zero( state->trick_vel ); } } -VG_STATIC void skate_apply_grab_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void skate_apply_grab_model(void){ + struct player_skate_state *state = &player_skate.state; float grabt = axis_state( k_sraxis_grab ); if( grabt > 0.5f ){ - v2_muladds( s->state.grab_mouse_delta, vg.mouse_delta, 0.02f, - s->state.grab_mouse_delta ); + v2_muladds( state->grab_mouse_delta, vg.mouse_delta, 0.02f, + state->grab_mouse_delta ); - v2_normalize_clamp( s->state.grab_mouse_delta ); + v2_normalize_clamp( state->grab_mouse_delta ); } else - v2_zero( s->state.grab_mouse_delta ); + v2_zero( state->grab_mouse_delta ); - s->state.grabbing = vg_lerpf( s->state.grabbing, grabt, 8.4f*k_rb_delta ); + state->grabbing = vg_lerpf( state->grabbing, grabt, 8.4f*k_rb_delta ); } -VG_STATIC void skate_apply_steering_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void skate_apply_steering_model(void){ + struct player_skate_state *state = &player_skate.state; v2f jsteer; joystick_state( k_srjoystick_steer, jsteer ); @@ -818,60 +811,60 @@ VG_STATIC void skate_apply_steering_model( player_instance *player ) steer = vg_signf( steer ) * steer*steer * k_steer_ground; v3f steer_axis; - v3_muls( player->rb.to_world[1], -vg_signf( steer ), steer_axis ); + v3_muls( localplayer.rb.to_world[1], -vg_signf( steer ), steer_axis ); float rate = 26.0f, top = 1.0f; - if( s->state.activity <= k_skate_activity_air_to_grind ){ + if( state->activity <= k_skate_activity_air_to_grind ){ rate = 6.0f * fabsf(steer); top = 1.5f; } else{ /* rotate slower when grabbing on ground */ - steer *= (1.0f-(s->state.jump_charge+grab)*0.4f); + steer *= (1.0f-(state->jump_charge+grab)*0.4f); - if( s->state.activity == k_skate_activity_grind_5050 ){ + if( state->activity == k_skate_activity_grind_5050 ){ rate = 0.0f; top = 0.0f; } - else if( s->state.activity >= k_skate_activity_grind_any ){ + else if( state->activity >= k_skate_activity_grind_any ){ rate *= fabsf(steer); float a = 0.8f * -steer * k_rb_delta; v4f q; - q_axis_angle( q, player->rb.to_world[1], a ); - q_mulv( q, s->grind_vec, s->grind_vec ); + q_axis_angle( q, localplayer.rb.to_world[1], a ); + q_mulv( q, player_skate.grind_vec, player_skate.grind_vec ); - v3_normalize( s->grind_vec ); + v3_normalize( player_skate.grind_vec ); } - else if( s->state.manual_direction ){ + else if( state->manual_direction ){ rate = 35.0f; top = 1.5f; } if( grab < 0.5f ){ - top *= 1.0f+v3_length( s->state.throw_v )*k_mmthrow_steer; + top *= 1.0f+v3_length( state->throw_v )*k_mmthrow_steer; } } - float current = v3_dot( player->rb.to_world[1], player->rb.w ), + float current = v3_dot( localplayer.rb.to_world[1], localplayer.rb.w ), addspeed = (steer * -top) - current, maxaccel = rate * k_rb_delta, accel = vg_clampf( addspeed, -maxaccel, maxaccel ); - v3_muladds( player->rb.w, player->rb.to_world[1], accel, player->rb.w ); + v3_muladds( localplayer.rb.w, localplayer.rb.to_world[1], + accel, localplayer.rb.w ); } /* * Computes friction and surface interface model */ -VG_STATIC void skate_apply_friction_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void skate_apply_friction_model(void){ + struct player_skate_state *state = &player_skate.state; /* * Computing localized friction forces for controlling the character @@ -879,7 +872,7 @@ VG_STATIC void skate_apply_friction_model( player_instance *player ) */ v3f vel; - m3x3_mulv( player->rb.to_local, player->rb.v, vel ); + m3x3_mulv( localplayer.rb.to_local, localplayer.rb.v, vel ); float slip = 0.0f; if( fabsf(vel[2]) > 0.01f ) @@ -888,8 +881,8 @@ VG_STATIC void skate_apply_friction_model( player_instance *player ) if( fabsf( slip ) > 1.2f ) slip = vg_signf( slip ) * 1.2f; - s->state.slip = slip; - s->state.reverse = -vg_signf(vel[2]); + state->slip = slip; + state->reverse = -vg_signf(vel[2]); vel[0] += vg_cfrictf( vel[0], k_friction_lat * k_rb_delta ); vel[2] += vg_cfrictf( vel[2], k_friction_resistance * k_rb_delta ); @@ -897,14 +890,14 @@ VG_STATIC void skate_apply_friction_model( player_instance *player ) /* Pushing additive force */ if( !button_press( k_srbind_jump ) ){ - if( button_press( k_srbind_push ) || (vg.time-s->state.start_push<0.75) ) + if( button_press( k_srbind_push ) || (vg.time-state->start_push<0.75) ) { - if( (vg.time - s->state.cur_push) > 0.25 ) - s->state.start_push = vg.time; + if( (vg.time - state->cur_push) > 0.25 ) + state->start_push = vg.time; - s->state.cur_push = vg.time; + state->cur_push = vg.time; - double push_time = vg.time - s->state.start_push; + double push_time = vg.time - state->start_push; float cycle_time = push_time*k_push_cycle_rate, accel = k_push_accel * (sinf(cycle_time)*0.5f+0.5f), @@ -913,143 +906,144 @@ VG_STATIC void skate_apply_friction_model( player_instance *player ) new_vel = vg_minf( current + amt, k_max_push_speed ), delta = new_vel - vg_minf( current, k_max_push_speed ); - vel[2] += delta * -s->state.reverse; + vel[2] += delta * -state->reverse; } } /* Send back to velocity */ - m3x3_mulv( player->rb.to_world, vel, player->rb.v ); + m3x3_mulv( localplayer.rb.to_world, vel, localplayer.rb.v ); } -VG_STATIC void skate_apply_jump_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; - int charging_jump_prev = s->state.charging_jump; - s->state.charging_jump = button_press( k_srbind_jump ); +static void skate_apply_jump_model(void){ + struct player_skate_state *state = &player_skate.state; + int charging_jump_prev = state->charging_jump; + state->charging_jump = button_press( k_srbind_jump ); /* Cannot charge this in air */ - if( s->state.activity <= k_skate_activity_air_to_grind ){ - s->state.charging_jump = 0; + if( state->activity <= k_skate_activity_air_to_grind ){ + state->charging_jump = 0; return; } - if( s->state.charging_jump ){ - s->state.jump_charge += k_rb_delta * k_jump_charge_speed; + if( state->charging_jump ){ + state->jump_charge += k_rb_delta * k_jump_charge_speed; if( !charging_jump_prev ) - s->state.jump_dir = s->state.reverse>0.0f? 1: 0; + state->jump_dir = state->reverse>0.0f? 1: 0; } else{ - s->state.jump_charge -= k_jump_charge_speed * k_rb_delta; + state->jump_charge -= k_jump_charge_speed * k_rb_delta; } - s->state.jump_charge = vg_clampf( s->state.jump_charge, 0.0f, 1.0f ); + state->jump_charge = vg_clampf( state->jump_charge, 0.0f, 1.0f ); /* player let go after charging past 0.2: trigger jump */ - if( (!s->state.charging_jump) && (s->state.jump_charge > 0.2f) ){ + if( (!state->charging_jump) && (state->jump_charge > 0.2f) ){ v3f jumpdir; /* Launch more up if alignment is up else improve velocity */ - float aup = v3_dot( player->basis[1], player->rb.to_world[1] ), + float aup = v3_dot( localplayer.basis[1], localplayer.rb.to_world[1] ), mod = 0.5f, dir = mod + fabsf(aup)*(1.0f-mod); - if( s->state.activity == k_skate_activity_ground ){ - v3_copy( player->rb.v, jumpdir ); + if( state->activity == k_skate_activity_ground ){ + v3_copy( localplayer.rb.v, jumpdir ); v3_normalize( jumpdir ); v3_muls( jumpdir, 1.0f-dir, jumpdir ); - v3_muladds( jumpdir, player->rb.to_world[1], dir, jumpdir ); + v3_muladds( jumpdir, localplayer.rb.to_world[1], dir, jumpdir ); v3_normalize( jumpdir ); }else{ - v3_copy( s->state.up_dir, jumpdir ); - s->state.grind_cooldown = 30; - s->state.activity = k_skate_activity_ground; + v3_copy( state->up_dir, jumpdir ); + state->grind_cooldown = 30; + state->activity = k_skate_activity_ground; v2f steer; joystick_state( k_srjoystick_steer, steer ); float tilt = steer[0] * 0.3f; - tilt *= vg_signf(v3_dot( player->rb.v, s->grind_dir )); + tilt *= vg_signf(v3_dot( localplayer.rb.v, + player_skate.grind_dir )); v4f qtilt; - q_axis_angle( qtilt, s->grind_dir, tilt ); + q_axis_angle( qtilt, player_skate.grind_dir, tilt ); q_mulv( qtilt, jumpdir, jumpdir ); } - s->state.surface_cooldown = 10; + state->surface_cooldown = 10; - float force = k_jump_force*s->state.jump_charge; - v3_muladds( player->rb.v, jumpdir, force, player->rb.v ); - s->state.jump_charge = 0.0f; - s->state.jump_time = vg.time; + float force = k_jump_force*state->jump_charge; + v3_muladds( localplayer.rb.v, jumpdir, force, localplayer.rb.v ); + state->jump_charge = 0.0f; + state->jump_time = vg.time; audio_lock(); - audio_oneshot_3d( &audio_jumps[vg_randu32()%2], player->rb.co,40.0f,1.0f); + audio_oneshot_3d( &audio_jumps[vg_randu32()%2], + localplayer.rb.co,40.0f,1.0f); audio_unlock(); } } -VG_STATIC void skate_apply_pump_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void skate_apply_pump_model(void){ + struct player_skate_state *state = &player_skate.state; - if( s->state.activity != k_skate_activity_ground ){ - v3_zero( s->state.throw_v ); + if( state->activity != k_skate_activity_ground ){ + v3_zero( state->throw_v ); return; } /* Throw / collect routine */ if( axis_state( k_sraxis_grab ) > 0.5f ){ - if( s->state.activity == k_skate_activity_ground ){ + if( state->activity == k_skate_activity_ground ){ /* Throw */ - v3_muls( player->rb.to_world[1], k_mmthrow_scale, s->state.throw_v ); + v3_muls( localplayer.rb.to_world[1], k_mmthrow_scale, state->throw_v ); } } else{ /* Collect */ - float doty = v3_dot( player->rb.to_world[1], s->state.throw_v ); + float doty = v3_dot( localplayer.rb.to_world[1], state->throw_v ); v3f Fl, Fv; - v3_muladds( s->state.throw_v, player->rb.to_world[1], -doty, Fl); + v3_muladds( state->throw_v, localplayer.rb.to_world[1], -doty, Fl); - if( s->state.activity == k_skate_activity_ground ){ - if( v3_length2(player->rb.v)<(20.0f*20.0f) ) - v3_muladds( player->rb.v, Fl, k_mmcollect_lat, player->rb.v ); - v3_muladds( s->state.throw_v, Fl, -k_mmcollect_lat, s->state.throw_v ); + if( state->activity == k_skate_activity_ground ){ + if( v3_length2(localplayer.rb.v)<(20.0f*20.0f) ){ + v3_muladds( localplayer.rb.v, Fl, + k_mmcollect_lat, localplayer.rb.v ); + } + v3_muladds( state->throw_v, Fl, -k_mmcollect_lat, state->throw_v ); } - v3_muls( player->rb.to_world[1], -doty, Fv ); - v3_muladds( player->rb.v, Fv, k_mmcollect_vert, player->rb.v ); - v3_muladds( s->state.throw_v, Fv, k_mmcollect_vert, s->state.throw_v ); + v3_muls( localplayer.rb.to_world[1], -doty, Fv ); + v3_muladds( localplayer.rb.v, Fv, k_mmcollect_vert, localplayer.rb.v ); + v3_muladds( state->throw_v, Fv, k_mmcollect_vert, state->throw_v ); } /* Decay */ - if( v3_length2( s->state.throw_v ) > 0.0001f ){ + if( v3_length2( state->throw_v ) > 0.0001f ){ v3f dir; - v3_copy( s->state.throw_v, dir ); + v3_copy( state->throw_v, dir ); v3_normalize( dir ); - float max = v3_dot( dir, s->state.throw_v ), + float max = v3_dot( dir, state->throw_v ), amt = vg_minf( k_mmdecay * k_rb_delta, max ); - v3_muladds( s->state.throw_v, dir, -amt, s->state.throw_v ); + v3_muladds( state->throw_v, dir, -amt, state->throw_v ); } } -VG_STATIC void skate_apply_cog_model( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void skate_apply_cog_model(void){ + struct player_skate_state *state = &player_skate.state; v3f ideal_cog, ideal_diff, ideal_dir; - v3_copy( s->state.up_dir, ideal_dir ); + v3_copy( state->up_dir, ideal_dir ); v3_normalize( ideal_dir ); float grab = axis_state( k_sraxis_grab ); - v3_muladds( player->rb.co, ideal_dir, 1.0f-grab, ideal_cog ); - v3_sub( ideal_cog, s->state.cog, ideal_diff ); + v3_muladds( localplayer.rb.co, ideal_dir, 1.0f-grab, ideal_cog ); + v3_sub( ideal_cog, state->cog, ideal_diff ); /* Apply velocities */ v3f rv; - v3_sub( player->rb.v, s->state.cog_v, rv ); + v3_sub( localplayer.rb.v, state->cog_v, rv ); v3f F; v3_muls( ideal_diff, -k_cog_spring * k_rb_rate, F ); @@ -1059,97 +1053,93 @@ VG_STATIC void skate_apply_cog_model( player_instance *player ) rb = 1.0f-k_cog_mass_ratio; /* Apply forces & intergrate */ - v3_muladds( s->state.cog_v, F, -rb, s->state.cog_v ); - v3_muladds( s->state.cog_v, player->basis[1], -9.8f * k_rb_delta, - s->state.cog_v ); + v3_muladds( state->cog_v, F, -rb, state->cog_v ); + v3_muladds( state->cog_v, localplayer.basis[1], -9.8f * k_rb_delta, + state->cog_v ); - v3_muladds( s->state.cog, s->state.cog_v, k_rb_delta, s->state.cog ); + v3_muladds( state->cog, state->cog_v, k_rb_delta, state->cog ); } +static void skate_integrate(void){ + struct player_skate_state *state = &player_skate.state; -VG_STATIC void skate_integrate( player_instance *player ) -{ - struct player_skate *s = &player->_skate; - - float decay_rate_x = 1.0f - (k_rb_delta * 3.0f), - decay_rate_z = decay_rate_x, - decay_rate_y = 1.0f; + float rate_x = 1.0f - (k_rb_delta * 3.0f), + rate_z = rate_x, + rate_y = 1.0f; - if( s->state.activity >= k_skate_activity_grind_any ){ -#if 0 - decay_rate = 1.0f-vg_lerpf( 3.0f, 20.0f, s->grind_strength ) * k_rb_delta; - decay_rate_y = decay_rate; -#endif - decay_rate_x = 1.0f-(16.0f*k_rb_delta); - decay_rate_y = 1.0f-(10.0f*k_rb_delta); - decay_rate_z = 1.0f-(40.0f*k_rb_delta); + if( state->activity >= k_skate_activity_grind_any ){ + rate_x = 1.0f-(16.0f*k_rb_delta); + rate_y = 1.0f-(10.0f*k_rb_delta); + rate_z = 1.0f-(40.0f*k_rb_delta); } - float wx = v3_dot( player->rb.w, player->rb.to_world[0] ) * decay_rate_x, - wy = v3_dot( player->rb.w, player->rb.to_world[1] ) * decay_rate_y, - wz = v3_dot( player->rb.w, player->rb.to_world[2] ) * decay_rate_z; + float wx = v3_dot( localplayer.rb.w, localplayer.rb.to_world[0] ) * rate_x, + wy = v3_dot( localplayer.rb.w, localplayer.rb.to_world[1] ) * rate_y, + wz = v3_dot( localplayer.rb.w, localplayer.rb.to_world[2] ) * rate_z; - v3_muls( player->rb.to_world[0], wx, player->rb.w ); - v3_muladds( player->rb.w, player->rb.to_world[1], wy, player->rb.w ); - v3_muladds( player->rb.w, player->rb.to_world[2], wz, player->rb.w ); + v3_muls( localplayer.rb.to_world[0], wx, localplayer.rb.w ); + v3_muladds( localplayer.rb.w, localplayer.rb.to_world[1], wy, + localplayer.rb.w ); + v3_muladds( localplayer.rb.w, localplayer.rb.to_world[2], wz, + localplayer.rb.w ); - s->state.flip_time += s->state.flip_rate * k_rb_delta; - rb_update_transform( &player->rb ); + state->flip_time += state->flip_rate * k_rb_delta; + rb_update_transform( &localplayer.rb ); } -VG_STATIC enum trick_type player_skate_trick_input( player_instance *player ){ +static enum trick_type player_skate_trick_input(void){ return (button_press( k_srbind_trick0 ) ) | (button_press( k_srbind_trick1 ) << 1) | (button_press( k_srbind_trick2 ) << 1) | (button_press( k_srbind_trick2 ) ); } -VG_STATIC void player__skate_pre_update( player_instance *player ){ - struct player_skate *s = &player->_skate; +static void player__skate_pre_update(void){ + struct player_skate_state *state = &player_skate.state; if( button_down( k_srbind_use ) ){ - player->subsystem = k_player_subsystem_walk; + localplayer.subsystem = k_player_subsystem_walk; v3f angles; - v3_copy( player->cam.angles, player->angles ); - player->angles[2] = 0.0f; + v3_copy( localplayer.cam.angles, localplayer.angles ); + localplayer.angles[2] = 0.0f; - player__begin_holdout( player ); - player__skate_kill_audio( player ); - player__walk_transition( player ); + player__begin_holdout(); + player__skate_kill_audio(); + player__walk_transition(); return; } - if( s->state.activity <= k_skate_activity_air_to_grind ){ + if( state->activity <= k_skate_activity_air_to_grind ){ enum trick_type trick = k_trick_type_none; - if( (trick = player_skate_trick_input( player )) ){ - if( (vg.time - s->state.jump_time) < 0.1f ){ - v3_zero( s->state.trick_vel ); - s->state.trick_time = 0.0f; + if( (trick = player_skate_trick_input()) ){ + if( (vg.time - state->jump_time) < 0.1f ){ + v3_zero( state->trick_vel ); + state->trick_time = 0.0f; if( trick == k_trick_type_kickflip ){ - s->state.trick_vel[0] = 3.0f; + state->trick_vel[0] = 3.0f; } else if( trick == k_trick_type_shuvit ){ - s->state.trick_vel[2] = 3.0f; + state->trick_vel[2] = 3.0f; } else if( trick == k_trick_type_treflip ){ - s->state.trick_vel[0] = 2.0f; - s->state.trick_vel[2] = 2.0f; + state->trick_vel[0] = 2.0f; + state->trick_vel[2] = 2.0f; } - s->state.trick_type = trick; + state->trick_type = trick; } } } else - s->state.trick_type = k_trick_type_none; + state->trick_type = k_trick_type_none; } -VG_STATIC void player__skate_post_update( player_instance *player ){ - struct player_skate *s = &player->_skate; +static void player__skate_post_update(void){ + struct player_skate_state *state = &player_skate.state; - for( int i=0; ipossible_jump_count; i++ ){ - jump_info *jump = &s->possible_jumps[i]; + for( int i=0; ilog_length == 0 ){ vg_fatal_error( "assert: jump->log_length == 0\n" ); @@ -1173,12 +1163,12 @@ VG_STATIC void player__skate_post_update( player_instance *player ){ audio_lock(); - float air = s->state.activity <= k_skate_activity_air_to_grind? 1.0f: 0.0f, - speed = v3_length( player->rb.v ), + float air = state->activity <= k_skate_activity_air_to_grind? 1.0f: 0.0f, + speed = v3_length( localplayer.rb.v ), attn = vg_minf( 1.0f, speed*0.1f ), - slide = vg_clampf( fabsf(s->state.slip), 0.0f, 1.0f ); + slide = vg_clampf( fabsf(state->slip), 0.0f, 1.0f ); - if( s->state.activity >= k_skate_activity_grind_any ){ + if( state->activity >= k_skate_activity_grind_any ){ slide = 0.0f; } @@ -1189,16 +1179,16 @@ VG_STATIC void player__skate_post_update( player_instance *player ){ const u32 flags = AUDIO_FLAG_SPACIAL_3D|AUDIO_FLAG_LOOP; - if( !s->aud_air ){ - s->aud_air = audio_get_first_idle_channel(); - if( s->aud_air ) - audio_channel_init( s->aud_air, &audio_board[1], flags ); + if( !player_skate.aud_air ){ + player_skate.aud_air = audio_get_first_idle_channel(); + if( player_skate.aud_air ) + audio_channel_init( player_skate.aud_air, &audio_board[1], flags ); } - if( !s->aud_slide ){ - s->aud_slide = audio_get_first_idle_channel(); - if( s->aud_slide ) - audio_channel_init( s->aud_slide, &audio_board[2], flags ); + if( !player_skate.aud_slide ){ + player_skate.aud_slide = audio_get_first_idle_channel(); + if( player_skate.aud_slide ) + audio_channel_init( player_skate.aud_slide, &audio_board[2], flags ); } @@ -1207,8 +1197,8 @@ VG_STATIC void player__skate_post_update( player_instance *player ){ float sidechain_amt = 0.0f, hz = vg_maxf( speed * 2.0f, 2.0f ); - if( (s->surface == k_surface_prop_tiles) && - (s->state.activity < k_skate_activity_grind_any) ) + if( (player_skate.surface == k_surface_prop_tiles) && + (state->activity < k_skate_activity_grind_any) ) sidechain_amt = 1.0f; else sidechain_amt = 0.0f; @@ -1217,34 +1207,35 @@ VG_STATIC void player__skate_post_update( player_instance *player ){ audio_set_lfo_wave( 0, k_lfo_polynomial_bipolar, vg_lerpf( 250.0f, 80.0f, attn ) ); - if( s->sample_change_cooldown > 0.0f ){ - s->sample_change_cooldown -= vg.time_frame_delta; + if( player_skate.sample_change_cooldown > 0.0f ){ + player_skate.sample_change_cooldown -= vg.time_frame_delta; } else{ int sample_type = k_skate_sample_concrete; - if( s->state.activity == k_skate_activity_grind_5050 ){ - if( s->surface == k_surface_prop_metal ) + if( state->activity == k_skate_activity_grind_5050 ){ + if( player_skate.surface == k_surface_prop_metal ) sample_type = k_skate_sample_metal_scrape_generic; else sample_type = k_skate_sample_concrete_scrape_metal; } - else if( (s->state.activity == k_skate_activity_grind_back50) || - (s->state.activity == k_skate_activity_grind_front50) ) + else if( (state->activity == k_skate_activity_grind_back50) || + (state->activity == k_skate_activity_grind_front50) ) { - if( s->surface == k_surface_prop_metal ){ + if( player_skate.surface == k_surface_prop_metal ){ sample_type = k_skate_sample_metal_scrape_generic; } else{ - float a = v3_dot( player->rb.to_world[2], s->grind_dir ); + float a = v3_dot( localplayer.rb.to_world[2], + player_skate.grind_dir ); if( fabsf(a) > 0.70710678118654752f ) sample_type = k_skate_sample_concrete_scrape_wood; else sample_type = k_skate_sample_concrete_scrape_metal; } } - else if( s->state.activity == k_skate_activity_grind_boardslide ){ - if( s->surface == k_surface_prop_metal ) + else if( state->activity == k_skate_activity_grind_boardslide ){ + if( player_skate.surface == k_surface_prop_metal ) sample_type = k_skate_sample_metal_scrape_generic; else sample_type = k_skate_sample_concrete_scrape_wood; @@ -1258,39 +1249,45 @@ VG_STATIC void player__skate_post_update( player_instance *player ){ &audio_board[5] }; - if( (s->main_sample_type != sample_type) || (!s->aud_main) ){ - s->aud_main = - audio_channel_crossfade( s->aud_main, relevant_samples[sample_type], + if( (player_skate.main_sample_type != sample_type) || + (!player_skate.aud_main) ){ + + player_skate.aud_main = + audio_channel_crossfade( player_skate.aud_main, + relevant_samples[sample_type], 0.06f, flags ); - s->sample_change_cooldown = 0.1f; - s->main_sample_type = sample_type; + player_skate.sample_change_cooldown = 0.1f; + player_skate.main_sample_type = sample_type; } } - 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_edit_volume( s->aud_main, vol_main, 1 ); - audio_channel_sidechain_lfo( s->aud_main, 0, sidechain_amt ); + if( player_skate.aud_main ){ + player_skate.aud_main->colour = 0x00103efe; + audio_channel_set_spacial( player_skate.aud_main, + localplayer.rb.co, 40.0f ); + //audio_channel_slope_volume( player_skate.aud_main, 0.05f, vol_main ); + audio_channel_edit_volume( player_skate.aud_main, vol_main, 1 ); + audio_channel_sidechain_lfo( player_skate.aud_main, 0, sidechain_amt ); float rate = 1.0f + (attn-0.5f)*0.2f; - audio_channel_set_sampling_rate( s->aud_main, rate ); + audio_channel_set_sampling_rate( player_skate.aud_main, rate ); } - 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_edit_volume( s->aud_slide, vol_slide, 1 ); - audio_channel_sidechain_lfo( s->aud_slide, 0, sidechain_amt ); + if( player_skate.aud_slide ){ + player_skate.aud_slide->colour = 0x00103efe; + audio_channel_set_spacial( player_skate.aud_slide, + localplayer.rb.co, 40.0f ); + //audio_channel_slope_volume( player_skate.aud_slide, 0.05f, vol_slide ); + audio_channel_edit_volume( player_skate.aud_slide, vol_slide, 1 ); + audio_channel_sidechain_lfo( player_skate.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_edit_volume( s->aud_air, vol_air, 1 ); + if( player_skate.aud_air ){ + player_skate.aud_air->colour = 0x00103efe; + audio_channel_set_spacial( player_skate.aud_air, + localplayer.rb.co, 40.0f ); + //audio_channel_slope_volume( player_skate.aud_air, 0.05f, vol_air ); + audio_channel_edit_volume( player_skate.aud_air, vol_air, 1 ); } audio_unlock(); @@ -1304,18 +1301,16 @@ VG_STATIC void player__skate_post_update( player_instance *player ){ * * returns 0 if no good surface found */ -VG_STATIC -int skate_compute_surface_alignment( player_instance *player, - v3f ra, u32 colour, +static +int skate_compute_surface_alignment( v3f ra, u32 colour, v3f surface_normal, v3f axel_dir ){ - struct player_skate *s = &player->_skate; world_instance *world = world_current_instance(); v3f truck, left, right; - m4x3_mulv( player->rb.to_world, ra, truck ); + m4x3_mulv( localplayer.rb.to_world, ra, truck ); - v3_muladds( truck, player->rb.to_world[0], -k_board_width, left ); - v3_muladds( truck, player->rb.to_world[0], k_board_width, right ); + v3_muladds( truck, localplayer.rb.to_world[0], -k_board_width, left ); + v3_muladds( truck, localplayer.rb.to_world[0], k_board_width, right ); vg_line( left, right, colour ); float k_max_truck_flex = VG_PIf * 0.25f; @@ -1323,14 +1318,14 @@ int skate_compute_surface_alignment( player_instance *player, ray_hit ray_l, ray_r; v3f dir; - v3_muls( player->rb.to_world[1], -1.0f, dir ); + v3_muls( localplayer.rb.to_world[1], -1.0f, dir ); int res_l = 0, res_r = 0; for( int i=0; i<8; i++ ){ float t = 1.0f - (float)i * (1.0f/8.0f); - v3_muladds( truck, player->rb.to_world[0], -k_board_radius*t, left ); - v3_muladds( left, player->rb.to_world[1], k_board_radius, left ); + v3_muladds( truck, localplayer.rb.to_world[0], -k_board_radius*t, left ); + v3_muladds( left, localplayer.rb.to_world[1], k_board_radius, left ); ray_l.dist = 2.1f * k_board_radius; res_l = ray_world( world, left, dir, &ray_l, k_material_flag_walking ); @@ -1341,8 +1336,8 @@ int skate_compute_surface_alignment( player_instance *player, for( int i=0; i<8; i++ ){ float t = 1.0f - (float)i * (1.0f/8.0f); - v3_muladds( truck, player->rb.to_world[0], k_board_radius*t, right ); - v3_muladds( right, player->rb.to_world[1], k_board_radius, right ); + v3_muladds( truck, localplayer.rb.to_world[0], k_board_radius*t, right ); + v3_muladds( right, localplayer.rb.to_world[1], k_board_radius, right ); ray_r.dist = 2.1f * k_board_radius; res_r = ray_world( world, right, dir, &ray_r, k_material_flag_walking ); @@ -1354,7 +1349,7 @@ int skate_compute_surface_alignment( player_instance *player, v3f v0; v3f midpoint; v3f tangent_average; - v3_muladds( truck, player->rb.to_world[1], -k_board_radius, midpoint ); + v3_muladds( truck, localplayer.rb.to_world[1], -k_board_radius, midpoint ); v3_zero( tangent_average ); if( res_l || res_r ){ @@ -1364,12 +1359,12 @@ int skate_compute_surface_alignment( player_instance *player, if( res_l ){ v3_copy( ray_l.pos, p0 ); - v3_cross( ray_l.normal, player->rb.to_world[0], t ); + v3_cross( ray_l.normal, localplayer.rb.to_world[0], t ); v3_add( t, tangent_average, tangent_average ); } if( res_r ){ v3_copy( ray_r.pos, p1 ); - v3_cross( ray_r.normal, player->rb.to_world[0], t ); + v3_cross( ray_r.normal, localplayer.rb.to_world[0], t ); v3_add( t, tangent_average, tangent_average ); } @@ -1394,16 +1389,16 @@ int skate_compute_surface_alignment( player_instance *player, v3_cross( vert0, vert1, n ); v3_normalize( n ); - if( v3_dot( n, player->rb.to_world[1] ) < 0.3f ) + if( v3_dot( n, localplayer.rb.to_world[1] ) < 0.3f ) return 0; - v3_cross( n, player->rb.to_world[2], v0 ); - v3_muladds( v0, player->rb.to_world[2], - -v3_dot( player->rb.to_world[2], v0 ), v0 ); + v3_cross( n, localplayer.rb.to_world[2], v0 ); + v3_muladds( v0, localplayer.rb.to_world[2], + -v3_dot( localplayer.rb.to_world[2], v0 ), v0 ); v3_normalize( v0 ); v3f t; - v3_cross( n, player->rb.to_world[0], t ); + v3_cross( n, localplayer.rb.to_world[0], t ); v3_add( t, tangent_average, tangent_average ); } else @@ -1422,88 +1417,90 @@ int skate_compute_surface_alignment( player_instance *player, return 1; } -VG_STATIC void skate_weight_distribute( player_instance *player ){ - struct player_skate *s = &player->_skate; - v3_zero( s->weight_distribution ); +static void skate_weight_distribute(void){ + struct player_skate_state *state = &player_skate.state; + v3_zero( player_skate.weight_distribution ); - int reverse_dir = v3_dot( player->rb.to_world[2], player->rb.v ) < 0.0f?1:-1; + int reverse_dir = v3_dot( localplayer.rb.to_world[2], + localplayer.rb.v ) < 0.0f?1:-1; v2f steer; joystick_state( k_srjoystick_steer, steer ); - if( s->state.manual_direction == 0 ){ - if( (steer[1] > 0.7f) && (s->state.activity == k_skate_activity_ground) && - (s->state.jump_charge <= 0.01f) ) - s->state.manual_direction = reverse_dir; + if( state->manual_direction == 0 ){ + if( (steer[1] > 0.7f) && (state->activity == k_skate_activity_ground) && + (state->jump_charge <= 0.01f) ) + state->manual_direction = reverse_dir; } else{ if( steer[1] < 0.1f ){ - s->state.manual_direction = 0; + state->manual_direction = 0; } else{ - if( reverse_dir != s->state.manual_direction ){ + if( reverse_dir != state->manual_direction ){ return; } } } - if( s->state.manual_direction ){ + if( state->manual_direction ){ float amt = vg_minf( steer[1] * 8.0f, 1.0f ); - s->weight_distribution[2] = k_board_length * amt * - (float)s->state.manual_direction; + player_skate.weight_distribution[2] = k_board_length * amt * + (float)state->manual_direction; } - if( s->state.manual_direction ){ + if( state->manual_direction ){ v3f plane_z; - m3x3_mulv( player->rb.to_world, s->weight_distribution, plane_z ); + m3x3_mulv( localplayer.rb.to_world, player_skate.weight_distribution, + plane_z ); v3_negate( plane_z, plane_z ); - v3_muladds( plane_z, s->surface_picture, - -v3_dot( plane_z, s->surface_picture ), plane_z ); + v3_muladds( plane_z, player_skate.surface_picture, + -v3_dot( plane_z, player_skate.surface_picture ), plane_z ); v3_normalize( plane_z ); - v3_muladds( plane_z, s->surface_picture, 0.3f, plane_z ); + v3_muladds( plane_z, player_skate.surface_picture, 0.3f, plane_z ); v3_normalize( plane_z ); v3f p1; - v3_muladds( player->rb.co, plane_z, 1.5f, p1 ); - vg_line( player->rb.co, p1, VG__GREEN ); + v3_muladds( localplayer.rb.co, plane_z, 1.5f, p1 ); + vg_line( localplayer.rb.co, p1, VG__GREEN ); v3f refdir; - v3_muls( player->rb.to_world[2], -(float)s->state.manual_direction, + v3_muls( localplayer.rb.to_world[2], -(float)state->manual_direction, refdir ); - rb_effect_spring_target_vector( &player->rb, refdir, plane_z, + rb_effect_spring_target_vector( &localplayer.rb, refdir, plane_z, k_manul_spring, k_manul_dampener, - s->substep_delta ); + player_skate.substep_delta ); } } -VG_STATIC void skate_adjust_up_direction( player_instance *player ){ - struct player_skate *s = &player->_skate; +static void skate_adjust_up_direction(void){ + struct player_skate_state *state = &player_skate.state; - if( s->state.activity == k_skate_activity_ground ){ + if( state->activity == k_skate_activity_ground ){ v3f target; - v3_copy( s->surface_picture, target ); + v3_copy( player_skate.surface_picture, target ); - target[1] += 2.0f * s->surface_picture[1]; + target[1] += 2.0f * player_skate.surface_picture[1]; v3_normalize( target ); - v3_lerp( s->state.up_dir, target, - 8.0f * s->substep_delta, s->state.up_dir ); + v3_lerp( state->up_dir, target, + 8.0f * player_skate.substep_delta, state->up_dir ); } - else if( s->state.activity <= k_skate_activity_air_to_grind ){ - v3_lerp( s->state.up_dir, player->rb.to_world[1], - 8.0f * s->substep_delta, s->state.up_dir ); + else if( state->activity <= k_skate_activity_air_to_grind ){ + v3_lerp( state->up_dir, localplayer.rb.to_world[1], + 8.0f * player_skate.substep_delta, state->up_dir ); } else{ - v3_lerp( s->state.up_dir, player->basis[1], - 12.0f * s->substep_delta, s->state.up_dir ); + v3_lerp( state->up_dir, localplayer.basis[1], + 12.0f * player_skate.substep_delta, state->up_dir ); } } -VG_STATIC int skate_point_visible( v3f origin, v3f target ){ +static int skate_point_visible( v3f origin, v3f target ){ v3f dir; v3_sub( target, origin, dir ); @@ -1519,61 +1516,59 @@ VG_STATIC int skate_point_visible( v3f origin, v3f target ){ return 1; } -VG_STATIC void skate_grind_orient( struct grind_info *inf, m3x3f mtx ){ +static void skate_grind_orient( struct grind_info *inf, m3x3f mtx ){ v3_copy( inf->dir, mtx[0] ); v3_copy( inf->n, mtx[1] ); v3_cross( mtx[0], mtx[1], mtx[2] ); } -VG_STATIC void skate_grind_friction( player_instance *player, - struct grind_info *inf, float strength ){ +static void skate_grind_friction( struct grind_info *inf, float strength ){ v3f v2; - v3_muladds( player->rb.to_world[2], inf->n, - -v3_dot( player->rb.to_world[2], inf->n ), v2 ); + v3_muladds( localplayer.rb.to_world[2], inf->n, + -v3_dot( localplayer.rb.to_world[2], inf->n ), v2 ); float a = 1.0f-fabsf( v3_dot( v2, inf->dir ) ), - dir = vg_signf( v3_dot( player->rb.v, inf->dir ) ), + dir = vg_signf( v3_dot( localplayer.rb.v, inf->dir ) ), F = a * -dir * k_grind_max_friction; - v3_muladds( player->rb.v, inf->dir, F*k_rb_delta*strength, player->rb.v ); + v3_muladds( localplayer.rb.v, inf->dir, F*k_rb_delta*strength, + localplayer.rb.v ); } -VG_STATIC void skate_grind_decay( player_instance *player, - struct grind_info *inf, float strength ){ +static void skate_grind_decay( struct grind_info *inf, float strength ){ m3x3f mtx, mtx_inv; skate_grind_orient( inf, mtx ); m3x3_transpose( mtx, mtx_inv ); v3f v_grind; - m3x3_mulv( mtx_inv, player->rb.v, v_grind ); + m3x3_mulv( mtx_inv, localplayer.rb.v, v_grind ); float decay = 1.0f - ( k_rb_delta * k_grind_decayxy * strength ); v3_mul( v_grind, (v3f){ 1.0f, decay, decay }, v_grind ); - m3x3_mulv( mtx, v_grind, player->rb.v ); + m3x3_mulv( mtx, v_grind, localplayer.rb.v ); } -VG_STATIC void skate_grind_truck_apply( player_instance *player, - float sign, struct grind_info *inf, +static void skate_grind_truck_apply( float sign, struct grind_info *inf, float strength ){ - struct player_skate *s = &player->_skate; + struct player_skate_state *state = &player_skate.state; /* REFACTOR */ v3f ra = { 0.0f, -k_board_radius, sign * k_board_length }; v3f raw, wsp; - m3x3_mulv( player->rb.to_world, ra, raw ); - v3_add( player->rb.co, raw, wsp ); + m3x3_mulv( localplayer.rb.to_world, ra, raw ); + v3_add( localplayer.rb.co, raw, wsp ); - v3_copy( ra, s->weight_distribution ); + v3_copy( ra, player_skate.weight_distribution ); v3f delta; v3_sub( inf->co, wsp, delta ); /* spring force */ - v3_muladds( player->rb.v, delta, k_spring_force*strength*k_rb_delta, - player->rb.v ); + v3_muladds( localplayer.rb.v, delta, k_spring_force*strength*k_rb_delta, + localplayer.rb.v ); - skate_grind_decay( player, inf, strength ); - skate_grind_friction( player, inf, strength ); + skate_grind_decay( inf, strength ); + skate_grind_friction( inf, strength ); /* yeah yeah yeah yeah */ v3f raw_nplane, axis; @@ -1585,9 +1580,9 @@ VG_STATIC void skate_grind_truck_apply( player_instance *player, m3x3f mtx; skate_grind_orient( inf, mtx ); v3f target_fwd, fwd, up, target_up; - m3x3_mulv( mtx, s->grind_vec, target_fwd ); + m3x3_mulv( mtx, player_skate.grind_vec, target_fwd ); v3_copy( raw_nplane, fwd ); - v3_copy( player->rb.to_world[1], up ); + v3_copy( localplayer.rb.to_world[1], up ); v3_copy( inf->n, target_up ); v3_muladds( target_fwd, inf->n, -v3_dot(inf->n,target_fwd), target_fwd ); @@ -1599,43 +1594,42 @@ VG_STATIC void skate_grind_truck_apply( player_instance *player, v2f steer; joystick_state( k_srjoystick_steer, steer ); - float way = steer[1] * vg_signf( v3_dot( raw_nplane, player->rb.v ) ); + float way = steer[1] * vg_signf( v3_dot( raw_nplane, localplayer.rb.v ) ); v4f q; q_axis_angle( q, axis, VG_PIf*0.125f * way ); q_mulv( q, target_up, target_up ); q_mulv( q, target_fwd, target_fwd ); - rb_effect_spring_target_vector( &player->rb, up, target_up, + rb_effect_spring_target_vector( &localplayer.rb, up, target_up, k_grind_spring, k_grind_dampener, k_rb_delta ); - rb_effect_spring_target_vector( &player->rb, fwd, target_fwd, + rb_effect_spring_target_vector( &localplayer.rb, fwd, target_fwd, k_grind_spring*strength, k_grind_dampener*strength, k_rb_delta ); - vg_line_arrow( player->rb.co, target_up, 1.0f, VG__GREEN ); - vg_line_arrow( player->rb.co, fwd, 0.8f, VG__RED ); - vg_line_arrow( player->rb.co, target_fwd, 1.0f, VG__YELOW ); + vg_line_arrow( localplayer.rb.co, target_up, 1.0f, VG__GREEN ); + vg_line_arrow( localplayer.rb.co, fwd, 0.8f, VG__RED ); + vg_line_arrow( localplayer.rb.co, target_fwd, 1.0f, VG__YELOW ); - s->grind_strength = strength; + player_skate.grind_strength = strength; /* Fake contact */ - struct grind_limit *limit = &s->limits[ s->limit_count ++ ]; - m4x3_mulv( player->rb.to_local, wsp, limit->ra ); - m3x3_mulv( player->rb.to_local, inf->n, limit->n ); + struct grind_limit *limit = + &player_skate.limits[ player_skate.limit_count ++ ]; + m4x3_mulv( localplayer.rb.to_local, wsp, limit->ra ); + m3x3_mulv( localplayer.rb.to_local, inf->n, limit->n ); limit->p = 0.0f; - v3_copy( inf->dir, s->grind_dir ); + v3_copy( inf->dir, player_skate.grind_dir ); } -VG_STATIC void skate_5050_apply( player_instance *player, - struct grind_info *inf_front, - struct grind_info *inf_back ) -{ - struct player_skate *s = &player->_skate; +static void skate_5050_apply( struct grind_info *inf_front, + struct grind_info *inf_back ){ + struct player_skate_state *state = &player_skate.state; struct grind_info inf_avg; v3_sub( inf_front->co, inf_back->co, inf_avg.dir ); @@ -1643,7 +1637,7 @@ VG_STATIC void skate_5050_apply( player_instance *player, v3_normalize( inf_avg.dir ); /* dont ask */ - v3_muls( inf_avg.dir, vg_signf(v3_dot(inf_avg.dir,player->rb.v)), + v3_muls( inf_avg.dir, vg_signf(v3_dot(inf_avg.dir,localplayer.rb.v)), inf_avg.dir ); v3f axis_front, axis_back, axis; @@ -1653,33 +1647,33 @@ VG_STATIC void skate_5050_apply( player_instance *player, v3_normalize( axis ); v3_cross( axis, inf_avg.dir, inf_avg.n ); - skate_grind_decay( player, &inf_avg, 1.0f ); + skate_grind_decay( &inf_avg, 1.0f ); v2f steer; joystick_state( k_srjoystick_steer, steer ); - float way = steer[1] * - vg_signf( v3_dot( player->rb.to_world[2], player->rb.v ) ); + float way = steer[1] * vg_signf( v3_dot( localplayer.rb.to_world[2], + localplayer.rb.v ) ); v4f q; v3f up, target_up; - v3_copy( player->rb.to_world[1], up ); + v3_copy( localplayer.rb.to_world[1], up ); v3_copy( inf_avg.n, target_up ); - q_axis_angle( q, player->rb.to_world[0], VG_PIf*0.25f * -way ); + q_axis_angle( q, localplayer.rb.to_world[0], VG_PIf*0.25f * -way ); q_mulv( q, target_up, target_up ); - v3_zero( s->weight_distribution ); - s->weight_distribution[2] = k_board_length * -way; + v3_zero( player_skate.weight_distribution ); + player_skate.weight_distribution[2] = k_board_length * -way; - rb_effect_spring_target_vector( &player->rb, up, target_up, + rb_effect_spring_target_vector( &localplayer.rb, up, target_up, k_grind_spring, k_grind_dampener, k_rb_delta ); - vg_line_arrow( player->rb.co, up, 1.0f, VG__GREEN ); - vg_line_arrow( player->rb.co, target_up, 1.0f, VG__GREEN ); + vg_line_arrow( localplayer.rb.co, up, 1.0f, VG__GREEN ); + vg_line_arrow( localplayer.rb.co, target_up, 1.0f, VG__GREEN ); v3f fwd_nplane, dir_nplane; - v3_muladds( player->rb.to_world[2], inf_avg.n, - -v3_dot( player->rb.to_world[2], inf_avg.n ), fwd_nplane ); + v3_muladds( localplayer.rb.to_world[2], inf_avg.n, + -v3_dot( localplayer.rb.to_world[2], inf_avg.n ), fwd_nplane ); v3f dir; v3_muls( inf_avg.dir, v3_dot( fwd_nplane, inf_avg.dir ), dir ); @@ -1688,48 +1682,48 @@ VG_STATIC void skate_5050_apply( player_instance *player, v3_normalize( fwd_nplane ); v3_normalize( dir_nplane ); - rb_effect_spring_target_vector( &player->rb, fwd_nplane, dir_nplane, + rb_effect_spring_target_vector( &localplayer.rb, fwd_nplane, dir_nplane, 1000.0f, k_grind_dampener, k_rb_delta ); - vg_line_arrow( player->rb.co, fwd_nplane, 0.8f, VG__RED ); - vg_line_arrow( player->rb.co, dir_nplane, 0.8f, VG__RED ); + vg_line_arrow( localplayer.rb.co, fwd_nplane, 0.8f, VG__RED ); + vg_line_arrow( localplayer.rb.co, dir_nplane, 0.8f, VG__RED ); v3f pos_front = { 0.0f, -k_board_radius, -1.0f * k_board_length }, pos_back = { 0.0f, -k_board_radius, 1.0f * k_board_length }, delta_front, delta_back, delta_total; - m4x3_mulv( player->rb.to_world, pos_front, pos_front ); - m4x3_mulv( player->rb.to_world, pos_back, pos_back ); + m4x3_mulv( localplayer.rb.to_world, pos_front, pos_front ); + m4x3_mulv( localplayer.rb.to_world, pos_back, pos_back ); v3_sub( inf_front->co, pos_front, delta_front ); v3_sub( inf_back->co, pos_back, delta_back ); v3_add( delta_front, delta_back, delta_total ); - v3_muladds( player->rb.v, delta_total, 50.0f * k_rb_delta, player->rb.v ); + v3_muladds( localplayer.rb.v, delta_total, 50.0f * k_rb_delta, + localplayer.rb.v ); /* Fake contact */ - struct grind_limit *limit = &s->limits[ s->limit_count ++ ]; + struct grind_limit *limit = + &player_skate.limits[ player_skate.limit_count ++ ]; v3_zero( limit->ra ); - m3x3_mulv( player->rb.to_local, inf_avg.n, limit->n ); + m3x3_mulv( localplayer.rb.to_local, inf_avg.n, limit->n ); limit->p = 0.0f; - v3_copy( inf_avg.dir, s->grind_dir ); + v3_copy( inf_avg.dir, player_skate.grind_dir ); } -VG_STATIC int skate_grind_truck_renew( player_instance *player, float sign, - struct grind_info *inf ) -{ - struct player_skate *s = &player->_skate; +static int skate_grind_truck_renew( f32 sign, struct grind_info *inf ){ + struct player_skate_state *state = &player_skate.state; v3f wheel_co = { 0.0f, 0.0f, sign * k_board_length }, grind_co = { 0.0f, -k_board_radius, sign * k_board_length }; - m4x3_mulv( player->rb.to_world, wheel_co, wheel_co ); - m4x3_mulv( player->rb.to_world, grind_co, grind_co ); + m4x3_mulv( localplayer.rb.to_world, wheel_co, wheel_co ); + m4x3_mulv( localplayer.rb.to_world, grind_co, grind_co ); /* Exit condition: lost grind tracking */ - if( !skate_grind_scansq( player, grind_co, player->rb.v, 0.3f, inf ) ) + if( !skate_grind_scansq( grind_co, localplayer.rb.v, 0.3f, inf ) ) return 0; /* Exit condition: cant see grind target directly */ @@ -1737,40 +1731,38 @@ VG_STATIC int skate_grind_truck_renew( player_instance *player, float sign, return 0; /* Exit condition: minimum velocity not reached, but allow a bit of error */ - float dv = fabsf(v3_dot( player->rb.v, inf->dir )), + float dv = fabsf(v3_dot( localplayer.rb.v, inf->dir )), minv = k_grind_axel_min_vel*0.8f; if( dv < minv ) return 0; - if( fabsf(v3_dot( inf->dir, s->grind_dir )) < k_grind_max_edge_angle ) + if( fabsf(v3_dot( inf->dir, player_skate.grind_dir )) < k_grind_max_edge_angle ) return 0; - v3_copy( inf->dir, s->grind_dir ); + v3_copy( inf->dir, player_skate.grind_dir ); return 1; } -VG_STATIC int skate_grind_truck_entry( player_instance *player, float sign, - struct grind_info *inf ) -{ - struct player_skate *s = &player->_skate; +static int skate_grind_truck_entry( f32 sign, struct grind_info *inf ){ + struct player_skate_state *state = &player_skate.state; /* REFACTOR */ v3f ra = { 0.0f, -k_board_radius, sign * k_board_length }; v3f raw, wsp; - m3x3_mulv( player->rb.to_world, ra, raw ); - v3_add( player->rb.co, raw, wsp ); + m3x3_mulv( localplayer.rb.to_world, ra, raw ); + v3_add( localplayer.rb.co, raw, wsp ); - if( skate_grind_scansq( player, wsp, player->rb.v, 0.3, inf ) ) - { - if( fabsf(v3_dot( player->rb.v, inf->dir )) < k_grind_axel_min_vel ) + if( skate_grind_scansq( wsp, localplayer.rb.v, 0.3, inf ) ){ + if( fabsf(v3_dot( localplayer.rb.v, inf->dir )) < k_grind_axel_min_vel ) return 0; /* velocity should be at least 60% aligned */ v3f pv, axis; v3_cross( inf->n, inf->dir, axis ); - v3_muladds( player->rb.v, inf->n, -v3_dot( player->rb.v, inf->n ), pv ); + v3_muladds( localplayer.rb.v, inf->n, + -v3_dot( localplayer.rb.v, inf->n ), pv ); if( v3_length2( pv ) < 0.0001f ) return 0; @@ -1779,27 +1771,21 @@ VG_STATIC int skate_grind_truck_entry( player_instance *player, float sign, if( fabsf(v3_dot( pv, inf->dir )) < k_grind_axel_max_angle ) return 0; - if( v3_dot( player->rb.v, inf->n ) > 0.5f ) - return 0; - -#if 0 - /* check for vertical alignment */ - if( v3_dot( player->rb.to_world[1], inf->n ) < k_grind_axel_max_vangle ) + if( v3_dot( localplayer.rb.v, inf->n ) > 0.5f ) return 0; -#endif v3f local_co, local_dir, local_n; - m4x3_mulv( player->rb.to_local, inf->co, local_co ); - m3x3_mulv( player->rb.to_local, inf->dir, local_dir ); - m3x3_mulv( player->rb.to_local, inf->n, local_n ); + m4x3_mulv( localplayer.rb.to_local, inf->co, local_co ); + m3x3_mulv( localplayer.rb.to_local, inf->dir, local_dir ); + m3x3_mulv( localplayer.rb.to_local, inf->n, local_n ); v2f delta = { local_co[0], local_co[2] - k_board_length*sign }; float truck_height = -(k_board_radius+0.03f); v3f rv; - v3_cross( player->rb.w, raw, rv ); - v3_add( player->rb.v, rv, rv ); + v3_cross( localplayer.rb.w, raw, rv ); + v3_add( localplayer.rb.v, rv, rv ); if( (local_co[1] >= truck_height) && (v2_length2( delta ) <= k_board_radius*k_board_radius) ) @@ -1811,23 +1797,21 @@ VG_STATIC int skate_grind_truck_entry( player_instance *player, float sign, return 0; } -VG_STATIC void skate_boardslide_apply( player_instance *player, - struct grind_info *inf ) -{ - struct player_skate *s = &player->_skate; +static void skate_boardslide_apply( struct grind_info *inf ){ + struct player_skate_state *state = &player_skate.state; v3f local_co, local_dir, local_n; - m4x3_mulv( player->rb.to_local, inf->co, local_co ); - m3x3_mulv( player->rb.to_local, inf->dir, local_dir ); - m3x3_mulv( player->rb.to_local, inf->n, local_n ); + m4x3_mulv( localplayer.rb.to_local, inf->co, local_co ); + m3x3_mulv( localplayer.rb.to_local, inf->dir, local_dir ); + m3x3_mulv( localplayer.rb.to_local, inf->n, local_n ); v3f intersection; v3_muladds( local_co, local_dir, local_co[0]/-local_dir[0], intersection ); - v3_copy( intersection, s->weight_distribution ); + v3_copy( intersection, player_skate.weight_distribution ); - skate_grind_decay( player, inf, 0.0125f ); - skate_grind_friction( player, inf, 0.25f ); + skate_grind_decay( inf, 0.0125f ); + skate_grind_friction( inf, 0.25f ); /* direction alignment */ v3f dir, perp; @@ -1835,47 +1819,45 @@ VG_STATIC void skate_boardslide_apply( player_instance *player, v3_muls( local_dir, vg_signf(local_dir[0]), dir ); v3_muls( perp, vg_signf(perp[2]), perp ); - m3x3_mulv( player->rb.to_world, dir, dir ); - m3x3_mulv( player->rb.to_world, perp, perp ); + m3x3_mulv( localplayer.rb.to_world, dir, dir ); + m3x3_mulv( localplayer.rb.to_world, perp, perp ); v4f qbalance; q_axis_angle( qbalance, dir, local_co[0]*k_grind_balance ); q_mulv( qbalance, perp, perp ); - rb_effect_spring_target_vector( &player->rb, player->rb.to_world[0], + rb_effect_spring_target_vector( &localplayer.rb, localplayer.rb.to_world[0], dir, k_grind_spring, k_grind_dampener, k_rb_delta ); - rb_effect_spring_target_vector( &player->rb, player->rb.to_world[2], + rb_effect_spring_target_vector( &localplayer.rb, localplayer.rb.to_world[2], perp, k_grind_spring, k_grind_dampener, k_rb_delta ); - vg_line_arrow( player->rb.co, dir, 0.5f, VG__GREEN ); - vg_line_arrow( player->rb.co, perp, 0.5f, VG__BLUE ); + vg_line_arrow( localplayer.rb.co, dir, 0.5f, VG__GREEN ); + vg_line_arrow( localplayer.rb.co, perp, 0.5f, VG__BLUE ); - v3_copy( inf->dir, s->grind_dir ); + v3_copy( inf->dir, player_skate.grind_dir ); } -VG_STATIC int skate_boardslide_entry( player_instance *player, - struct grind_info *inf ) -{ - struct player_skate *s = &player->_skate; +static int skate_boardslide_entry( struct grind_info *inf ){ + struct player_skate_state *state = &player_skate.state; - if( skate_grind_scansq( player, player->rb.co, - player->rb.to_world[0], k_board_length, + if( skate_grind_scansq( localplayer.rb.co, + localplayer.rb.to_world[0], k_board_length, inf ) ) { v3f local_co, local_dir; - m4x3_mulv( player->rb.to_local, inf->co, local_co ); - m3x3_mulv( player->rb.to_local, inf->dir, local_dir ); + m4x3_mulv( localplayer.rb.to_local, inf->co, local_co ); + m3x3_mulv( localplayer.rb.to_local, inf->dir, local_dir ); if( (fabsf(local_co[2]) <= k_board_length) && /* within wood area */ (local_co[1] >= 0.0f) && /* at deck level */ (fabsf(local_dir[0]) >= 0.25f) ) /* perpendicular to us */ { - if( fabsf(v3_dot( player->rb.v, inf->dir )) < k_grind_axel_min_vel ) + if( fabsf(v3_dot( localplayer.rb.v, inf->dir )) < k_grind_axel_min_vel ) return 0; return 1; @@ -1885,63 +1867,58 @@ VG_STATIC int skate_boardslide_entry( player_instance *player, return 0; } -VG_STATIC int skate_boardslide_renew( player_instance *player, - struct grind_info *inf ) -{ - struct player_skate *s = &player->_skate; +static int skate_boardslide_renew( struct grind_info *inf ){ + struct player_skate_state *state = &player_skate.state; - if( !skate_grind_scansq( player, player->rb.co, - player->rb.to_world[0], k_board_length, + if( !skate_grind_scansq( localplayer.rb.co, + localplayer.rb.to_world[0], k_board_length, inf ) ) return 0; /* Exit condition: cant see grind target directly */ v3f vis; - v3_muladds( player->rb.co, player->rb.to_world[1], 0.2f, vis ); + v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], 0.2f, vis ); if( !skate_point_visible( vis, inf->co ) ) return 0; /* Exit condition: minimum velocity not reached, but allow a bit of error */ - float dv = fabsf(v3_dot( player->rb.v, inf->dir )), + float dv = fabsf(v3_dot( localplayer.rb.v, inf->dir )), minv = k_grind_axel_min_vel*0.8f; if( dv < minv ) return 0; - if( fabsf(v3_dot( inf->dir, s->grind_dir )) < k_grind_max_edge_angle ) + if( fabsf(v3_dot( inf->dir, player_skate.grind_dir )) < k_grind_max_edge_angle ) return 0; return 1; } -VG_STATIC void skate_store_grind_vec( player_instance *player, - struct grind_info *inf ) -{ - struct player_skate *s = &player->_skate; +static void skate_store_grind_vec( struct grind_info *inf ){ + struct player_skate_state *state = &player_skate.state; m3x3f mtx; skate_grind_orient( inf, mtx ); m3x3_transpose( mtx, mtx ); v3f raw; - v3_sub( inf->co, player->rb.co, raw ); + v3_sub( inf->co, localplayer.rb.co, raw ); - m3x3_mulv( mtx, raw, s->grind_vec ); - v3_normalize( s->grind_vec ); - v3_copy( inf->dir, s->grind_dir ); + m3x3_mulv( mtx, raw, player_skate.grind_vec ); + v3_normalize( player_skate.grind_vec ); + v3_copy( inf->dir, player_skate.grind_dir ); } -VG_STATIC enum skate_activity skate_availible_grind( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static enum skate_activity skate_availible_grind(void){ + struct player_skate_state *state = &player_skate.state; - if( s->state.grind_cooldown > 100 ){ + if( state->grind_cooldown > 100 ){ vg_fatal_error( "wth!\n" ); } /* debounces this state manager a little bit */ - if( s->state.grind_cooldown ){ - s->state.grind_cooldown --; + if( state->grind_cooldown ){ + state->grind_cooldown --; return k_skate_activity_undefined; } @@ -1959,52 +1936,52 @@ VG_STATIC enum skate_activity skate_availible_grind( player_instance *player ) v2f steer; joystick_state( k_srjoystick_steer, steer ); - if( s->state.activity == k_skate_activity_grind_5050 || - s->state.activity == k_skate_activity_grind_back50 || - s->state.activity == k_skate_activity_grind_front50 ) + if( state->activity == k_skate_activity_grind_5050 || + state->activity == k_skate_activity_grind_back50 || + state->activity == k_skate_activity_grind_front50 ) { float tilt = steer[1]; if( fabsf(tilt) >= 0.25f ){ v3f raw = {0.0f,0.0f,tilt}; - m3x3_mulv( player->rb.to_world, raw, raw ); + m3x3_mulv( localplayer.rb.to_world, raw, raw ); - float way = tilt * vg_signf( v3_dot( raw, player->rb.v ) ); + float way = tilt * vg_signf( v3_dot( raw, localplayer.rb.v ) ); if( way < 0.0f ) allow_front = 0; else allow_back = 0; } } - if( s->state.activity == k_skate_activity_grind_boardslide ){ - res_slide = skate_boardslide_renew( player, &inf_slide ); + if( state->activity == k_skate_activity_grind_boardslide ){ + res_slide = skate_boardslide_renew( &inf_slide ); } - else if( s->state.activity == k_skate_activity_grind_back50 ){ - res_back50 = skate_grind_truck_renew( player, 1.0f, &inf_back50 ); + else if( state->activity == k_skate_activity_grind_back50 ){ + res_back50 = skate_grind_truck_renew( 1.0f, &inf_back50 ); if( allow_front ) - res_front50 = skate_grind_truck_entry( player, -1.0f, &inf_front50 ); + res_front50 = skate_grind_truck_entry( -1.0f, &inf_front50 ); } - else if( s->state.activity == k_skate_activity_grind_front50 ){ - res_front50 = skate_grind_truck_renew( player, -1.0f, &inf_front50 ); + else if( state->activity == k_skate_activity_grind_front50 ){ + res_front50 = skate_grind_truck_renew( -1.0f, &inf_front50 ); if( allow_back ) - res_back50 = skate_grind_truck_entry( player, 1.0f, &inf_back50 ); + res_back50 = skate_grind_truck_entry( 1.0f, &inf_back50 ); } - else if( s->state.activity == k_skate_activity_grind_5050 ){ + else if( state->activity == k_skate_activity_grind_5050 ){ if( allow_front ) - res_front50 = skate_grind_truck_renew( player, -1.0f, &inf_front50 ); + res_front50 = skate_grind_truck_renew( -1.0f, &inf_front50 ); if( allow_back ) - res_back50 = skate_grind_truck_renew( player, 1.0f, &inf_back50 ); + res_back50 = skate_grind_truck_renew( 1.0f, &inf_back50 ); } else{ - res_slide = skate_boardslide_entry( player, &inf_slide ); + res_slide = skate_boardslide_entry( &inf_slide ); if( allow_back ) - res_back50 = skate_grind_truck_entry( player, 1.0f, &inf_back50 ); + res_back50 = skate_grind_truck_entry( 1.0f, &inf_back50 ); if( allow_front ) - res_front50 = skate_grind_truck_entry( player, -1.0f, &inf_front50 ); + res_front50 = skate_grind_truck_entry( -1.0f, &inf_front50 ); if( res_back50 != res_front50 ){ int wants_to_do_that = fabsf(steer[1]) >= 0.25f; @@ -2030,48 +2007,47 @@ VG_STATIC enum skate_activity skate_availible_grind( player_instance *player ) , new_activity = table[ res_slide << 2 | res_back50 << 1 | res_front50 ]; if( new_activity == k_skate_activity_undefined ){ - if( s->state.activity >= k_skate_activity_grind_any ){ - s->state.grind_cooldown = 15; - s->state.surface_cooldown = 10; + if( state->activity >= k_skate_activity_grind_any ){ + state->grind_cooldown = 15; + state->surface_cooldown = 10; } } else if( new_activity == k_skate_activity_grind_boardslide ){ - skate_boardslide_apply( player, &inf_slide ); + skate_boardslide_apply( &inf_slide ); } else if( new_activity == k_skate_activity_grind_back50 ){ - if( s->state.activity != k_skate_activity_grind_back50 ) - skate_store_grind_vec( player, &inf_back50 ); + if( state->activity != k_skate_activity_grind_back50 ) + skate_store_grind_vec( &inf_back50 ); - skate_grind_truck_apply( player, 1.0f, &inf_back50, 1.0f ); + skate_grind_truck_apply( 1.0f, &inf_back50, 1.0f ); } else if( new_activity == k_skate_activity_grind_front50 ){ - if( s->state.activity != k_skate_activity_grind_front50 ) - skate_store_grind_vec( player, &inf_front50 ); + if( state->activity != k_skate_activity_grind_front50 ) + skate_store_grind_vec( &inf_front50 ); - skate_grind_truck_apply( player, -1.0f, &inf_front50, 1.0f ); + skate_grind_truck_apply( -1.0f, &inf_front50, 1.0f ); } else if( new_activity == k_skate_activity_grind_5050 ) - skate_5050_apply( player, &inf_front50, &inf_back50 ); + skate_5050_apply( &inf_front50, &inf_back50 ); return new_activity; } -VG_STATIC void player__skate_update( player_instance *player ) -{ - struct player_skate *s = &player->_skate; +static void player__skate_update(void){ + struct player_skate_state *state = &player_skate.state; world_instance *world = world_current_instance(); if( world->water.enabled ){ - if( player->rb.co[1]+0.25f < world->water.height ){ - audio_oneshot_3d( &audio_splash, player->rb.co, 40.0f, 1.0f ); - player__skate_kill_audio( player ); - player__dead_transition( player ); + if( localplayer.rb.co[1]+0.25f < world->water.height ){ + audio_oneshot_3d( &audio_splash, localplayer.rb.co, 40.0f, 1.0f ); + player__skate_kill_audio(); + player__dead_transition(); return; } } - v3_copy( player->rb.co, s->state.prev_pos ); - s->state.activity_prev = s->state.activity; + v3_copy( localplayer.rb.co, state->prev_pos ); + state->activity_prev = state->activity; v3f normal_total; v3_zero( normal_total ); @@ -2106,78 +2082,80 @@ VG_STATIC void player__skate_update( player_instance *player ) float slap = 0.0f; - if( s->state.activity <= k_skate_activity_air_to_grind ){ + if( state->activity <= k_skate_activity_air_to_grind ){ float min_dist = 0.6f; for( int i=0; i<2; i++ ){ v3f wpos, closest; - m4x3_mulv( player->rb.to_world, wheels[i].pos, wpos ); + m4x3_mulv( localplayer.rb.to_world, wheels[i].pos, wpos ); if( bh_closest_point( world->geo_bh, wpos, closest, min_dist ) != -1 ){ min_dist = vg_minf( min_dist, v3_dist( closest, wpos ) ); } } min_dist -= 0.2f; - float vy = v3_dot( player->basis[1], player->rb.v ); + float vy = v3_dot( localplayer.basis[1], localplayer.rb.v ); vy = vg_maxf( 0.0f, vy ); slap = vg_clampf( (min_dist/0.5f) + vy, 0.0f, 1.0f )*0.3f; } - s->state.slap = vg_lerpf( s->state.slap, slap, 10.0f*k_rb_delta ); + state->slap = vg_lerpf( state->slap, slap, 10.0f*k_rb_delta ); - wheels[0].pos[1] = s->state.slap; - wheels[1].pos[1] = s->state.slap; + wheels[0].pos[1] = state->slap; + wheels[1].pos[1] = state->slap; const int k_wheel_count = 2; - s->substep = k_rb_delta; - s->substep_delta = s->substep; - s->limit_count = 0; + player_skate.substep = k_rb_delta; + player_skate.substep_delta = player_skate.substep; + player_skate.limit_count = 0; int substep_count = 0; - v3_zero( s->surface_picture ); + v3_zero( player_skate.surface_picture ); int prev_contacts[2]; for( int i=0; iwheel_contacts[i]; + prev_contacts[i] = player_skate.wheel_contacts[i]; } /* check if we can enter or continue grind */ - enum skate_activity grindable_activity = skate_availible_grind( player ); + enum skate_activity grindable_activity = skate_availible_grind(); if( grindable_activity != k_skate_activity_undefined ){ - s->state.activity = grindable_activity; + state->activity = grindable_activity; goto grinding; } int contact_count = 0; for( int i=0; i<2; i++ ){ v3f normal, axel; - v3_copy( player->rb.to_world[0], axel ); + v3_copy( localplayer.rb.to_world[0], axel ); - if( skate_compute_surface_alignment( player, wheels[i].pos, + if( skate_compute_surface_alignment( wheels[i].pos, wheels[i].colour, normal, axel ) ) { - rb_effect_spring_target_vector( &player->rb, player->rb.to_world[0], + rb_effect_spring_target_vector( &localplayer.rb, + localplayer.rb.to_world[0], axel, k_surface_spring, k_surface_dampener, - s->substep_delta ); + player_skate.substep_delta ); - v3_add( normal, s->surface_picture, s->surface_picture ); + v3_add( normal, player_skate.surface_picture, + player_skate.surface_picture ); contact_count ++; - s->wheel_contacts[i] = 1; + player_skate.wheel_contacts[i] = 1; } else{ - s->wheel_contacts[i] = 0; + player_skate.wheel_contacts[i] = 0; } - m3x3_mulv( player->rb.to_local, axel, s->truckv0[i] ); + m3x3_mulv( localplayer.rb.to_local, axel, player_skate.truckv0[i] ); } - if( s->state.surface_cooldown ){ - s->state.surface_cooldown --; + if( state->surface_cooldown ){ + state->surface_cooldown --; contact_count = 0; } @@ -2186,7 +2164,7 @@ VG_STATIC void player__skate_update( player_instance *player ) for( int i=0; i<2; i++ ){ if( !prev_contacts[i] ){ v3f co; - m4x3_mulv( player->rb.to_world, wheels[i].pos, co ); + m4x3_mulv( localplayer.rb.to_world, wheels[i].pos, co ); audio_oneshot_3d( &audio_taps[vg_randu32()%4], co, 40.0f, 0.75f ); } } @@ -2194,40 +2172,40 @@ VG_STATIC void player__skate_update( player_instance *player ) } if( contact_count ){ - s->state.activity = k_skate_activity_ground; - s->state.gravity_bias = k_gravity; - v3_normalize( s->surface_picture ); + state->activity = k_skate_activity_ground; + state->gravity_bias = k_gravity; + v3_normalize( player_skate.surface_picture ); - skate_apply_friction_model( player ); - skate_weight_distribute( player ); + skate_apply_friction_model(); + skate_weight_distribute(); } else{ - if( s->state.activity > k_skate_activity_air_to_grind ) - s->state.activity = k_skate_activity_air; + if( state->activity > k_skate_activity_air_to_grind ) + state->activity = k_skate_activity_air; - v3_zero( s->weight_distribution ); - skate_apply_air_model( player ); + v3_zero( player_skate.weight_distribution ); + skate_apply_air_model(); } grinding:; - if( s->state.activity == k_skate_activity_grind_back50 ) + if( state->activity == k_skate_activity_grind_back50 ) wheels[1].state = k_collider_state_disabled; - if( s->state.activity == k_skate_activity_grind_front50 ) + if( state->activity == k_skate_activity_grind_front50 ) wheels[0].state = k_collider_state_disabled; - if( s->state.activity == k_skate_activity_grind_5050 ){ + if( state->activity == k_skate_activity_grind_5050 ){ wheels[0].state = k_collider_state_disabled; wheels[1].state = k_collider_state_disabled; } /* all activities */ - skate_apply_steering_model( player ); - skate_adjust_up_direction( player ); - skate_apply_cog_model( player ); - skate_apply_jump_model( player ); - skate_apply_grab_model( player ); - skate_apply_trick_model( player ); - skate_apply_pump_model( player ); + skate_apply_steering_model(); + skate_adjust_up_direction(); + skate_apply_cog_model(); + skate_apply_jump_model(); + skate_apply_grab_model(); + skate_apply_trick_model(); + skate_apply_pump_model(); begin_collision:; @@ -2237,35 +2215,36 @@ begin_collision:; */ v3f head_wp0, head_wp1, start_co; - m4x3_mulv( player->rb.to_world, s->state.head_position, head_wp0 ); - v3_copy( player->rb.co, start_co ); + m4x3_mulv( localplayer.rb.to_world, state->head_position, head_wp0 ); + v3_copy( localplayer.rb.co, start_co ); /* calculate transform one step into future */ v3f future_co; v4f future_q; - v3_muladds( player->rb.co, player->rb.v, s->substep, future_co ); + v3_muladds( localplayer.rb.co, localplayer.rb.v, player_skate.substep, + future_co ); - if( v3_length2( player->rb.w ) > 0.0f ){ + if( v3_length2( localplayer.rb.w ) > 0.0f ){ v4f rotation; v3f axis; - v3_copy( player->rb.w, axis ); + v3_copy( localplayer.rb.w, axis ); float mag = v3_length( axis ); v3_divs( axis, mag, axis ); - q_axis_angle( rotation, axis, mag*s->substep ); - q_mul( rotation, player->rb.q, future_q ); + q_axis_angle( rotation, axis, mag*player_skate.substep ); + q_mul( rotation, localplayer.rb.q, future_q ); q_normalize( future_q ); } else - v4_copy( player->rb.q, future_q ); + v4_copy( localplayer.rb.q, future_q ); v3f future_cg, current_cg, cg_offset; - q_mulv( player->rb.q, s->weight_distribution, current_cg ); - q_mulv( future_q, s->weight_distribution, future_cg ); + q_mulv( localplayer.rb.q, player_skate.weight_distribution, current_cg ); + q_mulv( future_q, player_skate.weight_distribution, future_cg ); v3_sub( future_cg, current_cg, cg_offset ); /* calculate the minimum time we can move */ - float max_time = s->substep; + float max_time = player_skate.substep; for( int i=0; irb.q, wheels[i].pos, current ); - v3_add( current, player->rb.co, current ); + q_mulv( localplayer.rb.q, wheels[i].pos, current ); + v3_add( current, localplayer.rb.co, current ); float t; v3f n; @@ -2286,7 +2265,7 @@ begin_collision:; float cast_radius = wheels[i].radius - k_penetration_slop * 2.0f; if( spherecast_world( world, current, future, cast_radius, &t, n, k_material_flag_walking ) != -1) - max_time = vg_minf( max_time, t * s->substep ); + max_time = vg_minf( max_time, t * player_skate.substep ); } /* clamp to a fraction of delta, to prevent locking */ @@ -2295,31 +2274,33 @@ begin_collision:; rate_lock *= rate_lock; max_time = vg_maxf( max_time, rate_lock ); - s->substep_delta = max_time; + player_skate.substep_delta = max_time; /* integrate */ - v3_muladds( player->rb.co, player->rb.v, s->substep_delta, player->rb.co ); - if( v3_length2( player->rb.w ) > 0.0f ){ + v3_muladds( localplayer.rb.co, localplayer.rb.v, + player_skate.substep_delta, localplayer.rb.co ); + if( v3_length2( localplayer.rb.w ) > 0.0f ){ v4f rotation; v3f axis; - v3_copy( player->rb.w, axis ); + v3_copy( localplayer.rb.w, axis ); float mag = v3_length( axis ); v3_divs( axis, mag, axis ); - q_axis_angle( rotation, axis, mag*s->substep_delta ); - q_mul( rotation, player->rb.q, player->rb.q ); - q_normalize( player->rb.q ); + q_axis_angle( rotation, axis, mag*player_skate.substep_delta ); + q_mul( rotation, localplayer.rb.q, localplayer.rb.q ); + q_normalize( localplayer.rb.q ); - q_mulv( player->rb.q, s->weight_distribution, future_cg ); + q_mulv( localplayer.rb.q, player_skate.weight_distribution, future_cg ); v3_sub( current_cg, future_cg, cg_offset ); - v3_add( player->rb.co, cg_offset, player->rb.co ); + v3_add( localplayer.rb.co, cg_offset, localplayer.rb.co ); } - rb_update_transform( &player->rb ); - v3_muladds( player->rb.v, player->basis[1], - -s->state.gravity_bias * s->substep_delta, player->rb.v ); + rb_update_transform( &localplayer.rb ); + v3_muladds( localplayer.rb.v, localplayer.basis[1], + -state->gravity_bias * player_skate.substep_delta, + localplayer.rb.v ); - s->substep -= s->substep_delta; + player_skate.substep -= player_skate.substep_delta; rb_ct manifold[128]; int manifold_len = 0; @@ -2327,7 +2308,7 @@ begin_collision:; * Phase -1: head detection * -------------------------------------------------------------------------- */ - m4x3_mulv( player->rb.to_world, s->state.head_position, head_wp1 ); + m4x3_mulv( localplayer.rb.to_world, state->head_position, head_wp1 ); float t; v3f n; @@ -2335,11 +2316,11 @@ begin_collision:; (spherecast_world( world, head_wp0, head_wp1, 0.2f, &t, n, k_material_flag_walking ) != -1) ) { - v3_lerp( start_co, player->rb.co, t, player->rb.co ); - rb_update_transform( &player->rb ); + v3_lerp( start_co, localplayer.rb.co, t, localplayer.rb.co ); + rb_update_transform( &localplayer.rb ); - player__skate_kill_audio( player ); - player__dead_transition( player ); + player__skate_kill_audio(); + player__dead_transition(); return; } @@ -2354,13 +2335,13 @@ begin_collision:; m4x3f mtx; m3x3_identity( mtx ); - m4x3_mulv( player->rb.to_world, wheels[i].pos, mtx[3] ); + m4x3_mulv( localplayer.rb.to_world, wheels[i].pos, mtx[3] ); rb_sphere collider = { .radius = wheels[i].radius }; rb_ct *man = &manifold[ manifold_len ]; - int l = skate_collide_smooth( player, mtx, &collider, man ); + int l = skate_collide_smooth( mtx, &collider, man ); if( l ) wheels[i].state = k_collider_state_colliding; @@ -2371,11 +2352,11 @@ begin_collision:; rb_capsule capsule = { .height = (k_board_length+0.2f)*2.0f, .radius=grind_radius }; m4x3f mtx; - v3_muls( player->rb.to_world[0], 1.0f, mtx[0] ); - v3_muls( player->rb.to_world[2], -1.0f, mtx[1] ); - v3_muls( player->rb.to_world[1], 1.0f, mtx[2] ); - v3_muladds( player->rb.to_world[3], player->rb.to_world[1], - grind_radius + k_board_radius*0.25f+s->state.slap, mtx[3] ); + v3_muls( localplayer.rb.to_world[0], 1.0f, mtx[0] ); + v3_muls( localplayer.rb.to_world[2], -1.0f, mtx[1] ); + v3_muls( localplayer.rb.to_world[1], 1.0f, mtx[2] ); + v3_muladds( localplayer.rb.to_world[3], localplayer.rb.to_world[1], + grind_radius + k_board_radius*0.25f+state->slap, mtx[3] ); rb_ct *cman = &manifold[manifold_len]; @@ -2394,12 +2375,12 @@ begin_collision:; vg_line_capsule( mtx, capsule.radius, capsule.height, VG__WHITE ); /* add limits */ - if( s->state.activity >= k_skate_activity_grind_any ){ - for( int i=0; ilimit_count; i++ ){ - struct grind_limit *limit = &s->limits[i]; + if( state->activity >= k_skate_activity_grind_any ){ + for( int i=0; irb.to_world, limit->ra, ct->co ); - m3x3_mulv( player->rb.to_world, limit->n, ct->n ); + m4x3_mulv( localplayer.rb.to_world, limit->ra, ct->co ); + m3x3_mulv( localplayer.rb.to_world, limit->n, ct->n ); ct->p = limit->p; ct->type = k_contact_type_default; } @@ -2412,11 +2393,12 @@ begin_collision:; v3f world_cog; - m4x3_mulv( player->rb.to_world, s->weight_distribution, world_cog ); + m4x3_mulv( localplayer.rb.to_world, + player_skate.weight_distribution, world_cog ); vg_line_point( world_cog, 0.02f, VG__BLACK ); for( int i=0; isubstep_delta ); + rb_prepare_contact( &manifold[i], player_skate.substep_delta ); rb_debug_contact( &manifold[i] ); } @@ -2442,8 +2424,8 @@ begin_collision:; m3x3_inv( iI, iI ); m3x3f iIw; - m3x3_mul( iI, player->rb.to_local, iIw ); - m3x3_mul( player->rb.to_world, iIw, iIw ); + m3x3_mul( iI, localplayer.rb.to_local, iIw ); + m3x3_mul( localplayer.rb.to_world, iIw, iIw ); for( int j=0; j<10; j++ ){ for( int i=0; ico, world_cog, delta ); - v3_cross( player->rb.w, delta, rv ); - v3_add( player->rb.v, rv, rv ); + v3_cross( localplayer.rb.w, delta, rv ); + v3_add( localplayer.rb.v, rv, rv ); v3f raCn; v3_cross( delta, ct->n, raCn ); @@ -2476,25 +2458,25 @@ begin_collision:; v3_muls( ct->n, lambda, impulse ); v3_muladds( normal_total, impulse, inv_mass, normal_total ); - v3_muladds( player->rb.v, impulse, inv_mass, player->rb.v ); + v3_muladds( localplayer.rb.v, impulse, inv_mass, localplayer.rb.v ); v3_cross( delta, impulse, impulse ); m3x3_mulv( iIw, impulse, impulse ); - v3_add( impulse, player->rb.w, player->rb.w ); + v3_add( impulse, localplayer.rb.w, localplayer.rb.w ); - v3_cross( player->rb.w, delta, rv ); - v3_add( player->rb.v, rv, rv ); + v3_cross( localplayer.rb.w, delta, rv ); + v3_add( localplayer.rb.v, rv, rv ); vn = v3_dot( rv, ct->n ); } } v3f dt; rb_depenetrate( manifold, manifold_len, dt ); - v3_add( dt, player->rb.co, player->rb.co ); - rb_update_transform( &player->rb ); + v3_add( dt, localplayer.rb.co, localplayer.rb.co ); + rb_update_transform( &localplayer.rb ); substep_count ++; - if( s->substep >= 0.0001f ) + if( player_skate.substep >= 0.0001f ) goto begin_collision; /* again! */ /* @@ -2505,93 +2487,93 @@ begin_collision:; f32 nforce = v3_length(normal_total); if( nforce > 4.0f ){ if( nforce > 17.6f ){ - v3_muladds( player->rb.v, normal_total, -1.0f, player->rb.v ); - player__dead_transition(player); - player__skate_kill_audio(player); + v3_muladds( localplayer.rb.v, normal_total, -1.0f, localplayer.rb.v ); + player__dead_transition(); + player__skate_kill_audio(); return; } f32 amt = k_cam_punch; - if( player->cam_control.camera_mode == k_cam_firstperson ){ + if( localplayer.cam_control.camera_mode == k_cam_firstperson ){ amt *= 0.25f; } - v3_muladds( player->cam_land_punch_v, normal_total, amt, - player->cam_land_punch_v ); + v3_muladds( localplayer.cam_land_punch_v, normal_total, amt, + localplayer.cam_land_punch_v ); } - s->surface = k_surface_prop_concrete; + player_skate.surface = k_surface_prop_concrete; for( int i=0; iinfo.surface_prop > s->surface ) - s->surface = surf->info.surface_prop; + if( surf->info.surface_prop > player_skate.surface ) + player_skate.surface = surf->info.surface_prop; } for( int i=0; irb.to_world, mtx ); - m4x3_mulv( player->rb.to_world, wheels[i].pos, mtx[3] ); + m3x3_copy( localplayer.rb.to_world, mtx ); + m4x3_mulv( localplayer.rb.to_world, wheels[i].pos, mtx[3] ); vg_line_sphere( mtx, wheels[i].radius, (u32[]){ VG__WHITE, VG__BLACK, wheels[i].colour }[ wheels[i].state ]); } - skate_integrate( player ); - vg_line_point( s->state.cog, 0.02f, VG__WHITE ); + skate_integrate(); + vg_line_point( state->cog, 0.02f, VG__WHITE ); ent_gate *gate = - world_intersect_gates(world, player->rb.co, s->state.prev_pos ); + world_intersect_gates(world, localplayer.rb.co, state->prev_pos ); if( gate ){ - m4x3_mulv( gate->transport, player->rb.co, player->rb.co ); - m3x3_mulv( gate->transport, player->rb.v, player->rb.v ); - m4x3_mulv( gate->transport, s->state.cog, s->state.cog ); - m3x3_mulv( gate->transport, s->state.cog_v, s->state.cog_v ); - m3x3_mulv( gate->transport, s->state.throw_v, s->state.throw_v ); - m3x3_mulv( gate->transport, s->state.head_position, - s->state.head_position ); - m3x3_mulv( gate->transport, s->state.up_dir, s->state.up_dir ); + m4x3_mulv( gate->transport, localplayer.rb.co, localplayer.rb.co ); + m3x3_mulv( gate->transport, localplayer.rb.v, localplayer.rb.v ); + m4x3_mulv( gate->transport, state->cog, state->cog ); + m3x3_mulv( gate->transport, state->cog_v, state->cog_v ); + m3x3_mulv( gate->transport, state->throw_v, state->throw_v ); + m3x3_mulv( gate->transport, state->head_position, + state->head_position ); + m3x3_mulv( gate->transport, state->up_dir, state->up_dir ); v4f transport_rotation; m3x3_q( gate->transport, transport_rotation ); - q_mul( transport_rotation, player->rb.q, player->rb.q ); - q_mul( transport_rotation, s->state.smoothed_rotation, - s->state.smoothed_rotation ); - rb_update_transform( &player->rb ); - player__pass_gate( player, gate ); + q_mul( transport_rotation, localplayer.rb.q, localplayer.rb.q ); + q_mul( transport_rotation, state->smoothed_rotation, + state->smoothed_rotation ); + rb_update_transform( &localplayer.rb ); + player__pass_gate( gate ); } /* FIXME: Rate limit */ static int stick_frames = 0; - if( s->state.activity >= k_skate_activity_ground ) + if( state->activity >= k_skate_activity_ground ) stick_frames ++; else stick_frames = 0; - if( stick_frames > 5 ) stick_frames = 5; + if( stick_frames > 5 ) stick_frames = 5; if( stick_frames == 4 ){ audio_lock(); - if( s->state.activity == k_skate_activity_ground ){ - if( (fabsf(s->state.slip) > 0.75f) ){ - audio_oneshot_3d( &audio_lands[vg_randu32()%2+3], player->rb.co, + if( state->activity == k_skate_activity_ground ){ + if( (fabsf(state->slip) > 0.75f) ){ + audio_oneshot_3d( &audio_lands[vg_randu32()%2+3], localplayer.rb.co, 40.0f, 1.0f ); } else{ - audio_oneshot_3d( &audio_lands[vg_randu32()%3], player->rb.co, + audio_oneshot_3d( &audio_lands[vg_randu32()%3], localplayer.rb.co, 40.0f, 1.0f ); } } - else if( s->surface == k_surface_prop_metal ){ - audio_oneshot_3d( &audio_board[3], player->rb.co, 40.0f, 1.0f ); + else if( player_skate.surface == k_surface_prop_metal ){ + audio_oneshot_3d( &audio_board[3], localplayer.rb.co, 40.0f, 1.0f ); } else{ - audio_oneshot_3d( &audio_board[8], player->rb.co, 40.0f, 1.0f ); + audio_oneshot_3d( &audio_board[8], localplayer.rb.co, 40.0f, 1.0f ); } audio_unlock(); @@ -2600,20 +2582,19 @@ begin_collision:; } } -VG_STATIC void player__skate_im_gui( player_instance *player ){ - struct player_skate *s = &player->_skate; - player__debugtext( 1, "V: %5.2f %5.2f %5.2f",player->rb.v[0], - player->rb.v[1], - player->rb.v[2] ); - player__debugtext( 1, "CO: %5.2f %5.2f %5.2f",player->rb.co[0], - player->rb.co[1], - player->rb.co[2] ); - player__debugtext( 1, "W: %5.2f %5.2f %5.2f",player->rb.w[0], - player->rb.w[1], - player->rb.w[2] ); - - const char *activity_txt[] = - { +static void player__skate_im_gui(void){ + struct player_skate_state *state = &player_skate.state; + player__debugtext( 1, "V: %5.2f %5.2f %5.2f",localplayer.rb.v[0], + localplayer.rb.v[1], + localplayer.rb.v[2] ); + player__debugtext( 1, "CO: %5.2f %5.2f %5.2f",localplayer.rb.co[0], + localplayer.rb.co[1], + localplayer.rb.co[2] ); + player__debugtext( 1, "W: %5.2f %5.2f %5.2f",localplayer.rb.w[0], + localplayer.rb.w[1], + localplayer.rb.w[2] ); + + const char *activity_txt[] = { "air", "air_to_grind", "ground", @@ -2626,28 +2607,27 @@ VG_STATIC void player__skate_im_gui( player_instance *player ){ "grind_5050" }; - player__debugtext( 1, "activity: %s", activity_txt[s->state.activity] ); + player__debugtext( 1, "activity: %s", activity_txt[state->activity] ); #if 0 player__debugtext( 1, "steer_s: %5.2f %5.2f [%.2f %.2f]", - s->state.steerx_s, s->state.steery_s, + state->steerx_s, state->steery_s, k_steer_ground, k_steer_air ); #endif - player__debugtext( 1, "flip: %.4f %.4f", s->state.flip_rate, - s->state.flip_time ); + player__debugtext( 1, "flip: %.4f %.4f", state->flip_rate, + state->flip_time ); player__debugtext( 1, "trickv: %.2f %.2f %.2f", - s->state.trick_vel[0], - s->state.trick_vel[1], - s->state.trick_vel[2] ); + state->trick_vel[0], + state->trick_vel[1], + state->trick_vel[2] ); player__debugtext( 1, "tricke: %.2f %.2f %.2f", - s->state.trick_euler[0], - s->state.trick_euler[1], - s->state.trick_euler[2] ); + state->trick_euler[0], + state->trick_euler[1], + state->trick_euler[2] ); } -VG_STATIC void player__skate_animate( player_instance *player ){ - struct player_skate *s = &player->_skate; - struct player_skate_state *state = &player->_skate.state; - struct player_skate_animator *animator = &s->animator; +static void player__skate_animate(void){ + struct player_skate_state *state = &player_skate.state; + struct player_skate_animator *animator = &player_skate.animator; /* Head */ float kheight = 2.0f, @@ -2656,18 +2636,18 @@ VG_STATIC void player__skate_animate( player_instance *player ){ v3_zero( animator->offset ); v3f cog_local, cog_ideal; - m4x3_mulv( player->rb.to_local, s->state.cog, cog_local ); + m4x3_mulv( localplayer.rb.to_local, state->cog, cog_local ); - v3_copy( s->state.up_dir, cog_ideal ); + v3_copy( state->up_dir, cog_ideal ); v3_normalize( cog_ideal ); - m3x3_mulv( player->rb.to_local, cog_ideal, cog_ideal ); + m3x3_mulv( localplayer.rb.to_local, cog_ideal, cog_ideal ); v3_sub( cog_ideal, cog_local, animator->offset ); v3_muls( animator->offset, 4.0f, animator->offset ); animator->offset[1] *= -1.0f; - float curspeed = v3_length( player->rb.v ), + float curspeed = v3_length( localplayer.rb.v ), kickspeed = vg_clampf( curspeed*(1.0f/40.0f), 0.0f, 1.0f ), kicks = (vg_randf64()-0.5f)*2.0f*kickspeed, sign = vg_signf( kicks ); @@ -2687,10 +2667,10 @@ VG_STATIC void player__skate_animate( player_instance *player ){ (1.0f-fabsf(animator->slide)*0.9f); animator->offset[1]=vg_clampf(animator->offset[1],-0.5f,0.0f); - v3_muls( animator->offset, 0.3f, player->cam_control.tpv_offset_extra ); + v3_muls( animator->offset, 0.3f, localplayer.cam_control.tpv_offset_extra ); /* localized vectors */ - m4x3_mulv( player->rb.to_local, s->state.cog, animator->local_cog ); + m4x3_mulv( localplayer.rb.to_local, state->cog, animator->local_cog ); /* * Animation blending @@ -2700,21 +2680,21 @@ VG_STATIC void player__skate_animate( player_instance *player ){ /* sliding */ { float desired = 0.0f; - if( s->state.activity == k_skate_activity_ground ) - desired = vg_clampf( fabsf( s->state.slip ), 0.0f, 1.0f ); + if( state->activity == k_skate_activity_ground ) + desired = vg_clampf( fabsf( state->slip ), 0.0f, 1.0f ); animator->slide = vg_lerpf( animator->slide, desired, 2.4f*vg.time_delta); } /* movement information */ - int iair = s->state.activity <= k_skate_activity_air_to_grind; + int iair = state->activity <= k_skate_activity_air_to_grind; - float dirz = s->state.reverse > 0.0f? 0.0f: 1.0f, - dirx = s->state.slip < 0.0f? 0.0f: 1.0f, + float dirz = state->reverse > 0.0f? 0.0f: 1.0f, + dirx = state->slip < 0.0f? 0.0f: 1.0f, fly = iair? 1.0f: 0.0f, - wdist= s->weight_distribution[2] / k_board_length; + wdist= player_skate.weight_distribution[2] / k_board_length; - if( s->state.activity >= k_skate_activity_grind_any ) + if( state->activity >= k_skate_activity_grind_any ) wdist = 0.0f; animator->z = vg_lerpf( animator->z, dirz, 2.4f*vg.time_delta ); @@ -2724,60 +2704,60 @@ VG_STATIC void player__skate_animate( player_instance *player ){ float stand = 1.0f - vg_clampf( curspeed * 0.03f, 0.0f, 1.0f ); animator->stand = vg_lerpf( animator->stand, stand, 6.0f*vg.time_delta ); - animator->reverse = s->state.reverse; + animator->reverse = state->reverse; - if( fabsf(s->state.slip) > 0.3f ){ - f32 slide_dir = vg_signf(v3_dot(player->rb.v,player->rb.to_world[0])); - s->state.delayed_slip_dir = slide_dir; + if( fabsf(state->slip) > 0.3f ){ + f32 slide_x = v3_dot(localplayer.rb.v, localplayer.rb.to_world[0]); + state->delayed_slip_dir = vg_signf(slide_x); } /* grinding */ - f32 grind=s->state.activity >= k_skate_activity_grind_any? 1.0f: 0.0f; + f32 grind=state->activity >= k_skate_activity_grind_any? 1.0f: 0.0f; animator->grind = vg_lerpf( animator->grind, grind, 5.0f*vg.time_delta ); f32 grind_frame = 0.5f; - if( s->state.activity == k_skate_activity_grind_front50 ) + if( state->activity == k_skate_activity_grind_front50 ) grind_frame = 0.0f; - else if( s->state.activity == k_skate_activity_grind_back50 ) + else if( state->activity == k_skate_activity_grind_back50 ) grind_frame = 1.0f; animator->grind_balance = vg_lerpf( animator->grind_balance, grind_frame, 5.0f*vg.time_delta ); /* pushing */ - animator->push_time = vg.time - s->state.start_push; + animator->push_time = vg.time - state->start_push; animator->push = vg_lerpf( animator->push, - (vg.time - s->state.cur_push) < 0.125, + (vg.time - state->cur_push) < 0.125, 6.0f*vg.time_delta ); /* jumping */ - animator->jump_charge = s->state.jump_charge; + animator->jump_charge = state->jump_charge; animator->jump = vg_lerpf( animator->jump, animator->jump_charge, 8.4f*vg.time_delta ); /* trick setup */ - animator->jump_dir = s->state.jump_dir; + animator->jump_dir = state->jump_dir; f32 jump_start_frame = 14.0f/30.0f; animator->jump_time = animator->jump_charge * jump_start_frame; - f32 jump_frame = (vg.time - s->state.jump_time) + jump_start_frame; + f32 jump_frame = (vg.time - state->jump_time) + jump_start_frame; if( jump_frame >= jump_start_frame && jump_frame <= (40.0f/30.0f) ) animator->jump_time = jump_frame; /* trick */ - float jump_t = vg.time-s->state.jump_time; + float jump_t = vg.time-state->jump_time; float k=17.0f; float h = k*jump_t; - float extra = h*exp(1.0-h) * (s->state.jump_dir?1.0f:-1.0f); - extra *= s->state.slap * 4.0f; + float extra = h*exp(1.0-h) * (state->jump_dir?1.0f:-1.0f); + extra *= state->slap * 4.0f; - v3_add( s->state.trick_euler, s->state.trick_residuald, + v3_add( state->trick_euler, state->trick_residuald, animator->board_euler ); v3_muls( animator->board_euler, VG_TAUf, animator->board_euler ); animator->board_euler[0] *= 0.5f; animator->board_euler[1] += extra; - animator->trick_type = s->state.trick_type; + animator->trick_type = state->trick_type; /* board lean */ f32 lean1, lean2 = animator->steer[0] * animator->reverse * -0.36f, @@ -2795,7 +2775,7 @@ VG_STATIC void player__skate_animate( player_instance *player ){ /* feet placement */ struct player_board *board = addon_cache_item_if_loaded( k_addon_type_board, - player->board_view_slot ); + localplayer.board_view_slot ); if( board ){ if( animator->weight > 0.0f ){ animator->foot_offset[0] = @@ -2807,25 +2787,25 @@ VG_STATIC void player__skate_animate( player_instance *player ){ } } - f32 slapm = vg_maxf( 1.0f-v3_length2( s->state.trick_vel ), 0.0f ); - animator->slap = s->state.slap; + f32 slapm = vg_maxf( 1.0f-v3_length2( state->trick_vel ), 0.0f ); + animator->slap = state->slap; animator->subslap = vg_lerpf( animator->subslap, slapm, vg.time_delta*10.0f ); - f32 l = ((s->state.activity < k_skate_activity_ground) && - v3_length2(s->state.trick_vel) > 0.1f )? 1: 0; + f32 l = ((state->activity < k_skate_activity_ground) && + v3_length2(state->trick_vel) > 0.1f )? 1: 0; animator->trick_foot = vg_lerpf( animator->trick_foot, l, 8.4f*vg.time_delta ); /* grab */ v2f grab_input; joystick_state( k_srjoystick_grab, grab_input ); - v2_add( s->state.grab_mouse_delta, grab_input, grab_input ); + v2_add( state->grab_mouse_delta, grab_input, grab_input ); if( v2_length2( grab_input ) <= 0.001f ) grab_input[0] = -1.0f; else v2_normalize_clamp( grab_input ); v2_lerp( animator->grab, grab_input, 2.4f*vg.time_delta, animator->grab ); - animator->grabbing = s->state.grabbing; + animator->grabbing = state->grabbing; /* steer */ joystick_state( k_srjoystick_steer, animator->steer ); @@ -2835,34 +2815,34 @@ VG_STATIC void player__skate_animate( player_instance *player ){ /* flip angle */ - if( (s->state.activity <= k_skate_activity_air_to_grind) && - (fabsf(s->state.flip_rate) > 0.01f) ){ + if( (state->activity <= k_skate_activity_air_to_grind) && + (fabsf(state->flip_rate) > 0.01f) ){ float substep = vg.time_fixed_extrapolate; - float t = s->state.flip_time+s->state.flip_rate*substep*k_rb_delta; + float t = state->flip_time+state->flip_rate*substep*k_rb_delta; sign = vg_signf( t ); t = 1.0f - vg_minf( 1.0f, fabsf( t * 1.1f ) ); t = sign * (1.0f-t*t); f32 angle = vg_clampf( t, -1.0f, 1.0f ) * VG_TAUf, - distm = s->state.land_dist * fabsf(s->state.flip_rate) * 3.0f, + distm = state->land_dist * fabsf(state->flip_rate) * 3.0f, blend = vg_clampf( 1.0f-distm, 0.0f, 1.0f ); - angle = vg_lerpf( angle, vg_signf(s->state.flip_rate)*VG_TAUf, blend ); - q_axis_angle( animator->qflip, s->state.flip_axis, angle ); + angle = vg_lerpf( angle, vg_signf(state->flip_rate)*VG_TAUf, blend ); + q_axis_angle( animator->qflip, state->flip_axis, angle ); } else q_identity( animator->qflip ); /* counter-rotation */ - if( v3_length2( s->state.up_dir ) > 0.001f ){ - v4_lerp( s->state.smoothed_rotation, player->rb.q, + if( v3_length2( state->up_dir ) > 0.001f ){ + v4_lerp( state->smoothed_rotation, localplayer.rb.q, 2.0f*vg.time_frame_delta, - s->state.smoothed_rotation ); - q_normalize( s->state.smoothed_rotation ); + state->smoothed_rotation ); + q_normalize( state->smoothed_rotation ); v3f yaw_smooth = {1.0f,0.0f,0.0f}; - q_mulv( s->state.smoothed_rotation, yaw_smooth, yaw_smooth ); - m3x3_mulv( player->rb.to_local, yaw_smooth, yaw_smooth ); + q_mulv( state->smoothed_rotation, yaw_smooth, yaw_smooth ); + m3x3_mulv( localplayer.rb.to_local, yaw_smooth, yaw_smooth ); yaw_smooth[1] = 0.0f; v3_normalize( yaw_smooth ); @@ -2872,7 +2852,7 @@ VG_STATIC void player__skate_animate( player_instance *player ){ yaw_counter_rotate *= 1.0f-animator->fly; v3f ndir; - m3x3_mulv( player->rb.to_local, s->state.up_dir, ndir ); + m3x3_mulv( localplayer.rb.to_local, state->up_dir, ndir ); v3_normalize( ndir ); v3f up = { 0.0f, 1.0f, 0.0f }; @@ -2892,21 +2872,21 @@ VG_STATIC void player__skate_animate( player_instance *player ){ q_normalize( animator->qfixuptotal ); v3f p1, p2; - m3x3_mulv( player->rb.to_world, up, p1 ); - m3x3_mulv( player->rb.to_world, ndir, p2 ); + m3x3_mulv( localplayer.rb.to_world, up, p1 ); + m3x3_mulv( localplayer.rb.to_world, ndir, p2 ); - vg_line_arrow( player->rb.co, p1, 0.5f, VG__PINK ); - vg_line_arrow( player->rb.co, p2, 0.5f, VG__PINK ); + vg_line_arrow( localplayer.rb.co, p1, 0.5f, VG__PINK ); + vg_line_arrow( localplayer.rb.co, p2, 0.5f, VG__PINK ); } else q_identity( animator->qfixuptotal ); - rb_extrapolate( &player->rb, animator->root_co, animator->root_q ); + rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q ); } -VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ - struct player_avatar *av = player->playeravatar; +static void player__skate_pose( void *_animator, player_pose *pose ){ + struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &av->sk; - struct player_skate *s = &player->_skate; - struct player_skate_animator *animator = &s->animator; + struct player_skate_animator *animator = _animator; + pose->type = k_player_pose_type_ik; v3_copy( animator->root_co, pose->root_co ); v4_copy( animator->root_q, pose->root_q ); @@ -2942,25 +2922,28 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ stand_blend = vg_clampf( 1.0f-animator->local_cog[1], 0, 1 ); - skeleton_sample_anim( sk, s->anim_stand, dir_frame, apose ); - skeleton_sample_anim( sk, s->anim_highg, dir_frame, bpose ); + skeleton_sample_anim( sk, player_skate.anim_stand, dir_frame, apose ); + skeleton_sample_anim( sk, player_skate.anim_highg, dir_frame, bpose ); skeleton_lerp_pose( sk, apose, bpose, stand_blend, apose ); /* sliding */ - skeleton_sample_anim( sk, s->anim_slide, animator->x * 0.5f, bpose ); + skeleton_sample_anim( sk, player_skate.anim_slide, animator->x * 0.5f, + bpose ); skeleton_lerp_pose( sk, apose, bpose, animator->slide, apose ); - if( animator->reverse > 0.0f ) - skeleton_sample_anim( sk, s->anim_push, animator->push_time, bpose ); - else{ - skeleton_sample_anim( sk, s->anim_push_reverse, animator->push_time, + if( animator->reverse > 0.0f ){ + skeleton_sample_anim( sk, player_skate.anim_push, animator->push_time, bpose ); } + else{ + skeleton_sample_anim( sk, player_skate.anim_push_reverse, + animator->push_time, bpose ); + } skeleton_lerp_pose( sk, apose, bpose, animator->push, apose ); struct skeleton_anim *jump_anim = animator->jump_dir? - s->anim_ollie: - s->anim_ollie_reverse; + player_skate.anim_ollie: + player_skate.anim_ollie_reverse; f32 setup_blend = vg_minf( animator->jump, 1.0f ); skeleton_sample_anim_clamped( sk, jump_anim, animator->jump_time, bpose ); @@ -2970,13 +2953,13 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ mdl_keyframe air_pose[32]; { float air_frame = (animator->airdir*0.5f+0.5f) * (15.0f/30.0f); - skeleton_sample_anim( sk, s->anim_air, air_frame, apose ); + skeleton_sample_anim( sk, player_skate.anim_air, air_frame, apose ); float ang = atan2f( animator->grab[0], animator->grab[1] ), ang_unit = (ang+VG_PIf) * (1.0f/VG_TAUf), grab_frame = ang_unit * (15.0f/30.0f); - skeleton_sample_anim( sk, s->anim_grabs, grab_frame, bpose ); + skeleton_sample_anim( sk, player_skate.anim_grabs, grab_frame, bpose ); skeleton_lerp_pose( sk, apose, bpose, animator->grabbing, air_pose ); } @@ -2997,8 +2980,8 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ { f32 frame = animator->grind_balance * 0.5f; - skeleton_sample_anim( sk, s->anim_grind, frame, apose ); - skeleton_sample_anim( sk, s->anim_grind_jump, frame, bpose ); + skeleton_sample_anim( sk, player_skate.anim_grind, frame, apose ); + skeleton_sample_anim( sk, player_skate.anim_grind_jump, frame, bpose ); skeleton_lerp_pose( sk, apose, bpose, animator->jump, grind_pose ); } skeleton_lerp_pose( sk, pose->keyframes, grind_pose, @@ -3082,8 +3065,8 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ /* truck rotation */ for( int i=0; i<2; i++ ){ - float a = vg_minf( s->truckv0[i][0], 1.0f ); - a = -acosf( a ) * vg_signf( s->truckv0[i][1] ); + float a = vg_minf( player_skate.truckv0[i][0], 1.0f ); + a = -acosf( a ) * vg_signf( player_skate.truckv0[i][1] ); v4f q; q_axis_angle( q, (v3f){0.0f,0.0f,1.0f}, a ); @@ -3125,84 +3108,79 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ #endif } -VG_STATIC void player__skate_post_animate( player_instance *player ) -{ - struct player_skate *s = &player->_skate; - struct player_avatar *av = player->playeravatar; +static void player__skate_post_animate(void){ + struct player_avatar *av = localplayer.playeravatar; + struct player_skate_state *state = &player_skate.state; - player->cam_velocity_influence = 1.0f; + localplayer.cam_velocity_influence = 1.0f; v3f head = { 0.0f, 1.8f, 0.0f }; - m4x3_mulv( av->sk.final_mtx[ av->id_head ], head, s->state.head_position ); - m4x3_mulv( player->rb.to_local, s->state.head_position, - s->state.head_position ); + m4x3_mulv( av->sk.final_mtx[ av->id_head ], head, state->head_position ); + m4x3_mulv( localplayer.rb.to_local, + state->head_position, state->head_position ); } -VG_STATIC void player__skate_reset_animator( player_instance *player ){ - struct player_skate *s = &player->_skate; - struct player_skate_state *state = &s->state; +static void player__skate_reset_animator(void){ + struct player_skate_state *state = &player_skate.state; - memset( &s->animator, 0, sizeof(s->animator) ); + memset( &player_skate.animator, 0, sizeof(player_skate.animator) ); - if( s->state.activity <= k_skate_activity_air_to_grind ) - s->animator.fly = 1.0f; + if( state->activity <= k_skate_activity_air_to_grind ) + player_skate.animator.fly = 1.0f; else - s->animator.fly = 0.0f; + player_skate.animator.fly = 0.0f; } -VG_STATIC void player__skate_clear_mechanics( player_instance *player ) -{ - struct player_skate *s = &player->_skate; - s->state.jump_charge = 0.0f; - s->state.charging_jump = 0; - s->state.jump_dir = 0; - v3_zero( s->state.flip_axis ); - s->state.flip_time = 0.0f; - s->state.flip_rate = 0.0f; - s->state.reverse = 0.0f; - s->state.slip = 0.0f; - s->state.grabbing = 0.0f; - v2_zero( s->state.grab_mouse_delta ); - s->state.slap = 0.0f; - s->state.jump_time = 0.0; - s->state.start_push = 0.0; - s->state.cur_push = 0.0; - s->state.air_start = 0.0; - - v3_zero( s->state.air_init_v ); - v3_zero( s->state.air_init_co ); - - s->state.gravity_bias = k_gravity; - v3_copy( player->rb.co, s->state.prev_pos ); - v4_copy( player->rb.q, s->state.smoothed_rotation ); - v3_zero( s->state.throw_v ); - v3_zero( s->state.trick_vel ); - v3_zero( s->state.trick_euler ); - v3_zero( s->state.cog_v ); - s->state.grind_cooldown = 0; - s->state.surface_cooldown = 0; - v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog ); - v3_copy( player->rb.to_world[1], s->state.up_dir ); - v3_copy( player->rb.to_world[1], s->surface_picture ); - v3_zero( s->weight_distribution ); - v3_copy( player->rb.co, s->state.prev_pos ); +static void player__skate_clear_mechanics(void){ + struct player_skate_state *state = &player_skate.state; + state->jump_charge = 0.0f; + state->charging_jump = 0; + state->jump_dir = 0; + v3_zero( state->flip_axis ); + state->flip_time = 0.0f; + state->flip_rate = 0.0f; + state->reverse = 0.0f; + state->slip = 0.0f; + state->grabbing = 0.0f; + v2_zero( state->grab_mouse_delta ); + state->slap = 0.0f; + state->jump_time = 0.0; + state->start_push = 0.0; + state->cur_push = 0.0; + state->air_start = 0.0; + + v3_zero( state->air_init_v ); + v3_zero( state->air_init_co ); + + state->gravity_bias = k_gravity; + v3_copy( localplayer.rb.co, state->prev_pos ); + v4_copy( localplayer.rb.q, state->smoothed_rotation ); + v3_zero( state->throw_v ); + v3_zero( state->trick_vel ); + v3_zero( state->trick_euler ); + v3_zero( state->cog_v ); + state->grind_cooldown = 0; + state->surface_cooldown = 0; + v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], 1.0f, state->cog ); + v3_copy( localplayer.rb.to_world[1], state->up_dir ); + v3_copy( localplayer.rb.to_world[1], player_skate.surface_picture ); + v3_copy( localplayer.rb.co, state->prev_pos ); + v3_zero( player_skate.weight_distribution ); } -VG_STATIC void player__skate_reset( player_instance *player, - ent_spawn *rp ) -{ - struct player_skate *s = &player->_skate; - v3_zero( player->rb.v ); - v4_copy( rp->transform.q, player->rb.q ); +static void player__skate_reset( ent_spawn *rp ){ + struct player_skate_state *state = &player_skate.state; + v3_zero( localplayer.rb.v ); + v4_copy( rp->transform.q, localplayer.rb.q ); - s->state.activity = k_skate_activity_air; - s->state.activity_prev = k_skate_activity_air; + state->activity = k_skate_activity_air; + state->activity_prev = k_skate_activity_air; - player__skate_clear_mechanics( player ); - player__skate_reset_animator( player ); + player__skate_clear_mechanics(); + player__skate_reset_animator(); - v3_zero( s->state.head_position ); - s->state.head_position[1] = 1.8f; + v3_zero( state->head_position ); + state->head_position[1] = 1.8f; } #endif /* PLAYER_SKATE_C */ diff --git a/player_skate.h b/player_skate.h index 3d1a980..6dbb897 100644 --- a/player_skate.h +++ b/player_skate.h @@ -1,10 +1,9 @@ #ifndef PLAYER_SKATE_H #define PLAYER_SKATE_H +#include "player.h" #include "player_api.h" -#define SKATE_CCD - typedef struct jump_info jump_info; struct player_skate{ @@ -194,51 +193,10 @@ struct player_skate{ } limits[3]; u32 limit_count; -}; - -struct player_skate_animator_q { - v3f root_co; - v4f root_q; - - i8 offset[3]; - i8 local_cog[3]; - i8 slide, - z, - x, - fly, - grind, - grind_balance, - stand, - push, - jump, - airdir, - weight, - trick_foot, - slap, - subslap, - reverse, - delayed_slip_dir, - grabbing; - - i8 wobble[2]; - i8 foot_offset[2]; - - i16 qfixuptotal[4]; - i16 qflip; - - i16 board_euler[3]; - i8 steer[2], grab[2]; - - u8 jump_charge; - - /* linear anims */ - i8 push_time, jump_time; - u8 jump_dir; - u8 trick_type; } -animator; +static player_skate; -VG_STATIC float +static float k_friction_lat = 12.0f, k_friction_resistance = 0.01f, @@ -290,7 +248,7 @@ VG_STATIC float k_grind_balance = -40.0f; -VG_STATIC void player__skate_register(void) +static void player__skate_register(void) { VG_VAR_F32( k_grind_dampener, flags=VG_VAR_CHEAT ); VG_VAR_F32( k_grind_spring, flags=VG_VAR_CHEAT ); @@ -320,19 +278,34 @@ VG_STATIC void player__skate_register(void) VG_VAR_F32( k_mmthrow_steer, flags=VG_VAR_CHEAT ); } -VG_STATIC void player__skate_bind ( player_instance *player ); -VG_STATIC void player__skate_pre_update ( player_instance *player ); -VG_STATIC void player__skate_update ( player_instance *player ); -VG_STATIC void player__skate_post_update ( player_instance *player ); -VG_STATIC void player__skate_im_gui ( player_instance *player ); -VG_STATIC void player__skate_animate ( player_instance *player ); -VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ); -VG_STATIC void player__skate_post_animate ( player_instance *player ); -VG_STATIC void player__skate_reset ( player_instance *player, - ent_spawn *rp ); - -VG_STATIC void player__skate_clear_mechanics( player_instance *player ); -VG_STATIC void player__skate_reset_animator( player_instance *player ); -VG_STATIC void player__approximate_best_trajectory( player_instance *player ); +static void player__skate_bind (void); +static void player__skate_pre_update (void); +static void player__skate_update (void); +static void player__skate_post_update (void); +static void player__skate_im_gui (void); +static void player__skate_animate (void); +static void player__skate_pose (void *animator, player_pose *pose); +static void player__skate_post_animate (void); +static void player__skate_reset (ent_spawn *rp); + +static void player__skate_clear_mechanics(void); +static void player__skate_reset_animator(void); +static void player__approximate_best_trajectory(void); + +struct player_subsystem_interface static player_subsystem_skate = { + .system_register = player__skate_register, + .bind = player__skate_bind, + .reset = player__skate_reset, + .pre_update = player__skate_pre_update, + .update = player__skate_update, + .post_update = player__skate_post_update, + .im_gui = player__skate_im_gui, + .animate = player__skate_animate, + .pose = player__skate_pose, + .post_animate = player__skate_post_animate, + + .animator_data = &player_skate.animator, + .animator_size = sizeof(player_skate.animator) +}; #endif /* PLAYER_SKATE_H */ diff --git a/player_walk.c b/player_walk.c index 8415741..ad58c73 100644 --- a/player_walk.c +++ b/player_walk.c @@ -5,111 +5,94 @@ #include "input.h" #include "audio.h" -VG_STATIC void player_walk_drop_in_vector( player_instance *player, v3f vec ) -{ - struct player_walk *w = &player->_walk; - +static void player_walk_drop_in_vector( v3f vec ){ v3f axis, init_dir; - v3_cross( player->basis[1], w->state.drop_in_normal, axis ); - v3_cross( axis, w->state.drop_in_normal, init_dir ); + v3_cross( localplayer.basis[1], player_walk.state.drop_in_normal, axis ); + v3_cross( axis, player_walk.state.drop_in_normal, init_dir ); v3_normalize( init_dir ); v3_muls( init_dir, 7.0f, vec ); } -VG_STATIC float player_xyspeed2( player_instance *player ) -{ +static float player_xyspeed2(void){ v3f xy; - v3_muladds( player->rb.v, player->basis[1], - -v3_dot( player->basis[1], player->rb.v ), xy ); + v3_muladds( localplayer.rb.v, localplayer.basis[1], + -v3_dot( localplayer.basis[1], localplayer.rb.v ), xy ); return v3_length2(xy); } -VG_STATIC void player_walk_generic_to_skate( player_instance *player, - enum skate_activity init, - float yaw ) -{ - player->subsystem = k_player_subsystem_skate; - - struct player_walk *w = &player->_walk; - struct player_skate *s = &player->_skate; +static void player_walk_generic_to_skate( enum skate_activity init, f32 yaw ){ + localplayer.subsystem = k_player_subsystem_skate; v3f v; - if( player_xyspeed2(player) < 0.1f * 0.1f ) - q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.6f}, v ); + if( player_xyspeed2() < 0.1f * 0.1f ) + q_mulv( localplayer.rb.q, (v3f){0.0f,0.0f,1.6f}, v ); else - v3_copy( player->rb.v, v ); + v3_copy( localplayer.rb.v, v ); - s->state.activity_prev = k_skate_activity_ground; - s->state.activity = init; + player_skate.state.activity_prev = k_skate_activity_ground; + player_skate.state.activity = init; v3f dir; v3_copy( v, dir ); v3_normalize( dir ); - m3x3_mulv( player->invbasis, dir, dir ); + m3x3_mulv( localplayer.invbasis, dir, dir ); - q_axis_angle( player->rb.q, (v3f){0.0f,1.0f,0.0f}, atan2f(-dir[0],-dir[2]) ); - q_mul( player->qbasis, player->rb.q, player->rb.q ); - q_normalize( player->rb.q ); + q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, + atan2f(-dir[0],-dir[2]) ); + q_mul( localplayer.qbasis, localplayer.rb.q, localplayer.rb.q ); + q_normalize( localplayer.rb.q ); - q_mulv( player->rb.q, (v3f){0.0f,1.0f,0.0f}, s->state.cog ); - v3_add( s->state.cog, player->rb.co, s->state.cog ); + q_mulv( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, player_skate.state.cog ); + v3_add( player_skate.state.cog, localplayer.rb.co, player_skate.state.cog ); - v3_copy( v, s->state.cog_v ); - v3_copy( v, player->rb.v ); + v3_copy( v, player_skate.state.cog_v ); + v3_copy( v, localplayer.rb.v ); - player__begin_holdout( player ); - player__skate_reset_animator( player ); - player__skate_clear_mechanics( player ); - rb_update_transform( &player->rb ); - v3_copy( (v3f){yaw,0.0f,0.0f}, s->state.trick_euler ); + player__begin_holdout(); + player__skate_reset_animator(); + player__skate_clear_mechanics(); + rb_update_transform( &localplayer.rb ); + v3_copy( (v3f){yaw,0.0f,0.0f}, player_skate.state.trick_euler ); if( init == k_skate_activity_air ) - player__approximate_best_trajectory( player ); + player__approximate_best_trajectory(); } -VG_STATIC void player_walk_drop_in_to_skate( player_instance *player ) -{ - player->immobile = 0; - player->subsystem = k_player_subsystem_skate; +static void player_walk_drop_in_to_skate(void){ + localplayer.immobile = 0; + localplayer.subsystem = k_player_subsystem_skate; - struct player_walk *w = &player->_walk; - struct player_skate *s = &player->_skate; - s->state.activity_prev = k_skate_activity_ground; - s->state.activity = k_skate_activity_ground; + player_skate.state.activity_prev = k_skate_activity_ground; + player_skate.state.activity = k_skate_activity_ground; - player__begin_holdout( player ); - player__skate_clear_mechanics( player ); - player__skate_reset_animator( player ); + player__begin_holdout(); + player__skate_clear_mechanics(); + player__skate_reset_animator(); v3f init_velocity; - player_walk_drop_in_vector( player, init_velocity ); - - rb_update_transform( &player->rb ); - v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog ); - v3_copy( init_velocity, s->state.cog_v ); - v3_copy( init_velocity, player->rb.v ); - v3_copy( init_velocity, player->cam_control.cam_velocity_smooth ); - v3_copy( (v3f){1.0f,0.0f,0.0f}, s->state.trick_euler ); + player_walk_drop_in_vector( init_velocity ); + + rb_update_transform( &localplayer.rb ); + v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], 1.0f, + player_skate.state.cog ); + v3_copy( init_velocity, player_skate.state.cog_v ); + v3_copy( init_velocity, localplayer.rb.v ); + v3_copy( init_velocity, localplayer.cam_control.cam_velocity_smooth ); + v3_copy( (v3f){1.0f,0.0f,0.0f}, player_skate.state.trick_euler ); } -VG_STATIC void player_walk_drop_in_overhang_transform( player_instance *player, - float t, - v3f co, v4f q ) -{ - struct player_walk *w = &player->_walk; - +static void player_walk_drop_in_overhang_transform( f32 t, v3f co, v4f q ){ v3f axis; - v3_cross( player->basis[1], w->state.drop_in_normal, axis ); + v3_cross( localplayer.basis[1], player_walk.state.drop_in_normal, axis ); v3_normalize( axis ); - float a = acosf( w->state.drop_in_normal[1] ) * t; - + float a = acosf( player_walk.state.drop_in_normal[1] ) * t; q_axis_angle( q, axis, a ); float l = t * 0.5f, - heading_angle = w->state.drop_in_angle; + heading_angle = player_walk.state.drop_in_angle; v3f overhang; overhang[0] = sinf( heading_angle ) * l; @@ -117,29 +100,26 @@ VG_STATIC void player_walk_drop_in_overhang_transform( player_instance *player, overhang[2] = cosf( heading_angle ) * l; q_mulv( q, overhang, overhang ); - v3_add( w->state.drop_in_target, overhang, co ); + v3_add( player_walk.state.drop_in_target, overhang, co ); } -VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) -{ - struct player_walk *w = &player->_walk; +static int player_walk_scan_for_drop_in(void){ world_instance *world = world_current_instance(); v3f dir, center; - q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.0f}, dir ); - v3_muladds( player->rb.co, player->rb.to_world[1], -1.0f, center ); + q_mulv( localplayer.rb.q, (v3f){0.0f,0.0f,1.0f}, dir ); + v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], -1.0f, center ); ray_hit samples[20]; int sample_count = 0; - for( int i=0; i<20; i ++ ) - { + for( int i=0; i<20; i ++ ){ float t = (float)i * (1.0f/19.0f), s = sinf( t * VG_PIf * 0.25f ), c = cosf( t * VG_PIf * 0.25f ); v3f ray_dir, pos; - v3_muls ( player->rb.to_world[1], -c, ray_dir ); + v3_muls ( localplayer.rb.to_world[1], -c, ray_dir ); v3_muladds( ray_dir, dir, -s, ray_dir ); v3_muladds( center, ray_dir, -2.0f, pos ); @@ -181,27 +161,28 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) v3_copy( s0->normal, pa ); v3_copy( s1->normal, pb ); - v3_cross( player->rb.to_world[1], dir, pc ); + v3_cross( localplayer.rb.to_world[1], dir, pc ); v3_normalize( pc ); pa[3] = v3_dot( pa, s0->pos ); pb[3] = v3_dot( pb, s1->pos ); - pc[3] = v3_dot( pc, player->rb.co ); + pc[3] = v3_dot( pc, localplayer.rb.co ); v3f edge; if( plane_intersect3( pa, pb, pc, edge ) ){ - v3_copy( edge, w->state.drop_in_target ); - v3_copy( s1->normal, w->state.drop_in_normal ); - v3_copy( player->rb.co, w->state.drop_in_start ); + v3_copy( edge, player_walk.state.drop_in_target ); + v3_copy( s1->normal, player_walk.state.drop_in_normal ); + v3_copy( localplayer.rb.co, player_walk.state.drop_in_start ); - w->state.drop_in_start_angle = player_get_heading_yaw( player ); - w->state.drop_in_angle = atan2f( w->state.drop_in_normal[0], - w->state.drop_in_normal[2] ); + player_walk.state.drop_in_start_angle = player_get_heading_yaw(); + player_walk.state.drop_in_angle = + atan2f( player_walk.state.drop_in_normal[0], + player_walk.state.drop_in_normal[2] ); /* TODO: scan multiple of these? */ v3f oco; v4f oq; - player_walk_drop_in_overhang_transform( player, 1.0f, oco, oq ); + player_walk_drop_in_overhang_transform( 1.0f, oco, oq ); v3f va = {0.0f,0.0f,-k_board_length - 0.3f}, vb = {0.0f,0.0f, k_board_length + 0.3f}; @@ -233,11 +214,10 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) return 0; } - player_walk_drop_in_vector( player, player->rb.v ); + player_walk_drop_in_vector( localplayer.rb.v ); return 1; } - else - { + else{ vg_error( "failed to find intersection of drop in\n" ); } } @@ -245,9 +225,8 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) return 0; } -VG_STATIC struct skeleton_anim *player_walk_outro_anim( player_instance *player, - enum walk_outro type ){ - struct player_walk *w = &player->_walk; +static struct skeleton_anim *player_walk_outro_anim( enum walk_outro type ){ + struct player_walk *w = &player_walk; return (struct skeleton_anim *[]){ [k_walk_outro_none] = NULL, @@ -258,54 +237,51 @@ VG_STATIC struct skeleton_anim *player_walk_outro_anim( player_instance *player, } -VG_STATIC void player__walk_pre_update( player_instance *player ) -{ - struct player_walk *w = &player->_walk; +static void player__walk_pre_update(void){ + struct player_walk *w = &player_walk; - if( !player->immobile ) - player_look( player->angles, skaterift.time_rate ); + if( !localplayer.immobile ) + player_look( localplayer.angles, skaterift.time_rate ); if( w->state.outro_type ){ - struct skeleton_anim *anim = - player_walk_outro_anim( player, w->state.outro_type ); + struct skeleton_anim *anim = player_walk_outro_anim(w->state.outro_type); f32 outro_length = (f32)anim->length / anim->rate, outro_time = vg.time - w->state.outro_start_time; if( outro_time >= outro_length ){ if( w->state.outro_type == k_walk_outro_drop_in ){ - player_walk_drop_in_to_skate( player ); + player_walk_drop_in_to_skate(); } else if( w->state.outro_type == k_walk_outro_jump_to_air ){ - player_walk_generic_to_skate( player, k_skate_activity_air, 0.0f ); + player_walk_generic_to_skate( k_skate_activity_air, 0.0f ); } else{ - player_walk_generic_to_skate( player, - k_skate_activity_ground, 1.0f ); + player_walk_generic_to_skate( k_skate_activity_ground, 1.0f ); } w->state.outro_type = k_walk_outro_none; return; } } - else if( button_down( k_srbind_use ) && !player->immobile ){ - if( v3_dist2( player->rb.co, gzoomer.obj.rb.co ) <= 4.0f*4.0f ){ - player->subsystem = k_player_subsystem_drive; + else if( button_down( k_srbind_use ) && !localplayer.immobile ){ + if( v3_dist2( localplayer.rb.co, gzoomer.obj.rb.co ) <= 4.0f*4.0f ){ + localplayer.subsystem = k_player_subsystem_drive; } else{ struct player_board *board = addon_cache_item_if_loaded( k_addon_type_board, - player->board_view_slot ); + localplayer.board_view_slot ); if( !board ) return; if( w->state.activity == k_walk_activity_ground ){ - if( player_walk_scan_for_drop_in( player ) ){ + if( player_walk_scan_for_drop_in() ){ w->state.outro_type = k_walk_outro_drop_in; w->state.outro_start_time = vg.time; - player->immobile = 1; + localplayer.immobile = 1; - struct player_avatar *av = player->playeravatar; + struct player_avatar *av = localplayer.playeravatar; m4x3_mulv( av->sk.final_mtx[ av->id_ik_foot_r ], av->sk.bones[ av->id_ik_foot_r ].co, w->state.drop_in_foot_anchor ); @@ -315,8 +291,10 @@ VG_STATIC void player__walk_pre_update( player_instance *player ) w->state.outro_start_time = vg.time; w->state.activity = k_walk_activity_lockedmove; - if( player_xyspeed2(player) < 0.1f * 0.1f ) - q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.6f}, player->rb.v ); + if( player_xyspeed2() < 0.1f * 0.1f ){ + q_mulv( localplayer.rb.q, (v3f){0.0f,0.0f,1.6f}, + localplayer.rb.v ); + } } } else{ @@ -326,17 +304,17 @@ VG_STATIC void player__walk_pre_update( player_instance *player ) } } } - else if( button_down( k_srbind_jump ) && !player->immobile ){ + else if( button_down( k_srbind_jump ) && !localplayer.immobile ){ w->state.jump_queued = 1; w->state.jump_input_time = vg.time; } } -VG_STATIC int player_walk_normal_standable( player_instance *player, v3f n ){ - return v3_dot( n, player->basis[1] ) > 0.70710678118f; +static int player_walk_normal_standable( v3f n ){ + return v3_dot( n, localplayer.basis[1] ) > 0.70710678118f; } -VG_STATIC void player_accelerate( v3f v, v3f movedir, f32 speed, f32 accel ){ +static void player_accelerate( v3f v, v3f movedir, f32 speed, f32 accel ){ float currentspeed = v3_dot( v, movedir ), addspeed = speed - currentspeed; @@ -351,7 +329,7 @@ VG_STATIC void player_accelerate( v3f v, v3f movedir, f32 speed, f32 accel ){ v3_muladds( v, movedir, accelspeed, v ); } -VG_STATIC void player_friction( v3f v ){ +static void player_friction( v3f v ){ float speed = v3_length( v ), drop = 0.0f, control = vg_maxf( speed, k_stopspeed ); @@ -367,7 +345,7 @@ VG_STATIC void player_friction( v3f v ){ v3_muls( v, newspeed, v ); } -VG_STATIC void player_walk_custom_filter( world_instance *world, +static void player_walk_custom_filter( world_instance *world, rb_ct *man, int len, f32 w ){ for( int i=0; i_walk; - v3_copy( player->rb.co, w->state.prev_pos ); - v3_zero( player->rb.w ); +static void player__walk_update(void){ + struct player_walk *w = &player_walk; + v3_copy( localplayer.rb.co, w->state.prev_pos ); + v3_zero( localplayer.rb.w ); world_instance *world = world_current_instance(); if( world->water.enabled ){ - if( player->rb.co[1]+0.4f < world->water.height ){ - audio_oneshot_3d( &audio_splash, player->rb.co, 40.0f, 1.0f ); - player__dead_transition( player ); + if( localplayer.rb.co[1]+0.4f < world->water.height ){ + audio_oneshot_3d( &audio_splash, localplayer.rb.co, 40.0f, 1.0f ); + player__dead_transition(); return; } } @@ -425,26 +403,26 @@ VG_STATIC void player__walk_update( player_instance *player ){ w->collider.radius = 0.3f; m4x3f mtx; - m3x3_copy( player->rb.to_world, mtx ); - v3_add( player->rb.co, player->basis[1], mtx[3] ); + m3x3_copy( localplayer.rb.to_world, mtx ); + v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] ); vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__WHITE ); rb_ct manifold[64]; int len; - float yaw = player->angles[0]; + float yaw = localplayer.angles[0]; v3f forward_dir = { -sinf(yaw), 0.0f, cosf(yaw) }; v3f right_dir = { forward_dir[2], 0.0f, -forward_dir[0] }; - m3x3_mulv( player->basis, forward_dir, forward_dir ); - m3x3_mulv( player->basis, right_dir, right_dir ); + m3x3_mulv( localplayer.basis, forward_dir, forward_dir ); + m3x3_mulv( localplayer.basis, right_dir, right_dir ); v2f steer; joystick_state( k_srjoystick_steer, steer ); - w->move_speed = player->immobile? 0.0f: v2_length( steer ); + w->move_speed = localplayer.immobile? 0.0f: v2_length( steer ); /* * Collision detection @@ -466,7 +444,7 @@ VG_STATIC void player__walk_update( player_instance *player ){ struct contact *ct = &manifold[i]; rb_debug_contact( ct ); - if( player_walk_normal_standable( player, ct->n ) ){ + if( player_walk_normal_standable( ct->n ) ){ if( w->state.activity != k_walk_activity_lockedmove ) w->state.activity = k_walk_activity_ground; @@ -510,9 +488,11 @@ VG_STATIC void player__walk_update( player_instance *player ){ f32 t = vg.time - w->state.jump_input_time; if( t < PLAYER_JUMP_EPSILON ){ - float d = v3_dot( player->basis[1], player->rb.v ); - v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v ); - v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v ); + float d = v3_dot( localplayer.basis[1], localplayer.rb.v ); + v3_muladds( localplayer.rb.v, localplayer.basis[1], -d, + localplayer.rb.v ); + v3_muladds( localplayer.rb.v, localplayer.basis[1], 5.0f, + localplayer.rb.v ); w->state.activity = k_walk_activity_air; prev_state = k_walk_activity_air; accel_speed = k_walk_air_accel; @@ -520,7 +500,7 @@ VG_STATIC void player__walk_update( player_instance *player ){ } } else{ - player_friction( player->rb.v ); + player_friction( localplayer.rb.v ); } } else{ @@ -529,7 +509,8 @@ VG_STATIC void player__walk_update( player_instance *player ){ } if( v2_length2( steer ) > 0.001f ){ - player_accelerate( player->rb.v, movedir, nominal_speed, accel_speed ); + player_accelerate( localplayer.rb.v, movedir, + nominal_speed, accel_speed ); v3_normalize( movedir ); } @@ -541,13 +522,13 @@ VG_STATIC void player__walk_update( player_instance *player ){ struct contact *ct = &manifold[i]; /*normal */ - float vn = -v3_dot( player->rb.v, ct->n ); + float vn = -v3_dot( localplayer.rb.v, ct->n ); float temp = ct->norm_impulse; ct->norm_impulse = vg_maxf( temp + vn, 0.0f ); vn = ct->norm_impulse - temp; - v3_muladds( player->rb.v, ct->n, vn, player->rb.v ); + v3_muladds( localplayer.rb.v, ct->n, vn, localplayer.rb.v ); } } @@ -557,26 +538,27 @@ VG_STATIC void player__walk_update( player_instance *player ){ float max_dist = 0.4f; v3f pa, pb; - v3_copy( player->rb.co, pa ); - v3_muladds( pa, player->basis[1], w->collider.radius + max_dist, pa ); - v3_muladds( pa, player->basis[1], -max_dist * 2.0f, pb ); + v3_copy( localplayer.rb.co, pa ); + v3_muladds( pa, localplayer.basis[1], w->collider.radius + max_dist, pa ); + v3_muladds( pa, localplayer.basis[1], -max_dist * 2.0f, pb ); vg_line( pa, pb, 0xff000000 ); v3f n; float t; if( spherecast_world( world, pa, pb, w->collider.radius, &t, n, 0 ) != -1 ){ - if( player_walk_normal_standable( player, n ) ){ - v3_lerp( pa, pb, t, player->rb.co ); - v3_muladds( player->rb.co, player->basis[1], + if( player_walk_normal_standable(n) ){ + v3_lerp( pa, pb, t, localplayer.rb.co ); + v3_muladds( localplayer.rb.co, localplayer.basis[1], -w->collider.radius - k_penetration_slop, - player->rb.co ); + localplayer.rb.co ); w->state.activity = k_walk_activity_ground; - float d = -v3_dot(n,player->rb.v), + float d = -v3_dot(n,localplayer.rb.v), g = -k_gravity * k_rb_delta; - v3_muladds( player->rb.v, n, d, player->rb.v ); - v3_muladds( player->rb.v, player->basis[1], g, player->rb.v ); + v3_muladds( localplayer.rb.v, n, d, localplayer.rb.v ); + v3_muladds( localplayer.rb.v, localplayer.basis[1], g, + localplayer.rb.v ); } } } @@ -586,21 +568,22 @@ VG_STATIC void player__walk_update( player_instance *player ){ */ v3f dt; rb_depenetrate( manifold, len, dt ); - v3_add( dt, player->rb.co, player->rb.co ); + v3_add( dt, localplayer.rb.co, localplayer.rb.co ); /* integrate */ if( w->state.activity == k_walk_activity_air ){ - v3_muladds( player->rb.v, player->basis[1], -k_gravity*k_rb_delta, - player->rb.v ); + v3_muladds( localplayer.rb.v, localplayer.basis[1], -k_gravity*k_rb_delta, + localplayer.rb.v ); } - if( player->immobile ){ - player->rb.v[0] = 0.0f; - player->rb.v[2] = 0.0f; + if( localplayer.immobile ){ + localplayer.rb.v[0] = 0.0f; + localplayer.rb.v[2] = 0.0f; } - v3_muladds( player->rb.co, player->rb.v, k_rb_delta, player->rb.co ); - v3_add( player->rb.co, player->basis[1], mtx[3] ); + v3_muladds( localplayer.rb.co, localplayer.rb.v, k_rb_delta, + localplayer.rb.co ); + v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] ); vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__GREEN ); /* @@ -613,10 +596,10 @@ VG_STATIC void player__walk_update( player_instance *player ){ lwr_offs = { 0.0f, w->collider.radius, 0.0f }; v3_add( lwr_offs, w->state.prev_pos, lwr_prev ); - v3_add( lwr_offs, player->rb.co, lwr_now ); + v3_add( lwr_offs, localplayer.rb.co, lwr_now ); v3f movedelta; - v3_sub( player->rb.co, w->state.prev_pos, movedelta ); + v3_sub( localplayer.rb.co, w->state.prev_pos, movedelta ); float movedist = v3_length( movedelta ); @@ -625,75 +608,75 @@ VG_STATIC void player__walk_update( player_instance *player ){ v3f n; if( spherecast_world( world, lwr_prev, lwr_now, sr, &t, n, 0 ) != -1 ){ - v3_lerp( lwr_prev, lwr_now, vg_maxf(0.01f,t), player->rb.co ); - player->rb.co[1] -= w->collider.radius; - rb_update_transform( &player->rb ); + v3_lerp( lwr_prev, lwr_now, vg_maxf(0.01f,t), localplayer.rb.co ); + localplayer.rb.co[1] -= w->collider.radius; + rb_update_transform( &localplayer.rb ); - v3_add( player->rb.co, player->basis[1], mtx[3] ); + v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] ); vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__RED); } } ent_gate *gate = - world_intersect_gates( world, player->rb.co, w->state.prev_pos ); + world_intersect_gates( world, localplayer.rb.co, w->state.prev_pos ); if( gate ){ - m4x3_mulv( gate->transport, player->rb.co, player->rb.co ); - m3x3_mulv( gate->transport, player->rb.v, player->rb.v ); + m4x3_mulv( gate->transport, localplayer.rb.co, localplayer.rb.co ); + m3x3_mulv( gate->transport, localplayer.rb.v, localplayer.rb.v ); v4f transport_rotation; m3x3_q( gate->transport, transport_rotation ); - q_mul( transport_rotation, player->rb.q, player->rb.q ); + q_mul( transport_rotation, localplayer.rb.q, localplayer.rb.q ); - rb_update_transform( &player->rb ); - player__pass_gate( player, gate ); + rb_update_transform( &localplayer.rb ); + player__pass_gate( gate ); } - rb_update_transform( &player->rb ); + rb_update_transform( &localplayer.rb ); } -VG_STATIC void player__walk_post_update( player_instance *player ){ - struct player_walk *w = &player->_walk; +static void player__walk_post_update(void){ + struct player_walk *w = &player_walk; m4x3f mtx; - m3x3_copy( player->rb.to_world, mtx ); - v3_add( player->rb.co, player->basis[1], mtx[3] ); + m3x3_copy( localplayer.rb.to_world, mtx ); + v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] ); float substep = vg.time_fixed_extrapolate; - v3_muladds( mtx[3], player->rb.v, k_rb_delta*substep, mtx[3] ); + v3_muladds( mtx[3], localplayer.rb.v, k_rb_delta*substep, mtx[3] ); vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__YELOW ); /* Calculate header */ v3f v; - if( player_xyspeed2(player) > 0.1f*0.1f ) + if( player_xyspeed2() > 0.1f*0.1f ) { v3f v_xy; - m3x3_mulv( player->invbasis, player->rb.v, v_xy ); + m3x3_mulv( localplayer.invbasis, localplayer.rb.v, v_xy ); float a = atan2f( v_xy[0], v_xy[2] ); - q_axis_angle( player->rb.q, (v3f){0.0f,1.0f,0.0f}, a ); - q_mul( player->qbasis, player->rb.q, player->rb.q ); - q_normalize( player->rb.q ); + q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, a ); + q_mul( localplayer.qbasis, localplayer.rb.q, localplayer.rb.q ); + q_normalize( localplayer.rb.q ); } vg_line_point( w->state.drop_in_target, 0.1f, VG__GREEN ); v3f p1; v3_muladds( w->state.drop_in_target, w->state.drop_in_normal, 0.3f, p1 ); vg_line( w->state.drop_in_target, p1, VG__GREEN ); - v3_muladds( w->state.drop_in_target, player->rb.to_world[1], 0.3f, p1 ); + v3_muladds( w->state.drop_in_target, localplayer.rb.to_world[1], 0.3f, p1 ); vg_line( w->state.drop_in_target, p1, VG__GREEN ); vg_line( w->state.drop_in_target, w->state.drop_in_foot_anchor, VG__WHITE ); vg_line_point( w->state.drop_in_foot_anchor, 0.08f, VG__PINK ); - float a = player_get_heading_yaw( player ); + float a = player_get_heading_yaw(); p1[0] = sinf( a ); p1[1] = 0.0f; p1[2] = cosf( a ); - m3x3_mulv( player->basis, p1, p1 ); + m3x3_mulv( localplayer.basis, p1, p1 ); - v3_add( player->rb.co, p1, p1 ); - vg_line( player->rb.co, p1, VG__PINK ); + v3_add( localplayer.rb.co, p1, p1 ); + vg_line( localplayer.rb.co, p1, VG__PINK ); int walk_phase = 0; @@ -709,21 +692,21 @@ VG_STATIC void player__walk_post_update( player_instance *player ){ if( w->surface == k_surface_prop_concrete ){ audio_oneshot_3d( &audio_footsteps[vg_randu32()%vg_list_size(audio_footsteps)], - player->rb.co, 40.0f, 1.0f + localplayer.rb.co, 40.0f, 1.0f ); } else if( w->surface == k_surface_prop_grass ){ audio_oneshot_3d( &audio_footsteps_grass[ vg_randu32()% vg_list_size(audio_footsteps_grass)], - player->rb.co, 40.0f, 1.0f + localplayer.rb.co, 40.0f, 1.0f ); } else if( w->surface == k_surface_prop_wood ){ audio_oneshot_3d( &audio_footsteps_wood[ vg_randu32()% vg_list_size(audio_footsteps_wood)], - player->rb.co, 40.0f, 1.0f + localplayer.rb.co, 40.0f, 1.0f ); } audio_unlock(); @@ -732,9 +715,9 @@ VG_STATIC void player__walk_post_update( player_instance *player ){ w->state.step_phase = walk_phase; } -VG_STATIC void player__walk_animate( player_instance *player ){ - struct player_walk *w = &player->_walk; - player_pose *pose = &player->pose; +static void player__walk_animate(void){ + struct player_walk *w = &player_walk; + player_pose *pose = &localplayer.pose; struct player_walk_animator *animator = &w->animator; animator->outro_type = w->state.outro_type; @@ -763,18 +746,18 @@ VG_STATIC void player__walk_animate( player_instance *player ){ w->state.walk_timer = 0.0f; animator->walk_timer = w->state.walk_timer; - if( !player->immobile ) - rb_extrapolate( &player->rb, animator->root_co, animator->root_q ); + if( !localplayer.immobile ) + rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q ); else{ - v3_copy( player->rb.co, animator->root_co ); - v4_copy( player->rb.q, animator->root_q ); + v3_copy( localplayer.rb.co, animator->root_co ); + v4_copy( localplayer.rb.q, animator->root_q ); } - f32 walk_yaw = player_get_heading_yaw( player ); + f32 walk_yaw = player_get_heading_yaw(); if( w->state.outro_type ){ - struct player_avatar *av = player->playeravatar; + struct player_avatar *av = localplayer.playeravatar; struct skeleton_anim *anim = - player_walk_outro_anim( player, w->state.outro_type ); + player_walk_outro_anim( w->state.outro_type ); f32 outro_length = (f32)anim->length / anim->rate, outro_time = vg.time - w->state.outro_start_time; animator->outro_t = outro_time / outro_length; @@ -794,7 +777,7 @@ VG_STATIC void player__walk_animate( player_instance *player ){ w->state.drop_in_angle, step_t ); v3_lerp( w->state.drop_in_start, w->state.drop_in_target, - step_t, player->rb.co ); + step_t, localplayer.rb.co ); q_axis_angle( animator->root_q, (v3f){0.0f,1.0f,0.0f}, walk_yaw + VG_PIf ); @@ -803,32 +786,32 @@ VG_STATIC void player__walk_animate( player_instance *player ){ /* the drop in bit */ if( step_t >= 1.0f ){ v4f final_q; - player_walk_drop_in_overhang_transform( player, dop_t, - player->rb.co, final_q ); + player_walk_drop_in_overhang_transform( dop_t, localplayer.rb.co, + final_q ); q_mul( final_q, animator->root_q, animator->root_q ); - v4_copy( animator->root_q, player->rb.q ); - v3_muladds( animator->root_co, player->rb.to_world[1], + v4_copy( animator->root_q, localplayer.rb.q ); + v3_muladds( animator->root_co, localplayer.rb.to_world[1], -0.1f*dop_t, animator->root_co ); } return; } else{ - v3_muladds( animator->root_co, player->rb.to_world[1], + v3_muladds( animator->root_co, localplayer.rb.to_world[1], -0.1f*animator->outro_t, animator->root_co ); } } q_axis_angle( animator->root_q, (v3f){0.0f,1.0f,0.0f}, walk_yaw + VG_PIf ); - q_mul( player->qbasis, animator->root_q, animator->root_q ); + q_mul( localplayer.qbasis, animator->root_q, animator->root_q ); q_normalize( animator->root_q ); } -VG_STATIC void player__walk_pose( player_instance *player, player_pose *pose ){ - struct player_walk *w = &player->_walk; - struct player_walk_animator *animator = &w->animator; - struct skeleton *sk = &player->playeravatar->sk; - struct player_avatar *av = player->playeravatar; +static void player__walk_pose( void *_animator, player_pose *pose ){ + struct player_walk *w = &player_walk; + struct player_walk_animator *animator = _animator; + struct skeleton *sk = &localplayer.playeravatar->sk; + struct player_avatar *av = localplayer.playeravatar; v3_copy( animator->root_co, pose->root_co ); v4_copy( animator->root_q, pose->root_q ); @@ -857,8 +840,7 @@ VG_STATIC void player__walk_pose( player_instance *player, player_pose *pose ){ skeleton_lerp_pose( sk, apose, bpose, animator->fly, apose ); if( animator->outro_type ){ - struct skeleton_anim *anim = - player_walk_outro_anim( player, animator->outro_type ); + struct skeleton_anim *anim = player_walk_outro_anim(animator->outro_type); f32 outro_length = (f32)anim->length / anim->rate, outro_time = animator->outro_t*outro_length; @@ -885,35 +867,34 @@ VG_STATIC void player__walk_pose( player_instance *player, player_pose *pose ){ skeleton_copy_pose( sk, apose, pose->keyframes ); } -VG_STATIC void player__walk_post_animate( player_instance *player ){ +static void player__walk_post_animate(void){ /* * Camera */ - struct player_walk *w = &player->_walk; - struct player_avatar *av = player->playeravatar; + struct player_walk *w = &player_walk; + struct player_avatar *av = localplayer.playeravatar; if( w->state.outro_type ){ - struct skeleton_anim *anim = - player_walk_outro_anim( player, w->state.outro_type ); + struct skeleton_anim *anim = player_walk_outro_anim(w->state.outro_type); f32 outro_length = (f32)anim->length / anim->rate, outro_time = vg.time - w->state.outro_start_time, outro_t = outro_time / outro_length; - player->cam_velocity_influence = outro_t; + localplayer.cam_velocity_influence = outro_t; } else - player->cam_velocity_influence = 0.0f; + localplayer.cam_velocity_influence = 0.0f; } -VG_STATIC void player__walk_im_gui( player_instance *player ){ - struct player_walk *w = &player->_walk; - player__debugtext( 1, "V: %5.2f %5.2f %5.2f",player->rb.v[0], - player->rb.v[1], - player->rb.v[2] ); - player__debugtext( 1, "CO: %5.2f %5.2f %5.2f",player->rb.co[0], - player->rb.co[1], - player->rb.co[2] ); +static void player__walk_im_gui(void){ + struct player_walk *w = &player_walk; + player__debugtext( 1, "V: %5.2f %5.2f %5.2f",localplayer.rb.v[0], + localplayer.rb.v[1], + localplayer.rb.v[2] ); + player__debugtext( 1, "CO: %5.2f %5.2f %5.2f",localplayer.rb.co[0], + localplayer.rb.co[1], + localplayer.rb.co[2] ); player__debugtext( 1, "activity: %s\n", (const char *[]){ "k_walk_activity_air", "k_walk_activity_ground", @@ -930,7 +911,7 @@ VG_STATIC void player__walk_im_gui( player_instance *player ){ if( w->state.outro_type ){ struct skeleton_anim *anim = - player_walk_outro_anim( player, w->state.outro_type ); + player_walk_outro_anim( w->state.outro_type ); f32 outro_length = (f32)anim->length / anim->rate, outro_time = vg.time - w->state.outro_start_time; @@ -938,9 +919,9 @@ VG_STATIC void player__walk_im_gui( player_instance *player ){ } } -VG_STATIC void player__walk_bind( player_instance *player ){ - struct player_walk *w = &player->_walk; - struct player_avatar *av = player->playeravatar; +static void player__walk_bind(void){ + struct player_walk *w = &player_walk; + struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &av->sk; w->anim_idle = skeleton_get_anim( sk, "idle_cycle+y" ); @@ -952,8 +933,8 @@ VG_STATIC void player__walk_bind( player_instance *player ){ w->anim_intro = skeleton_get_anim( sk, "into_skate" ); } -VG_STATIC void player__walk_transition( player_instance *player ){ - struct player_walk *w = &player->_walk; +static void player__walk_transition(void){ + struct player_walk *w = &player_walk; w->state.activity = k_walk_activity_air; w->state.outro_type = k_walk_outro_none; w->state.outro_start_time = 0.0; @@ -963,18 +944,19 @@ VG_STATIC void player__walk_transition( player_instance *player ){ w->state.step_phase = 0; v3f fwd = { 0.0f, 0.0f, 1.0f }; - q_mulv( player->rb.q, fwd, fwd ); - m3x3_mulv( player->invbasis, fwd, fwd ); + q_mulv( localplayer.rb.q, fwd, fwd ); + m3x3_mulv( localplayer.invbasis, fwd, fwd ); - q_axis_angle( player->rb.q, (v3f){0.0f,1.0f,0.0f}, atan2f(fwd[0], fwd[2]) ); - q_mul( player->qbasis, player->rb.q, player->rb.q ); - q_normalize( player->rb.q ); + q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, + atan2f(fwd[0], fwd[2]) ); + q_mul( localplayer.qbasis, localplayer.rb.q, localplayer.rb.q ); + q_normalize( localplayer.rb.q ); - rb_update_transform( &player->rb ); + rb_update_transform( &localplayer.rb ); } -VG_STATIC void player__walk_reset( player_instance *player, ent_spawn *rp ){ - struct player_walk *w = &player->_walk; +static void player__walk_reset( ent_spawn *rp ){ + struct player_walk *w = &player_walk; w->state.activity = k_walk_activity_air; w->state.outro_type = k_walk_outro_none; w->state.outro_start_time = 0.0; diff --git a/player_walk.h b/player_walk.h index d422e75..ae0f9c3 100644 --- a/player_walk.h +++ b/player_walk.h @@ -1,6 +1,7 @@ #ifndef PLAYER_WALK_H #define PLAYER_WALK_H +#include "player.h" #include "player_api.h" #include "rigidbody.h" @@ -65,9 +66,10 @@ struct player_walk{ commit_t; } animator; -}; +} +static player_walk; -VG_STATIC float +static f32 k_walkspeed = 10.0f, k_airspeed = 1.2f, k_stopspeed = 4.0f, @@ -76,8 +78,7 @@ VG_STATIC float k_walk_friction = 10.0f, k_walk_step_height = 0.2f; -VG_STATIC void player__walk_register(void) -{ +static void player__walk_register(void){ VG_VAR_F32( k_walkspeed, flags=VG_VAR_CHEAT ); VG_VAR_F32( k_stopspeed, flags=VG_VAR_CHEAT ); VG_VAR_F32( k_airspeed, flags=VG_VAR_CHEAT ); @@ -86,17 +87,32 @@ VG_STATIC void player__walk_register(void) VG_VAR_F32( k_walk_accel, flags=VG_VAR_CHEAT ); } -VG_STATIC void player__walk_pre_update ( player_instance *player ); -VG_STATIC void player__walk_update ( player_instance *player ); -VG_STATIC void player__walk_post_update ( player_instance *player ); -VG_STATIC void player__walk_animate ( player_instance *player ); -VG_STATIC void player__walk_pose( player_instance *player, player_pose *pose ); -VG_STATIC void player__walk_post_animate( player_instance *player ); -VG_STATIC void player__walk_im_gui ( player_instance *player ); -VG_STATIC void player__walk_bind ( player_instance *player ); -VG_STATIC void player__walk_transition ( player_instance *player ); -VG_STATIC void player__walk_reset ( player_instance *player, - ent_spawn *rp ); -VG_STATIC void player__walk_restore( player_instance *player ); +static void player__walk_pre_update (void); +static void player__walk_update (void); +static void player__walk_post_update (void); +static void player__walk_animate (void); +static void player__walk_pose (void *animator, player_pose *pose); +static void player__walk_post_animate(void); +static void player__walk_im_gui (void); +static void player__walk_bind (void); +static void player__walk_transition (void); +static void player__walk_reset (ent_spawn *rp ); +static void player__walk_restore (void); + +struct player_subsystem_interface static player_subsystem_walk = { + .system_register = player__walk_register, + .bind = player__walk_bind, + .reset = player__walk_reset, + .pre_update = player__walk_pre_update, + .update = player__walk_update, + .post_update = player__walk_post_update, + .im_gui = player__walk_im_gui, + .animate = player__walk_animate, + .post_animate = player__walk_post_animate, + .pose = player__walk_pose, + + .animator_data = &player_walk.animator, + .animator_size = sizeof(player_walk.animator) +}; #endif /* PLAYER_WALK_H */ diff --git a/render.h b/render.h index e77a809..ea88ecc 100644 --- a/render.h +++ b/render.h @@ -27,7 +27,7 @@ typedef struct framebuffer framebuffer; /* * All standard buffers used in rendering */ -VG_STATIC struct pipeline{ +static struct pipeline{ glmesh fsquad; framebuffer *fb_main, @@ -196,7 +196,7 @@ framebuffers[] = /* * Get the current (automatically scaled or fixed) resolution of framebuffer */ -VG_STATIC void render_fb_get_current_res( struct framebuffer *fb, +static void render_fb_get_current_res( struct framebuffer *fb, int *x, int *y ) { if( fb->resolution_div ){ @@ -209,7 +209,7 @@ VG_STATIC void render_fb_get_current_res( struct framebuffer *fb, } } -VG_STATIC void render_fb_inverse_ratio( framebuffer *fb, v2f inverse ) +static void render_fb_inverse_ratio( framebuffer *fb, v2f inverse ) { if( fb ){ int x, y; @@ -228,7 +228,7 @@ VG_STATIC void render_fb_inverse_ratio( framebuffer *fb, v2f inverse ) /* * Bind framebuffer for drawing to */ -VG_STATIC void render_fb_bind( framebuffer *fb, int use_scaling ) +static void render_fb_bind( framebuffer *fb, int use_scaling ) { int x, y; render_fb_get_current_res( fb, &x, &y ); @@ -251,7 +251,7 @@ VG_STATIC void render_fb_bind( framebuffer *fb, int use_scaling ) /* * Bind framebuffer attachment's texture */ -VG_STATIC void render_fb_bind_texture( framebuffer *fb, +static void render_fb_bind_texture( framebuffer *fb, int attachment, int slot ) { struct framebuffer_attachment *at = &fb->attachments[attachment]; @@ -277,7 +277,7 @@ VG_STATIC void render_fb_bind_texture( framebuffer *fb, /* * Convert OpenGL attachment ID enum to string */ -VG_STATIC const char *render_fb_attachment_str( GLenum e ) +static const char *render_fb_attachment_str( GLenum e ) { struct { GLenum e; const char *str; } formats[] = @@ -301,7 +301,7 @@ VG_STATIC const char *render_fb_attachment_str( GLenum e ) * Convert OpenGL texture format enums from TexImage2D table 1,2 & * RenderBufferStorage Table 1, into strings */ -VG_STATIC const char *render_fb_format_str( GLenum format ) +static const char *render_fb_format_str( GLenum format ) { struct { GLenum e; const char *str; } formats[] = @@ -396,7 +396,7 @@ VG_STATIC const char *render_fb_format_str( GLenum format ) /* * Bind and allocate texture for framebuffer attachment */ -VG_STATIC void render_fb_allocate_texture( struct framebuffer *fb, +static void render_fb_allocate_texture( struct framebuffer *fb, struct framebuffer_attachment *a ) { int rx, ry; @@ -418,7 +418,7 @@ VG_STATIC void render_fb_allocate_texture( struct framebuffer *fb, /* * Full allocation of a framebuffer */ -VG_STATIC void render_fb_allocate( struct framebuffer *fb ) +static void render_fb_allocate( struct framebuffer *fb ) { glGenFramebuffers( 1, &fb->fb ); glBindFramebuffer( GL_FRAMEBUFFER, fb->fb ); @@ -502,7 +502,7 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb ) /* * Resize/Update all framebuffers(we know about) */ -VG_STATIC void render_fb_resize(void) +static void render_fb_resize(void) { if( !gpipeline.ready ) return; @@ -515,10 +515,10 @@ VG_STATIC void render_fb_resize(void) } } -VG_STATIC int render_framebuffer_control( int argc, char const *argv[] ); -VG_STATIC void render_framebuffer_poll( int argc, char const *argv[] ); +static int render_framebuffer_control( int argc, char const *argv[] ); +static void render_framebuffer_poll( int argc, char const *argv[] ); -VG_STATIC void async_render_init( void *payload, u32 size ) +static void async_render_init( void *payload, u32 size ) { /* * Complete Framebuffers @@ -582,7 +582,7 @@ VG_STATIC void async_render_init( void *payload, u32 size ) gpipeline.ready = 1; } -VG_STATIC void render_init(void) +static void render_init(void) { vg_console_reg_var( "blur_strength", &k_blur_strength, k_var_dtype_f32, 0 ); vg_console_reg_var( "render_scale", &k_render_scale, @@ -604,19 +604,19 @@ VG_STATIC void render_init(void) /* * Utility */ -VG_STATIC void render_fsquad(void) +static void render_fsquad(void) { glBindVertexArray( gpipeline.fsquad.vao ); glDrawArrays( GL_TRIANGLES, 0, 6 ); } -VG_STATIC void render_fsquad1(void) +static void render_fsquad1(void) { glBindVertexArray( gpipeline.fsquad.vao ); glDrawArrays( GL_TRIANGLES, 6, 6 ); } -VG_STATIC void render_fsquad2(void) +static void render_fsquad2(void) { glBindVertexArray( gpipeline.fsquad.vao ); glDrawArrays( GL_TRIANGLES, 66,6 ); @@ -625,7 +625,7 @@ VG_STATIC void render_fsquad2(void) /* * Call this inside the UI function */ -VG_STATIC void render_view_framebuffer_ui(void) +static void render_view_framebuffer_ui(void) { #if 0 int viewing_count = 0; @@ -681,7 +681,7 @@ VG_STATIC void render_view_framebuffer_ui(void) #endif } -VG_STATIC void render_framebuffer_show( struct framebuffer *fb, +static void render_framebuffer_show( struct framebuffer *fb, struct framebuffer_attachment *at, int operation ) { @@ -695,7 +695,7 @@ VG_STATIC void render_framebuffer_show( struct framebuffer *fb, * arg1: framebuffer name /"all" * arg2: subname /none */ -VG_STATIC int render_framebuffer_control( int argc, char const *argv[] ) +static int render_framebuffer_control( int argc, char const *argv[] ) { if( argc < 2 ){ vg_error( "Usage: fb \"show/hide\" /\"all\" /none\n" ); @@ -743,7 +743,7 @@ VG_STATIC int render_framebuffer_control( int argc, char const *argv[] ) return 0; } -VG_STATIC void render_framebuffer_poll( int argc, char const *argv[] ) +static void render_framebuffer_poll( int argc, char const *argv[] ) { const char *term = argv[argc-1]; diff --git a/respawn.c b/respawn.c index 50ddea2..e10d0cf 100644 --- a/respawn.c +++ b/respawn.c @@ -9,7 +9,7 @@ #include "menu.h" #include "scene.h" -VG_STATIC void respawn_chooser_get_dir( v3f dir ){ +static void respawn_chooser_get_dir( v3f dir ){ /* idk */ dir[0] = -sqrtf(0.5f); dir[2] = sqrtf(0.5f); @@ -17,7 +17,7 @@ VG_STATIC void respawn_chooser_get_dir( v3f dir ){ v3_normalize(dir); } -VG_STATIC void respawn_chooser_get_plane( v4f plane ){ +static void respawn_chooser_get_plane( v4f plane ){ world_instance *world = &world_static.instances[ respawn_chooser.world_id ]; f32 h = localplayer.rb.co[1]; if( respawn_chooser.world_id != world_static.active_instance ) @@ -26,7 +26,7 @@ VG_STATIC void respawn_chooser_get_plane( v4f plane ){ v4_copy( (v4f){0.0f,1.0f,0.0f,h}, plane ); } -VG_STATIC void respawn_world_to_plane_pos( v3f pos, v2f plane_pos ){ +static void respawn_world_to_plane_pos( v3f pos, v2f plane_pos ){ v3f dir; respawn_chooser_get_dir( dir ); v3_negate(dir,dir); @@ -40,7 +40,7 @@ VG_STATIC void respawn_world_to_plane_pos( v3f pos, v2f plane_pos ){ plane_pos[1] = co[2]; } -VG_STATIC void respawn_chooser_setworld( u32 next ){ +static void respawn_chooser_setworld( u32 next ){ world_instance *nw = &world_static.instances[next]; if( nw->status == k_world_status_loaded ){ respawn_chooser.world_id = next; @@ -56,7 +56,7 @@ VG_STATIC void respawn_chooser_setworld( u32 next ){ } } -VG_STATIC void respawn_chooser_gohome(void){ +static void respawn_chooser_gohome(void){ respawn_chooser_setworld(0); world_instance *world = &world_static.instances[ respawn_chooser.world_id ]; @@ -73,7 +73,7 @@ VG_STATIC void respawn_chooser_gohome(void){ gui_location_print_ccmd( 1, (const char *[]){ "Invalid home ID" } ); } -VG_STATIC void respawn_map_draw_icon( camera *cam, +static void respawn_map_draw_icon( camera *cam, enum gui_icon icon, v3f pos ){ v4f v; v3_copy( pos, v ); @@ -84,7 +84,7 @@ VG_STATIC void respawn_map_draw_icon( camera *cam, gui_draw_icon( icon, (v2f){ v[0]*0.5f+0.5f,v[1]*0.5f+0.5f }, 1.0f ); } -VG_STATIC void respawn_chooser_pre_update(void){ +static void respawn_chooser_pre_update(void){ if( skaterift.activity != k_skaterift_respawning ) return; gui_helper_action( joystick_display_string(k_srjoystick_steer,2), "move" ); @@ -109,7 +109,7 @@ VG_STATIC void respawn_chooser_pre_update(void){ world_static.active_instance = respawn_chooser.world_id; localplayer.viewable_world = &world_static.instances[ respawn_chooser.world_id ]; - player__spawn( &localplayer, respawn_chooser.spawn ); + player__spawn( respawn_chooser.spawn ); } return; } @@ -222,7 +222,7 @@ VG_STATIC void respawn_chooser_pre_update(void){ } } -VG_STATIC void respawn_begin_chooser(void){ +static void respawn_begin_chooser(void){ skaterift.activity = k_skaterift_respawning; respawn_chooser.world_id = world_static.active_instance; @@ -234,7 +234,7 @@ VG_STATIC void respawn_begin_chooser(void){ respawn_chooser.home_select = 0; } -VG_STATIC void respawn_chooser_shader_uniforms(void){ +static void respawn_chooser_shader_uniforms(void){ v4f uPlayerPos, uSpawnPos; v4_zero( uPlayerPos ); v4_zero( uSpawnPos ); diff --git a/respawn.h b/respawn.h index 002ffff..fed65fd 100644 --- a/respawn.h +++ b/respawn.h @@ -19,7 +19,7 @@ static const char *respawn_homes[][2] = { { "world_select", "World Selector" }, }; -VG_STATIC void respawn_begin_chooser(void); -VG_STATIC void respawn_chooser_shader_uniforms(void); +static void respawn_begin_chooser(void); +static void respawn_chooser_shader_uniforms(void); #endif /* RESPAWN_H */ diff --git a/rigidbody.h b/rigidbody.h index d19b786..7d878e9 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -105,7 +105,7 @@ struct rb_object{ inf; }; -VG_STATIC struct contact{ +static struct contact{ rigidbody *rba, *rbb; v3f co, n; v3f t[2]; @@ -117,7 +117,7 @@ VG_STATIC struct contact{ enum contact_type type; } rb_contact_buffer[256]; -VG_STATIC int rb_contact_count = 0; +static int rb_contact_count = 0; typedef struct rb_constr_pos rb_constr_pos; typedef struct rb_constr_swingtwist rb_constr_swingtwist; @@ -147,7 +147,7 @@ struct rb_constr_swingtwist{ * ----------------------------------------------------------------------------- */ -VG_STATIC void rb_debug_contact( rb_ct *ct ){ +static void rb_debug_contact( rb_ct *ct ){ v3f p1; v3_muladds( ct->co, ct->n, 0.05f, p1 ); @@ -162,7 +162,7 @@ VG_STATIC void rb_debug_contact( rb_ct *ct ){ } -VG_STATIC void rb_object_debug( rb_object *obj, u32 colour ){ +static void rb_object_debug( rb_object *obj, u32 colour ){ if( obj->type == k_rb_shape_box ){ v3f *box = obj->rb.bbx; vg_line_boxf_transformed( obj->rb.to_world, obj->rb.bbx, colour ); @@ -191,7 +191,7 @@ VG_STATIC void rb_object_debug( rb_object *obj, u32 colour ){ /* * Update world space bounding box based on local one */ -VG_STATIC void rb_update_bounds( rigidbody *rb ){ +static void rb_update_bounds( rigidbody *rb ){ box_init_inf( rb->bbx_world ); m4x3_expand_aabb_aabb( rb->to_world, rb->bbx_world, rb->bbx ); } @@ -199,7 +199,7 @@ VG_STATIC void rb_update_bounds( rigidbody *rb ){ /* * Commit transform to rigidbody. Updates matrices */ -VG_STATIC void rb_update_transform( rigidbody *rb ) +static void rb_update_transform( rigidbody *rb ) { q_normalize( rb->q ); q_m3x3( rb->q, rb->to_world ); @@ -216,7 +216,7 @@ VG_STATIC void rb_update_transform( rigidbody *rb ) * Extrapolate rigidbody into a transform based on vg accumulator. * Useful for rendering */ -VG_STATIC void rb_extrapolate( rigidbody *rb, v3f co, v4f q ) +static void rb_extrapolate( rigidbody *rb, v3f co, v4f q ) { float substep = vg.time_fixed_extrapolate; v3_muladds( rb->co, rb->v, k_rb_delta*substep, co ); @@ -240,7 +240,7 @@ VG_STATIC void rb_extrapolate( rigidbody *rb, v3f co, v4f q ) /* * Initialize rigidbody and calculate masses, inertia */ -VG_STATIC void rb_init_object( rb_object *obj ){ +static void rb_init_object( rb_object *obj ){ float volume = 1.0f; int inert = 0; @@ -302,7 +302,7 @@ VG_STATIC void rb_init_object( rb_object *obj ){ rb_update_transform( &obj->rb ); } -VG_STATIC void rb_iter( rigidbody *rb ){ +static void rb_iter( rigidbody *rb ){ if( !vg_validf( rb->v[0] ) || !vg_validf( rb->v[1] ) || !vg_validf( rb->v[2] ) ) @@ -345,7 +345,7 @@ VG_STATIC void rb_iter( rigidbody *rb ){ /* * Project AABB, and triangle interval onto axis to check if they overlap */ -VG_STATIC int rb_box_triangle_interval( v3f extent, v3f axis, v3f tri[3] ){ +static int rb_box_triangle_interval( v3f extent, v3f axis, v3f tri[3] ){ float r = extent[0] * fabsf(axis[0]) + @@ -365,7 +365,7 @@ VG_STATIC int rb_box_triangle_interval( v3f extent, v3f axis, v3f tri[3] ){ /* * Seperating axis test box vs triangle */ -VG_STATIC int rb_box_triangle_sat( v3f extent, v3f center, +static int rb_box_triangle_sat( v3f extent, v3f center, m4x3f to_local, v3f tri_src[3] ){ v3f tri[3]; @@ -412,7 +412,7 @@ VG_STATIC int rb_box_triangle_sat( v3f extent, v3f center, * ----------------------------------------------------------------------------- */ -VG_STATIC int rb_manifold_apply_filtered( rb_ct *man, int len ){ +static int rb_manifold_apply_filtered( rb_ct *man, int len ){ int k = 0; for( int i=0; ico, cj->co ) < r*r ){ cj->type = k_contact_type_disabled; ci->p = (ci->p + cj->p) * 0.5f; @@ -461,7 +461,7 @@ VG_STATIC void rb_manifold_contact_weld( rb_ct *ci, rb_ct *cj, float r ){ /* * */ -VG_STATIC void rb_manifold_filter_joint_edges( rb_ct *man, int len, float r ){ +static void rb_manifold_filter_joint_edges( rb_ct *man, int len, float r ){ for( int i=0; itype != k_contact_type_edge ) @@ -480,7 +480,7 @@ VG_STATIC void rb_manifold_filter_joint_edges( rb_ct *man, int len, float r ){ /* * Resolve overlapping pairs */ -VG_STATIC void rb_manifold_filter_pairs( rb_ct *man, int len, float r ){ +static void rb_manifold_filter_pairs( rb_ct *man, int len, float r ){ for( int i=0; itype == k_contact_type_disabled ) @@ -533,7 +533,7 @@ VG_STATIC void rb_manifold_filter_backface( rb_ct *man, int len ){ /* * Filter out duplicate coplanar results. Good for spheres. */ -VG_STATIC void rb_manifold_filter_coplanar( rb_ct *man, int len, float w ){ +static void rb_manifold_filter_coplanar( rb_ct *man, int len, float w ){ for( int i=0; itype == k_contact_type_disabled || @@ -597,7 +597,7 @@ struct capsule_manifold{ * Expand a line manifold with a new pair. t value is the time along segment * on the oriented object which created this pair. */ -VG_STATIC void rb_capsule_manifold( v3f pa, v3f pb, float t, float r, +static void rb_capsule_manifold( v3f pa, v3f pb, float t, float r, capsule_manifold *manifold ){ v3f delta; v3_sub( pa, pb, delta ); @@ -617,12 +617,12 @@ VG_STATIC void rb_capsule_manifold( v3f pa, v3f pb, float t, float r, } } -VG_STATIC void rb_capsule_manifold_init( capsule_manifold *manifold ){ +static void rb_capsule_manifold_init( capsule_manifold *manifold ){ manifold->t0 = INFINITY; manifold->t1 = -INFINITY; } -VG_STATIC int rb_capsule__manifold_done( m4x3f mtx, rb_capsule *c, +static int rb_capsule__manifold_done( m4x3f mtx, rb_capsule *c, capsule_manifold *manifold, rb_ct *buf ){ v3f p0, p1; @@ -673,7 +673,7 @@ VG_STATIC int rb_capsule__manifold_done( m4x3f mtx, rb_capsule *c, return count; } -VG_STATIC int rb_capsule_sphere( rb_object *obja, rb_object *objb, rb_ct *buf ){ +static int rb_capsule_sphere( rb_object *obja, rb_object *objb, rb_ct *buf ){ rigidbody *rba = &obja->rb, *rbb = &objb->rb; float h = obja->inf.capsule.height, ra = obja->inf.capsule.radius, @@ -713,7 +713,7 @@ VG_STATIC int rb_capsule_sphere( rb_object *obja, rb_object *objb, rb_ct *buf ){ return 0; } -VG_STATIC int rb_capsule__capsule( m4x3f mtxA, rb_capsule *ca, +static int rb_capsule__capsule( m4x3f mtxA, rb_capsule *ca, m4x3f mtxB, rb_capsule *cb, rb_ct *buf ){ float ha = ca->height, hb = cb->height, @@ -748,7 +748,7 @@ VG_STATIC int rb_capsule__capsule( m4x3f mtxA, rb_capsule *ca, return rb_capsule__manifold_done( mtxA, ca, &manifold, buf ); } -VG_STATIC int rb_sphere_box( rb_object *obja, rb_object *objb, rb_ct *buf ){ +static int rb_sphere_box( rb_object *obja, rb_object *objb, rb_ct *buf ){ v3f co, delta; rigidbody *rba = &obja->rb, *rbb = &objb->rb; @@ -803,7 +803,7 @@ VG_STATIC int rb_sphere_box( rb_object *obja, rb_object *objb, rb_ct *buf ){ return 0; } -VG_STATIC int rb_sphere_sphere( rb_object *obja, rb_object *objb, rb_ct *buf ){ +static int rb_sphere_sphere( rb_object *obja, rb_object *objb, rb_ct *buf ){ rigidbody *rba = &obja->rb, *rbb = &objb->rb; v3f delta; v3_sub( rba->co, rbb->co, delta ); @@ -832,7 +832,7 @@ VG_STATIC int rb_sphere_sphere( rb_object *obja, rb_object *objb, rb_ct *buf ){ return 0; } -VG_STATIC int rb_sphere__triangle( m4x3f mtxA, rb_sphere *b, +static int rb_sphere__triangle( m4x3f mtxA, rb_sphere *b, v3f tri[3], rb_ct *buf ){ v3f delta, co; enum contact_type type = closest_on_triangle_1( mtxA[3], tri, co ); @@ -871,7 +871,7 @@ VG_STATIC int rb_sphere__triangle( m4x3f mtxA, rb_sphere *b, return 0; } -VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, +static int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, m4x3f mtxB, rb_scene *s, rb_ct *buf, u16 ignore ){ scene_context *sc = s->bh_scene->user; @@ -914,7 +914,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, return count; } -VG_STATIC int rb_box__scene( m4x3f mtxA, boxf bbx, +static int rb_box__scene( m4x3f mtxA, boxf bbx, m4x3f mtxB, rb_scene *s, rb_ct *buf, u16 ignore ){ scene_context *sc = s->bh_scene->user; v3f tri[3]; @@ -1068,7 +1068,7 @@ VG_STATIC int rb_box__scene( m4x3f mtxA, boxf bbx, return count; } -VG_STATIC int rb_capsule__triangle( m4x3f mtxA, rb_capsule *c, +static int rb_capsule__triangle( m4x3f mtxA, rb_capsule *c, v3f tri[3], rb_ct *buf ){ v3f pc, p0w, p1w; v3_muladds( mtxA[3], mtxA[1], -c->height*0.5f+c->radius, p0w ); @@ -1128,7 +1128,7 @@ VG_STATIC int rb_capsule__triangle( m4x3f mtxA, rb_capsule *c, } /* mtxB is defined only for tradition; it is not used currently */ -VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, +static int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, m4x3f mtxB, rb_scene *s, rb_ct *buf, u16 ignore ){ int count = 0; @@ -1164,14 +1164,14 @@ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, return count; } -VG_STATIC int rb_global_has_space( void ){ +static int rb_global_has_space( void ){ if( rb_contact_count + 16 > vg_list_size(rb_contact_buffer) ) return 0; return 1; } -VG_STATIC rb_ct *rb_global_buffer( void ){ +static rb_ct *rb_global_buffer( void ){ return &rb_contact_buffer[ rb_contact_count ]; } @@ -1181,15 +1181,15 @@ VG_STATIC rb_ct *rb_global_buffer( void ){ * ----------------------------------------------------------------------------- */ -VG_STATIC void rb_solver_reset(void){ +static void rb_solver_reset(void){ rb_contact_count = 0; } -VG_STATIC rb_ct *rb_global_ct(void){ +static rb_ct *rb_global_ct(void){ return rb_contact_buffer + rb_contact_count; } -VG_STATIC void rb_prepare_contact( rb_ct *ct, float timestep ){ +static void rb_prepare_contact( rb_ct *ct, float timestep ){ ct->bias = -0.2f * (timestep*3600.0f) * vg_minf( 0.0f, -ct->p+k_penetration_slop ); @@ -1200,7 +1200,7 @@ VG_STATIC void rb_prepare_contact( rb_ct *ct, float timestep ){ } /* calculate total move. manifold should belong to ONE object only */ -VG_STATIC void rb_depenetrate( rb_ct *manifold, int len, v3f dt ){ +static void rb_depenetrate( rb_ct *manifold, int len, v3f dt ){ v3_zero( dt ); for( int j=0; j<7; j++ ) @@ -1221,7 +1221,7 @@ VG_STATIC void rb_depenetrate( rb_ct *manifold, int len, v3f dt ){ /* * Initializing things like tangent vectors */ -VG_STATIC void rb_presolve_contacts( rb_ct *buffer, int len ){ +static void rb_presolve_contacts( rb_ct *buffer, int len ){ for( int i=0; iw, ra, rva ); v3_add( rba->v, rva, rva ); @@ -1272,7 +1272,7 @@ VG_STATIC void rb_rcv( rigidbody *rba, rigidbody *rbb, v3f ra, v3f rb, v3f rv ){ v3_sub( rva, rvb, rv ); } -VG_STATIC void rb_contact_restitution( rb_ct *ct, float cr ){ +static void rb_contact_restitution( rb_ct *ct, float cr ){ v3f rv, ra, rb; v3_sub( ct->co, ct->rba->co, ra ); v3_sub( ct->co, ct->rbb->co, rb ); @@ -1288,7 +1288,7 @@ VG_STATIC void rb_contact_restitution( rb_ct *ct, float cr ){ /* * Apply impulse to object */ -VG_STATIC void rb_linear_impulse( rigidbody *rb, v3f delta, v3f impulse ){ +static void rb_linear_impulse( rigidbody *rb, v3f delta, v3f impulse ){ /* linear */ v3_muladds( rb->v, impulse, rb->inv_mass, rb->v ); @@ -1303,7 +1303,7 @@ VG_STATIC void rb_linear_impulse( rigidbody *rb, v3f delta, v3f impulse ){ /* * One iteration to solve the contact constraint */ -VG_STATIC void rb_solve_contacts( rb_ct *buf, int len ){ +static void rb_solve_contacts( rb_ct *buf, int len ){ for( int i=0; irba, *rbb = constr->rbb; @@ -1372,7 +1372,7 @@ VG_STATIC void rb_debug_position_constraints( rb_constr_pos *buffer, int len ){ } } -VG_STATIC void rb_presolve_swingtwist_constraints( rb_constr_swingtwist *buf, +static void rb_presolve_swingtwist_constraints( rb_constr_swingtwist *buf, int len ){ float size = 0.12f; @@ -1463,7 +1463,7 @@ VG_STATIC void rb_presolve_swingtwist_constraints( rb_constr_swingtwist *buf, } } -VG_STATIC void rb_debug_swingtwist_constraints( rb_constr_swingtwist *buf, +static void rb_debug_swingtwist_constraints( rb_constr_swingtwist *buf, int len ){ float size = 0.12f; @@ -1559,7 +1559,7 @@ VG_STATIC void rb_debug_swingtwist_constraints( rb_constr_swingtwist *buf, /* * Solve a list of positional constraints */ -VG_STATIC void rb_solve_position_constraints( rb_constr_pos *buf, int len ){ +static void rb_solve_position_constraints( rb_constr_pos *buf, int len ){ for( int i=0; irba, *rbb = constr->rbb; @@ -1623,7 +1623,7 @@ VG_STATIC void rb_solve_position_constraints( rb_constr_pos *buf, int len ){ } } -VG_STATIC void rb_solve_swingtwist_constraints( rb_constr_swingtwist *buf, +static void rb_solve_swingtwist_constraints( rb_constr_swingtwist *buf, int len ){ float size = 0.12f; @@ -1678,7 +1678,7 @@ VG_STATIC void rb_solve_swingtwist_constraints( rb_constr_swingtwist *buf, } } -VG_STATIC void rb_solve_constr_angle( rigidbody *rba, rigidbody *rbb, +static void rb_solve_constr_angle( rigidbody *rba, rigidbody *rbb, v3f ra, v3f rb ){ m3x3f ssra, ssrb, ssrat, ssrbt; m3x3f cma, cmb; @@ -1720,7 +1720,7 @@ VG_STATIC void rb_solve_constr_angle( rigidbody *rba, rigidbody *rbb, * Correct position constraint drift errors * [ 0.0 <= amt <= 1.0 ]: the correction amount */ -VG_STATIC void rb_correct_position_constraints( rb_constr_pos *buf, int len, +static void rb_correct_position_constraints( rb_constr_pos *buf, int len, float amt ){ for( int i=0; irba, @@ -1803,7 +1803,7 @@ VG_STATIC void rb_correct_contact_constraints( rb_ct *buf, int len, float amt ){ * Effectors */ -VG_STATIC void rb_effect_simple_bouyency( rigidbody *ra, v4f plane, +static void rb_effect_simple_bouyency( rigidbody *ra, v4f plane, float amt, float drag ){ /* float */ float depth = v3_dot( plane, ra->co ) - plane[3], @@ -1818,7 +1818,7 @@ VG_STATIC void rb_effect_simple_bouyency( rigidbody *ra, v4f plane, /* apply a spring&dampener force to match ra(worldspace) on rigidbody, to * rt(worldspace) */ -VG_STATIC void rb_effect_spring_target_vector( rigidbody *rba, v3f ra, v3f rt, +static void rb_effect_spring_target_vector( rigidbody *rba, v3f ra, v3f rt, float spring, float dampening, float timestep ){ float d = v3_dot( rt, ra ); diff --git a/scene.h b/scene.h index b54587a..f448bbc 100644 --- a/scene.h +++ b/scene.h @@ -41,7 +41,7 @@ struct scene_context mdl_submesh submesh; }; -VG_STATIC u32 scene_mem_required( scene_context *ctx ) +static u32 scene_mem_required( scene_context *ctx ) { u32 vertex_length = vg_align8(ctx->max_vertices * sizeof(scene_vert)), index_length = vg_align8(ctx->max_indices * sizeof(u32)); @@ -49,7 +49,7 @@ VG_STATIC u32 scene_mem_required( scene_context *ctx ) return vertex_length + index_length; } -VG_STATIC +static void scene_init( scene_context *ctx, u32 max_vertices, u32 max_indices ) { ctx->vertex_count = 0; @@ -73,7 +73,7 @@ void scene_supply_buffer( scene_context *ctx, void *buffer ) ctx->arrindices = (u32*)(((u8*)buffer) + vertex_length); } -VG_STATIC void scene_vert_pack_norm( scene_vert *vert, v3f norm ) +static void scene_vert_pack_norm( scene_vert *vert, v3f norm ) { v3f n; v3_muls( norm, 127.0f, n ); @@ -88,7 +88,7 @@ VG_STATIC void scene_vert_pack_norm( scene_vert *vert, v3f norm ) /* * Append a model into the scene with a given transform */ -VG_STATIC void scene_add_mdl_submesh( scene_context *ctx, mdl_context *mdl, +static void scene_add_mdl_submesh( scene_context *ctx, mdl_context *mdl, mdl_submesh *sm, m4x3f transform ) { if( ctx->vertex_count + sm->vertex_count > ctx->max_vertices ){ @@ -166,7 +166,7 @@ VG_STATIC void scene_add_mdl_submesh( scene_context *ctx, mdl_context *mdl, /* * One by one adders for simplified access (mostly procedural stuff) */ -VG_STATIC void scene_push_tri( scene_context *ctx, u32 tri[3] ) +static void scene_push_tri( scene_context *ctx, u32 tri[3] ) { if( ctx->indice_count + 3 > ctx->max_indices ) vg_fatal_error( "Scene indice buffer overflow (%u exceeds %u)\n", @@ -181,7 +181,7 @@ VG_STATIC void scene_push_tri( scene_context *ctx, u32 tri[3] ) ctx->indice_count += 3; } -VG_STATIC void scene_push_vert( scene_context *ctx, scene_vert *v ) +static void scene_push_vert( scene_context *ctx, scene_vert *v ) { if( ctx->vertex_count + 1 > ctx->max_vertices ) vg_fatal_error( "Scene vertex buffer overflow (%u exceeds %u)\n", @@ -193,7 +193,7 @@ VG_STATIC void scene_push_vert( scene_context *ctx, scene_vert *v ) ctx->vertex_count ++; } -VG_STATIC void scene_copy_slice( scene_context *ctx, mdl_submesh *sm ) +static void scene_copy_slice( scene_context *ctx, mdl_submesh *sm ) { sm->indice_start = ctx->submesh.indice_start; sm->indice_count = ctx->indice_count - sm->indice_start; @@ -205,7 +205,7 @@ VG_STATIC void scene_copy_slice( scene_context *ctx, mdl_submesh *sm ) ctx->submesh.vertex_start = ctx->vertex_count; } -VG_STATIC void scene_set_vertex_flags( scene_context *ctx, +static void scene_set_vertex_flags( scene_context *ctx, u32 start, u32 count, u16 flags ){ for( u32 i=0; iarrvertices[ start + i ].flags = flags; @@ -216,7 +216,7 @@ struct scene_upload_info{ glmesh *mesh; }; -VG_STATIC void async_scene_upload( void *payload, u32 size ) +static void async_scene_upload( void *payload, u32 size ) { struct scene_upload_info *info = payload; @@ -265,7 +265,7 @@ VG_STATIC void async_scene_upload( void *payload, u32 size ) vg_info( " verts:%u\n", ctx->vertex_count ); } -VG_STATIC void scene_upload_async( scene_context *ctx, glmesh *mesh ) +static void scene_upload_async( scene_context *ctx, glmesh *mesh ) { vg_async_item *call = vg_async_alloc( sizeof(struct scene_upload_info) ); @@ -276,7 +276,7 @@ VG_STATIC void scene_upload_async( scene_context *ctx, glmesh *mesh ) vg_async_dispatch( call, async_scene_upload ); } -VG_STATIC +static vg_async_item *scene_alloc_async( scene_context *scene, glmesh *mesh, u32 max_vertices, u32 max_indices ) { @@ -302,7 +302,7 @@ vg_async_item *scene_alloc_async( scene_context *scene, glmesh *mesh, * BVH implementation */ -VG_STATIC void scene_bh_expand_bound( void *user, boxf bound, u32 item_index ) +static void scene_bh_expand_bound( void *user, boxf bound, u32 item_index ) { scene_context *s = user; scene_vert *pa = &s->arrvertices[ s->arrindices[item_index*3+0] ], @@ -314,7 +314,7 @@ VG_STATIC void scene_bh_expand_bound( void *user, boxf bound, u32 item_index ) box_addpt( bound, pc->co ); } -VG_STATIC float scene_bh_centroid( void *user, u32 item_index, int axis ) +static float scene_bh_centroid( void *user, u32 item_index, int axis ) { scene_context *s = user; scene_vert *pa = &s->arrvertices[ s->arrindices[item_index*3+0] ], @@ -337,7 +337,7 @@ VG_STATIC float scene_bh_centroid( void *user, u32 item_index, int axis ) #endif } -VG_STATIC void scene_bh_swap( void *user, u32 ia, u32 ib ) +static void scene_bh_swap( void *user, u32 ia, u32 ib ) { scene_context *s = user; @@ -358,7 +358,7 @@ VG_STATIC void scene_bh_swap( void *user, u32 ia, u32 ib ) tj[2] = temp[2]; } -VG_STATIC void scene_bh_debug( void *user, u32 item_index ) +static void scene_bh_debug( void *user, u32 item_index ) { scene_context *s = user; u32 idx = item_index*3; @@ -371,7 +371,7 @@ VG_STATIC void scene_bh_debug( void *user, u32 item_index ) vg_line( pc->co, pa->co, 0xff0000ff ); } -VG_STATIC void scene_bh_closest( void *user, u32 index, v3f point, v3f closest ) +static void scene_bh_closest( void *user, u32 index, v3f point, v3f closest ) { scene_context *s = user; @@ -383,7 +383,7 @@ VG_STATIC void scene_bh_closest( void *user, u32 index, v3f point, v3f closest ) closest_on_triangle_1( point, positions, closest ); } -VG_STATIC bh_system bh_system_scene = +static bh_system bh_system_scene = { .expand_bound = scene_bh_expand_bound, .item_centroid = scene_bh_centroid, @@ -395,7 +395,7 @@ VG_STATIC bh_system bh_system_scene = /* * An extra step is added onto the end to calculate the hit normal */ -VG_STATIC int scene_raycast( scene_context *s, bh_tree *bh, +static int scene_raycast( scene_context *s, bh_tree *bh, v3f co, v3f dir, ray_hit *hit, u16 ignore ) { hit->tri = NULL; @@ -439,7 +439,7 @@ VG_STATIC int scene_raycast( scene_context *s, bh_tree *bh, return hit->tri?1:0; } -VG_STATIC bh_tree *scene_bh_create( void *lin_alloc, scene_context *s ) +static bh_tree *scene_bh_create( void *lin_alloc, scene_context *s ) { u32 triangle_count = s->indice_count / 3; return bh_create( lin_alloc, &bh_system_scene, s, triangle_count, 2 ); diff --git a/servermonitor_client.c b/servermonitor_client.c index 5c16db1..f2498ca 100644 --- a/servermonitor_client.c +++ b/servermonitor_client.c @@ -34,7 +34,7 @@ int main( int argc, char *argv[] ){ return 0; } -VG_STATIC void vg_launch_opt(void){} +static void vg_launch_opt(void){} static int sockfd = -1; @@ -63,9 +63,9 @@ static void connect_to_monitor_server(void){ vg_success( "Connected\n" ); } -VG_STATIC void vg_preload(void){} +static void vg_preload(void){} -VG_STATIC void vg_load(void){ +static void vg_load(void){ vg_bake_shaders(); vg_console_load_autos(); } @@ -74,7 +74,7 @@ VG_STATIC void vg_load(void){ * UPDATE LOOP * ---------------------------------------------------------------------------*/ -VG_STATIC void vg_pre_update(void){ +static void vg_pre_update(void){ if( sockfd == -1 ) return; char recvBuff[1024]; @@ -86,20 +86,20 @@ VG_STATIC void vg_pre_update(void){ } } -VG_STATIC void vg_fixed_update(void){ +static void vg_fixed_update(void){ } -VG_STATIC void vg_post_update(void){ +static void vg_post_update(void){ } /* * RENDERING * ---------------------------------------------------------------------------*/ -VG_STATIC void vg_framebuffer_resize( int w, int h ){ +static void vg_framebuffer_resize( int w, int h ){ } -VG_STATIC void vg_render(void){ +static void vg_render(void){ glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glViewport( 0,0, vg.window_x, vg.window_y ); glDisable( GL_DEPTH_TEST ); @@ -111,7 +111,7 @@ VG_STATIC void vg_render(void){ vg_lines_drawall(); } -VG_STATIC void vg_gui(void){ +static void vg_gui(void){ vg_ui.wants_mouse = 1; static i32 page = 0; ui_rect panel = { 0, 0, vg.window_x, vg.window_y }; diff --git a/skaterift.c b/skaterift.c index 2e6fca6..14c6410 100644 --- a/skaterift.c +++ b/skaterift.c @@ -63,13 +63,13 @@ int main( int argc, char *argv[] ){ return 0; } -VG_STATIC void vg_launch_opt(void){ +static void vg_launch_opt(void){ if( vg_long_opt( "noauth" ) ){ network_client.auth_mode = eServerModeNoAuthentication; } } -VG_STATIC void vg_preload(void){ +static void vg_preload(void){ //skaterift_read_savedata(); vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" ); @@ -85,14 +85,14 @@ vg_info(" ' ' '--' [] '----- '----- ' ' '---' " vg_loader_step( network_init, network_end ); } -VG_STATIC void load_playermodels(void){ +static void load_playermodels(void){ /* FIXME: hack */ shader_model_character_view_register(); shader_model_board_view_register(); shader_model_entity_register(); } -VG_STATIC void async_skaterift_player_start( void *payload, u32 size ){ +static void async_skaterift_player_start( void *payload, u32 size ){ localplayer.viewable_world = world_current_instance(); localplayer_cmd_respawn( 1, (const char *[]){ "start" } ); } @@ -165,11 +165,11 @@ static void skaterift_restore_state(void){ vg_msg_convert_num( &position, k_vg_msg_float|k_vg_msg_32b, 3, pos ); if( v3_length2(pos) > 1.0f ) - player__setpos( &localplayer, pos ); + player__setpos( pos ); } } -VG_STATIC void vg_load(void){ +static void vg_load(void){ vg_console_reg_cmd( "changeworld", skaterift_change_world_command, NULL ); vg_loader_step( render_init, NULL ); @@ -197,11 +197,10 @@ VG_STATIC void vg_load(void){ skaterift.replay.size = bytes; replay_clear( &skaterift.replay ); - player__create( &localplayer ); player_avatar_load( &localplayer_avatar, "models/ch_none.mdl" ); - player__use_avatar( &localplayer, &localplayer_avatar ); + player__use_avatar( &localplayer_avatar ); player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" ); - player__bind( &localplayer ); + player__bind(); /* --------------------- */ @@ -279,7 +278,7 @@ VG_STATIC void vg_load(void){ vg_async_call( async_call_ready, NULL, 0 ); } -VG_STATIC void draw_origin_axis(void){ +static void draw_origin_axis(void){ vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 ); vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 ); vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff ); @@ -290,7 +289,7 @@ static void skaterift_change_client_world_preupdate(void); * UPDATE LOOP * ---------------------------------------------------------------------------*/ -VG_STATIC void vg_pre_update(void){ +static void vg_pre_update(void){ srinput.enabled = 1; steam_update(); @@ -312,7 +311,7 @@ VG_STATIC void vg_pre_update(void){ vg_slewf( &skaterift.time_rate, target, vg.time_frame_delta * (1.0f/0.3f) ); vg.time_rate = vg_smoothstepf( skaterift.time_rate ); - player__pre_update( &localplayer ); + player__pre_update(); world_entity_focus_preupdate(); skaterift_replay_pre_update(); @@ -321,18 +320,18 @@ VG_STATIC void vg_pre_update(void){ respawn_chooser_pre_update(); } -VG_STATIC void vg_fixed_update(void){ +static void vg_fixed_update(void){ if( skaterift.op == k_async_op_clientloading ) return; world_routes_fixedupdate( world_current_instance() ); - player__update( &localplayer ); + player__update(); vehicle_update_fixed(); } -VG_STATIC void vg_post_update(void){ +static void vg_post_update(void){ if( skaterift.op == k_async_op_clientloading ) return; - player__post_update( &localplayer ); + player__post_update(); float dist; int sample_index; @@ -368,11 +367,11 @@ VG_STATIC void vg_post_update(void){ * RENDERING * ---------------------------------------------------------------------------*/ -VG_STATIC void vg_framebuffer_resize( int w, int h ){ +static void vg_framebuffer_resize( int w, int h ){ render_fb_resize(); } -VG_STATIC void present_view_with_post_processing(void){ +static void present_view_with_post_processing(void){ glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glViewport( 0,0, vg.window_x, vg.window_y ); @@ -430,7 +429,7 @@ VG_STATIC void present_view_with_post_processing(void){ render_fsquad(); } -VG_STATIC void render_player_transparent(void){ +static void render_player_transparent(void){ static camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW SAIS OTHERWISE */ @@ -445,10 +444,10 @@ VG_STATIC void render_player_transparent(void){ camera_finalize( &small_cam ); /* Draw player to window buffer and blend background ontop */ - player__render( &small_cam, &localplayer ); + player__render( &small_cam ); } -VG_STATIC void render_scene(void){ +static void render_scene(void){ /* Draw world */ glEnable( GL_DEPTH_TEST ); @@ -483,7 +482,7 @@ VG_STATIC void render_scene(void){ } } -VG_STATIC void render_scene_gate_subview(void){ +static void render_scene_gate_subview(void){ render_fb_bind( gpipeline.fb_main, 1 ); world_instance *view_world = localplayer.viewable_world; if( !view_world ) return; /* ??? */ @@ -494,7 +493,7 @@ VG_STATIC void render_scene_gate_subview(void){ render_world_gates( view_world, &skaterift.cam, depth ); } -VG_STATIC void skaterift_composite_maincamera(void){ +static void skaterift_composite_maincamera(void){ camera_lerp( &localplayer.cam, &world_static.focus_cam, vg_smoothstepf(world_static.focus_strength), &skaterift.cam ); @@ -529,15 +528,15 @@ VG_STATIC void skaterift_composite_maincamera(void){ camera_finalize( &skaterift.cam ); } -VG_STATIC void render_main_game(void){ +static void render_main_game(void){ if( skaterift.activity == k_skaterift_replay ){ - player__animate_from_replay( &localplayer, &skaterift.replay ); + player__animate_from_replay( &skaterift.replay ); } else{ - player__animate( &localplayer ); + player__animate(); skaterift_record_frame( &skaterift.replay, 0 ); } - player__pre_render( &localplayer ); + player__pre_render(); skaterift_composite_maincamera(); @@ -594,7 +593,7 @@ VG_STATIC void render_main_game(void){ } } -VG_STATIC void vg_render(void){ +static void vg_render(void){ if( skaterift.op == k_async_op_clientloading ){ _vg_loader_render(); return; @@ -620,7 +619,7 @@ VG_STATIC void vg_render(void){ gui_draw(); } -VG_STATIC void vg_gui(void){ +static void vg_gui(void){ if( skaterift.op == k_async_op_clientloading ) return; menu_update(); @@ -629,7 +628,7 @@ VG_STATIC void vg_gui(void){ menu_render(); } - player__im_gui( &localplayer ); + player__im_gui(); world_instance *world = world_current_instance(); skaterift_replay_imgui(); diff --git a/skaterift_imgui_dev.c b/skaterift_imgui_dev.c index 9618a04..187bdf4 100644 --- a/skaterift_imgui_dev.c +++ b/skaterift_imgui_dev.c @@ -34,10 +34,10 @@ int main( int argc, char *argv[] ){ return 0; } -VG_STATIC void vg_launch_opt(void){ +static void vg_launch_opt(void){ } -VG_STATIC void vg_preload(void){ +static void vg_preload(void){ vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" ); vg_info(" 2021-2023 |\\ /| | / | | | | /| \n" ); vg_info(" | \\ / | +-- / +----- +---' | / | \n" ); @@ -47,29 +47,29 @@ vg_info(" ' ' '--' [] '----- '----- ' ' '---' " "SOFTWARE\n" ); } -VG_STATIC void skaterift_load_post( void *data, u32 len ){ +static void skaterift_load_post( void *data, u32 len ){ skaterift_loaded = 1; } -VG_STATIC void vg_load(void){ +static void vg_load(void){ vg_bake_shaders(); vg_async_call( skaterift_load_post, NULL, 0 ); } -VG_STATIC void vg_pre_update(void){ +static void vg_pre_update(void){ } -VG_STATIC void vg_fixed_update(void){ +static void vg_fixed_update(void){ } -VG_STATIC void vg_post_update(void){ +static void vg_post_update(void){ } -VG_STATIC void vg_framebuffer_resize( int w, int h ){ +static void vg_framebuffer_resize( int w, int h ){ //render_fb_resize(); } -VG_STATIC void vg_render(void){ +static void vg_render(void){ glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glViewport( 0,0, vg.window_x, vg.window_y ); @@ -92,7 +92,7 @@ static struct ui_enum_opt dropdown_options[] = { static i32 dropdown_value = 8; static i32 checkbox_value = 0; -VG_STATIC void vg_gui(void){ +static void vg_gui(void){ if( !skaterift_loaded ) return; static ui_rect window; diff --git a/skeleton.h b/skeleton.h index 2be9a9a..6791d1c 100644 --- a/skeleton.h +++ b/skeleton.h @@ -53,7 +53,7 @@ struct skeleton bindable_count; }; -VG_STATIC u32 skeleton_bone_id( struct skeleton *skele, const char *name ) +static u32 skeleton_bone_id( struct skeleton *skele, const char *name ) { for( u32 i=1; ibone_count; i++ ){ if( !strcmp( skele->bones[i].name, name )) @@ -66,7 +66,7 @@ VG_STATIC u32 skeleton_bone_id( struct skeleton *skele, const char *name ) return 0; } -VG_STATIC void keyframe_copy_pose( mdl_keyframe *kfa, mdl_keyframe *kfb, +static void keyframe_copy_pose( mdl_keyframe *kfa, mdl_keyframe *kfb, int num ) { for( int i=0; ibone_count-1 ); } -VG_STATIC void skeleton_copy_pose( struct skeleton *skele, +static void skeleton_copy_pose( struct skeleton *skele, mdl_keyframe *kfa, mdl_keyframe *kfd ) { keyframe_copy_pose( kfa, kfd, skele->bone_count-1 ); @@ -129,7 +129,7 @@ VG_STATIC void skeleton_copy_pose( struct skeleton *skele, * Sample animation between 2 closest frames using time value. Output is a * keyframe buffer that is allocated with an appropriate size */ -VG_STATIC void skeleton_sample_anim( struct skeleton *skele, +static void skeleton_sample_anim( struct skeleton *skele, struct skeleton_anim *anim, float time, mdl_keyframe *output ) @@ -147,7 +147,7 @@ VG_STATIC void skeleton_sample_anim( struct skeleton *skele, skeleton_lerp_pose( skele, base, nbase, t, output ); } -VG_STATIC int skeleton_sample_anim_clamped( struct skeleton *skele, +static int skeleton_sample_anim_clamped( struct skeleton *skele, struct skeleton_anim *anim, float time, mdl_keyframe *output ) @@ -170,7 +170,7 @@ typedef enum anim_apply } anim_apply; -VG_STATIC +static int should_apply_bone( struct skeleton *skele, u32 id, anim_apply type ) { struct skeleton_bone *sb = &skele->bones[ id ], @@ -201,7 +201,7 @@ int should_apply_bone( struct skeleton *skele, u32 id, anim_apply type ) /* * Apply block of keyframes to skeletons final pose */ -VG_STATIC void skeleton_apply_pose( struct skeleton *skele, mdl_keyframe *pose, +static void skeleton_apply_pose( struct skeleton *skele, mdl_keyframe *pose, anim_apply passtype ) { if( passtype == k_anim_apply_absolute ){ @@ -249,7 +249,7 @@ VG_STATIC void skeleton_apply_pose( struct skeleton *skele, mdl_keyframe *pose, /* * Take the final matrices and decompose it into an absolute positioned anim */ -VG_STATIC void skeleton_decompose_mtx_absolute( struct skeleton *skele, +static void skeleton_decompose_mtx_absolute( struct skeleton *skele, mdl_keyframe *anim ){ for( u32 i=1; ibone_count; i++ ){ struct skeleton_bone *sb = &skele->bones[i]; @@ -262,7 +262,7 @@ VG_STATIC void skeleton_decompose_mtx_absolute( struct skeleton *skele, * creates the reference inverse matrix for an IK bone, as it has an initial * intrisic rotation based on the direction that the IK is setup.. */ -VG_STATIC void skeleton_inverse_for_ik( struct skeleton *skele, +static void skeleton_inverse_for_ik( struct skeleton *skele, v3f ivaxis, u32 id, m3x3f inverse ) { @@ -276,7 +276,7 @@ VG_STATIC void skeleton_inverse_for_ik( struct skeleton *skele, /* * Creates inverse rotation matrices which the IK system uses. */ -VG_STATIC void skeleton_create_inverses( struct skeleton *skele ) +static void skeleton_create_inverses( struct skeleton *skele ) { /* IK: inverse 'plane-bone space' axis '(^axis,^bone,...)[base] */ for( u32 i=0; iik_count; i++ ){ @@ -297,7 +297,7 @@ VG_STATIC void skeleton_create_inverses( struct skeleton *skele ) /* * Apply a model matrix to all bones, should be done last */ -VG_STATIC +static void skeleton_apply_transform( struct skeleton *skele, m4x3f transform ) { for( u32 i=0; ibone_count; i++ ){ @@ -310,7 +310,7 @@ void skeleton_apply_transform( struct skeleton *skele, m4x3f transform ) * Apply an inverse matrix to all bones which maps vertices from bind space into * bone relative positions */ -VG_STATIC void skeleton_apply_inverses( struct skeleton *skele ) +static void skeleton_apply_inverses( struct skeleton *skele ) { for( u32 i=0; ibone_count; i++ ){ struct skeleton_bone *sb = &skele->bones[i]; @@ -325,7 +325,7 @@ VG_STATIC void skeleton_apply_inverses( struct skeleton *skele ) /* * Apply all IK modifiers (2 bone ik reference from blender is supported) */ -VG_STATIC void skeleton_apply_ik_pass( struct skeleton *skele ) +static void skeleton_apply_ik_pass( struct skeleton *skele ) { for( u32 i=0; iik_count; i++ ){ struct skeleton_ik *ik = &skele->ik[i]; @@ -404,7 +404,7 @@ VG_STATIC void skeleton_apply_ik_pass( struct skeleton *skele ) * Applies the typical operations that you want for an IK rig: * Pose, IK, Pose(deferred), Inverses, Transform */ -VG_STATIC void skeleton_apply_standard( struct skeleton *skele, mdl_keyframe *pose, +static void skeleton_apply_standard( struct skeleton *skele, mdl_keyframe *pose, m4x3f transform ) { skeleton_apply_pose( skele, pose, k_anim_apply_defer_ik ); @@ -417,7 +417,7 @@ VG_STATIC void skeleton_apply_standard( struct skeleton *skele, mdl_keyframe *po /* * Get an animation by name */ -VG_STATIC struct skeleton_anim *skeleton_get_anim( struct skeleton *skele, +static struct skeleton_anim *skeleton_get_anim( struct skeleton *skele, const char *name ) { for( u32 i=0; ianim_count; i++ ){ @@ -433,7 +433,7 @@ VG_STATIC struct skeleton_anim *skeleton_get_anim( struct skeleton *skele, return NULL; } -VG_STATIC void skeleton_alloc_from( struct skeleton *skele, +static void skeleton_alloc_from( struct skeleton *skele, void *lin_alloc, mdl_context *mdl, mdl_armature *armature ) @@ -469,13 +469,13 @@ VG_STATIC void skeleton_alloc_from( struct skeleton *skele, memset( skele->anims, 0, anim_size ); } -VG_STATIC void skeleton_fatal_err(void) +static void skeleton_fatal_err(void) { vg_fatal_error( "Skeleton setup failed" ); } /* Setup an animated skeleton from model. mdl's metadata should stick around */ -VG_STATIC void skeleton_setup( struct skeleton *skele, +static void skeleton_setup( struct skeleton *skele, void *lin_alloc, mdl_context *mdl ) { u32 ik_count = 0, collider_count = 0; @@ -560,7 +560,7 @@ VG_STATIC void skeleton_setup( struct skeleton *skele, vg_success( " %u colliders\n", skele->collider_count ); } -VG_STATIC void skeleton_debug( struct skeleton *skele ) +static void skeleton_debug( struct skeleton *skele ) { for( u32 i=1; ibone_count; i ++ ){ struct skeleton_bone *sb = &skele->bones[i]; diff --git a/steam.h b/steam.h index 251c51e..730784e 100644 --- a/steam.h +++ b/steam.h @@ -27,9 +27,9 @@ * nothing. */ -VG_STATIC char steam_username_at_startup[128]; +static char steam_username_at_startup[128]; -VG_STATIC void recv_steam_warning( int severity, const char *msg ) +static void recv_steam_warning( int severity, const char *msg ) { if( severity == 0 ) vg_low( "%s\n", msg ); @@ -37,30 +37,30 @@ VG_STATIC void recv_steam_warning( int severity, const char *msg ) vg_info( "%s\n", msg ); } -VG_STATIC int steam_ready = 0, +static int steam_ready = 0, steam_stats_ready = 0; -VG_STATIC void *hSteamNetworkingSockets, +static void *hSteamNetworkingSockets, *hSteamUser; -VG_STATIC ISteamUserStats *hSteamUserStats; -VG_STATIC HSteamPipe hSteamClientPipe; +static ISteamUserStats *hSteamUserStats; +static HSteamPipe hSteamClientPipe; -VG_STATIC const char *steam_achievement_names[] = +static const char *steam_achievement_names[] = { "ALBERT", "MARC", "ROUTE_MPY", "ROUTE_MPG", "ROUTE_MPB", "ROUTE_MPR", "ROUTE_TO", "ROUTE_TC" }; -VG_STATIC void steam_store_achievements(void) +static void steam_store_achievements(void) { if( steam_ready && steam_stats_ready ){ SteamAPI_ISteamUserStats_StoreStats( hSteamUserStats ); } } -VG_STATIC void steam_set_achievement( const char *name ) +static void steam_set_achievement( const char *name ) { if( steam_ready && steam_stats_ready ){ if( SteamAPI_ISteamUserStats_SetAchievement( hSteamUserStats, name ) ){ @@ -75,7 +75,7 @@ VG_STATIC void steam_set_achievement( const char *name ) } } -VG_STATIC void steam_clear_achievement( const char *name ) +static void steam_clear_achievement( const char *name ) { if( steam_ready && steam_stats_ready ){ if( SteamAPI_ISteamUserStats_ClearAchievement( hSteamUserStats, name ) ){ @@ -91,7 +91,7 @@ VG_STATIC void steam_clear_achievement( const char *name ) } -VG_STATIC void steam_print_all_achievements(void){ +static void steam_print_all_achievements(void){ vg_info( "Achievements: \n" ); if( steam_ready && steam_stats_ready ){ @@ -114,7 +114,7 @@ VG_STATIC void steam_print_all_achievements(void){ } } -VG_STATIC int steam_achievement_ccmd( int argc, char const *argv[] ) +static int steam_achievement_ccmd( int argc, char const *argv[] ) { if( !(steam_ready && steam_stats_ready) ) return 1; @@ -147,7 +147,7 @@ VG_STATIC int steam_achievement_ccmd( int argc, char const *argv[] ) return 1; } -VG_STATIC void steam_on_recieve_current_stats( CallbackMsg_t *msg ) +static void steam_on_recieve_current_stats( CallbackMsg_t *msg ) { UserStatsReceived_t *rec = (UserStatsReceived_t *)msg->m_pubParam; @@ -161,7 +161,7 @@ VG_STATIC void steam_on_recieve_current_stats( CallbackMsg_t *msg ) } } -VG_STATIC u32 utf8_byte0_byte_count( u8 char0 ) +static u32 utf8_byte0_byte_count( u8 char0 ) { for( u32 k=2; k<4; k++ ){ if( !(char0 & (0x80 >> k)) ) @@ -171,7 +171,7 @@ VG_STATIC u32 utf8_byte0_byte_count( u8 char0 ) return 0; } -VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length ) +static void str_utf8_collapse( const char *str, char *buf, u32 length ) { u8 *ustr = (u8 *)str; u32 utf32_code = 0x00000000; @@ -212,7 +212,7 @@ VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length ) buf[j] = 0x00; } -VG_STATIC int steam_init(void){ +static int steam_init(void){ const char *username = "offline player"; #ifdef SR_NETWORKED @@ -265,14 +265,14 @@ VG_STATIC int steam_init(void){ return 1; } -VG_STATIC void steam_update(void) +static void steam_update(void) { if( steam_ready ){ steamworks_event_loop( hSteamClientPipe ); } } -VG_STATIC void steam_end(void) +static void steam_end(void) { if( steam_ready ){ vg_info( "Shutting down\n..." ); diff --git a/vehicle.c b/vehicle.c index d9c6d30..3d68d11 100644 --- a/vehicle.c +++ b/vehicle.c @@ -3,7 +3,7 @@ #include "vehicle.h" -VG_STATIC int spawn_car( int argc, const char *argv[] ){ +static int spawn_car( int argc, const char *argv[] ){ v3f ra, rb, rx; v3_copy( skaterift.cam.pos, ra ); v3_muladds( ra, skaterift.cam.transform[2], -10.0f, rb ); @@ -30,7 +30,7 @@ VG_STATIC int spawn_car( int argc, const char *argv[] ){ return 0; } -VG_STATIC void vehicle_init(void) +static void vehicle_init(void) { q_identity( gzoomer.obj.rb.q ); v3_zero( gzoomer.obj.rb.w ); @@ -58,7 +58,7 @@ VG_STATIC void vehicle_init(void) v3_copy((v3f){ 1.0f, -0.25f, 1.5f }, gzoomer.wheels_local[3] ); } -VG_STATIC void vehicle_wheel_force( int index ) +static void vehicle_wheel_force( int index ) { v3f pa, pb, n; m4x3_mulv( gzoomer.obj.rb.to_world, gzoomer.wheels_local[index], pa ); @@ -165,7 +165,7 @@ VG_STATIC void vehicle_wheel_force( int index ) } } -VG_STATIC void vehicle_solve_friction(void) +static void vehicle_solve_friction(void) { rigidbody *rb = &gzoomer.obj.rb; for( int i=0; i<4; i++ ){ @@ -198,7 +198,7 @@ VG_STATIC void vehicle_solve_friction(void) } } -VG_STATIC void vehicle_update_fixed(void) +static void vehicle_update_fixed(void) { if( !gzoomer.alive ) return; @@ -249,7 +249,7 @@ VG_STATIC void vehicle_update_fixed(void) rb_update_transform( rb ); } -VG_STATIC void vehicle_update_post(void) +static void vehicle_update_post(void) { if( !gzoomer.alive ) return; diff --git a/vehicle.h b/vehicle.h index b1f5a28..74408e4 100644 --- a/vehicle.h +++ b/vehicle.h @@ -7,7 +7,7 @@ #include "world.h" #include "world_physics.h" -VG_STATIC float k_car_spring = 1.0f, +static float k_car_spring = 1.0f, k_car_spring_damp = 0.001f, k_car_spring_length = 0.5f, k_car_wheel_radius = 0.2f, @@ -40,11 +40,11 @@ static gzoomer = .obj = { .type = k_rb_shape_sphere, .inf.sphere.radius = 1.0f } }; -VG_STATIC int spawn_car( int argc, const char *argv[] ); -VG_STATIC void vehicle_init(void); -VG_STATIC void vehicle_wheel_force( int index ); -VG_STATIC void vehicle_solve_friction(void); -VG_STATIC void vehicle_update_fixed(void); -VG_STATIC void vehicle_update_post(void); +static int spawn_car( int argc, const char *argv[] ); +static void vehicle_init(void); +static void vehicle_wheel_force( int index ); +static void vehicle_solve_friction(void); +static void vehicle_update_fixed(void); +static void vehicle_update_post(void); #endif /* VEHICLE_H */ diff --git a/workshop.c b/workshop.c index 1414fc6..ffe776c 100644 --- a/workshop.c +++ b/workshop.c @@ -32,7 +32,7 @@ static struct ui_enum_opt workshop_form_type_opts[] = { /* * Close the form and discard UGC query result */ -VG_STATIC void workshop_quit_form(void){ +static void workshop_quit_form(void){ player_board_unload( &workshop_form.board_model ); workshop_form.file_intent = k_workshop_form_file_intent_none; @@ -51,7 +51,7 @@ VG_STATIC void workshop_quit_form(void){ /* * Delete all information about the submission */ -VG_STATIC void workshop_reset_submission_data(void) +static void workshop_reset_submission_data(void) { workshop_form.submission.file_id = 0; /* assuming id of 0 is none/invalid */ workshop_form.submission.description[0] = '\0'; @@ -73,7 +73,7 @@ VG_STATIC void workshop_reset_submission_data(void) /* * Mostly copies of what it sais on the Steam API documentation */ -VG_STATIC const char *workshop_EResult_user_string( EResult result ) +static const char *workshop_EResult_user_string( EResult result ) { switch( result ){ case k_EResultInsufficientPrivilege: @@ -125,7 +125,7 @@ VG_STATIC const char *workshop_EResult_user_string( EResult result ) /* * The endpoint of this operation */ -VG_STATIC void on_workshop_update_result( void *data, void *user ) +static void on_workshop_update_result( void *data, void *user ) { vg_info( "Recieved workshop update result\n" ); SubmitItemUpdateResult_t *result = data; @@ -150,7 +150,7 @@ VG_STATIC void on_workshop_update_result( void *data, void *user ) workshop_form.op = k_workshop_op_none; } -VG_STATIC const char *workshop_filetype_folder(void){ +static const char *workshop_filetype_folder(void){ enum addon_type type = workshop_form.submission.type; if ( type == k_addon_type_board ) return "boards/"; else if( type == k_addon_type_player ) return "playermodels/"; @@ -163,7 +163,7 @@ VG_STATIC const char *workshop_filetype_folder(void){ * reciever on completion of packaging the files, it will then start the item * update with Steam API */ -VG_STATIC void workshop_form_upload_submission( PublishedFileId_t file_id, +static void workshop_form_upload_submission( PublishedFileId_t file_id, char *metadata ) { ISteamUGC *hSteamUGC = SteamAPI_SteamUGC(); @@ -221,7 +221,7 @@ VG_STATIC void workshop_form_upload_submission( PublishedFileId_t file_id, * Steam API call result for when we've created a new item on their network, or * not, if it has failed */ -VG_STATIC void on_workshop_createitem( void *data, void *user ) +static void on_workshop_createitem( void *data, void *user ) { CreateItemResult_t *result = data; @@ -251,7 +251,7 @@ VG_STATIC void on_workshop_createitem( void *data, void *user ) /* * Starts the workshop upload process through Steam API */ -VG_STATIC void workshop_form_async_submit_begin( void *payload, u32 size ) +static void workshop_form_async_submit_begin( void *payload, u32 size ) { /* use existing file */ @@ -272,7 +272,7 @@ VG_STATIC void workshop_form_async_submit_begin( void *payload, u32 size ) /* * Downloads the framebuffer into scratch memory */ -VG_STATIC void workshop_form_async_download_image( void *payload, u32 size ) +static void workshop_form_async_download_image( void *payload, u32 size ) { int w, h; render_fb_get_current_res( gpipeline.fb_workshop_preview, &w, &h ); @@ -292,7 +292,7 @@ VG_STATIC void workshop_form_async_download_image( void *payload, u32 size ) /* * Thread which kicks off the upload process */ -VG_STATIC void _workshop_form_submit_thread( void *data ) +static void _workshop_form_submit_thread( void *data ) { vg_async_call( workshop_form_async_download_image, NULL, 0 ); vg_async_stall(); @@ -404,7 +404,7 @@ VG_STATIC void _workshop_form_submit_thread( void *data ) /* * Entry point for the publishing submission operation */ -VG_STATIC void workshop_op_submit(void){ +static void workshop_op_submit(void){ /* TODO: Show these errors to the user */ if( workshop_form.submission.submit_title ){ if( !workshop_form.submission.title[0] ){ @@ -448,7 +448,7 @@ VG_STATIC void workshop_op_submit(void){ /* * Reciever for completion of the model file load */ -VG_STATIC void workshop_form_loadmodel_async_complete( void *payload, u32 size ) +static void workshop_form_loadmodel_async_complete( void *payload, u32 size ) { v2_zero( workshop_form.view_angles ); v3_zero( workshop_form.view_offset ); @@ -463,13 +463,13 @@ VG_STATIC void workshop_form_loadmodel_async_complete( void *payload, u32 size ) /* * Reciever for failure to load */ -VG_STATIC void workshop_form_loadmodel_async_error( void *payload, u32 size ){ +static void workshop_form_loadmodel_async_error( void *payload, u32 size ){ } /* * Thread which loads the model from the disk */ -VG_STATIC void _workshop_form_load_thread( void *data ) +static void _workshop_form_load_thread( void *data ) { char path_buf[4096]; vg_str folder; @@ -533,7 +533,7 @@ VG_STATIC void _workshop_form_load_thread( void *data ) /* * Entry point for load model operation */ -VG_STATIC void workshop_op_load_model(void){ +static void workshop_op_load_model(void){ world_instance *world = world_current_instance(); workshop_form.view_world = world; @@ -569,7 +569,7 @@ VG_STATIC void workshop_op_load_model(void){ /* * The image has been decoded and is ready to slap into the framebuffer */ -VG_STATIC void workshop_form_async_imageload( void *data, u32 len ) +static void workshop_form_async_imageload( void *data, u32 len ) { if( data ){ struct framebuffer_attachment *a = @@ -594,7 +594,7 @@ VG_STATIC void workshop_form_async_imageload( void *data, u32 len ) /* * Load the image located at ./workshop_preview.jpg into our framebuffer */ -VG_STATIC void _workshop_load_preview_thread( void *data ){ +static void _workshop_load_preview_thread( void *data ){ char path_buf[ 4096 ]; vg_str path; vg_strnull( &path, path_buf, 4096 ); @@ -630,7 +630,7 @@ VG_STATIC void _workshop_load_preview_thread( void *data ){ /* * Entry point to view operation */ -VG_STATIC void workshop_op_download_and_view_submission( int result_index ) +static void workshop_op_download_and_view_submission( int result_index ) { workshop_form.op = k_workshop_op_downloading_submission; ISteamUGC *hSteamUGC = SteamAPI_SteamUGC(); @@ -724,7 +724,7 @@ VG_STATIC void workshop_op_download_and_view_submission( int result_index ) /* * View a page of results on the sidebar */ -VG_STATIC void workshop_view_page( int req ) +static void workshop_view_page( int req ) { if( workshop_form.ugc_query.result != k_EResultOK ){ vg_error( "Tried to change page without complete data\n" ); @@ -775,7 +775,7 @@ VG_STATIC void workshop_view_page( int req ) /* * Steam API result for when we recieve submitted UGC information about the user */ -VG_STATIC void on_workshop_UGCQueryComplete( void *data, void *userdata ) +static void on_workshop_UGCQueryComplete( void *data, void *userdata ) { SteamUGCQueryCompleted_t *query = data; workshop_form.ugc_query.result = query->m_eResult; @@ -813,7 +813,7 @@ VG_STATIC void on_workshop_UGCQueryComplete( void *data, void *userdata ) /* * Console command to open the workshop publisher */ -VG_STATIC int workshop_submit_command( int argc, const char *argv[] ) +static int workshop_submit_command( int argc, const char *argv[] ) { if( !steam_ready ){ ui_start_modal( "Steam API is not initialized\n", UI_MODAL_BAD ); @@ -849,12 +849,12 @@ VG_STATIC int workshop_submit_command( int argc, const char *argv[] ) return 0; } -VG_STATIC void workshop_init(void) +static void workshop_init(void) { vg_console_reg_cmd( "workshop_submit", workshop_submit_command, NULL ); } -VG_STATIC void workshop_render_world_preview(void){ +static void workshop_render_world_preview(void){ render_fb_bind( gpipeline.fb_workshop_preview, 0 ); glClearColor( 0.0f, 0.0f, 0.3f, 1.0f ); @@ -871,7 +871,7 @@ VG_STATIC void workshop_render_world_preview(void){ /* * Redraw the playermodel into the workshop framebuffer */ -VG_STATIC void workshop_render_player_preview(void){ +static void workshop_render_player_preview(void){ render_fb_bind( gpipeline.fb_workshop_preview, 0 ); glClearColor( 0.16f, 0.15f, 0.15f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT ); @@ -923,7 +923,7 @@ VG_STATIC void workshop_render_player_preview(void){ /* * Redraw the model file into the workshop framebuffer */ -VG_STATIC void workshop_render_board_preview(void){ +static void workshop_render_board_preview(void){ if( !workshop_form.ptr_ent ){ return; } @@ -1017,19 +1017,19 @@ VG_STATIC void workshop_render_board_preview(void){ * ----------------------------------------------------------------------------- */ -VG_STATIC void workshop_changed_model_path( char *buf, u32 len ){ +static void workshop_changed_model_path( char *buf, u32 len ){ workshop_form.submission.submit_file_and_image = 1; } -VG_STATIC void workshop_changed_title( char *buf, u32 len ){ +static void workshop_changed_title( char *buf, u32 len ){ workshop_form.submission.submit_title = 1; } -VG_STATIC void workshop_changed_description( char *buf, u32 len ){ +static void workshop_changed_description( char *buf, u32 len ){ workshop_form.submission.submit_description = 1; } -VG_STATIC void workshop_form_gui_page_undecided( ui_rect content ){ +static void workshop_form_gui_page_undecided( ui_rect content ){ ui_rect box; rect_copy( content, box ); box[3] = 128; @@ -1074,7 +1074,7 @@ VG_STATIC void workshop_form_gui_page_undecided( ui_rect content ){ } } -VG_STATIC void workshop_form_gui_draw_preview( ui_rect img_box ){ +static void workshop_form_gui_draw_preview( ui_rect img_box ){ enum addon_type type = workshop_form.submission.type; if( workshop_form.file_intent == k_workshop_form_file_intent_keep_old ){ ui_image( img_box, gpipeline.fb_workshop_preview->attachments[0].id ); @@ -1141,7 +1141,7 @@ VG_STATIC void workshop_form_gui_draw_preview( ui_rect img_box ){ } } -VG_STATIC void workshop_form_gui_edit_page( ui_rect content ){ +static void workshop_form_gui_edit_page( ui_rect content ){ enum addon_type type = workshop_form.submission.type; if( type == k_addon_type_none ){ @@ -1283,7 +1283,7 @@ VG_STATIC void workshop_form_gui_edit_page( ui_rect content ){ ui_colour( k_ui_fg+4 ) ); } -VG_STATIC void workshop_form_gui_sidebar( ui_rect sidebar ) +static void workshop_form_gui_sidebar( ui_rect sidebar ) { ui_fill( sidebar, ui_colour( k_ui_bg+2 ) ); @@ -1379,7 +1379,7 @@ VG_STATIC void workshop_form_gui_sidebar( ui_rect sidebar ) } } -VG_STATIC void workshop_form_gui(void) +static void workshop_form_gui(void) { enum workshop_form_page stable_page = workshop_form.page; if( stable_page == k_workshop_form_hidden ) return; @@ -1507,7 +1507,7 @@ VG_STATIC void workshop_form_gui(void) * ----------------------------------------------------------------------------- */ -VG_STATIC void async_workshop_get_filepath( void *data, u32 len ) +static void async_workshop_get_filepath( void *data, u32 len ) { struct async_workshop_filepath_info *info = data; @@ -1523,7 +1523,7 @@ VG_STATIC void async_workshop_get_filepath( void *data, u32 len ) } } -VG_STATIC void async_workshop_get_installed_files( void *data, u32 len ) +static void async_workshop_get_installed_files( void *data, u32 len ) { struct async_workshop_installed_files_info *info = data; diff --git a/workshop.h b/workshop.h index f28dc77..e09faf1 100644 --- a/workshop.h +++ b/workshop.h @@ -133,10 +133,10 @@ static workshop_form; -VG_STATIC int workshop_submit_command( int argc, const char *argv[] ); -VG_STATIC void async_workshop_get_filepath( void *data, u32 len ); -VG_STATIC void async_workshop_get_installed_files( void *data, u32 len ); -VG_STATIC void workshop_load_metadata( const char *path, +static int workshop_submit_command( int argc, const char *argv[] ); +static void async_workshop_get_filepath( void *data, u32 len ); +static void async_workshop_get_installed_files( void *data, u32 len ); +static void workshop_load_metadata( const char *path, struct workshop_file_info *info ); #endif /* WORKSHOP_H */ diff --git a/world.c b/world.c index 019e572..14200d9 100644 --- a/world.c +++ b/world.c @@ -63,7 +63,7 @@ static void skaterift_world_get_save_path( enum world_purpose which, #include "world_routes.c" #include "world_traffic.c" -VG_STATIC void world_update( world_instance *world, v3f pos ) +static void world_update( world_instance *world, v3f pos ) { world_render.sky_time += world_render.sky_rate * vg.time_delta; world_render.sky_rate = vg_lerp( world_render.sky_rate, diff --git a/world_audio.c b/world_audio.c index 8a167e4..1e902fa 100644 --- a/world_audio.c +++ b/world_audio.c @@ -6,7 +6,7 @@ /* finds any active playing in world and fades them out, we can only do this * while unloading */ -VG_STATIC void world_fadeout_audio( world_instance *world ) +static void world_fadeout_audio( world_instance *world ) { if( world->status != k_world_status_unloading ){ vg_fatal_error( "World status must be set to 'unloading', to fadeout" @@ -29,7 +29,7 @@ VG_STATIC void world_fadeout_audio( world_instance *world ) /* * Trace out a random point, near the player to try and determine water areas */ -VG_STATIC +static enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output) { v3f chance = { (vg_randf64()-0.5f) * 30.0f, @@ -69,7 +69,7 @@ enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output) return k_audio_sprite_type_none; } -VG_STATIC void world_audio_sample_distances( v3f co, int *index, float *value ) +static void world_audio_sample_distances( v3f co, int *index, float *value ) { float inr3 = 0.57735027, inr2 = 0.70710678118; diff --git a/world_audio.h b/world_audio.h index 285dc23..b1b14da 100644 --- a/world_audio.h +++ b/world_audio.h @@ -3,9 +3,9 @@ #include "world.h" -VG_STATIC void world_fadeout_audio( world_instance *world ); -VG_STATIC void world_audio_sample_distances( v3f co, int *index, float *value ); -VG_STATIC enum audio_sprite_type world_audio_sample_sprite_random( v3f origin, +static void world_fadeout_audio( world_instance *world ); +static void world_audio_sample_distances( v3f co, int *index, float *value ); +static enum audio_sprite_type world_audio_sample_sprite_random( v3f origin, v3f output ); #endif /* WORLD_AUDIO_H */ diff --git a/world_entity.c b/world_entity.c index 67db6af..3b2837f 100644 --- a/world_entity.c +++ b/world_entity.c @@ -11,18 +11,18 @@ #include "ent_challenge.h" #include "ent_skateshop.h" -VG_STATIC void world_entity_focus( u32 entity_id ){ +static void world_entity_focus( u32 entity_id ){ localplayer.immobile = 1; menu.disable_open = 1; v3_zero( localplayer.rb.v ); v3_zero( localplayer.rb.w ); - localplayer._walk.move_speed = 0.0f; + player_walk.move_speed = 0.0f; world_static.focused_entity = entity_id; skaterift.activity = k_skaterift_ent_focus; } -VG_STATIC void world_entity_unfocus(void){ +static void world_entity_unfocus(void){ localplayer.immobile = 0; skaterift.activity = k_skaterift_default; menu.disable_open = 0; @@ -30,7 +30,7 @@ VG_STATIC void world_entity_unfocus(void){ } /* logic preupdate */ -VG_STATIC void world_entity_focus_preupdate(void){ +static void world_entity_focus_preupdate(void){ f32 rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f ); int active = 0; if( skaterift.activity == k_skaterift_ent_focus ) @@ -54,7 +54,7 @@ VG_STATIC void world_entity_focus_preupdate(void){ } /* additional renderings like text etc.. */ -VG_STATIC void world_entity_focus_render(void){ +static void world_entity_focus_render(void){ if( skaterift.activity != k_skaterift_ent_focus ) return; @@ -74,7 +74,7 @@ VG_STATIC void world_entity_focus_render(void){ } } -VG_STATIC void world_gen_entities_init( world_instance *world ){ +static void world_gen_entities_init( world_instance *world ){ /* lights */ for( u32 j=0; jent_light); j ++ ){ ent_light *light = mdl_arritm( &world->ent_light, j ); @@ -187,7 +187,7 @@ VG_STATIC void world_gen_entities_init( world_instance *world ){ indexed_count, 2 ); } -VG_STATIC +static ent_spawn *world_find_closest_spawn( world_instance *world, v3f position ) { ent_spawn *rp = NULL, *r; @@ -216,7 +216,7 @@ ent_spawn *world_find_closest_spawn( world_instance *world, v3f position ) return rp; } -VG_STATIC +static ent_spawn *world_find_spawn_by_name( world_instance *world, const char *name ) { ent_spawn *rp = NULL, *r; @@ -234,7 +234,7 @@ ent_spawn *world_find_spawn_by_name( world_instance *world, const char *name ) return rp; } -VG_STATIC void ent_volume_call( world_instance *world, ent_call *call ) +static void ent_volume_call( world_instance *world, ent_call *call ) { u32 index = mdl_entity_id_id( call->id ); ent_volume *volume = mdl_arritm( &world->ent_volume, index ); @@ -261,7 +261,7 @@ VG_STATIC void ent_volume_call( world_instance *world, ent_call *call ) } } -VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ){ +static void ent_audio_call( world_instance *world, ent_call *call ){ if( world->status == k_world_status_unloading ){ vg_warn( "cannot modify audio while unloading world\n" ); return; @@ -354,7 +354,7 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ){ } -VG_STATIC void ent_ccmd_call( world_instance *world, ent_call *call ){ +static void ent_ccmd_call( world_instance *world, ent_call *call ){ if( call->function == k_ent_function_trigger ){ u32 index = mdl_entity_id_id( call->id ); ent_ccmd *ccmd = mdl_arritm( &world->ent_ccmd, index ); @@ -367,7 +367,7 @@ VG_STATIC void ent_ccmd_call( world_instance *world, ent_call *call ){ * ---------------------------------------------------------------------------- */ -VG_STATIC void +static void entity_bh_expand_bound( void *user, boxf bound, u32 item_index ){ world_instance *world = user; @@ -420,7 +420,7 @@ entity_bh_expand_bound( void *user, boxf bound, u32 item_index ){ } } -VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ){ +static float entity_bh_centroid( void *user, u32 item_index, int axis ){ world_instance *world = user; u32 id = world->entity_list[ item_index ], @@ -449,7 +449,7 @@ VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ){ } } -VG_STATIC void entity_bh_swap( void *user, u32 ia, u32 ib ){ +static void entity_bh_swap( void *user, u32 ia, u32 ib ){ world_instance *world = user; u32 a = world->entity_list[ ia ], @@ -459,7 +459,7 @@ VG_STATIC void entity_bh_swap( void *user, u32 ia, u32 ib ){ world->entity_list[ ib ] = a; } -VG_STATIC void entity_bh_debug( void *user, u32 item_index ){ +static void entity_bh_debug( void *user, u32 item_index ){ world_instance *world = user; u32 id = world->entity_list[ item_index ], @@ -507,7 +507,7 @@ VG_STATIC void entity_bh_debug( void *user, u32 item_index ){ } } -VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point, +static void entity_bh_closest( void *user, u32 item_index, v3f point, v3f closest ){ world_instance *world = user; @@ -536,7 +536,7 @@ VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point, } } -VG_STATIC void world_entity_start( world_instance *world, vg_msg *sav ){ +static void world_entity_start( world_instance *world, vg_msg *sav ){ vg_info( "Start instance %p\n", world ); world->probabilities[ k_probability_curve_constant ] = 1.0f; @@ -568,7 +568,7 @@ VG_STATIC void world_entity_start( world_instance *world, vg_msg *sav ){ } } -VG_STATIC void world_entity_serialize( world_instance *world, vg_msg *sav ){ +static void world_entity_serialize( world_instance *world, vg_msg *sav ){ for( u32 i=0; ient_challenge); i++ ){ ent_challenge *challenge = mdl_arritm(&world->ent_challenge,i); diff --git a/world_entity.h b/world_entity.h index ba58df8..49e2cd5 100644 --- a/world_entity.h +++ b/world_entity.h @@ -7,29 +7,29 @@ #include "save.h" #include "vg/vg_msg.h" -VG_STATIC void world_gen_entities_init( world_instance *world ); -VG_STATIC ent_spawn *world_find_spawn_by_name( world_instance *world, +static void world_gen_entities_init( world_instance *world ); +static ent_spawn *world_find_spawn_by_name( world_instance *world, const char *name ); -VG_STATIC ent_spawn *world_find_closest_spawn( world_instance *world, +static ent_spawn *world_find_closest_spawn( world_instance *world, v3f position ); -VG_STATIC void world_entity_start( world_instance *world, vg_msg *sav ); -VG_STATIC void world_entity_serialize( world_instance *world, vg_msg *sav ); +static void world_entity_start( world_instance *world, vg_msg *sav ); +static void world_entity_serialize( world_instance *world, vg_msg *sav ); -VG_STATIC void ent_volume_call( world_instance *world, ent_call *call ); -VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ); -VG_STATIC void ent_ccmd_call( world_instance *world, ent_call *call ); +static void ent_volume_call( world_instance *world, ent_call *call ); +static void ent_audio_call( world_instance *world, ent_call *call ); +static void ent_ccmd_call( world_instance *world, ent_call *call ); -VG_STATIC void entity_bh_expand_bound( void *user, boxf bound, u32 item_index ); -VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ); -VG_STATIC void entity_bh_swap( void *user, u32 ia, u32 ib ); -VG_STATIC void entity_bh_debug( void *user, u32 item_index ); -VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point, +static void entity_bh_expand_bound( void *user, boxf bound, u32 item_index ); +static float entity_bh_centroid( void *user, u32 item_index, int axis ); +static void entity_bh_swap( void *user, u32 ia, u32 ib ); +static void entity_bh_debug( void *user, u32 item_index ); +static void entity_bh_closest( void *user, u32 item_index, v3f point, v3f closest ); -VG_STATIC void world_entity_focus( u32 entity_id ); -VG_STATIC void world_entity_focus_preupdate(void); -VG_STATIC void world_entity_focus_render(void); -VG_STATIC void world_entity_unfocus(); +static void world_entity_focus( u32 entity_id ); +static void world_entity_focus_preupdate(void); +static void world_entity_focus_render(void); +static void world_entity_unfocus(); static bh_system bh_system_entity_list = { .expand_bound = entity_bh_expand_bound, diff --git a/world_gate.c b/world_gate.c index b4760b4..b236bc9 100644 --- a/world_gate.c +++ b/world_gate.c @@ -20,7 +20,7 @@ /* * Update the transform matrices for gate */ -VG_STATIC void gate_transform_update( ent_gate *gate ){ +static void gate_transform_update( ent_gate *gate ){ if( gate->flags & k_ent_gate_flip ){ v4f qflip; q_axis_angle( qflip, (v3f){0.0f,1.0f,0.0f}, VG_PIf ); @@ -39,7 +39,7 @@ VG_STATIC void gate_transform_update( ent_gate *gate ){ m4x3_mul( recv_to_world, to_local, gate->transport ); } -VG_STATIC void world_gates_init(void) +static void world_gates_init(void) { vg_info( "world_gates_init\n" ); @@ -68,7 +68,7 @@ VG_STATIC void world_gates_init(void) mdl_close( &mgate ); } -VG_STATIC void ent_gate_get_mdl_mtx( ent_gate *gate, m4x3f mmdl ){ +static void ent_gate_get_mdl_mtx( ent_gate *gate, m4x3f mmdl ){ m4x3_copy( gate->to_world, mmdl ); if( !(gate->flags & k_ent_gate_custom_mesh) ){ @@ -80,7 +80,7 @@ VG_STATIC void ent_gate_get_mdl_mtx( ent_gate *gate, m4x3f mmdl ){ /* * Render the view through a gate */ -VG_STATIC int render_gate( world_instance *world, world_instance *world_inside, +static int render_gate( world_instance *world, world_instance *world_inside, ent_gate *gate, camera *cam, int layer_depth ) { v3f viewdir, gatedir; @@ -203,7 +203,7 @@ VG_STATIC int render_gate( world_instance *world, world_instance *world_inside, * Intersect the plane of a gate with a line segment, plane coordinate result * stored in 'where' */ -VG_STATIC int gate_intersect_plane( ent_gate *gate, +static int gate_intersect_plane( ent_gate *gate, v3f pos, v3f last, v2f where ) { v4f surface; @@ -247,7 +247,7 @@ VG_STATIC int gate_intersect_plane( ent_gate *gate, /* * Intersect specific gate */ -VG_STATIC int gate_intersect( ent_gate *gate, v3f pos, v3f last ) +static int gate_intersect( ent_gate *gate, v3f pos, v3f last ) { v2f xy; @@ -264,7 +264,7 @@ VG_STATIC int gate_intersect( ent_gate *gate, v3f pos, v3f last ) /* * Intersect all gates in the world */ -VG_STATIC ent_gate *world_intersect_gates( world_instance *world, +static ent_gate *world_intersect_gates( world_instance *world, v3f pos, v3f last ){ for( u32 i=0; ient_gate); i++ ){ ent_gate *gate = mdl_arritm( &world->ent_gate, i ); @@ -289,7 +289,7 @@ VG_STATIC ent_gate *world_intersect_gates( world_instance *world, /* * detatches any nonlocal gates */ -VG_STATIC void world_unlink_nonlocal( world_instance *world ){ +static void world_unlink_nonlocal( world_instance *world ){ for( u32 j=0; jent_gate); j ++ ){ ent_gate *gate = mdl_arritm( &world->ent_gate, j ); @@ -302,7 +302,7 @@ VG_STATIC void world_unlink_nonlocal( world_instance *world ){ /* * attatches nonlocal gates, to be called from main thread ONLY! */ -VG_STATIC void world_link_nonlocal_async( void *payload, u32 size ){ +static void world_link_nonlocal_async( void *payload, u32 size ){ world_instance *world = payload; u32 world_id = world - world_static.instances; @@ -368,7 +368,7 @@ VG_STATIC void world_link_nonlocal_async( void *payload, u32 size ){ } } -VG_STATIC void ent_gate_call( world_instance *world, ent_call *call ){ +static void ent_gate_call( world_instance *world, ent_call *call ){ u32 index = mdl_entity_id_id( call->id ); ent_gate *gate = mdl_arritm( &world->ent_gate, index ); diff --git a/world_gate.h b/world_gate.h index 6f38440..bf23beb 100644 --- a/world_gate.h +++ b/world_gate.h @@ -16,18 +16,18 @@ struct world_gates{ } static world_gates; -VG_STATIC void world_gates_init(void); -VG_STATIC void gate_transform_update( ent_gate *gate ); -VG_STATIC void world_link_nonlocal_async( void *payload, u32 size ); -VG_STATIC void world_unlink_nonlocal( world_instance *world ); -VG_STATIC int render_gate( world_instance *world, world_instance *world_inside, +static void world_gates_init(void); +static void gate_transform_update( ent_gate *gate ); +static void world_link_nonlocal_async( void *payload, u32 size ); +static void world_unlink_nonlocal( world_instance *world ); +static int render_gate( world_instance *world, world_instance *world_inside, ent_gate *gate, camera *cam, int layer_depth ); -VG_STATIC int gate_intersect( ent_gate *gate, v3f pos, v3f last ); -VG_STATIC ent_gate *world_intersect_gates( world_instance *world, +static int gate_intersect( ent_gate *gate, v3f pos, v3f last ); +static ent_gate *world_intersect_gates( world_instance *world, v3f pos, v3f last ); -VG_STATIC void ent_gate_call( world_instance *world, ent_call *call ); -VG_STATIC void ent_gate_get_mdl_mtx( ent_gate *gate, m4x3f mmdl ); +static void ent_gate_call( world_instance *world, ent_call *call ); +static void ent_gate_get_mdl_mtx( ent_gate *gate, m4x3f mmdl ); #endif /* WORLD_GATE_H */ diff --git a/world_gen.c b/world_gen.c index 7c0f756..0b0c344 100644 --- a/world_gen.c +++ b/world_gen.c @@ -18,7 +18,7 @@ * Add all triangles from the model, which match the material ID * applies affine transform to the model */ -VG_STATIC void world_add_all_if_material( m4x3f transform, scene_context *scene, +static void world_add_all_if_material( m4x3f transform, scene_context *scene, mdl_context *mdl, u32 id ) { for( u32 i=0; imeshs); i++ ){ @@ -46,7 +46,7 @@ VG_STATIC void world_add_all_if_material( m4x3f transform, scene_context *scene, * | | * |________| */ -VG_STATIC void world_gen_add_blob( world_instance *world, +static void world_gen_add_blob( world_instance *world, scene_context *scene, ray_hit *hit ) { m4x3f transform; @@ -106,7 +106,7 @@ VG_STATIC void world_gen_add_blob( world_instance *world, /* * Sprinkle foliage models over the map on terrain material */ -VG_STATIC void world_apply_procedural_foliage( world_instance *world, +static void world_apply_procedural_foliage( world_instance *world, scene_context *scene, struct world_surface *mat ) { @@ -149,7 +149,7 @@ VG_STATIC void world_apply_procedural_foliage( world_instance *world, vg_info( "%d foliage models added\n", count ); } -VG_STATIC +static void world_unpack_submesh_dynamic( world_instance *world, scene_context *scene, mdl_submesh *sm ){ if( sm->flags & k_submesh_flag_consumed ) return; @@ -165,7 +165,7 @@ void world_unpack_submesh_dynamic( world_instance *world, /* * Create the main meshes for the world */ -VG_STATIC void world_gen_generate_meshes( world_instance *world ){ +static void world_gen_generate_meshes( world_instance *world ){ /* * Compile meshes into the world scenes */ @@ -326,7 +326,7 @@ struct light_indices_upload_info{ /* * Async reciever to buffer light index data */ -VG_STATIC void async_upload_light_indices( void *payload, u32 size ){ +static void async_upload_light_indices( void *payload, u32 size ){ struct light_indices_upload_info *info = payload; glGenTextures( 1, &info->world->tex_light_cubes ); @@ -341,7 +341,7 @@ VG_STATIC void async_upload_light_indices( void *payload, u32 size ){ /* * Computes light indices for world */ -VG_STATIC void world_gen_compute_light_indices( world_instance *world ){ +static void world_gen_compute_light_indices( world_instance *world ){ /* light cubes */ v3f cubes_min, cubes_max; v3_muls( world->scene_geo.bbx[0], 1.0f/k_world_light_cube_size, cubes_min ); @@ -501,7 +501,7 @@ VG_STATIC void world_gen_compute_light_indices( world_instance *world ){ /* * Rendering pass needed to complete the world */ -VG_STATIC void async_world_postprocess( void *payload, u32 _size ){ +static void async_world_postprocess( void *payload, u32 _size ){ /* create scene lighting buffer */ world_instance *world = payload; @@ -656,7 +656,7 @@ VG_STATIC void async_world_postprocess( void *payload, u32 _size ){ } /* Loads textures from the pack file */ -VG_STATIC void world_gen_load_surfaces( world_instance *world ){ +static void world_gen_load_surfaces( world_instance *world ){ vg_info( "Loading textures\n" ); world->texture_count = 0; diff --git a/world_gen.h b/world_gen.h index 5e2f0b1..ba4adc5 100644 --- a/world_gen.h +++ b/world_gen.h @@ -10,10 +10,10 @@ #include "world.h" -VG_STATIC void world_init_blank( world_instance *world ); -VG_STATIC void world_gen_load_surfaces( world_instance *world ); -VG_STATIC void world_gen_generate_meshes( world_instance *world ); -VG_STATIC void world_gen_compute_light_indices( world_instance *world ); -VG_STATIC void async_world_postprocess( void *payload, u32 _size ); +static void world_init_blank( world_instance *world ); +static void world_gen_load_surfaces( world_instance *world ); +static void world_gen_generate_meshes( world_instance *world ); +static void world_gen_compute_light_indices( world_instance *world ); +static void async_world_postprocess( void *payload, u32 _size ); #endif /* WORLD_GEN_H */ diff --git a/world_load.c b/world_load.c index ee7df7d..00be612 100644 --- a/world_load.c +++ b/world_load.c @@ -12,7 +12,7 @@ /* * load the .mdl file located in path as a world instance */ -VG_STATIC void world_instance_load_mdl( u32 instance_id, const char *path ){ +static void world_instance_load_mdl( u32 instance_id, const char *path ){ vg_rand_seed( 9001 ); world_instance *world = &world_static.instances[ instance_id ]; @@ -393,7 +393,7 @@ static void world_free( world_instance *world ) * reset the world structure without deallocating persistent buffers * TODO: Make this a memset(0), and have persistent items live in a static loc */ -VG_STATIC void world_init_blank( world_instance *world ) +static void world_init_blank( world_instance *world ) { memset( &world->meta, 0, sizeof(mdl_context) ); diff --git a/world_physics.c b/world_physics.c index fb68eb5..ebe8f89 100644 --- a/world_physics.c +++ b/world_physics.c @@ -4,14 +4,14 @@ #include "world.h" #include "world_physics.h" -VG_STATIC void ray_world_get_tri( world_instance *world, +static void ray_world_get_tri( world_instance *world, ray_hit *hit, v3f tri[3] ) { for( int i=0; i<3; i++ ) v3_copy( world->scene_geo.arrvertices[ hit->tri[i] ].co, tri[i] ); } -VG_STATIC int ray_world( world_instance *world, +static int ray_world( world_instance *world, v3f pos, v3f dir, ray_hit *hit, u16 ignore ) { return scene_raycast( &world->scene_geo, world->geo_bh, pos, dir, hit, @@ -21,7 +21,7 @@ VG_STATIC int ray_world( world_instance *world, /* * Cast a sphere from a to b and see what time it hits */ -VG_STATIC int spherecast_world( world_instance *world, +static int spherecast_world( world_instance *world, v3f pa, v3f pb, float r, float *t, v3f n, u16 ignore ) { @@ -80,7 +80,7 @@ VG_STATIC int spherecast_world( world_instance *world, return hit; } -VG_STATIC +static struct world_surface *world_tri_index_surface( world_instance *world, u32 index ) { @@ -97,13 +97,13 @@ struct world_surface *world_tri_index_surface( world_instance *world, return &world->surfaces[0]; } -VG_STATIC struct world_surface *world_contact_surface( world_instance *world, +static struct world_surface *world_contact_surface( world_instance *world, rb_ct *ct ) { return world_tri_index_surface( world, ct->element_id ); } -VG_STATIC struct world_surface *ray_hit_surface( world_instance *world, +static struct world_surface *ray_hit_surface( world_instance *world, ray_hit *hit ) { return world_tri_index_surface( world, hit->tri[0] ); diff --git a/world_physics.h b/world_physics.h index 2a38330..6cc8c5d 100644 --- a/world_physics.h +++ b/world_physics.h @@ -4,23 +4,23 @@ #include "world.h" #include "rigidbody.h" -VG_STATIC void ray_world_get_tri( world_instance *world, +static void ray_world_get_tri( world_instance *world, ray_hit *hit, v3f tri[3] ); -VG_STATIC int ray_world( world_instance *world, +static int ray_world( world_instance *world, v3f pos, v3f dir, ray_hit *hit, u16 ignore ); -VG_STATIC int spherecast_world( world_instance *world, +static int spherecast_world( world_instance *world, v3f pa, v3f pb, float r, float *t, v3f n, u16 ignore ); -VG_STATIC struct world_surface *world_tri_index_surface( world_instance *world, +static struct world_surface *world_tri_index_surface( world_instance *world, u32 index ); -VG_STATIC struct world_surface *world_contact_surface( world_instance *world, +static struct world_surface *world_contact_surface( world_instance *world, rb_ct *ct ); -VG_STATIC struct world_surface *ray_hit_surface( world_instance *world, +static struct world_surface *ray_hit_surface( world_instance *world, ray_hit *hit ); #endif /* WORLD_PHYSICS_H */ diff --git a/world_render.c b/world_render.c index 2cbd07b..37b095c 100644 --- a/world_render.c +++ b/world_render.c @@ -22,7 +22,7 @@ static int ccmd_set_time( int argc, const char *argv[] ){ return 0; } -VG_STATIC void async_world_render_init( void *payload, u32 size ) +static void async_world_render_init( void *payload, u32 size ) { vg_info( "Allocate uniform buffers\n" ); for( int i=0; i<4; i++ ){ @@ -65,7 +65,7 @@ VG_STATIC void async_world_render_init( void *payload, u32 size ) } } -VG_STATIC void world_render_init(void) +static void world_render_init(void) { VG_VAR_F32( k_day_length ); VG_VAR_I32( k_debug_light_indices ); @@ -104,13 +104,13 @@ VG_STATIC void world_render_init(void) vg_async_call( async_world_render_init, NULL, 0 ); } -VG_STATIC void world_link_lighting_ub( world_instance *world, GLuint shader ) +static void world_link_lighting_ub( world_instance *world, GLuint shader ) { GLuint idx = glGetUniformBlockIndex( shader, "ub_world_lighting" ); glUniformBlockBinding( shader, idx, world->ubo_bind_point ); } -VG_STATIC void world_bind_position_texture( world_instance *world, +static void world_bind_position_texture( world_instance *world, GLuint shader, GLuint location, int slot ) { @@ -118,7 +118,7 @@ VG_STATIC void world_bind_position_texture( world_instance *world, glUniform1i( location, slot ); } -VG_STATIC void world_bind_light_array( world_instance *world, +static void world_bind_light_array( world_instance *world, GLuint shader, GLuint location, int slot ) { @@ -127,7 +127,7 @@ VG_STATIC void world_bind_light_array( world_instance *world, glUniform1i( location, slot ); } -VG_STATIC void world_bind_light_index( world_instance *world, +static void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ) { @@ -136,13 +136,13 @@ VG_STATIC void world_bind_light_index( world_instance *world, glUniform1i( location, slot ); } -VG_STATIC void render_world_depth( world_instance *world, camera *cam ); +static void render_world_depth( world_instance *world, camera *cam ); /* * Rendering */ -VG_STATIC void bind_terrain_noise(void) +static void bind_terrain_noise(void) { glActiveTexture( GL_TEXTURE0 ); glBindTexture( GL_TEXTURE_2D, world_render.tex_terrain_noise ); @@ -159,7 +159,7 @@ struct world_pass{ void (*fn_set_uPvmPrev)( m4x4f pvm ); }; -VG_STATIC +static void world_render_traffic( world_instance *world, u32 material_id, struct world_pass *pass ){ if( !mdl_arrcount( &world->ent_traffic ) ) return; @@ -197,7 +197,7 @@ void world_render_traffic( world_instance *world, u32 material_id, } } -VG_STATIC +static void world_render_pass( world_instance *world, struct world_pass *pass ){ for( int i=0; isurface_count; i++ ){ struct world_surface *mat = &world->surfaces[i]; @@ -227,7 +227,7 @@ void world_render_pass( world_instance *world, struct world_pass *pass ){ } } -VG_STATIC +static void world_render_both_stages( world_instance *world, struct world_pass *pass ) { mesh_bind( &world->mesh_geo ); @@ -241,7 +241,7 @@ void world_render_both_stages( world_instance *world, struct world_pass *pass ) glEnable( GL_CULL_FACE ); } -VG_STATIC void bindpoint_diffuse_texture1( world_instance *world, +static void bindpoint_diffuse_texture1( world_instance *world, struct world_surface *mat ) { @@ -249,7 +249,7 @@ VG_STATIC void bindpoint_diffuse_texture1( world_instance *world, glBindTexture( GL_TEXTURE_2D, world->textures[ mat->info.tex_diffuse ] ); } -VG_STATIC void bindpoint_diffuse1_and_cubemap10( world_instance *world, +static void bindpoint_diffuse1_and_cubemap10( world_instance *world, struct world_surface *mat ){ glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, world->textures[ mat->info.tex_diffuse ] ); @@ -268,7 +268,7 @@ VG_STATIC void bindpoint_diffuse1_and_cubemap10( world_instance *world, shader_scene_cubemapped_uColour( mat->info.colour ); } -VG_STATIC void render_world_vb( world_instance *world, camera *cam ) +static void render_world_vb( world_instance *world, camera *cam ) { shader_scene_vertex_blend_use(); shader_scene_vertex_blend_uTexGarbage(0); @@ -298,7 +298,7 @@ VG_STATIC void render_world_vb( world_instance *world, camera *cam ) world_render_both_stages( world, &pass ); } -VG_STATIC void world_shader_standard_bind( world_instance *world, camera *cam ){ +static void world_shader_standard_bind( world_instance *world, camera *cam ){ shader_scene_standard_use(); shader_scene_standard_uTexGarbage(0); shader_scene_standard_uTexMain(1); @@ -316,7 +316,7 @@ VG_STATIC void world_shader_standard_bind( world_instance *world, camera *cam ){ shader_scene_standard_uCamera( cam->transform[3] ); } -VG_STATIC void render_world_standard( world_instance *world, camera *cam ){ +static void render_world_standard( world_instance *world, camera *cam ){ world_shader_standard_bind( world, cam ); struct world_pass pass = { .shader = k_shader_standard, @@ -329,7 +329,7 @@ VG_STATIC void render_world_standard( world_instance *world, camera *cam ){ world_render_both_stages( world, &pass ); } -VG_STATIC void render_world_cubemapped( world_instance *world, camera *cam, +static void render_world_cubemapped( world_instance *world, camera *cam, int layer_depth ){ if( !mdl_arrcount( &world->ent_cubemap ) ) return; @@ -377,7 +377,7 @@ VG_STATIC void render_world_cubemapped( world_instance *world, camera *cam, } } -VG_STATIC void render_world_alphatest( world_instance *world, camera *cam ){ +static void render_world_alphatest( world_instance *world, camera *cam ){ shader_scene_standard_alphatest_use(); shader_scene_standard_alphatest_uTexGarbage(0); shader_scene_standard_alphatest_uTexMain(1); @@ -412,7 +412,7 @@ VG_STATIC void render_world_alphatest( world_instance *world, camera *cam ){ glEnable(GL_CULL_FACE); } -VG_STATIC +static void world_render_challenges( world_instance *world, struct world_pass *pass, v3f pos, int layer_depth ){ if( !world ) return; @@ -605,7 +605,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass, } } -VG_STATIC void render_world_fxglow( world_instance *world, camera *cam, +static void render_world_fxglow( world_instance *world, camera *cam, int layer_depth ){ shader_scene_fxglow_use(); shader_scene_fxglow_uUvOffset( (v2f){ 0.0f, 0.0f } ); @@ -637,7 +637,7 @@ VG_STATIC void render_world_fxglow( world_instance *world, camera *cam, glEnable(GL_CULL_FACE); } -VG_STATIC void bindpoint_terrain( world_instance *world, +static void bindpoint_terrain( world_instance *world, struct world_surface *mat ) { glActiveTexture( GL_TEXTURE1 ); @@ -647,7 +647,7 @@ VG_STATIC void bindpoint_terrain( world_instance *world, shader_scene_terrain_uBlendOffset( mat->info.colour1 ); } -VG_STATIC void bindpoint_override( world_instance *world, +static void bindpoint_override( world_instance *world, struct world_surface *mat ){ if( mat->info.flags & k_material_flag_collision ){ shader_scene_override_uAlphatest(0); @@ -659,7 +659,7 @@ VG_STATIC void bindpoint_override( world_instance *world, } } -VG_STATIC void render_terrain( world_instance *world, camera *cam ) +static void render_terrain( world_instance *world, camera *cam ) { shader_scene_terrain_use(); shader_scene_terrain_uTexGarbage(0); @@ -690,7 +690,7 @@ VG_STATIC void render_terrain( world_instance *world, camera *cam ) world_render_both_stages( world, &pass ); } -VG_STATIC void render_sky( world_instance *world, camera *cam ) +static void render_sky( world_instance *world, camera *cam ) { /* * Modify matrix to remove clipping and view translation @@ -739,7 +739,7 @@ VG_STATIC void render_sky( world_instance *world, camera *cam ) glDepthMask( GL_TRUE ); } -VG_STATIC void render_world_gates( world_instance *world, camera *cam, +static void render_world_gates( world_instance *world, camera *cam, int layer_depth ) { float closest = INFINITY; @@ -780,7 +780,7 @@ VG_STATIC void render_world_gates( world_instance *world, camera *cam, } } -VG_STATIC void world_prerender( world_instance *world ) +static void world_prerender( world_instance *world ) { if( mdl_arrcount( &world->ent_light ) ){ @@ -829,7 +829,7 @@ VG_STATIC void world_prerender( world_instance *world ) sizeof(struct ub_world_lighting), &world->ub_lighting ); } -VG_STATIC void render_world( world_instance *world, camera *cam, +static void render_world( world_instance *world, camera *cam, int layer_depth ) { render_sky( world, cam ); @@ -893,7 +893,7 @@ VG_STATIC void render_world( world_instance *world, camera *cam, } -VG_STATIC +static void render_world_override_pass( world_instance *world, struct world_pass *pass ){ for( int i=0; isurface_count; i++ ){ @@ -919,7 +919,7 @@ void render_world_override_pass( world_instance *world, } } -VG_STATIC void render_world_override( world_instance *world ){ +static void render_world_override( world_instance *world ){ struct world_pass pass = { .cam = &skaterift.cam, .fn_bind_textures = bindpoint_override, @@ -955,7 +955,7 @@ VG_STATIC void render_world_override( world_instance *world ){ glEnable( GL_CULL_FACE ); } -VG_STATIC void render_cubemap_side( world_instance *world, ent_cubemap *cm, +static void render_cubemap_side( world_instance *world, ent_cubemap *cm, u32 side ){ camera cam; glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -1001,7 +1001,7 @@ VG_STATIC void render_cubemap_side( world_instance *world, ent_cubemap *cm, render_world( world, &cam, -1 ); } -VG_STATIC void render_world_cubemaps( world_instance *world ){ +static void render_world_cubemaps( world_instance *world ){ if( world->cubemap_cooldown ) world->cubemap_cooldown --; else{ @@ -1021,7 +1021,7 @@ VG_STATIC void render_world_cubemaps( world_instance *world ){ } } -VG_STATIC void render_world_depth( world_instance *world, camera *cam ) +static void render_world_depth( world_instance *world, camera *cam ) { m4x3f identity_matrix; m4x3_identity( identity_matrix ); @@ -1037,7 +1037,7 @@ VG_STATIC void render_world_depth( world_instance *world, camera *cam ) mesh_draw( &world->mesh_geo ); } -VG_STATIC void render_world_position( world_instance *world, camera *cam ) +static void render_world_position( world_instance *world, camera *cam ) { m4x3f identity_matrix; m4x3_identity( identity_matrix ); diff --git a/world_render.h b/world_render.h index d90c01b..a28221f 100644 --- a/world_render.h +++ b/world_render.h @@ -60,22 +60,22 @@ struct world_render{ u32 text_particle_count; } static world_render; -VG_STATIC void world_render_init(void); +static void world_render_init(void); -VG_STATIC void world_link_lighting_ub( world_instance *world, GLuint shader ); -VG_STATIC void world_bind_position_texture( world_instance *world, +static void world_link_lighting_ub( world_instance *world, GLuint shader ); +static void world_bind_position_texture( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void world_bind_light_array( world_instance *world, +static void world_bind_light_array( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void world_bind_light_index( world_instance *world, +static void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void render_world_position( world_instance *world, camera *cam ); -VG_STATIC void render_world_depth( world_instance *world, camera *cam ); -VG_STATIC void render_world( world_instance *world, camera *cam, +static void render_world_position( world_instance *world, camera *cam ); +static void render_world_depth( world_instance *world, camera *cam ); +static void render_world( world_instance *world, camera *cam, int layer_depth ); -VG_STATIC void render_world_cubemaps( world_instance *world ); +static void render_world_cubemaps( world_instance *world ); #endif /* WORLD_RENDER_H */ diff --git a/world_routes.c b/world_routes.c index 3e21df0..53ccb90 100644 --- a/world_routes.c +++ b/world_routes.c @@ -21,7 +21,7 @@ #include "shaders/routeui.h" -VG_STATIC +static void world_routes_local_set_record( world_instance *world, ent_route *route, f64 lap_time ) { @@ -52,7 +52,7 @@ void world_routes_local_set_record( world_instance *world, ent_route *route, } -VG_STATIC void world_routes_clear( world_instance *world ) +static void world_routes_clear( world_instance *world ) { for( u32 i=0; ient_route ); i++ ){ ent_route *route = mdl_arritm( &world->ent_route, i ); @@ -69,7 +69,7 @@ VG_STATIC void world_routes_clear( world_instance *world ) world_static.last_use = 0.0; } -VG_STATIC void world_routes_time_lap( world_instance *world, ent_route *route ) +static void world_routes_time_lap( world_instance *world, ent_route *route ) { vg_info( "------- time lap %s -------\n", mdl_pstr(&world->meta,route->pstr_name) ); @@ -127,7 +127,7 @@ VG_STATIC void world_routes_time_lap( world_instance *world, ent_route *route ) /* * When going through a gate this is called for bookkeeping purposes */ -VG_STATIC void world_routes_activate_entry_gate( world_instance *world, +static void world_routes_activate_entry_gate( world_instance *world, ent_gate *rg ) { world_static.last_use = world_static.time; @@ -175,7 +175,7 @@ VG_STATIC void world_routes_activate_entry_gate( world_instance *world, } /* draw lines along the paths */ -VG_STATIC void world_routes_debug( world_instance *world ) +static void world_routes_debug( world_instance *world ) { for( u32 i=0; ient_route_node); i++ ){ ent_route_node *rn = mdl_arritm(&world->ent_route_node,i); @@ -224,7 +224,7 @@ VG_STATIC void world_routes_debug( world_instance *world ) } } -VG_STATIC +static void world_routes_pointcloud_spot( world_instance *world, pointcloud_buffer *pcbuf, v3f co, f32 radius, u32 samples, v4f colour ) @@ -268,7 +268,7 @@ void world_routes_pointcloud_spot( world_instance *world, * /#\ * -'###`- */ -VG_STATIC +static void world_routes_pointcloud_tower( world_instance *world, pointcloud_buffer *pcbuf, v3f co, f32 radius, f32 height, @@ -304,7 +304,7 @@ void world_routes_pointcloud_tower( world_instance *world, } } -VG_STATIC +static void world_routes_place_curve( world_instance *world, ent_route *route, v4f h[3], v3f n0, v3f n2, scene_context *scene, pointcloud_buffer *pcbuf ) @@ -426,7 +426,7 @@ void world_routes_place_curve( world_instance *world, ent_route *route, } } -VG_STATIC void world_routes_gen_meshes( world_instance *world, u32 route_id, +static void world_routes_gen_meshes( world_instance *world, u32 route_id, scene_context *sc, pointcloud_buffer *pcbuf ) { @@ -549,11 +549,11 @@ VG_STATIC void world_routes_gen_meshes( world_instance *world, u32 route_id, scene_copy_slice( sc, &route->sm ); } -VG_STATIC +static struct world_surface *world_tri_index_surface( world_instance *world, u32 index ); -VG_STATIC f64 world_routes_scatter_surface_points( world_instance *world, +static f64 world_routes_scatter_surface_points( world_instance *world, pointcloud_buffer *pcbuf, f32 rate ) { @@ -675,7 +675,7 @@ VG_STATIC f64 world_routes_scatter_surface_points( world_instance *world, return total_area; } -VG_STATIC void world_routes_surface_grid( world_instance *world, +static void world_routes_surface_grid( world_instance *world, pointcloud_buffer *pcbuf ) { i32 const k_gridlines = 32, @@ -744,7 +744,7 @@ VG_STATIC void world_routes_surface_grid( world_instance *world, } } -VG_STATIC void world_write_preview( addon_reg *reg, pointcloud_buffer *pcbuf ){ +static void world_write_preview( addon_reg *reg, pointcloud_buffer *pcbuf ){ if( reg->alias.workshop_id ) return; /* @@ -773,7 +773,7 @@ VG_STATIC void world_write_preview( addon_reg *reg, pointcloud_buffer *pcbuf ){ /* * Create the strips of colour that run through the world along course paths */ -VG_STATIC void world_gen_routes_generate( u32 instance_id ){ +static void world_gen_routes_generate( u32 instance_id ){ world_instance *world = &world_static.instances[ instance_id ]; vg_info( "Generating route meshes\n" ); vg_async_stall(); @@ -877,7 +877,7 @@ VG_STATIC void world_gen_routes_generate( u32 instance_id ){ } /* load all routes from model header */ -VG_STATIC void world_gen_routes_ent_init( world_instance *world ){ +static void world_gen_routes_ent_init( world_instance *world ){ vg_info( "Initializing routes\n" ); for( u32 i=0; ient_gate); i++ ){ @@ -943,7 +943,7 @@ VG_STATIC void world_gen_routes_ent_init( world_instance *world ){ * ----------------------------------------------------------------------------- */ -VG_STATIC void world_routes_init(void) +static void world_routes_init(void) { world_static.current_run_version = 200; world_static.time = 300.0; @@ -953,7 +953,7 @@ VG_STATIC void world_routes_init(void) shader_routeui_register(); } -VG_STATIC void world_routes_update( world_instance *world ) +static void world_routes_update( world_instance *world ) { world_static.time += vg.time_delta; @@ -970,7 +970,7 @@ VG_STATIC void world_routes_update( world_instance *world ) } } -VG_STATIC void world_routes_fixedupdate( world_instance *world ) +static void world_routes_fixedupdate( world_instance *world ) { rb_solver_reset(); @@ -1015,15 +1015,15 @@ VG_STATIC void world_routes_fixedupdate( world_instance *world ) } } -VG_STATIC void bind_terrain_noise(void); -VG_STATIC void world_bind_light_array( world_instance *world, +static void bind_terrain_noise(void); +static void world_bind_light_array( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void world_bind_light_index( world_instance *world, +static void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void world_routes_update_timer_texts( world_instance *world ) +static void world_routes_update_timer_texts( world_instance *world ) { world_render.timer_text_count = 0; @@ -1125,7 +1125,7 @@ VG_STATIC void world_routes_update_timer_texts( world_instance *world ) } } -VG_STATIC void world_routes_fracture( world_instance *world, ent_gate *gate, +static void world_routes_fracture( world_instance *world, ent_gate *gate, v3f imp_co, v3f imp_v ) { world_render.text_particle_count = 0; @@ -1199,7 +1199,7 @@ VG_STATIC void world_routes_fracture( world_instance *world, ent_gate *gate, } } -VG_STATIC void render_world_routes( world_instance *world, camera *cam, +static void render_world_routes( world_instance *world, camera *cam, int layer_depth ) { m4x3f identity_matrix; diff --git a/world_routes.h b/world_routes.h index f10dc03..b6843ed 100644 --- a/world_routes.h +++ b/world_routes.h @@ -7,18 +7,18 @@ #include "world.h" -VG_STATIC void world_routes_init(void); -VG_STATIC void world_routes_fracture( world_instance *world, ent_gate *gate, +static void world_routes_init(void); +static void world_routes_fracture( world_instance *world, ent_gate *gate, v3f imp_co, v3f imp_v ); -VG_STATIC void world_routes_activate_entry_gate( world_instance *world, +static void world_routes_activate_entry_gate( world_instance *world, ent_gate *rg ); -VG_STATIC void render_world_routes( world_instance *world, camera *cam, +static void render_world_routes( world_instance *world, camera *cam, int layer_depth ); -VG_STATIC void world_gen_routes_ent_init( world_instance *world ); -VG_STATIC void world_gen_routes_generate( u32 instance_id ); -VG_STATIC void world_routes_update_timer_texts( world_instance *world ); -VG_STATIC void world_routes_update( world_instance *world ); -VG_STATIC void world_routes_fixedupdate( world_instance *world ); +static void world_gen_routes_ent_init( world_instance *world ); +static void world_gen_routes_generate( u32 instance_id ); +static void world_routes_update_timer_texts( world_instance *world ); +static void world_routes_update( world_instance *world ); +static void world_routes_fixedupdate( world_instance *world ); #endif /* ROUTES_H */ diff --git a/world_sfd.c b/world_sfd.c index a5ba3f6..d960b0d 100644 --- a/world_sfd.c +++ b/world_sfd.c @@ -39,7 +39,7 @@ static f32 sfd_encode_glyph( char c ) return (float)value; } -VG_STATIC void sfd_encode( u32 row, const char *str ) +static void sfd_encode( u32 row, const char *str ) { int end=0; u32 row_h = world_sfd.h -1 -row; @@ -59,7 +59,7 @@ VG_STATIC void sfd_encode( u32 row, const char *str ) } } -VG_STATIC void world_sfd_update( world_instance *world, v3f pos ){ +static void world_sfd_update( world_instance *world, v3f pos ){ if( mdl_arrcount( &world->ent_route ) ){ u32 closest = 0; float min_dist = INFINITY; @@ -113,8 +113,8 @@ VG_STATIC void world_sfd_update( world_instance *world, v3f pos ){ } } -VG_STATIC void bind_terrain_noise(void); -VG_STATIC void sfd_render( world_instance *world, camera *cam, m4x3f transform ) +static void bind_terrain_noise(void); +static void sfd_render( world_instance *world, camera *cam, m4x3f transform ) { mesh_bind( &world_sfd.mesh_display ); shader_scene_scoretext_use(); @@ -173,7 +173,7 @@ VG_STATIC void sfd_render( world_instance *world, camera *cam, m4x3f transform ) mdl_draw_submesh( &world_sfd.sm_base ); } -VG_STATIC int world_sfd_test( int argc, const char *argv[] ) +static int world_sfd_test( int argc, const char *argv[] ) { if( argc == 2 ){ int row = vg_min( vg_max(atoi(argv[0]),0), world_sfd.h); @@ -183,7 +183,7 @@ VG_STATIC int world_sfd_test( int argc, const char *argv[] ) return 0; } -VG_STATIC void world_sfd_init(void) +static void world_sfd_init(void) { vg_info( "world_sfd_init\n" ); shader_scene_scoretext_register(); diff --git a/world_sfd.h b/world_sfd.h index e49d8ff..9049cc2 100644 --- a/world_sfd.h +++ b/world_sfd.h @@ -19,9 +19,9 @@ struct world_sfd{ float *buffer; } static world_sfd; -VG_STATIC void world_sfd_init(void); +static void world_sfd_init(void); -VG_STATIC void sfd_render( world_instance *world, camera *cam, +static void sfd_render( world_instance *world, camera *cam, m4x3f transform ); #endif /* SFD_H */ diff --git a/world_water.c b/world_water.c index fca3972..87b5a62 100644 --- a/world_water.c +++ b/world_water.c @@ -12,7 +12,7 @@ #include "shaders/scene_water_fast.h" #include "scene.h" -VG_STATIC void world_water_init(void) +static void world_water_init(void) { vg_info( "world_water_init\n" ); shader_scene_water_register(); @@ -25,27 +25,27 @@ VG_STATIC void world_water_init(void) vg_success( "done\n" ); } -VG_STATIC void water_set_surface( world_instance *world, float height ) +static void water_set_surface( world_instance *world, float height ) { world->water.height = height; v4_copy( (v4f){ 0.0f, 1.0f, 0.0f, height }, world->water.plane ); } -VG_STATIC void world_link_lighting_ub( world_instance *world, GLuint shader ); -VG_STATIC void world_bind_position_texture( world_instance *world, +static void world_link_lighting_ub( world_instance *world, GLuint shader ); +static void world_bind_position_texture( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void world_bind_light_array( world_instance *world, +static void world_bind_light_array( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void world_bind_light_index( world_instance *world, +static void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ); /* * Does not write motion vectors */ -VG_STATIC void render_water_texture( world_instance *world, camera *cam, +static void render_water_texture( world_instance *world, camera *cam, int layer_depth ) { if( !world->water.enabled || (vg.quality_profile == k_quality_profile_low) ) @@ -121,7 +121,7 @@ VG_STATIC void render_water_texture( world_instance *world, camera *cam, //glViewport( 0,0, g_render_x, g_render_y ); } -VG_STATIC void render_water_surface( world_instance *world, camera *cam ) +static void render_water_surface( world_instance *world, camera *cam ) { if( !world->water.enabled ) return; diff --git a/world_water.h b/world_water.h index ae7a696..6681460 100644 --- a/world_water.h +++ b/world_water.h @@ -11,11 +11,11 @@ struct world_water{ GLuint tex_water_surf; } static world_water; -VG_STATIC void world_water_init(void); +static void world_water_init(void); -VG_STATIC void water_set_surface( world_instance *world, float height ); -VG_STATIC void render_water_texture( world_instance *world, camera *cam, +static void water_set_surface( world_instance *world, float height ); +static void render_water_texture( world_instance *world, camera *cam, int layer_depth ); -VG_STATIC void render_water_surface( world_instance *world, camera *cam ); +static void render_water_surface( world_instance *world, camera *cam ); #endif /* WATER_H */ -- 2.25.1