X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.h;h=7f8432ab08d9f0630777be8aa1e33db78cac529f;hb=15beb60ade240af4e00b0d204f7e89a4d35dca36;hp=8c5837d5c77cff4f7c117bf6e0954e83fac66cdf;hpb=c2d67378dd5c82de50b8fbbbe222ec6be2da4eee;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index 8c5837d..7f8432a 100644 --- a/world.h +++ b/world.h @@ -1,3 +1,7 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #include "common.h" static int ray_world( v3f pos, v3f dir, ray_hit *hit ); @@ -10,11 +14,9 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit ); #include "network.h" #include "network_msg.h" #include "scene.h" -#include "terrain.h" #include "render.h" #include "rigidbody.h" #include "bvh.h" -#include "lighting.h" #include "model.h" #include "traffic.h" /*TODO: -> world_traffic.h */ @@ -40,6 +42,12 @@ enum { k_route_ui_max_indices = k_max_ui_elements*k_max_element_indices }; static struct gworld { + struct subworld_gen + { + + } + subworld_gen; + /* gameplay */ struct respawn_point { @@ -50,6 +58,17 @@ static struct gworld spawns[32]; u32 spawn_count; + struct achievement_zone + { + m4x3f transform, inv_transform; + char name[32]; + int triggered; + } + * achievement_zones; + + u32 achievement_zones_count, + achievement_zones_cap; + struct subworld_routes { struct route_node @@ -233,7 +252,7 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit ); * ----------------------------------------------------------------------------- */ -static int world_init(void) +static void world_init(void) { shader_terrain_register(); shader_sky_register(); @@ -244,84 +263,51 @@ static int world_init(void) vg_info( "Loading world resources\n" ); - mdl_header *mcars = mdl_load( "models/rs_cars.mdl" ); + VG_REQUIRED_ASSET( mdl_header*, mcars, mdl_load, "models/rs_cars.mdl" ); + VG_REQUIRED_ASSET( mdl_header*, msky, mdl_load, "models/rs_skydome.mdl" ); + mdl_node *nholden = mdl_node_from_name( mcars, "holden" ); world.car_holden = *mdl_node_submesh( mcars, nholden, 0 ); - mdl_header *msky = mdl_load("models/rs_skydome.mdl"); mdl_node *nlower = mdl_node_from_name( msky, "dome_lower" ), *nupper = mdl_node_from_name( msky, "dome_upper" ); world.dome_lower = *mdl_node_submesh( msky, nlower, 0 ); world.dome_upper = *mdl_node_submesh( msky, nupper, 0 ); - /* TODO: cleanup resource acquisition */ - if( !mcars || !msky ) - { - free( mcars ); - free( msky ); - return 0; - } - - if( vg_acquire_thread_sync(1) ) - { - if( !mdl_unpack_glmesh( mcars, &world.cars ) ) - { - free( mcars ); - free( msky ); - vg_release_thread_sync(1); - return 0; - } - - if( !mdl_unpack_glmesh( msky, &world.skydome ) ) - { - mesh_free( &world.cars ); - free( mcars ); - free( msky ); - vg_release_thread_sync(1); - return 0; - } - - vg_release_thread_sync(1); - } - else + vg_acquire_thread_sync(); { - free(mcars); - free(msky); - return 0; + mdl_unpack_glmesh( mcars, &world.cars ); + mdl_unpack_glmesh( msky, &world.skydome ); } + vg_release_thread_sync(); - free(mcars); - free(msky); - - vg_info( "Loading other world systems\n" ); - - if( !vg_loader_highwater( (void *)mesh_free, &world.cars ) ) return 0; - if( !vg_loader_highwater( (void *)mesh_free, &world.skydome ) ) return 0; + vg_free(mcars); + vg_free(msky); /* Other systems */ + vg_info( "Loading other world systems\n" ); - if( !world_render_init() ) return 0; - if( !vg_loader_highwater( world_render_free, NULL ) ) return 0; - - if( !world_sfd_init() ) return 0; - if( !vg_loader_highwater( world_sfd_free, NULL ) ) return 0; - - if( !world_water_init() ) return 0; - if( !vg_loader_highwater( world_water_free, NULL ) ) return 0; - - if( !world_gates_init() ) return 0; - if( !vg_loader_highwater( world_gates_free, NULL ) ) return 0; + vg_loader_highwater( world_render_init, world_render_free, NULL ); + vg_loader_highwater( world_sfd_init, world_sfd_free, NULL ); + vg_loader_highwater( world_water_init, world_water_free, NULL ); + vg_loader_highwater( world_gates_init, world_gates_free, NULL ); + vg_loader_highwater( world_routes_init, world_routes_free, NULL ); +} - if( !world_routes_init() ) return 0; - if( !vg_loader_highwater( world_routes_free, NULL ) ) return 0; - return 1; +static void world_free( void *_ ) +{ + mesh_free( &world.cars ); + mesh_free( &world.skydome ); + vg_free( world.achievement_zones ); } static void world_update( v3f pos ) { world_routes_update(); +#if 0 world_routes_debug(); +#endif int closest = 0; float min_dist = INFINITY; @@ -357,26 +343,32 @@ static void world_update( v3f pos ) } } } - - sfd_update( &world.sfd.tester ); -#if 0 - rb_solver_reset(); - rb_build_manifold_terrain_sphere( &world.mr_ball ); - - for( int i=0; i<5; i++ ) - rb_solve_contacts( rb_contact_buffer, rb_contact_count ); + for( int i=0; itriggered ) + continue; - for( int i=0; iinv_transform, pos, local ); + + if( (fabsf(local[0]) <= 1.0f) && + (fabsf(local[1]) <= 1.0f) && + (fabsf(local[2]) <= 1.0f) ) + { + zone->triggered = 1; + steam_set_achievement( zone->name ); + steam_store_achievements(); + } + + vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f}, + { 1.0f, 1.0f, 1.0f}}, + 0xff00ff00 ); } -#endif + + sfd_update( &world.sfd.tester ); } /*