fix(web): robot rig places bones on the URDF chain and keeps bound worlds
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

The rig step placed every bone at its parent-link-relative URDF offset and
the engine's keep_transform world recursion treated already-bound ancestors
as plain PAROBJECT, so binding in chain order dropped the ancestor bone
matrix and every link jumped on the rig click (deltas up to 1.26).

- set_parent: refresh the pose before computing the world and compose
  PARBONE ancestors like BKE_object_calc_parent/ob_parbone.
- robot-workflow rig: accumulate URDF joint frames from rootLink (fixed
  joints included) and place head/axis on the real joint position.
- robot-rig-web now asserts zero world drift, bone pivots on the URDF
  joints, bone Y on the joint axes, joint_3 rotation moving only its
  subtree about the true axis, and 恢复零位 restoring every link.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-29 19:20:27 +08:00
parent 8f08c1bda9
commit 013ea78a45
7 changed files with 133 additions and 40 deletions

View File

@@ -94,12 +94,19 @@ elif action=='rig':
arm.parent=root;arm.matrix_parent_inverse=Matrix.Identity(4);arm.matrix_basis=Matrix.Identity(4)
bpy.context.view_layer.objects.active=arm
bpy.ops.object.mode_set(mode='EDIT')
frames={model['rootLink']:Matrix.Identity(4)};pending=list(model['joints'])
while pending:
progressed=False
for joint in list(pending):
if joint['parent'] in frames:
frames[joint['child']]=frames[joint['parent']]@origin(joint);pending.remove(joint);progressed=True
if not progressed:raise RuntimeError('URDF 关节链不完整')
previous=None;bindings={}
for joint in model['joints']:
if joint['type']=='fixed':continue
head=origin(joint).translation.copy()
frame=frames[joint['child']];head=frame.translation.copy()
bone=armature.edit_bones.new(joint['name'])
bone.head=head;bone.tail=head+Vector(joint['axis']).normalized()*.12
bone.head=head;bone.tail=head+(frame.to_3x3()@Vector(joint['axis']).normalized())*.12
if previous:bone.parent=armature.edit_bones[previous]
previous=joint['name'];bindings[joint['child']]=joint['name']
bpy.ops.object.mode_set(mode='OBJECT')

Binary file not shown.