2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 12:24:56 +00:00

Blender Python API updates and better CMake dependency handling

This commit is contained in:
Jack Andersen
2019-06-11 16:01:19 -10:00
parent 7cc157c8b9
commit 387f8fa864
26 changed files with 73 additions and 112 deletions

View File

@@ -22,7 +22,6 @@ add_custom_command(OUTPUT hecl.zip DEPENDS ${PY_SOURCES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating addon package")
bintoc(hecl_addon.cpp "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON)
bintoc(hecl_startup.cpp hecl_startup.blend HECL_STARTUP)
add_library(hecl-blender-addon
hecl_blendershell.py
@@ -30,5 +29,4 @@ add_library(hecl-blender-addon
zip_package.py
hecl.zip
hecl_addon.cpp
hecl_startup.cpp
${PY_SOURCES})

View File

@@ -35,10 +35,9 @@ def cook(writebuf, mesh_obj, use_luv=False):
# Copy mesh (and apply mesh modifiers with triangulation)
copy_name = mesh_obj.name + "_hmdltri"
copy_mesh = bpy.data.meshes.new(copy_name)
copy_mesh = bpy.data.meshes.new_from_object(mesh_obj, preserve_all_data_layers=True,
depsgraph=bpy.context.evaluated_depsgraph_get())
copy_obj = bpy.data.objects.new(copy_name, copy_mesh)
copy_obj.data = mesh_obj.to_mesh(bpy.context.depsgraph, True)
copy_mesh = copy_obj.data
copy_obj.scale = mesh_obj.scale
bpy.context.scene.collection.objects.link(copy_obj)
bpy.ops.object.select_all(action='DESELECT')
@@ -48,7 +47,7 @@ def cook(writebuf, mesh_obj, use_luv=False):
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.mesh.select_all(action='DESELECT')
bpy.context.scene.update()
bpy.context.scene.update_tag()
bpy.ops.object.mode_set(mode='OBJECT')
copy_mesh.calc_normals_split()
rna_loops = copy_mesh.loops
@@ -132,10 +131,9 @@ def cookcol(writebuf, mesh_obj):
# Copy mesh (and apply mesh modifiers with triangulation)
copy_name = mesh_obj.name + "_hmdltri"
copy_mesh = bpy.data.meshes.new(copy_name)
copy_mesh = bpy.data.meshes.new_from_object(mesh_obj, preserve_all_data_layers=True,
depsgraph=bpy.context.evaluated_depsgraph_get())
copy_obj = bpy.data.objects.new(copy_name, copy_mesh)
copy_obj.data = mesh_obj.to_mesh(bpy.context.depsgraph, True)
copy_mesh = copy_obj.data
copy_obj.scale = mesh_obj.scale
bpy.context.scene.collection.objects.link(copy_obj)
bpy.ops.object.select_all(action='DESELECT')
@@ -145,7 +143,7 @@ def cookcol(writebuf, mesh_obj):
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.mesh.select_all(action='DESELECT')
bpy.context.scene.update()
bpy.context.scene.update_tag()
bpy.ops.object.mode_set(mode='OBJECT')
copy_mesh.calc_normals_split()
rna_loops = copy_mesh.loops

View File

@@ -257,10 +257,9 @@ def cook(writebuf, mesh_obj):
# Copy mesh (and apply mesh modifiers with triangulation)
copy_name = mesh_obj.name + "_hmdltri"
copy_mesh = bpy.data.meshes.new(copy_name)
copy_mesh = bpy.data.meshes.new_from_object(mesh_obj, preserve_all_data_layers=True,
depsgraph=bpy.context.evaluated_depsgraph_get())
copy_obj = bpy.data.objects.new(copy_name, copy_mesh)
copy_obj.data = mesh_obj.to_mesh(bpy.context.depsgraph, True)
copy_mesh = copy_obj.data
copy_obj.scale = mesh_obj.scale
bpy.context.scene.collection.objects.link(copy_obj)
bpy.ops.object.select_all(action='DESELECT')
@@ -270,7 +269,7 @@ def cook(writebuf, mesh_obj):
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.mesh.select_all(action='DESELECT')
bpy.context.scene.update()
bpy.context.scene.update_tag()
bpy.ops.object.mode_set(mode='OBJECT')
copy_mesh.calc_normals_split()
rna_loops = copy_mesh.loops

View File

@@ -179,7 +179,7 @@ def write_action_aabb(writebuf, arm_obj, mesh_obj):
scene.frame_set(frame_idx)
root_bone.location = (0.0,0.0,0.0)
scene.update()
scene.update_tag()
if root_bone.rotation_mode == 'QUATERNION':
root_bone.rotation_quaternion = (1.0,0.0,0.0,0.0)
else:

View File

@@ -479,10 +479,9 @@ try:
elif cmdargs[0] == 'CREATE':
if len(cmdargs) >= 4:
bpy.ops.wm.open_mainfile(filepath=cmdargs[3])
loaded_blend = cmdargs[1]
else:
bpy.ops.wm.read_homefile()
loaded_blend = None
loaded_blend = cmdargs[1]
bpy.context.preferences.filepaths.save_version = 0
if 'FINISHED' in bpy.ops.wm.save_as_mainfile(filepath=cmdargs[1]):
bpy.ops.file.hecl_patching_load()

Binary file not shown.