achievements
[carveJwlIkooP6JGAAIwe30JlM.git] / world_gen.h
index d9037c9191fb0e97eb2e59cf5bf8f7c5be9c6ee4..49ea4953480bb8b3455c3a2ce1dc2ce70cf833ce 100644 (file)
@@ -1,8 +1,16 @@
+/*
+ * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
+ */
+
 #ifndef WORLD_GEN_H
 #define WORLD_GEN_H
 
-#include "world.h"
+/* 
+ * FUTURE:
+ *    If we have multiple levels, write an unloader
+ */
 
+#include "world.h"
 
 static void world_add_all_if_material( m4x3f transform, scene *pscene, 
                                        mdl_header *mdl, u32 id )
@@ -87,7 +95,7 @@ static void world_apply_procedural_foliage(void)
       }
    }
 
-   free( mfoliage );
+   vg_free( mfoliage );
 }
 
 static void world_load(void)
@@ -129,17 +137,13 @@ static void world_load(void)
          
          if( sm )
          {
-
-            if( vg_acquire_thread_sync(1) )
+            vg_acquire_thread_sync();
             {
                glmesh surf;
-               if( mdl_unpack_submesh( mworld, &surf, sm ) )
-               {
-                  water_set_surface( &surf, pnode->co[1] );
-               }
-
-               vg_release_thread_sync(1);
+               mdl_unpack_submesh( mworld, &surf, sm );
+               water_set_surface( &surf, pnode->co[1] );
             }
+            vg_release_thread_sync();
          }
       }
       else if( pnode->classtype == k_classtype_car_path )
@@ -270,15 +274,9 @@ static void world_load(void)
       world_add_all_if_material( midentity, &world.geo,mworld,mat_vertex_blend);
    scene_copy_slice( &world.geo, &world.sm_geo_vb );
 
-   if( vg_acquire_thread_sync(1) )
-   {
-      if( !scene_upload( &world.geo ) )
-      {
-
-      }
-
-      vg_release_thread_sync(1);
-   }
+   vg_acquire_thread_sync();
+   scene_upload( &world.geo );
+   vg_release_thread_sync();
 
    scene_bh_create( &world.geo );
 
@@ -298,12 +296,9 @@ static void world_load(void)
    scene_copy_slice( &world.foliage, &world.sm_graffiti );
 
 
-   if( vg_acquire_thread_sync(1) )
+   vg_acquire_thread_sync();
    {
-      if( !scene_upload( &world.foliage ) )
-      {
-         
-      }
+      scene_upload( &world.foliage );
 
       /* 
        * Rendering the depth map
@@ -360,17 +355,17 @@ static void world_load(void)
 
       winfo->g_water_fog = 0.04f;
       render_update_lighting_ub();
-
-      vg_release_thread_sync(1);
    }
 
+   vg_release_thread_sync();
+
    world_routes_loadfrom( mworld );
 
    for( int i=0; i<world.instance_cache_count; i++ )
-      free( world.instance_cache[i].mdl );
+      vg_free( world.instance_cache[i].mdl );
 
-   free( world.instance_cache );
-   free( mworld );
+   vg_free( world.instance_cache );
+   vg_free( mworld );
    scene_free_offline_buffers( &world.foliage );
 
    /*