summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-04-20 18:33:05 +1000
committerGitHub <noreply@github.com>2024-04-20 18:33:05 +1000
commitb283835c5e6998bda9b986ff49ee4fd57fe68fc7 (patch)
treebe478c168506a669876ff9df8920b7e35539e98f /src/resources
parentb240374c23365e33727d78ca74e901bcb383e077 (diff)
parent013e1c111e0717f6dc01a8e8582e13a4095e05bc (diff)
Merge pull request #7 from omnisci3nce/transform-hierarchy
Transform hierarchy
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/obj.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/resources/obj.c b/src/resources/obj.c
index 710d5f0..c6e9fa6 100644
--- a/src/resources/obj.c
+++ b/src/resources/obj.c
@@ -15,6 +15,7 @@
#include "file.h"
#include "log.h"
#include "maths.h"
+#include "mem.h"
#include "path.h"
#include "render.h"
#include "render_types.h"
@@ -40,16 +41,16 @@ bool model_load_obj_str(const char *file_string, str8 relative_path, model *out_
bool invert_textures_y);
model_handle model_load_obj(core *core, const char *path, bool invert_textures_y) {
+ size_t arena_size = 1024;
+ arena scratch = arena_create(malloc(arena_size), arena_size);
+
TRACE("Loading model at Path %s\n", path);
- path_opt relative_path = path_parent(path);
+ path_opt relative_path = path_parent(&scratch, path);
if (!relative_path.has_value) {
WARN("Couldnt get a relative path for the path to use for loading materials & textures later");
}
- printf("Relative path: %s\n", relative_path.path.buf);
const char *file_string = string_from_file(path);
- // TODO: store the relative path without the name.obj at the end
-
model model = { 0 };
model.name = str8_cstr_view(path);
model.meshes = mesh_darray_new(1);
@@ -64,6 +65,9 @@ model_handle model_load_obj(core *core, const char *path, bool invert_textures_y
u32 index = model_darray_len(core->models);
model_darray_push(core->models, model);
+
+ arena_free_all(&scratch);
+ arena_free_storage(&scratch);
return (model_handle){ .raw = index };
}