From b62fd323a4539d090c74fbc7f4d644001be2d4a3 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 9 Sep 2025 00:03:23 +0200 Subject: [PATCH] Add basic uv map check --- base/sources/iron_obj.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/sources/iron_obj.c b/base/sources/iron_obj.c index 61088663..5e5c15e5 100644 --- a/base/sources/iron_obj.c +++ b/base/sources/iron_obj.c @@ -29,6 +29,8 @@ static size_t bytes_length = 0; static f32_array_t *pos_first; static f32_array_t *uv_first; static f32_array_t *nor_first; +void console_info(char *s); +static bool check_uvmap = true; static int read_int() { int bi = 0; @@ -234,6 +236,7 @@ raw_mesh_t *obj_parse(buffer_t *file_bytes, char split_code, uint64_t start_pos, bool reading_faces = false; bool reading_object = false; bool full_attrib = false; + check_uvmap = true; if (start_pos == 0) { vind_off = tind_off = nind_off = 0; @@ -320,6 +323,10 @@ raw_mesh_t *obj_parse(buffer_t *file_bytes, char split_code, uint64_t start_pos, i32_array_push(&uv_indices, ua[i - 1]); i32_array_push(&uv_indices, ua[i]); } + if (check_uvmap && ua[0] == 0 && ua[1] == 0 && ua[2] == 0) { // Blender points faces with no UV to 0.0 (vt index 0) + check_uvmap = false; + console_info("Warning: Mesh is not fully UV unwrapped"); + } } if (nor_temp.length > 0) { i32_array_push(&nor_indices, na[0]); @@ -619,6 +626,7 @@ raw_mesh_t *obj_parse(buffer_t *file_bytes, char split_code, uint64_t start_pos, part->texa->buffer[i * 2 + 1] = (int)((1.0 - uvy) * 32767); } } + bytes = NULL; if (!part->has_next) { pos_first = nor_first = uv_first = NULL;