X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.h;h=45003cccbe9d87afa6b4fed9c0912bfec860d454;hb=d57b7661518800479c00300ce57407378696eec9;hp=e8c47d22085b8edad828aeccdaac3082739d97a0;hpb=1c97cb161f885ad24d3356d92c8f4fd0e252bc61;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index e8c47d2..45003cc 100644 --- a/world.h +++ b/world.h @@ -14,7 +14,9 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit ); #include "bvh.h" #include "lighting.h" #include "model.h" -#include "traffic.h" + +#include "traffic.h" /*TODO: -> world_traffic.h */ +#include "world_routes.h" #include "shaders/terrain.h" #include "shaders/sky.h" @@ -23,6 +25,7 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit ); #include "shaders/vblend.h" #include "shaders/gpos.h" #include "shaders/fscolour.h" +#include "shaders/alphatest.h" static struct gworld { @@ -36,6 +39,13 @@ static struct gworld spawns[32]; u32 spawn_count; + struct subworld_routes routes; + + /* ... + struct subworld_spawns system_spawns; + struct subworld_physics system_physics; + */ + teleport_gate gates[64]; u32 gate_count; @@ -43,17 +53,18 @@ static struct gworld traffic_node traffic[128]; u32 traffic_count; +#if 0 traffic_driver van_man[6]; +#endif /* Physics */ - rigidbody temp_rbs[128]; - u32 rb_count; /* Rendering & geometry */ scene geo, foliage; rigidbody rb_geo; - mdl_submesh sm_geo_std_oob, sm_geo_std, sm_geo_vb; + mdl_submesh sm_geo_std_oob, sm_geo_std, sm_geo_vb, + sm_foliage_main, sm_foliage_alphatest; glmesh skybox, skydome; mdl_submesh dome_upper, dome_lower; @@ -76,12 +87,18 @@ static struct gworld } world; +static struct subworld_routes *subworld_routes(void) { return &world.routes; } + + vg_tex2d tex_terrain_colours = { .path = "textures/gradients.qoi", .flags = VG_TEXTURE_CLAMP|VG_TEXTURE_NEAREST }; vg_tex2d tex_terrain_noise = { .path = "textures/garbage.qoi", .flags = VG_TEXTURE_NEAREST }; +vg_tex2d tex_alphatest = { .path = "textures/alphatest.qoi", + .flags = VG_TEXTURE_NEAREST }; + static void ray_world_get_tri( ray_hit *hit, v3f tri[3] ) { for( int i=0; i<3; i++ ) @@ -105,6 +122,7 @@ static void world_register(void) shader_planeinf_register(); shader_gpos_register(); shader_fscolour_register(); + shader_alphatest_register(); } static void world_free(void) @@ -153,9 +171,8 @@ static void add_all_if_material( m4x3f transform, scene *pscene, } } -static void world_apply_foliage(void) +static void world_apply_procedural_foliage(void) { - scene_init( &world.foliage ); mdl_header *mfoliage = mdl_load("models/rs_foliage.mdl"); v3f volume; @@ -197,8 +214,6 @@ static void world_apply_foliage(void) } } } - - scene_upload( &world.foliage ); free( mfoliage ); } @@ -208,7 +223,6 @@ static void world_load(void) world.spawn_count = 0; world.gate_count = 0; - world.rb_count = 0; world.traffic_count = 0; world.instance_cache = NULL; @@ -221,6 +235,7 @@ static void world_load(void) if( pnode->classtype == k_classtype_none ) {} +#if 0 else if( pnode->classtype == k_classtype_gate ) { struct classtype_gate *entgate = mdl_get_entdata( mworld, pnode ); @@ -240,21 +255,7 @@ static void world_load(void) gate_transform_update( gate ); } } - else if( pnode->classtype == k_classtype_block ) - { - struct classtype_block *block = mdl_get_entdata( mworld, pnode ); - - m4x3f transform; - mdl_node_transform( pnode, transform ); - - rigidbody *rb = &world.temp_rbs[ world.rb_count ++ ]; - - box_copy( block->bbx, rb->bbx ); /* TODO: apply scale */ - v3_copy( pnode->co, rb->co ); - rb_init( rb ); - v4_copy( pnode->q, rb->q ); - rb_update_transform( rb ); - } +#endif else if( pnode->classtype == k_classtype_spawn ) { struct respawn_point *rp = &world.spawns[ world.spawn_count ++ ]; @@ -345,15 +346,17 @@ static void world_load(void) } } } - + world.instance_cache = buffer_fix( world.instance_cache, world.instance_cache_count, &world.instance_cache_cap, sizeof( struct instance_cache ) ); +#if 0 traffic_finalize( world.traffic, world.traffic_count ); for( int i=0; imaterial_count; i++ ) { @@ -375,11 +379,10 @@ static void world_load(void) mat_surf_oob = i; else if( !strcmp( "vertex_blend", mat_name )) mat_vertex_blend = i; + else if( !strcmp( "alphatest", mat_name )) + mat_alphatest = i; } - vg_info( "surf %d\noob %d\nvert_blend %d\n", mat_surf, mat_surf_oob, - mat_vertex_blend ); - m4x3f midentity; m4x3_identity( midentity ); @@ -400,7 +403,24 @@ static void world_load(void) scene_upload( &world.geo ); scene_bh_create( &world.geo ); - world_apply_foliage(); + + /* Foliage /nocollide layer. + * TODO: Probably should have material traits for this + */ + scene_init( &world.foliage ); + + world_apply_procedural_foliage(); + scene_copy_slice( &world.foliage, &world.sm_foliage_main ); + + add_all_if_material( midentity, &world.foliage, mworld, mat_alphatest ); + scene_copy_slice( &world.foliage, &world.sm_foliage_alphatest ); + + scene_upload( &world.foliage ); + world_routes_init( mworld ); + + for( int i=0; i