GodotVR / godot-xr-tools

Support scenes for AR and VR in Godot
MIT License
525 stars 75 forks source link

Whats the point of this line of code? (hand_physics_bone.gd) #689

Closed TrevorBlythe closed 4 weeks ago

TrevorBlythe commented 1 month ago

Why are you doing this

# This method teleports the physics-bone to the skeletal-bone.
func _teleport_bone() -> void:
    # Get the bone transform
    var bone_xform := _skeletal_bone.global_transform

        #Set the bone position
    _physics_bone.global_transform = Transform3D(
        Basis(bone_xform.basis.get_rotation_quaternion()),
        bone_xform.origin)

Why dont you just set the transforms to be the same directly? like this ->

    # Set the bone position
    _physics_bone.global_transform = _skeletal_bone.global_transform

I tried it and nothing changed in my game so I guess it worked?

ProPuke commented 1 month ago

They're avoiding differences in scale. Their code only applies the rotation and translation, but not scale. So in cases where a bone is stretched or squished the physics bone will still be uniform scale.

I don't believe physics bones support non-uniform scales, so this is probably to avoid spamming the console with warnings when that happens.

TrevorBlythe commented 4 weeks ago

alright my bad