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

Basis inconsistencies between GDScript and C++ #426

Closed
Jummit opened this issue Jul 13, 2020 · 6 comments
Closed

Basis inconsistencies between GDScript and C++ #426

Jummit opened this issue Jul 13, 2020 · 6 comments
Labels
archived bug This has been identified as a bug

Comments

@Jummit
Copy link
Contributor

Jummit commented Jul 13, 2020

godot::Godot::print(Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9)))
// prints 1, 2, 3, 4, 5, 6, 7, 8, 9
godot::Godot::print(Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9)).y);
// prints 2, 5, 8
print(Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9)))
# prints ((1, 4, 7), (2, 5, 8), (3, 6, 9))
print(Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9)).y)
# prints (4, 5, 6)

This could be related to how basis printing works, or with how they are stored, but it affects calculations (GDScript code ported directly to C++ behaves differently, so it should definitely made more consistent.

If I'm missing something here, I'd be happy if someone could clear it up.

Related: godotengine/godot#14553

@Zylann
Copy link
Collaborator

Zylann commented Jul 22, 2020

Printing might be different, but behaviour should at least be the same. You could check that with some test cases to see if the functionality works. If it does, then we can fix the printing to be transposed. If it doesn't work, in doubt, we could re-port the whole class by copying Godot's over to make it up to date.
Although, it's also possible that GDScript exposes Godot's Basis differently than the way it's implemented internally, which could explain the difference.

@sheepandshepherd
Copy link
Contributor

I think printing uses the same convention as GDScript already, even though operator String in Basis formats it without parentheses. The numbers are the same if you let Godot format it:

godot::Godot::print("{0}", Basis(Vector3(1, 2, 3), Vector3(4, 5, 6), Vector3(7, 8, 9)));

The linked issue and PR should have fixed x/y/z already too.

I assume the Basis(Vector3, Vector3, Vector3) constructor is what's causing the incorrect values in both C++ lines. The Basis is just being constructed with the wrong row/column convention, the one used in the core engine.

@BastiaanOlij
Copy link
Collaborator

I assume the Basis(Vector3, Vector3, Vector3) constructor is what's causing the incorrect values in both C++ lines. The Basis is just being constructed with the wrong row/column convention, the one used in the core engine.

If that is true (and from the above print statements I would conclude the same), that is a pretty serious bug

@DmitriySalnikov
Copy link
Contributor

Basis(row0, row1, row2) is still broken. #533 seems to be working correctly.

@Calinou Calinou added the bug This has been identified as a bug label Aug 7, 2022
@aaronfranke
Copy link
Member

PR #859 updated Basis to match the engine core, so if there is an inconsistency then it also exists in the engine.

@akien-mga
Copy link
Member

This issue is pretty old by now and things have changed in 4.0+, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archived bug This has been identified as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants