X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_remote.c;h=c816a26d48ade3b307de9b94c1480f3992a085f9;hb=01154bc01a470dc1ccfe8c05fe6b56857a08cca9;hp=7a85910d2781edd3a03c45bddd0ccaf26aa557e0;hpb=4fa9aa9a1e09940e91cc30e171e3de0606515ef3;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_remote.c b/player_remote.c index 7a85910..c816a26 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, @@ -723,7 +738,12 @@ static void remote_player_gui_info( ui_rect box, ui_rect top, bottom; ui_split_ratio( box, k_ui_axis_h, 0.6666f, 1, top, bottom ); - u32 fg = ui_colour( in_world? k_ui_fg: k_ui_fg+4 ); + u32 fg; + + if( type == k_remote_player_gui_type_friend ) + fg = ui_colour( k_ui_yellow + (in_world? k_ui_brighter: 0) ); + else + fg = ui_colour( in_world? k_ui_fg: k_ui_fg+4 ); vg_ui.font = &vg_ui_font_big; ui_text( top, username, 1, k_ui_align_middle_center, fg ); @@ -754,25 +774,67 @@ static void remote_players_imgui_lobby(void){ for( u32 i=0; iactive || player->isblocked ) continue; + + int in_same_world = player->active_world != world_current_instance(); + + if( !player->isfriend && !in_same_world ) + continue; ui_rect box = { x, y, width, height }; - remote_player_gui_info( - box, player->username, "", - player->isfriend, - player->world_match[ world_static.active_instance ] ); + remote_player_gui_info( box, player->username, "", + player->isfriend, in_same_world ); y += height + gap; } } 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; }