X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_remote.c;h=3c5614a1a5c0b6e203cdf199b4482e7f87e97278;hb=1b889e55df5f9c0a8a26daba03ffa21754d78230;hp=7a85910d2781edd3a03c45bddd0ccaf26aa557e0;hpb=4fa9aa9a1e09940e91cc30e171e3de0606515ef3;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_remote.c b/player_remote.c index 7a85910..3c5614a 100644 --- a/player_remote.c +++ b/player_remote.c @@ -517,7 +517,8 @@ static void animate_remote_player( u32 index ){ } struct network_player *player = &netplayers.list[ index ]; - player->active_world = NULL; + if( player->active != 2 ) + player->active_world = NULL; if( minframe && maxframe ){ pose_remote_player( index, minframe, maxframe ); @@ -580,12 +581,17 @@ static int remote_players_randomize( int argc, const char *argv[] ){ for( int i=0; iactive = vg_randu32() & 0x1; + player->active = (vg_randu32() & 0x1)? 2: 0; player->isfriend = vg_randu32() & vg_randu32() & 0x1; player->isblocked = vg_randu32() & vg_randu32() & vg_randu32() & 0x1; player->world_match[ 0 ] = vg_randu32() & 0x1; player->world_match[ 1 ] = 0; + if( player->world_match[0] ) + player->active_world = &world_static.instances[0]; + else + player->active_world = NULL; + for( int i=0; iusername)-1; i ++ ){ player->username[i] = 'a' + (vg_randu32() % 30); player->username[i+1] = '\0'; @@ -601,8 +607,8 @@ static int remote_players_randomize( int argc, const char *argv[] ){ v3f pos; vg_rand_sphere( pos ); - v3_muls( pos, 100.0f, - netplayers.final_mtx[ i*localplayer.skeleton.bone_count][3] ); + v3_muladds( localplayer.rb.co, pos, 100.0f, + netplayers.final_mtx[ i*localplayer.skeleton.bone_count][3] ); } return 0; @@ -631,6 +637,15 @@ static void remote_sfx_pre_update(void){ } } +/* + * animator->root_co of remote player + */ +static void remote_player_position( int id, v3f out_co ){ + struct skeleton *sk = &localplayer.skeleton; + m4x3f *final_mtx = &netplayers.final_mtx[ sk->bone_count*id ]; + v3_copy( final_mtx[0][3], out_co ); +} + enum remote_player_gui_type { k_remote_player_gui_type_stranger, k_remote_player_gui_type_friend, @@ -662,7 +677,7 @@ static void remote_player_nametag( m4x4f pv, v3f co, const char *name, wr[1] = vg_clampf((1.0f-wpos[1]) * vg.window_y, -32000.0f, 32000.0f ); wr[3] = 32; - ui_fill( wr, ui_opacity( ui_colour(k_ui_bg), 0.6f ) ); + ui_fill( wr, ui_opacity( ui_colour(k_ui_bg), 0.23f ) ); ui_text( wr, name, 1, k_ui_align_middle_center, 0 ); vg_ui.font = &vg_ui_font_small; @@ -687,7 +702,7 @@ static void remote_player_nametag( m4x4f pv, v3f co, const char *name, vg_ui.font->glyph_height }; vg_strnull( &str, buf, 32 ); - vg_strcatch( &str, (char)k_SRglyph_ps4_circle ); + vg_strcatch( &str, (char)k_SRglyph_vg_circle ); vg_strcati32( &str, medals[i] ); ui_text( col, buf, 1, k_ui_align_middle_center, @@ -765,14 +780,53 @@ static void remote_players_imgui_lobby(void){ } static void remote_players_imgui_world( world_instance *world, m4x4f pv, - f32 max_dist ){ + f32 max_dist, int geo_cull ){ + ui_flush( k_ui_shader_colour ); + for( u32 i=0; iactive ){ + v3f co; + remote_player_position( i, co ); + + if( player->active_world != world ){ + continue; + } + + f32 d2 = v3_dist2( co, localplayer.rb.co ); + + if( d2 > (max_dist*max_dist) ) + continue; + + f32 dist = sqrtf(d2); + f32 opacity = 0.95f * sqrtf(((max_dist-dist)/max_dist)); + + if( geo_cull ){ + ray_hit hit; + hit.dist = dist; + + v3f dir; + v3_sub( co, skaterift.cam.pos, dir ); + v3_normalize( dir ); + + if( ray_world( world, skaterift.cam.pos, dir, &hit, + k_material_flag_ghosts ) ){ + opacity *= 0.5f; + } + } + + player->opacity = vg_lerpf( player->opacity, opacity, + vg.time_frame_delta * 2.0f ); + remote_player_nametag( pv, netplayers.final_mtx[localplayer.skeleton.bone_count*i][3], player->username, player->isfriend, player->medals ); + + vg_ui.colour[3] = player->opacity; + ui_flush( k_ui_shader_colour ); } } + + vg_ui.colour[3] = 1.0f; }