Skip to content

Commit

Permalink
plugin - export some ragdolls data
Browse files Browse the repository at this point in the history
  • Loading branch information
HENDRIX-ZT2 committed Nov 6, 2023
1 parent b76b6c1 commit bfe6010
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
29 changes: 25 additions & 4 deletions plugin/modules_export/armature.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,32 @@ def export_joints(bone_info, corrector):
else:
rb.mass = -1.0
rb.flag = 0
# update ragdoll constraints, relies on previously updated joints
j_map = {j.name: j for j in joints.joint_infos}
# update the ragdolls to make sure they point to valid joints
for rd in joints.ragdoll_constraints:
rd.parent.joint = j_map[rd.parent.joint.name]
rd.child.joint = j_map[rd.child.joint.name]
joints_with_ragdoll_constraints = [b_joint for b_joint in joint_coll.objects if b_joint.rigid_body_constraint]
joints.num_ragdoll_constraints = len(joints_with_ragdoll_constraints)
joints.reset_field("ragdoll_constraints")
for rd, b_joint in zip(joints.ragdoll_constraints, joints_with_ragdoll_constraints):
rbc = b_joint.rigid_body_constraint
# get the joint empties, which are the parents of the respective rigidbody objects
child_joint_name = bone_name_for_ovl(get_joint_name(rbc.object1.parent))
parent_joint_name = bone_name_for_ovl(get_joint_name(rbc.object2.parent))
rd.child.joint = j_map[child_joint_name]
rd.parent.joint = j_map[parent_joint_name]
# update the ragdolls to make sure they point to valid joints
# rd.parent.joint = j_map[rd.parent.joint.name]
# rd.child.joint = j_map[rd.child.joint.name]
rd.loc = joints.joint_transforms[rd.child.joint.index].loc
# before correcting, rot tends to point y to the child joint
# todo rot, vec_b
rd.vec_a.set(rd.rot[0])
rd.x.min = -rbc.limit_ang_x_lower
rd.x.max = rbc.limit_ang_x_upper
rd.y.min = -rbc.limit_ang_y_lower
rd.y.max = rbc.limit_ang_y_upper
rd.z.min = -rbc.limit_ang_z_lower
rd.z.max = rbc.limit_ang_z_upper
# todo plasticity
# find the root joint, assuming the first one with least parents
parents_map = []
for joint_i, b_joint in enumerate(joint_coll.objects):
Expand Down
1 change: 1 addition & 0 deletions plugin/modules_import/armature.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def import_joints(scene, armature_ob, bone_info, b_bone_names, corrector):
rbc.use_limit_lin_x = rbc.use_limit_lin_y = rbc.use_limit_lin_z = True
rbc.limit_lin_x_lower = rbc.limit_lin_x_upper = rbc.limit_lin_y_lower = rbc.limit_lin_y_upper = \
rbc.limit_lin_z_lower = rbc.limit_lin_z_upper = 0.0
# todo plasticity
ob1 = joint_map[child_name].children[0]
ob2 = joint_map[parent_name].children[0]
rbc.object1 = ob1
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2146dd861 - Mon Nov 6 20:11:34 2023 +0100
b76b6c1e0 - Mon Nov 6 20:47:13 2023 +0100

0 comments on commit bfe6010

Please sign in to comment.