From 265166c4d48e87883f4d9b252362173975cafd9c Mon Sep 17 00:00:00 2001 From: Cameron Murphy Reikes Date: Mon, 10 Jul 2023 02:11:57 -0700 Subject: [PATCH] Massive art import, fix scale coord transform bug. Remove zig from build --- art/Cube.295_color.png.png | 3 +++ art/Cube.296_color.png.png | 3 +++ art/Cube.297_color.png.png | 3 +++ art/Cube.314_color.png.png | 3 +++ art/Cylinder.130_color.png.png | 3 +++ art/Cylinder.131_color.png.png | 3 +++ art/EGround.001.png | 3 +++ art/Exporter.py | 14 ++++++++++++-- art/art.blend | 4 ++-- build_desktop_debug.bat | 2 +- main.c | 5 ++++- 11 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 art/Cube.295_color.png.png create mode 100644 art/Cube.296_color.png.png create mode 100644 art/Cube.297_color.png.png create mode 100644 art/Cube.314_color.png.png create mode 100644 art/Cylinder.130_color.png.png create mode 100644 art/Cylinder.131_color.png.png create mode 100644 art/EGround.001.png diff --git a/art/Cube.295_color.png.png b/art/Cube.295_color.png.png new file mode 100644 index 0000000..d636f5e --- /dev/null +++ b/art/Cube.295_color.png.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d24e5292a7323c6b2d4f118abff0be12f783d987774fe2dbe38632f1722a8e57 +size 513863 diff --git a/art/Cube.296_color.png.png b/art/Cube.296_color.png.png new file mode 100644 index 0000000..d94a218 --- /dev/null +++ b/art/Cube.296_color.png.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d0207663989db553d96c1701352f2d65c9b21617e6d9ebafbe7243696df0910 +size 170182 diff --git a/art/Cube.297_color.png.png b/art/Cube.297_color.png.png new file mode 100644 index 0000000..3bb9b32 --- /dev/null +++ b/art/Cube.297_color.png.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2652b1b17e7b36480c845828c4cc25fbc9afcd3efa58b3d9780453dd617809ed +size 34344 diff --git a/art/Cube.314_color.png.png b/art/Cube.314_color.png.png new file mode 100644 index 0000000..5a0825a --- /dev/null +++ b/art/Cube.314_color.png.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07aaf77036b9304c59c68c9db237e3ad92fede440254776f36bdc3e51f3436e3 +size 41012 diff --git a/art/Cylinder.130_color.png.png b/art/Cylinder.130_color.png.png new file mode 100644 index 0000000..4c64e7e --- /dev/null +++ b/art/Cylinder.130_color.png.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73b1983a8f0132e04756c39a4589428eef4cb032d631835eeecf5a799494a5f8 +size 136122 diff --git a/art/Cylinder.131_color.png.png b/art/Cylinder.131_color.png.png new file mode 100644 index 0000000..86177b5 --- /dev/null +++ b/art/Cylinder.131_color.png.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2a77ce33d6c6927481e8d65383bf97c0a70d0c8952c2dca3fc884d78a790939 +size 30001 diff --git a/art/EGround.001.png b/art/EGround.001.png new file mode 100644 index 0000000..c6971de --- /dev/null +++ b/art/EGround.001.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2d77ccfd742ef34528b7466363858c2ca26b0e8acd5ec3b504d75e9edff3d2f4 +size 3034306 diff --git a/art/Exporter.py b/art/Exporter.py index 14d1cf4..bcc5ac4 100644 --- a/art/Exporter.py +++ b/art/Exporter.py @@ -84,7 +84,6 @@ project_directory = bpy.path.abspath("//") def is_file_in_project(file_path): file_name = os.path.basename(file_path) for root, dirs, files in os.walk(project_directory): - print(f"Looking for {file_name} Dirs: {dirs} files: {files}") if file_name in files: return True return False @@ -111,7 +110,14 @@ def ensure_tex_saved_and_get_name(o) -> str: img_obj.save(filepath=bpy.path.abspath(save_to)) else: assert img_obj.filepath != "", f"{img_obj.filepath} in mesh {mesh_name} Isn't there but should be, as it has no packed image" - assert is_file_in_project(bpy.path.abspath(img_obj.filepath)), f"The image {image_filename} has filepath {img_obj.filepath} which isn't in the project directory {project_directory}" + old_path = bpy.path.abspath(img_obj.filepath) + if not is_file_in_project(old_path): + print(f"Image {image_filename} has filepath {img_obj.filepath}, outside of the current directory. So we're copying it baby. Hoo-rah!") + new_path = bpy.path.abspath(f"//{image_filename}") + assert not os.path.exists(new_path), f"Tried to migrate {image_filename} to a new home {new_path}, but its already taken. It's over!" + shutil.copyfile(old_path, new_path) + img_obj.filepath = new_path + assert is_file_in_project(bpy.path.abspath(img_obj.filepath)), f"The image {image_filename} has filepath {img_obj.filepath} which isn't in the project directory {project_directory}, even after copying it! WTF" shutil.copyfile(bpy.path.abspath(img_obj.filepath),bpy.path.abspath(save_to)) return image_filename @@ -119,6 +125,7 @@ def ensure_tex_saved_and_get_name(o) -> str: # meshes can either be Meshes, or Armatures. Armatures contain all mesh data to draw it, and any anims it has for o in D.objects: + if o.hide_get(): continue if o.type == "MESH": if o.parent and o.parent.type == "ARMATURE": mesh_object = o @@ -320,6 +327,7 @@ for o in D.objects: vertices.append((position, uv)) write_u64(f, len(vertices)) + print(f"\n\n{output_filepath} vertices:") for v_and_uv in vertices: v, uv = v_and_uv write_f32(f, v.x) @@ -327,6 +335,8 @@ for o in D.objects: write_f32(f, v.z) write_f32(f, uv.x) write_f32(f, uv.y) + if len(vertices) < 100: + print(v) print(f"Wrote {len(vertices)} vertices") with open(bpy.path.abspath(f"//{EXPORT_DIRECTORY}/{LEVEL_EXPORT_NAME}.bin"), "wb") as f: diff --git a/art/art.blend b/art/art.blend index 466e9f8..24b1f5b 100644 --- a/art/art.blend +++ b/art/art.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b050b460e023a08ad7a66750adc512c931b171eee84d49f0b66eabe7ebd6ea6 -size 10991788 +oid sha256:54df86175ef7a0c9724cc9102ff01a334140526709f747da337f86465ed33581 +size 22694204 diff --git a/build_desktop_debug.bat b/build_desktop_debug.bat index e686fb2..21e5d1d 100644 --- a/build_desktop_debug.bat +++ b/build_desktop_debug.bat @@ -4,7 +4,7 @@ if "%1" == "codegen" ( call run_codegen.bat || goto :error ) else ( echo NOT RUNNING CODEGEN ) -start /B zig cc -DDEVTOOLS -Igen -Ithirdparty -lDbghelp -lGdi32 -lD3D11 -lOle32 -lwinhttp -gfull -gcodeview -o main_zig.exe main.c +@REM start /B zig cc -DDEVTOOLS -Igen -Ithirdparty -lDbghelp -lGdi32 -lD3D11 -lOle32 -lwinhttp -gfull -gcodeview -o main_zig.exe main.c cl /diagnostics:caret /DDEVTOOLS /Igen /Ithirdparty /W3 /Zi /WX Dbghelp.lib winhttp.lib main.c || goto :error goto :EOF diff --git a/main.c b/main.c index 80aaf3e..498cc0f 100644 --- a/main.c +++ b/main.c @@ -1036,6 +1036,7 @@ typedef struct Armature load_armature(MD_Arena *arena, MD_String8 binary_file, MD_String8 armature_name) { + assert(binary_file.str); MD_ArenaTemp scratch = MD_GetScratch(&arena, 1); SerState ser = { .data = binary_file.str, @@ -1232,7 +1233,9 @@ Transform blender_to_game_transform(BlenderTransform blender_transform) to_return.offset = blender_transform.pos; - to_return.scale = blender_transform.scale; + to_return.scale.x = blender_transform.scale.x; + to_return.scale.y = blender_transform.scale.z; + to_return.scale.z = blender_transform.scale.y; Mat4 rotation_matrix = M4D(1.0f); rotation_matrix = MulM4(Rotate_RH(AngleRad(blender_transform.euler_rotation.x), V3(1,0,0)), rotation_matrix);