Closed TokisanGames closed 6 months ago
See the latest documentation, it has been updated to clarify this
What works in GDScript should also work in GDExtension. A passible, but tacky alternative is documentation on how it should be done differently in GDExtension.
godot-cpp aims to be compatible with the internal engine API used by Godot modules, and this is how Basis
works in the engine (which is different than how than it works in GDScript).
I understand that this is confusing - it confused me when I started contributing to the engine too! I'm glad this is represented in the docs now, as @AThousandShips points out. But it's not something we can change in Godot 4.x for compatibility reasons.
Closing since its by design and documented here and in docs.
The documentation should also suggest using the axes constructor: Basis(x_axis, y_axis, z_axis)
;
Godot version
4.2.1-stable
godot-cpp version
4.1.3 631cd5f and godot-4.2.1-stable
System information
Windows 11/64, RTX 3070, Vulkan
Issue description
GDExtension swaps some variables in
Basis
and gives different (wrong) results compared to GDScript in Godot-cpp 4.1.3 and 4.2.1. Inserting and printing the individual x/y/z vectors is fine. However, when printing the Basis, using it, orthonormalizing it, using it in a Transform3D, the end result is wrong.I can manually swap y.z and z.y, however this negates x.y and whether I insert x.y as positive or negative, I cannot get it to turn positive again.
May be related to issue #426 and PR #859
I was able to get it to work by using the axes constructor. Even though the stored axes are wrong, I'm able to get the same orthonormalized result in the basis as the GDScript version.
So, at the very least, the documentation is missing or inaccurate as it clearly states using [] is the same as accessing the axes directly and gives no indication that any thing else is needed. There's even a note that C# is different from GDScript, but that link says nothing about this.
What works in GDScript should also work in GDExtension. A passible, but tacky alternative is documentation on how it should be done differently in GDExtension.