X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_render.c;fp=world_render.c;h=2355e20bf204bd942870515167bbe75d2366e502;hb=888e62fcd8f9777cee774fbb8fab2e52660303a7;hp=103304196783e864dbdd7fe8e3e9600c6d011c01;hpb=0d211bc488751a2cbc380990492ec549e91b19ca;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_render.c b/world_render.c index 1033041..2355e20 100644 --- a/world_render.c +++ b/world_render.c @@ -13,6 +13,7 @@ #include "ent_miniworld.h" #include "player_remote.h" #include "ent_skateshop.h" +#include "shaders/model_entity.h" static int ccmd_set_time( int argc, const char *argv[] ){ world_instance *world = world_current_instance(); @@ -891,6 +892,50 @@ static void world_prerender( world_instance *world ){ sizeof(struct ub_world_lighting), &world->ub_lighting ); } +static void render_other_entities( world_instance *world, camera *cam ){ + f32 radius = 40.0f; + bh_iter it; + bh_iter_init_range( 0, &it, cam->pos, radius+10.0f ); + + u32 glider_list[4], + glider_count = 0; + + i32 idx; + while( bh_next( world->entity_bh, &it, &idx ) ){ + u32 id = world->entity_list[ idx ], + type = mdl_entity_id_type( id ), + index = mdl_entity_id_id( id ); + + if( type == k_ent_glider ) { + if( glider_count < vg_list_size(glider_list) ) + glider_list[ glider_count ++ ] = index; + } + } + + shader_model_entity_use(); + shader_model_entity_uTexMain( 0 ); + shader_model_entity_uCamera( cam->transform[3] ); + shader_model_entity_uPv( cam->mtx.pv ); + + WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_entity ); + + for( u32 j=0; jent_glider, glider_list[j] ); + + if( !(glider->flags & 0x1) ) + continue; + + m4x3f mdl; + mdl_transform_m4x3( &glider->transform, mdl ); + + f32 dist = v3_dist( glider->transform.co, cam->pos ) * (1.0f/radius), + scale = vg_smoothstepf( vg_clampf( 5.0f-dist*5.0f, 0.0f,1.0f ) ); + m3x3_scalef( mdl, scale ); + + render_glider_model( cam, world, mdl, k_board_shader_entity ); + } +} + static void render_world( world_instance *world, camera *cam, int stenciled, int viewing_from_gate, int with_water, int with_cubemaps ){ @@ -987,6 +1032,7 @@ static void render_world( world_instance *world, camera *cam, } render_remote_players( world, cam ); + render_other_entities( world, cam ); ent_miniworld_render( world, cam ); if( stenciled ){