X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.c;h=c31c2c2dd904955be10e8c7fde126cdfd2b2438e;hb=7eba38b8178c82040618a518634d8ff4813e2ff2;hp=799059a5f423626e00dd8a9969f94f3ece09a58e;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.c b/world_gen.c index 799059a..c31c2c2 100644 --- a/world_gen.c +++ b/world_gen.c @@ -148,6 +148,19 @@ VG_STATIC void world_apply_procedural_foliage( scene_context *scene, vg_info( "%d foliage models added\n", count ); } +VG_STATIC +void world_unpack_submesh_dynamic( world_instance *world, + scene_context *scene, mdl_submesh *sm ){ + if( sm->flags & k_submesh_flag_consumed ) return; + + m4x3f identity; + m4x3_identity( identity ); + scene_add_mdl_submesh( scene, &world->meta, sm, identity ); + + scene_copy_slice( scene, sm ); + sm->flags |= k_submesh_flag_consumed; +} + /* * Create the main meshes for the world */ @@ -227,7 +240,7 @@ VG_STATIC void world_gen_generate_meshes(void) vg_async_item *call = scene_alloc_async( &world->scene_no_collide, &world->mesh_no_collide, - 200000, 500000 ); + 250000, 500000 ); for( u32 i=0; isurface_count; i++ ){ struct world_surface *surf = &world->surfaces[ i ]; @@ -243,24 +256,29 @@ VG_STATIC void world_gen_generate_meshes(void) scene_copy_slice( &world->scene_no_collide, &surf->sm_no_collide ); } + /* unpack traffic models.. TODO: should we just put all these submeshes in a + * dynamic models list? and then the actual entitities point to the + * models. we only have 2 types at the moment which need dynamic models but + * would make sense to do this when/if we have more. + */ for( u32 i=0; ient_traffic ); i++ ){ ent_traffic *vehc = mdl_arritm( &world->ent_traffic, i ); for( u32 j=0; jsubmesh_count; j++ ){ mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, vehc->submesh_start+j ); + world_unpack_submesh_dynamic( world, &world->scene_no_collide, sm ); + } + } - if( sm->flags & k_submesh_flag_consumed ){ - continue; - } - - m4x3f identity; - m4x3_identity( identity ); - scene_add_mdl_submesh( &world->scene_no_collide, - &world->meta, sm, identity ); + /* unpack challenge models */ + for( u32 i=0; ient_challenge ); i++ ){ + ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i ); - scene_copy_slice( &world->scene_no_collide, sm ); - sm->flags |= k_submesh_flag_consumed; + for( u32 j=0; jsubmesh_count; j ++ ){ + mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, + challenge->submesh_start+j ); + world_unpack_submesh_dynamic( world, &world->scene_no_collide, sm ); } } @@ -577,6 +595,19 @@ VG_STATIC void async_world_postprocess_render( void *payload, u32 _size ) glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting ); glBufferSubData( GL_UNIFORM_BUFFER, 0, sizeof(struct ub_world_lighting), &world->ub_lighting ); + + /* yes we are using this as the entity begin thing. FIXME */ + world->probabilities[ k_probability_curve_constant ] = 1.0f; + for( u32 i=0; ient_audio); i++ ){ + ent_audio *audio = mdl_arritm(&world->ent_audio,i); + if( audio->flags & AUDIO_FLAG_AUTO_START ){ + ent_call call; + call.data = NULL; + call.function = k_ent_function_trigger; + call.id = mdl_entity_id( k_ent_audio, i ); + entity_call( world, &call ); + } + } } /* Loads textures from the pack file */