Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions fast64_internal/sm64/sm64_geolayout_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,36 +694,36 @@ 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")
bone = armatureObj.data.edit_bones.new(boneName)
bone.use_connect = False
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:
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
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, bone.name)
addBoneToGroup(armatureObj, boneName)

return boneName

Expand Down