From d26100734623f37063206b9b144c2a29fd71d414 Mon Sep 17 00:00:00 2001 From: quou Date: Wed, 1 Jan 2025 18:43:31 +1100 Subject: material system --- asset.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'asset.cpp') diff --git a/asset.cpp b/asset.cpp index 8a5a1cc..1d0da2c 100644 --- a/asset.cpp +++ b/asset.cpp @@ -8,7 +8,7 @@ extern "C" { } #define max_asset_types 32 -#define asset_scratch_size (1024 * 1024) +#define asset_scratch_size (1024) struct RLoader { char magic[4]; @@ -75,12 +75,6 @@ void Asset_Arena::init( p = pack_open(pack_name, arena); assert(p != 0); a = arena; - s = (Arena*)arena_alloc(a, sizeof *s); - init_arena( - s, - arena_alloc(a, asset_scratch_size), - asset_scratch_size - ); max_assets = max; assets = (Bucket*)arena_alloc(arena, max * sizeof(Bucket)); for (i = 0; i < max; i++) @@ -112,6 +106,8 @@ int Asset_Arena::bucket(const char* name) { Asset* Asset_Arena::load(const char* name) { char magic[4]; + char scratch[asset_scratch_size]; + Arena sa; Pack_File* f; int b = bucket(name); assert(b >= 0); @@ -122,8 +118,8 @@ Asset* Asset_Arena::load(const char* name) { pack_read(f, magic, 4); pack_seek(f, 0, seek_rel_start); Asset_Loader& loader = manager.get_loader(magic); - clear_arena(s); - Asset* asset = loader.load(a, s, name, f); + init_arena(&sa, scratch, sizeof scratch); + Asset* asset = loader.load(a, &sa, name, f); if (asset) { asset->loader = &loader; assets[b].name = dup_string(a, name); -- cgit v1.2.3-54-g00ecf