From 2673c575386c604fc2c0603dba2480eda05cf97a Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 31 Mar 2023 16:51:21 +0100 Subject: [PATCH] fixe --- blender_export.py | 26 +++++-- entity.h | 7 ++ maps_src/mp_gridmap.mdl | Bin 693952 -> 694432 bytes player.c | 2 - player.h | 2 +- player_skate.c | 63 +++------------- player_walk.c | 12 ++- player_walk.h | 2 + render.h | 4 +- shaders/common_world.glsl | 3 +- shaders/model_character_view.h | 2 +- shaders/model_sky.h | 2 +- shaders/scene_depth.h | 2 +- shaders/scene_position.h | 2 +- shaders/scene_route.h | 2 +- shaders/scene_scoretext.h | 2 +- shaders/scene_standard.h | 2 +- shaders/scene_standard_alphatest.h | 2 +- shaders/scene_terrain.h | 2 +- shaders/scene_vertex_blend.h | 2 +- shaders/scene_water.fs | 2 +- shaders/scene_water.h | 4 +- shaders/scene_water_fast.h | 2 +- skaterift.c | 3 +- skeleton.h | 2 - world.h | 3 +- world_gate.h | 2 - world_gen.h | 113 ++++------------------------- world_routes.h | 2 - world_water.h | 4 + 30 files changed, 88 insertions(+), 190 deletions(-) diff --git a/blender_export.py b/blender_export.py index 8b04a20..07179e7 100644 --- a/blender_export.py +++ b/blender_export.py @@ -196,6 +196,14 @@ class ent_route(Structure): ("latest_pass",c_double)] #} +class ent_water(Structure): +#{ + _fields_ = [("transform",mdl_transform), + ("max_dist",c_float), + ("reserved0",c_uint32), + ("reserved1",c_uint32)] +#} + def obj_ent_type( obj ): #{ if obj.type == 'ARMATURE': return 'mdl_armature' @@ -366,9 +374,6 @@ def material_info(mat): _graph_read( from_node_def, from_node, depth+1 ) #} - - # No definition! :( - # TODO: Make a warning for this? #} else:#{ if "default" in link_def:#{ @@ -430,8 +435,6 @@ def sr_compile_material( mat ): if mat.name in sr_compile.material_cache: return sr_compile.material_cache[mat.name] - print( "\n"+ mat.name+"\n" ) - index = (len(sr_compile.material_data)//sizeof(mdl_material))+1 sr_compile.material_cache[mat.name] = index @@ -1080,7 +1083,7 @@ def sr_compile( collection ): elif ent_type == 'ent_route': #{ obj_data = obj.SR_data.ent_route[0] route = ent_route() - route.pstr_name = sr_compile_string( obj_data.alias ) #TODO + route.pstr_name = sr_compile_string( obj_data.alias ) route.checkpoints_start = checkpoint_count route.checkpoints_count = 0 @@ -1144,6 +1147,12 @@ def sr_compile( collection ): rn.co[2] = -obj.location[1] sr_ent_push( rn ) #} + elif ent_type == 'ent_water':#{ + water = ent_water() + compile_obj_transform( obj, water.transform ) + water.max_dist = 0.0 + sr_ent_push( water ) + #} #} #} @@ -1518,7 +1527,7 @@ class SR_MATERIAL_PANEL(bpy.types.Panel): def sr_get_type_enum( scene, context ): #{ items = [('none','None',"")] - mesh_entities=['ent_gate'] + mesh_entities=['ent_gate','ent_water'] point_entities=['ent_spawn','ent_route_node','ent_route'] for e in point_entities: items += [(e,e,'')] @@ -1665,7 +1674,8 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup): ('ent_gate','Gate','', 1), ('ent_spawn','Spawn','', 2), ('ent_route_node', 'Route Node', '', 3 ), - ('ent_route', 'Route', '', 4)], + ('ent_route', 'Route', '', 4), + ('ent_water', 'Water Surface', '', 5)], update=sr_on_type_change ) #} diff --git a/entity.h b/entity.h index 3215a69..2c70b82 100644 --- a/entity.h +++ b/entity.h @@ -10,6 +10,7 @@ typedef struct ent_route_node ent_route_node; typedef struct ent_path_index ent_path_index; typedef struct ent_checkpoint ent_checkpoint; typedef struct ent_route ent_route; +typedef struct ent_water ent_water; struct ent_spawn{ mdl_transform transform; @@ -102,4 +103,10 @@ struct ent_route{ double latest_pass; }; +struct ent_water{ + mdl_transform transform; + float max_dist; + u32 reserved0, reserved1; +}; + #endif /* ENTITY_H */ diff --git a/maps_src/mp_gridmap.mdl b/maps_src/mp_gridmap.mdl index f20740e41ecf73329e5bb8a195f135ca7e82a996..726aaa877c4142926691c5b4701ff79d4f644f02 100644 GIT binary patch delta 1873 zcmZ8h3rv$&6u#$g|H7}lCMpP4iB4fWo#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PeqCzlRT=Kox;I@V4FGy+subsystem ]( player, &res ); - /* TODO: eventually, blending code goes here */ - m4x3f transform; q_m3x3( res.root_q, transform ); v3_copy( res.root_co, transform[3] ); diff --git a/player.h b/player.h index 1c02a4e..65f8241 100644 --- a/player.h +++ b/player.h @@ -121,7 +121,7 @@ void (*_player_bind[])( player_instance *player ) = VG_STATIC void (*_player_reset[])( player_instance *player, ent_spawn *rp ) = { - NULL, + player__walk_reset, player__skate_reset, NULL }; diff --git a/player_skate.c b/player_skate.c index b372aa2..bfccb61 100644 --- a/player_skate.c +++ b/player_skate.c @@ -345,42 +345,6 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player, return valid_count; } -#if 0 -VG_STATIC -int create_jump_for_target( world_instance *world, player_instance *player, - v3f target, float max_angle, jump_info *jump ) -{ - - if( fabsf(a0-a) > fabsf(a1-a) ) - a0 = a1; - - if( fabsf(a0-a) > max_angle ) - return 0; - - /* TODO: sweep the path before chosing the smallest dist */ - - -#if 0 - /* add a trace */ - for( int i=0; i<=20; i++ ) - { - float t = (float)i * (1.0f/20.0f) * p->land_dist; - - v3f p0; - v3_muls( p->v, t, p0 ); - v3_muladds( p0, player->basis[1], -0.5f * p->gravity * t*t, p0 ); - - v3_add( player->rb.co, p0, p->log[ p->log_length ++ ] ); - } -#endif - - return 1; - } - else - return 0; -} -#endif - VG_STATIC void player__approximate_best_trajectory( player_instance *player ) { @@ -464,7 +428,7 @@ void player__approximate_best_trajectory( player_instance *player ) if( grind_located ) search_for_grind = 0; if( launch_vy - gravity*t > 0.0f ) search_for_grind = 0; - /* TODO Cleanup */ + /* REFACTOR */ v3f closest; if( search_for_grind ){ @@ -589,8 +553,7 @@ void player__approximate_best_trajectory( player_instance *player ) create_jumps_to_hit_target( player, grind_jumps, grind.co, 0.175f*VG_PIf, grind_located_gravity ); - /* knock out original landing points in the 1m area - * TODO: Make this a konstant */ + /* knock out original landing points in the 1m area */ for( u32 j=0; jpossible_jump_count; j++ ){ jump_info *jump = &s->possible_jumps[ j ]; float dist = v3_dist2( jump->log[jump->log_length-1], grind.co ); @@ -615,8 +578,9 @@ void player__approximate_best_trajectory( player_instance *player ) v3_muladds( co0, basis[1], -0.5f * jump->gravity * t*t, co0 ); v3_add( launch_co, co0, co0 ); -#if 0 /* rough scan to make sure we dont collide with anything */ + /* NOTE this was rarely needed and ends up with false negatives. */ +#if 0 for( int j=1; j<=16; j++ ){ t = (float)j*(1.0f/16.0f); t *= 0.9f; @@ -1031,8 +995,6 @@ VG_STATIC void skate_apply_pump_model( player_instance *player ) } /* Throw / collect routine - * - * TODO: Max speed boost */ if( player->input_grab->axis.value > 0.5f ){ if( s->state.activity == k_skate_activity_ground ){ @@ -1293,7 +1255,7 @@ VG_STATIC void player__skate_post_update( player_instance *player ) audio_clip *relevant_samples[] = { &audio_board[0], - &audio_board[0], /* TODO? */ + &audio_board[0], &audio_board[7], &audio_board[6], &audio_board[5] @@ -1498,8 +1460,6 @@ VG_STATIC void skate_weight_distribute( player_instance *player ) (float)s->state.manual_direction; } - /* TODO: Fall back on land normal */ - /* TODO: Lerp weight distribution */ if( s->state.manual_direction ){ v3f plane_z; @@ -1569,7 +1529,6 @@ VG_STATIC int skate_point_visible( v3f origin, v3f target ) VG_STATIC void skate_grind_orient( struct grind_info *inf, m3x3f mtx ) { - /* TODO: Is N and Dir really orthogonal? */ v3_copy( inf->dir, mtx[0] ); v3_copy( inf->n, mtx[1] ); v3_cross( mtx[0], mtx[1], mtx[2] ); @@ -1610,7 +1569,7 @@ VG_STATIC void skate_grind_truck_apply( player_instance *player, { struct player_skate *s = &player->_skate; - /* TODO: Trash compactor this */ + /* REFACTOR */ v3f ra = { 0.0f, -k_board_radius, sign * k_board_length }; v3f raw, wsp; m3x3_mulv( player->rb.to_world, ra, raw ); @@ -1797,7 +1756,7 @@ VG_STATIC int skate_grind_truck_entry( player_instance *player, float sign, { struct player_skate *s = &player->_skate; - /* TODO: Trash compactor this */ + /* REFACTOR */ v3f ra = { 0.0f, -k_board_radius, sign * k_board_length }; v3f raw, wsp; @@ -1943,8 +1902,7 @@ VG_STATIC int skate_boardslide_renew( player_instance *player, if( !skate_point_visible( vis, inf->co ) ) return 0; - /* Exit condition: minimum velocity not reached, but allow a bit of error - * TODO: trash compactor */ + /* Exit condition: minimum velocity not reached, but allow a bit of error */ float dv = fabsf(v3_dot( player->rb.v, inf->dir )), minv = k_grind_axel_min_vel*0.8f; @@ -1978,6 +1936,10 @@ VG_STATIC enum skate_activity skate_availible_grind( player_instance *player ) { struct player_skate *s = &player->_skate; + if( s->grind_cooldown > 100 ){ + vg_fatal_exit_loop( "wth!\n" ); + } + /* debounces this state manager a little bit */ if( s->grind_cooldown ){ s->grind_cooldown --; @@ -2837,7 +2799,6 @@ VG_STATIC void player__skate_animate( player_instance *player, mdl_keyframe grind_pose[32]; { - /* TODO: factor balance into this sampler */ float grind_frame = 0.5f; if( s->state.activity == k_skate_activity_grind_front50 ){ diff --git a/player_walk.c b/player_walk.c index 75e3a37..e39c819 100644 --- a/player_walk.c +++ b/player_walk.c @@ -855,8 +855,7 @@ VG_STATIC void player__walk_im_gui( player_instance *player ) "metal" } [w->surface] ); - if( w->state.outro_anim ) - { + if( w->state.outro_anim ){ float outro_length = (float)w->state.outro_anim->length / w->state.outro_anim->rate, outro_time = vg.time - w->state.outro_start_time; @@ -895,4 +894,13 @@ VG_STATIC void player__walk_transition( player_instance *player, v3f angles ) rb_update_transform( &player->rb ); } +VG_STATIC void player__walk_reset( player_instance *player, 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_anim = NULL; + w->state.outro_start_time = 0.0; +} + #endif /* PLAYER_DEVICE_WALK_H */ diff --git a/player_walk.h b/player_walk.h index fc26280..465a581 100644 --- a/player_walk.h +++ b/player_walk.h @@ -66,5 +66,7 @@ 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, v3f angles ); +VG_STATIC void player__walk_reset ( player_instance *player, + ent_spawn *rp ); #endif /* PLAYER_WALK_H */ diff --git a/render.h b/render.h index f17018b..e7220b0 100644 --- a/render.h +++ b/render.h @@ -158,7 +158,7 @@ framebuffers[] = */ "water_reflection", .link = &gpipeline.fb_water_reflection, - .resolution_div = 3, + .resolution_div = 2, .attachments = { { @@ -183,7 +183,7 @@ framebuffers[] = */ "water_beneath", .link = &gpipeline.fb_water_beneath, - .resolution_div = 4, + .resolution_div = 2, .attachments = { { diff --git a/shaders/common_world.glsl b/shaders/common_world.glsl index 5c06d73..2b70885 100644 --- a/shaders/common_world.glsl +++ b/shaders/common_world.glsl @@ -48,9 +48,8 @@ float world_depth_sample( vec3 pos ) float world_water_depth( vec3 pos ) { - vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; float ref_depth = g_water_plane.y*g_water_plane.w; - return texture( g_world_depth, depth_coord ).g - ref_depth; + return world_depth_sample( pos ) - ref_depth; } float shadow_sample( vec3 vdir ) diff --git a/shaders/model_character_view.h b/shaders/model_character_view.h index 23cba25..d7e6901 100644 --- a/shaders/model_character_view.h +++ b/shaders/model_character_view.h @@ -214,7 +214,7 @@ static struct vg_shader _shader_model_character_view = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/model_sky.h b/shaders/model_sky.h index 2ddc5bd..d549831 100644 --- a/shaders/model_sky.h +++ b/shaders/model_sky.h @@ -208,7 +208,7 @@ static struct vg_shader _shader_model_sky = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_depth.h b/shaders/scene_depth.h index 0a88b46..8e836e4 100644 --- a/shaders/scene_depth.h +++ b/shaders/scene_depth.h @@ -207,7 +207,7 @@ static struct vg_shader _shader_scene_depth = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_position.h b/shaders/scene_position.h index b3bf28f..8f902a1 100644 --- a/shaders/scene_position.h +++ b/shaders/scene_position.h @@ -207,7 +207,7 @@ static struct vg_shader _shader_scene_position = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_route.h b/shaders/scene_route.h index 3f41eca..4fe92e0 100644 --- a/shaders/scene_route.h +++ b/shaders/scene_route.h @@ -208,7 +208,7 @@ static struct vg_shader _shader_scene_route = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_scoretext.h b/shaders/scene_scoretext.h index 417cc2a..8b04293 100644 --- a/shaders/scene_scoretext.h +++ b/shaders/scene_scoretext.h @@ -228,7 +228,7 @@ static struct vg_shader _shader_scene_scoretext = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_standard.h b/shaders/scene_standard.h index 656498d..994f7f3 100644 --- a/shaders/scene_standard.h +++ b/shaders/scene_standard.h @@ -208,7 +208,7 @@ static struct vg_shader _shader_scene_standard = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_standard_alphatest.h b/shaders/scene_standard_alphatest.h index 74b36f6..d2d6e08 100644 --- a/shaders/scene_standard_alphatest.h +++ b/shaders/scene_standard_alphatest.h @@ -208,7 +208,7 @@ static struct vg_shader _shader_scene_standard_alphatest = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_terrain.h b/shaders/scene_terrain.h index 2027fd2..6befad3 100644 --- a/shaders/scene_terrain.h +++ b/shaders/scene_terrain.h @@ -209,7 +209,7 @@ static struct vg_shader _shader_scene_terrain = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_vertex_blend.h b/shaders/scene_vertex_blend.h index b350fda..6bfb882 100644 --- a/shaders/scene_vertex_blend.h +++ b/shaders/scene_vertex_blend.h @@ -207,7 +207,7 @@ static struct vg_shader _shader_scene_vertex_blend = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/shaders/scene_water.fs b/shaders/scene_water.fs index c40e246..22aa665 100644 --- a/shaders/scene_water.fs +++ b/shaders/scene_water.fs @@ -44,7 +44,7 @@ void main() vec2 ssuv = gl_FragCoord.xy*uInvRes; // Surface colour composite - float depthvalue = clamp( -world_water_depth( aCo )*(1.0/25.0), 0.0, 1.0 ); + float depthvalue = clamp( -world_water_depth(aCo)*(1.0/25.0), 0.0,1.0 ); vec2 world_coord = aCo.xz * 0.008; vec4 time_offsets = vec4( uTime ) * vec4( 0.008, 0.006, 0.003, 0.03 ); diff --git a/shaders/scene_water.h b/shaders/scene_water.h index 5d4a5d2..f36b34e 100644 --- a/shaders/scene_water.h +++ b/shaders/scene_water.h @@ -215,7 +215,7 @@ static struct vg_shader _shader_scene_water = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" @@ -462,7 +462,7 @@ static struct vg_shader _shader_scene_water = { " vec2 ssuv = gl_FragCoord.xy*uInvRes;\n" " \n" " // Surface colour composite\n" -" float depthvalue = clamp( -world_water_depth( aCo )*(1.0/25.0), 0.0, 1.0 );\n" +" float depthvalue = clamp( -world_water_depth(aWorldCo)*(1.0/25.0), 0.0,1.0 );\n" "\n" " vec2 world_coord = aCo.xz * 0.008;\n" " vec4 time_offsets = vec4( uTime ) * vec4( 0.008, 0.006, 0.003, 0.03 );\n" diff --git a/shaders/scene_water_fast.h b/shaders/scene_water_fast.h index b02f8ca..5d3b534 100644 --- a/shaders/scene_water_fast.h +++ b/shaders/scene_water_fast.h @@ -212,7 +212,7 @@ static struct vg_shader _shader_scene_water_fast = { "{\n" " vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n" " float ref_depth = g_water_plane.y*g_water_plane.w;\n" -" return texture( g_world_depth, depth_coord ).g - ref_depth;\n" +" return texture( g_world_depth, depth_coord ).g-ref_depth;\n" "}\n" "\n" "float shadow_sample( vec3 vdir )\n" diff --git a/skaterift.c b/skaterift.c index 8e7b738..67e87cc 100644 --- a/skaterift.c +++ b/skaterift.c @@ -512,7 +512,6 @@ VG_STATIC void render_scene(void) if( !player_transparent && player_draw ) player__render( &main_camera, &localplayer ); - render_water_texture( view_world, &main_camera, 0 ); render_fb_bind( gpipeline.fb_main ); render_water_surface( view_world, &main_camera ); @@ -611,7 +610,7 @@ VG_STATIC void vg_render(void) /* Other shite */ glDisable(GL_BLEND); - glDisable( GL_DEPTH_TEST ); + glDisable(GL_DEPTH_TEST); vg_lines_drawall(); glViewport( 0,0, vg.window_x, vg.window_y ); } diff --git a/skeleton.h b/skeleton.h index 0332a60..2595cda 100644 --- a/skeleton.h +++ b/skeleton.h @@ -475,8 +475,6 @@ VG_STATIC void skeleton_setup( struct skeleton *skele, sb->collider = bone->collider; sb->orig_bone = bone; - vg_info( "orig: %u\n", bone->collider ); - if( sb->flags & k_bone_flag_ik ){ skele->bones[ sb->parent ].flags |= k_bone_flag_ik; diff --git a/world.h b/world.h index 9883b29..80bf3b6 100644 --- a/world.h +++ b/world.h @@ -154,7 +154,8 @@ struct world_instance ent_route_node, ent_path_index, ent_checkpoint, - ent_route; + ent_route, + ent_water; ent_gate *rendering_gate; diff --git a/world_gate.h b/world_gate.h index 93322aa..2febafa 100644 --- a/world_gate.h +++ b/world_gate.h @@ -130,8 +130,6 @@ VG_STATIC int render_gate( world_instance *world_inside, shader_model_gate_uPv( cam->mtx.pv ); shader_model_gate_uMdl( gate->to_world ); shader_model_gate_uCam( cam->pos ); - - /* TODO(ART IMPROVEMENT): animate alpha of this? */ shader_model_gate_uColour( (v4f){0.0f,1.0f,0.0f,0.0f} ); shader_model_gate_uTime( vg.time*0.25f ); shader_model_gate_uInvRes( (v2f){ diff --git a/world_gen.h b/world_gen.h index b35c6c2..5120bd7 100644 --- a/world_gen.h +++ b/world_gen.h @@ -126,92 +126,6 @@ VG_STATIC void world_apply_procedural_foliage( world_instance *world, vg_info( "%d foliage models added\n", count ); } -#if 0 -VG_STATIC void world_ents_allocate( world_instance *world ) -{ - vg_info( "Allocating entities\n" ); - - /* --count entites to allocate buffers for them.-- - * --maybe in the future we just store these numbers in the model file...-- - * - * ... 16.03.23: I HOPE YOUR FUCKING HAPPY - * ... 22.03.23: incomprehensible pain - * - * -- use this in world_routes too -- - * - */ - - struct countable - { - enum classtype ct, ct1; - void **to_allocate; - u32 item_size; - int count; - } - entity_counts[] = - { - { - k_classtype_spawn, - k_classtype_none, - (void*)&world->spawns, - sizeof(struct respawn_point) - }, - { - k_classtype_audio, - k_classtype_none, - (void*)&world->audio_things, - sizeof(struct world_audio_thing) - }, - { - k_classtype_world_light, - k_classtype_none, - (void*)&world->lights, - sizeof(struct world_light) - }, - { - k_classtype_nonlocal_gate, - k_classtype_none, - (void*)&world->nonlocal_gates, - sizeof(struct nonlocal_gate) - }, - }; - - for( int i=0; imeta->info.node_count; i++ ) - { - mdl_node *pnode = mdl_node_from_id( world->meta, i ); - - for( int j=0; jclasstype == entity_counts[j].ct) || - (pnode->classtype == entity_counts[j].ct1) ) - { - pnode->sub_uid = entity_counts[j].count; - entity_counts[j].count ++; - break; - } - } - } - - for( int i=0; iitem_size*counter->count; - *counter->to_allocate = vg_linear_alloc( world_global.generic_heap, - bufsize ); - memset( *counter->to_allocate, 0, bufsize ); - } - - world->volume_bh = bh_create( world_global.generic_heap, - &bh_system_volumes, - world, - world->volume_count, - 1 ); -} -#endif #if 0 VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode ) @@ -223,19 +137,6 @@ VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode ) rp->name = mdl_pstr( world->meta, pnode->pstr_name ); } -VG_STATIC void world_pct_water( world_instance *world, mdl_node *pnode ) -{ - if( world->water.enabled ) - { - vg_warn( "Multiple water surfaces in level! ('%s')\n", - mdl_pstr( world->meta, pnode->pstr_name )); - return; - } - - world->water.enabled = 1; - water_set_surface( world, pnode->co[1] ); -} - VG_STATIC void world_pct_audio( world_instance *world, mdl_node *pnode ) { struct world_audio_thing *thing = &world->audio_things[ @@ -974,6 +875,18 @@ VG_STATIC void world_entities_init( world_instance *world ) ent_gate *gate = mdl_arritm( &world->ent_gate, j ); gate_transform_update( gate ); } + + /* water */ + for( u32 j=0; jent_water); j++ ){ + ent_water *water = mdl_arritm( &world->ent_water, j ); + if( world->water.enabled ){ + vg_warn( "Multiple water surfaces in level!\n" ); + break; + } + + world->water.enabled = 1; + water_set_surface( world, water->transform.co[1] ); + } } VG_STATIC void world_load( world_instance *world, const char *path ) @@ -1004,6 +917,8 @@ VG_STATIC void world_load( world_instance *world, const char *path ) "ent_checkpoint", world_global.generic_heap ); mdl_load_array( &world->meta, &world->ent_route, "ent_route", world_global.generic_heap ); + mdl_load_array( &world->meta, &world->ent_water, + "ent_water", world_global.generic_heap ); mdl_close( &world->meta ); diff --git a/world_routes.h b/world_routes.h index 5862657..f8a566c 100644 --- a/world_routes.h +++ b/world_routes.h @@ -612,8 +612,6 @@ VG_STATIC void render_world_routes( world_instance *world, camera *cam, mesh_bind( &world_global.mesh_gate ); /* skip writing into the motion vectors for this */ - /* TODO: draw future gate if the one we're looking through is to be passed, - * instead of current gate */ glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } ); for( u32 i=0; ient_route); i++ ){ diff --git a/world_water.h b/world_water.h index f44d265..5dd1b91 100644 --- a/world_water.h +++ b/world_water.h @@ -91,6 +91,8 @@ VG_STATIC void render_water_texture( world_instance *world, camera *cam, /* * Draw world */ + glEnable( GL_DEPTH_TEST ); + glDisable( GL_BLEND ); glCullFace( GL_FRONT ); render_world( world, &water_cam, layer_depth ); glCullFace( GL_BACK ); @@ -116,6 +118,8 @@ VG_STATIC void render_water_texture( world_instance *world, camera *cam, m4x4_clip_projection( beneath_cam.mtx.p, clippb ); camera_finalize( &beneath_cam ); + glEnable( GL_DEPTH_TEST ); + glDisable( GL_BLEND ); render_world_depth( world, &beneath_cam ); glViewport( 0, 0, vg.window_x, vg.window_y ); } -- 2.25.1