-
-
Notifications
You must be signed in to change notification settings - Fork 97
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 to_global_basis()
and to_local_basis()
to Spatial/Node2D
#857
Comments
Note that I opened this proposal instead of directly making a PR because I added these methods on the 3.2 branch. master is somewhat broken for me, and there is also the issue of renamed nodes: I could not find Spatial in the master branch, and I didn't see any Node3D either, so I would appreciate if someone could tell me what the new name for the Spatial node is. Also, unless this would only be added to Godot 4, the change has to be made specifically for both 3.2 and 4.0. Edit: I found this PR which states Spatial is now Node3D, but for some reason it doesn't show up in QtCreator for me - though the files are in the source and the Godot.files and Godot.includes do list them as well. Edit again: I fixed my issue with QtCreator, the node_3d files were not actually in Godot.files, so I have also added this to Node3D on master. My question then is how should I make my PR? Doing it on master is the obvious option, but is not compatible with 3.2 for Spatial nodes. The changes are however simple enough that they can be backported to 3.2 with minimal effort. |
In this case, you should remake the PR manually against the |
I don't think this is a useful feature, the use cases are pretty uncommon. In the demo projects:
There are only 7 places where these functions could be used, all of them in the 3D IK demo, 6 of them in It also hides the fact that (copied from my review in the PR) |
I don't think this should be added. The to_global() and to_local() make sense, they are simple enough and a lot of people are using it to transform mouse positions. They are definitely useful even if we don't use them a lot in the demo projects. (I basically advised yesterday to use it, as it's a lot simpler than using transforms, to map a coordinate from a tilemap to the global coordinates) But regarding the proposal, I think the "basis" ones are kind of confusing. While it's easy to understand the current versions, those are significantly harder to understand, and bring confusion to the user when having to choose which function to use. |
Looks like I proposed this while thinking more about my own project (3D and physics based, I have lots of |
We already have documentation articles such as Matrices and transforms, which comes with a minimal project that allows users to manually play around with transforms. We don't currently have a policy on what kinds of demos we should have (see 349 and 390), I'm not sure we need such a demo. |
to_global_basis()
and to_local_basis()
to Spatial/Node2D
The PR implementing this proposal was rejected, so closing this too. |
Describe the project you are working on:
This proposal is not related to any particular project.
Describe the problem or limitation you are having in your project:
Transforming direction vectors from local space to global space (or the other way around) can be cumbersome and unintuitive, with calls such as
spatial.get_global_transform.basis.xform_inv(vector3)
.Describe the feature / enhancement and how it helps to overcome the problem or limitation:
I propose adding a
to_global_basis(vector3)
method (and the equivalent to_local_basis) to Spatial nodes. This is mainly for convenience, similar to the already availableto_global
method. For Node2D, I am not sure whetherto_global_basis
orto_global_rotation
would make more sense.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
I have already added these methods in the following way:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
This can of course be worked around easily, the point of this proposal is to add convenience to manipulation of vectors, which could be used often, especially by beginners.
Is there a reason why this should be core and not an add-on in the asset library?:
Again, this is mainly for convenience, in the same way
to_global
andto_local
have already been made available, but are only suitable for position vectors.The text was updated successfully, but these errors were encountered: