diff --git a/plugin/modules_export/armature.py b/plugin/modules_export/armature.py index 0e68e9794..ea5d8296c 100644 --- a/plugin/modules_export/armature.py +++ b/plugin/modules_export/armature.py @@ -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): diff --git a/plugin/modules_import/armature.py b/plugin/modules_import/armature.py index 9464525e7..c2956747f 100644 --- a/plugin/modules_import/armature.py +++ b/plugin/modules_import/armature.py @@ -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 diff --git a/version.txt b/version.txt index 0ef409813..9ea1ce9fc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2146dd861 - Mon Nov 6 20:11:34 2023 +0100 \ No newline at end of file +b76b6c1e0 - Mon Nov 6 20:47:13 2023 +0100 \ No newline at end of file