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

Gizmo is rendering based on GizmoTarget's Transform not WorldTransform #76

Open
ethereumdegen opened this issue Sep 6, 2024 · 11 comments

Comments

@ethereumdegen
Copy link

Gizmo is rendering based on GizmoTarget's Transform not WorldTransform

Therefore, child entities whose parents are not all Origin cannot be translated properly... I tried changing gizmo config resource too to no avail

@ethereumdegen
Copy link
Author

To replicate the bug, simply spawn an entity with a nonzero transform, spawn a child under it, and then try to transform the child with the gizmo. The gizmo will be all messed up . ! This is a huge flaw in this crate

@Shenmarukai
Copy link

I'm currently running into the same issue as well.

@Shenmarukai
Copy link

I made a fork that makes the gizmo transform based on the entities global transform instead of its local transform: https://github.com/Shenmarukai/transform-gizmo-global-transform you can use it by replacing transform-gizmo-bevy = "0.3.0" with transform-gizmo-bevy = { git = "https://github.com/Shenmarukai/transform-gizmo-global-transform" }. Let me know if it works for you. :)

@Shenmarukai
Copy link

I made a fork that makes the gizmo transform based on the entities global transform instead of its local transform: https://github.com/Shenmarukai/transform-gizmo-global-transform you can use it by replacing transform-gizmo-bevy = "0.3.0" with transform-gizmo-bevy = { git = "https://github.com/Shenmarukai/transform-gizmo-global-transform" }. Let me know if it works for you. :)

It puts the gizmos in the correct place but its breaking the gizmo control. :( I will see if I can fix that.

@ethereumdegen
Copy link
Author

ethereumdegen commented Sep 6, 2024 via email

@Shenmarukai
Copy link

Shenmarukai commented Sep 6, 2024

Yeah, I got the control to work now but when the parent is rotated the control of the children starts to get wonky, I need to figure out why its doing that.

It would be nice to eventually have an enum on one of the gizmo configs that would let you switch between using the local and global transforms.

@Shenmarukai
Copy link

Turns out its more difficult to fix than I thought but I'm going to keep trying.

@Shenmarukai
Copy link

My latest push seems to be working for rotation and translation. Scaling still needs a fix though.

@ethereumdegen
Copy link
Author

ok my pr is both updated to 0.15 and pulls in your changes to fix this issue as well !

https://github.com/ethereumdegen/transform-gizmo

@ethereumdegen
Copy link
Author

ethereumdegen commented Dec 21, 2024

okay @Shenmarukai and @urholaukkarinen we probably need to test and fix this up a lot more. The new code that allegedly 'fixes' the child local transform (this issue) seems to behave in very bizarre ways. I dont think its rdy to ship.

For example I will rotate an object (who is a child of another object with a non-zero xform) and then i will use the gizmo to translate it and after i translate it about 1.0 units, the rotation will break and go back to default . then if i manually set the rotation Y to 0.0, i can rotate it again to how i want and then translate it again and it works fine. its ... extremely bizarre and weird. Its like it works but i have to fight w it and it does buggy things.

@ethereumdegen
Copy link
Author

ethereumdegen commented Dec 27, 2024

oh i got it !! i figured it out !! by adding normalization to the rotation!

target_transform.rotation = ( rotation_delta * target_transform.rotation.normalize() ).normalize();

it is absolutely critical to add the normalize before and after when doing this ^ when multiplying a scalar to the rotation

now it works much much better for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants