From 1836f2c185110fae4e9bee76ec9cb1de036163f1 Mon Sep 17 00:00:00 2001 From: Lila Date: Thu, 13 Nov 2025 12:29:11 +0000 Subject: [PATCH 1/2] [SM64] Fix createBone (regression in custom commands) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bone = armatureObj.data.bones[boneName] was incorrect cause of duplicates (if i remember correctly), so I removed it in place of using the edit bone, but I failed to remember edit bones don“t share properties with their bone counterparts. --- fast64_internal/sm64/sm64_geolayout_parser.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/fast64_internal/sm64/sm64_geolayout_parser.py b/fast64_internal/sm64/sm64_geolayout_parser.py index dfcd324ea..01497c599 100644 --- a/fast64_internal/sm64/sm64_geolayout_parser.py +++ b/fast64_internal/sm64/sm64_geolayout_parser.py @@ -698,32 +698,33 @@ def createBone(armatureObj, parentBoneName, boneName, currentTransform, boneGrou bpy.ops.object.mode_set(mode="OBJECT") selectSingleObject(armatureObj) bpy.ops.object.mode_set(mode="EDIT") - bone = armatureObj.data.edit_bones.new(boneName) - bone.use_connect = False + edit_bone: bpy.types.EditBone = armatureObj.data.edit_bones.new(boneName) + edit_bone.use_connect = False if parentBoneName is not None: - bone.parent = armatureObj.data.edit_bones[parentBoneName] - bone.head = currentTransform @ mathutils.Vector((0, 0, 0)) - bone.tail = bone.head + ( + edit_bone.parent = armatureObj.data.edit_bones[parentBoneName] + edit_bone.head = currentTransform @ mathutils.Vector((0, 0, 0)) + edit_bone.tail = edit_bone.head + ( currentTransform.to_quaternion() @ mathutils.Vector((0, 1, 0)) * (0.2 if boneGroup != "DisplayList" else 0.1) ) # Connect bone to parent if it is possible without changing parent direction. if parentBoneName is not None: - nodeOffsetVector = mathutils.Vector(bone.head - bone.parent.head) + nodeOffsetVector = mathutils.Vector(edit_bone.head - edit_bone.parent.head) # set fallback to nonzero to avoid creating zero length bones - if nodeOffsetVector.angle(bone.parent.tail - bone.parent.head, 1) < 0.0001 and loadDL: - for child in bone.parent.children: - if child != bone: + if nodeOffsetVector.angle(edit_bone.parent.tail - edit_bone.parent.head, 1) < 0.0001 and loadDL: + for child in edit_bone.parent.children: + if child != edit_bone: child.use_connect = False - bone.parent.tail = bone.head - bone.use_connect = True - elif bone.head == bone.parent.head and bone.tail == bone.parent.tail: - bone.tail += currentTransform.to_quaternion() @ mathutils.Vector((0, 1, 0)) * 0.02 + edit_bone.parent.tail = edit_bone.head + edit_bone.use_connect = True + elif edit_bone.head == edit_bone.parent.head and edit_bone.tail == edit_bone.parent.tail: + edit_bone.tail += currentTransform.to_quaternion() @ mathutils.Vector((0, 1, 0)) * 0.02 - boneName = bone.name + boneName = edit_bone.name + bone: bpy.types.Bone = armatureObj.data.bones[boneName] bone.geo_cmd = boneGroup if boneGroup is not None else "DisplayListWithOffset" - addBoneToGroup(armatureObj, bone.name) + addBoneToGroup(armatureObj, boneName) return boneName From 69c3784ecf2cd683a3aec2c7b11f04c2b3751e86 Mon Sep 17 00:00:00 2001 From: Lila Date: Thu, 20 Nov 2025 16:53:15 +0000 Subject: [PATCH 2/2] change to object mode --- fast64_internal/sm64/sm64_geolayout_parser.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fast64_internal/sm64/sm64_geolayout_parser.py b/fast64_internal/sm64/sm64_geolayout_parser.py index 01497c599..095dfa89e 100644 --- a/fast64_internal/sm64/sm64_geolayout_parser.py +++ b/fast64_internal/sm64/sm64_geolayout_parser.py @@ -694,11 +694,10 @@ def createConnectBone(armatureObj, childName, parentName): def createBone(armatureObj, parentBoneName, boneName, currentTransform, boneGroup, loadDL): - if bpy.context.mode != "OBJECT": - bpy.ops.object.mode_set(mode="OBJECT") - selectSingleObject(armatureObj) - bpy.ops.object.mode_set(mode="EDIT") + if bpy.context.mode != "EDIT": + bpy.ops.object.mode_set(mode="EDIT") edit_bone: bpy.types.EditBone = armatureObj.data.edit_bones.new(boneName) + boneName = edit_bone.name edit_bone.use_connect = False if parentBoneName is not None: edit_bone.parent = armatureObj.data.edit_bones[parentBoneName] @@ -721,7 +720,7 @@ def createBone(armatureObj, parentBoneName, boneName, currentTransform, boneGrou elif edit_bone.head == edit_bone.parent.head and edit_bone.tail == edit_bone.parent.tail: edit_bone.tail += currentTransform.to_quaternion() @ mathutils.Vector((0, 1, 0)) * 0.02 - boneName = edit_bone.name + bpy.ops.object.mode_set(mode="OBJECT") bone: bpy.types.Bone = armatureObj.data.bones[boneName] bone.geo_cmd = boneGroup if boneGroup is not None else "DisplayListWithOffset" addBoneToGroup(armatureObj, boneName)