fix(web): robot rig places bones on the URDF chain and keeps bound worlds
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:
@@ -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')
|
||||
|
||||
BIN
web/app/src/vendor/blender/web_engine.wasm
vendored
BIN
web/app/src/vendor/blender/web_engine.wasm
vendored
Binary file not shown.
Reference in New Issue
Block a user