Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set_bone_pose(bone_idx : int, t : Transform3D) to Skeleton3D #8869

Closed
soppermann opened this issue Jan 12, 2024 · 2 comments
Closed

Add set_bone_pose(bone_idx : int, t : Transform3D) to Skeleton3D #8869

soppermann opened this issue Jan 12, 2024 · 2 comments

Comments

@soppermann
Copy link

soppermann commented Jan 12, 2024

Describe the project you are working on

A VR game that procedurally poses a Skeleton3D

Describe the problem or limitation you are having in your project

There is no Skeleton3D function that accepts a Transform3D to get a bone's local transform. I currently set_bone_pose_position(), set_bone_pose_rotation() and set_bone_pose_scale(), which adds unnecessary lines of code, is less efficient, and I believe it can't be used to properly set all possible transforms (i.e. shears).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Adding set_bone_pose(t : Transform3D) to Skeleton3D turns three lines of code to set local transform into one and allows for any valid Transform3D.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Currently, I have:

func set_bone_local_transform(skeleton : Skeleton3D, bone_idx : int, t : Transform3D):
	skeleton.set_bone_pose_position(bone_idx, t.origin)
	skeleton.set_bone_pose_rotation(bone_idx, t.basis.get_rotation_quaternion())
	skeleton.set_bone_pose_scale(bone_idx, t.basis.get_scale())

With the change, it would be:

func set_bone_local_transform(skeleton : Skeleton3D, bone_idx : int, t : Transform3D):
        skeleton.set_bone_pose(bone_idx, t)

If this enhancement will not be used often, can it be worked around with a few lines of script?

I'm unaware of a way to access and set the local transform of each bone directly, and using set_bone_pose_position(), set_bone_pose_rotation() and set_bone_pose_scale() is a workaround in most cases, I'm unsure if it will work as expected for every possible Transform3D.

Is there a reason why this should be core and not an add-on in the asset library?

set_bone_rest() and set_bone_global_pose_override() already do this for rest poses and global poses. It makes sense to do the same for the bone pose.

@goatchurchprime
Copy link

It appears that this is now in 4.3, according to the docs https://docs.godotengine.org/en/latest/classes/class_skeleton3d.html#class-skeleton3d-method-set-bone-pose

It looks like it got in with this humongous Pull Request godotengine/godot#87888 so it can probably be closed.

Just as an aside, another reason that we needed this is that it's sometimes necessary to apply non-orthogonal bone transforms in a skeleton that will compose into orthogonal transforms. For example, if you want to undo a scaling in one axis on the previous bone, apply a rotation, and scale back in a different axis you need to multiply by a non-orthogonal basis.

@Calinou
Copy link
Member

Calinou commented Aug 2, 2024

Closing per @goatchurchprime's comment.

@Calinou Calinou closed this as completed Aug 2, 2024
@Calinou Calinou added this to the 4.3 milestone Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants