X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_render.c;h=04db5a008a123f8314a8447272c88c8007ebaaf7;hb=bdd98e4458be4a143cd415e5077b373129b1b0d9;hp=b63d8a78d2198e14b11ece4c41845ede50bf428a;hpb=43dc3602effdf0af4f22ce78c0e76565c0be03e6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_render.c b/world_render.c index b63d8a7..04db5a0 100644 --- a/world_render.c +++ b/world_render.c @@ -12,6 +12,7 @@ #include "respawn.h" #include "ent_miniworld.h" #include "player_remote.h" +#include "ent_skateshop.h" static int ccmd_set_time( int argc, const char *argv[] ){ world_instance *world = world_current_instance(); @@ -278,18 +279,25 @@ void world_render_both_stages( world_instance *world, struct world_pass *pass ) glEnable( GL_CULL_FACE ); } +static GLuint world_get_texture( world_instance *world, u32 id ){ + if( id & 0x80000000 ) + return skaterift.rt_textures[id & ~0x80000000]; + else + return world->textures[ id ]; +} + static void bindpoint_diffuse_texture1( world_instance *world, - struct world_surface *mat ) - -{ + struct world_surface *mat ){ glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, world->textures[ mat->info.tex_diffuse ] ); + glBindTexture( GL_TEXTURE_2D, + world_get_texture(world,mat->info.tex_diffuse) ); } 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 ] ); + glBindTexture( GL_TEXTURE_2D, + world_get_texture(world,mat->info.tex_diffuse) ); u32 cubemap_id = mat->info.tex_none0, cubemap_index = 0; @@ -645,7 +653,8 @@ static void bindpoint_terrain( world_instance *world, struct world_surface *mat ) { glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, world->textures[ mat->info.tex_diffuse ] ); + glBindTexture( GL_TEXTURE_2D, + world_get_texture(world,mat->info.tex_diffuse) ); shader_scene_terrain_uSandColour( mat->info.colour ); shader_scene_terrain_uBlendOffset( mat->info.colour1 ); @@ -658,7 +667,8 @@ static void bindpoint_override( world_instance *world, } else{ glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, world->textures[ mat->info.tex_diffuse ] ); + glBindTexture( GL_TEXTURE_2D, + world_get_texture(world,mat->info.tex_diffuse) ); shader_scene_override_uAlphatest(1); } } @@ -762,9 +772,7 @@ static void render_world_gates( world_instance *world, camera *cam ){ for( u32 i=0; ient_gate); i++ ){ ent_gate *gi = mdl_arritm( &world->ent_gate, i ); - - if( !(gi->flags & (k_ent_gate_linked|k_ent_gate_nonlocal_DELETED| - k_ent_gate_locked)) ) + if( !(gi->flags & k_ent_gate_linked) ) continue; float dist = v3_dist2( gi->co[0], cam->transform[3] ); @@ -778,8 +786,25 @@ static void render_world_gates( world_instance *world, camera *cam ){ } world->rendering_gate = gate; - if( gate ) - render_gate( world, world, gate, cam ); + + if( gate ){ + if( gate->flags & k_ent_gate_locked ){ + world->rendering_gate = NULL; + return; + } + + if( gate->flags & k_ent_gate_nonlocal ){ + if( world_static.load_state != k_world_loader_none ){ + world->rendering_gate = NULL; + return; + } + + world_instance *dest_world = &world_static.instances[ gate->target ]; + render_gate( world, dest_world, gate, cam ); + } + else + render_gate( world, world, gate, cam ); + } } static void world_prerender( world_instance *world ){ @@ -798,11 +823,7 @@ static void world_prerender( world_instance *world ){ state->g_debug_indices = k_debug_light_indices; state->g_light_preview = k_light_preview; state->g_debug_complexity = k_debug_light_complexity; - - if( skaterift.activity == k_skaterift_respawning ) - state->g_time_of_day = 0.1f; - else - state->g_time_of_day = vg_fractf( world->time ); + state->g_time_of_day = vg_fractf( world->time ); state->g_day_phase = cosf( state->g_time_of_day * VG_PIf * 2.0f ); state->g_sunset_phase= cosf( state->g_time_of_day * VG_PIf * 4.0f + VG_PIf ); @@ -963,7 +984,8 @@ static void render_world_override_pass( world_instance *world, static void render_world_override( world_instance *world, world_instance *lighting_source, m4x3f mmdl, - camera *cam ){ + camera *cam, + ent_spawn *dest_spawn, v4f map_info ){ struct world_pass pass = { .cam = cam, .fn_bind_textures = bindpoint_override, @@ -974,12 +996,10 @@ static void render_world_override( world_instance *world, }; shader_scene_override_use(); -#if 0 - respawn_chooser_shader_uniforms(); -#endif shader_scene_override_uTexGarbage(0); shader_scene_override_uTexMain(1); shader_scene_override_uPv( pass.cam->mtx.pv ); + shader_scene_override_uMapInfo( map_info ); WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( lighting_source, scene_override ); bind_terrain_noise(); @@ -1003,13 +1023,10 @@ static void render_world_override( world_instance *world, v3_copy( world->player_co, uPlayerPos ); - m4x3f mmdl_inv; - m4x3_invert_full( mmdl, mmdl_inv ); - v3f localized; - m4x3_mulv( mmdl_inv, localplayer.rb.co, localized ); - ent_spawn *spawn = world_find_closest_spawn( world, localized ); - if( spawn ) - v3_copy( spawn->transform.co, uSpawnPos ); + if( dest_spawn && (v3_dist2(dest_spawn->transform.co,uPlayerPos) > 0.1f) ) + v3_copy( dest_spawn->transform.co, uSpawnPos ); + else + v3_add( uPlayerPos, (v3f){0,-1,0}, uSpawnPos ); uPlayerPos[3] = v3_dist(uPlayerPos,uSpawnPos); uSpawnPos[3] = 1.0f/uPlayerPos[3];