godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.96k stars 19.49k forks source link

Rotating a node 90/180 degrees through the Euler angle rotation mode in inspector does not produce the same basis as using the quaternion or matrix properties. #92898

Open ModularNucleus opened 1 month ago

ModularNucleus commented 1 month ago

Tested versions

Reproducible in:

System information

Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.3758) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

I am unsure if this is actually a bug, because of:

The issue is: When rotating a Node3D 90 or 180 degrees by using the Euler angle properties in the inspector, the resulting basis is not identical to the one produced by performing the same rotation using the quaternion or basis rotation edit modes.

E.g., rotating th x-axis 90 degrees produces the following transform when the scene is viewed in Notepad++: transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)

billede

Rotating the node by pasting the quaternion (0.707, 0, 0, 0.707) into the quaternion field produces the following basis: transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)

billede

Rotating the node using the basis rotation mode also produces the following basis: transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)

billede

Switching rotation modes: Switching the rotation edit mode to quaternion or basis modes after having rotated using Euler retains the Euler-derived basis: transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)

billede

Switching to Euler rotation mode after having first rotated via quaternion or basis retains the quaternion/basis-derived basis:

billede

Like I said, I do not really know if this is expected behaviour, e.g., due to precision issues, but it does seem a little odd to me.

Steps to reproduce

Minimal reproduction project (MRP)

rotation_test.zip

AThousandShips commented 1 month ago

This is likely due to rounding errors, the values are very tiny and reasonably within margins for comparison, remember that the angle mode will perform several conversions, first from degrees to radians, and then computing the transform