-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Added method to retrieve a direction vector from one point to another #27452
Conversation
This looks ok, guess it will also need to be added to C# and GDnative :P |
Added to C#, GDNative and fixed "directed from current" to "pointing from this" :) |
4468de3
to
634729d
Compare
modules/gdnative/gdnative_api.json
Outdated
@@ -538,6 +538,14 @@ | |||
["const godot_vector2 *", "p_self"] | |||
] | |||
}, | |||
{ | |||
"name": "godot_vector2_direction_to", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks binary compatibility with all previously build GDNative libraries.
If desired I can start a new GDNative core-extension for this, but in GDNative code it's not as easy as just plugging in code, there's a bit more bookkeeping involved.
If the PR itself is accepted, I can help you set up the extension properly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. should I change it somehow now? I did it cuz @reduz is requested to do it. Overall it is a correct procedure to add something to GDNative ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this workflow is correct if the change is for an "unpublished" extension.
GDNative aims to always be binary compatible, so all functionality is passed via structs which contain function pointers.
Once an extension is released the struct must not change!
To add new functionality a new extension has to be created, which will be available as a gdnative_api_struct_extension *next
field (or something like that).
So the correct way is to add a new "extension" to the core API in the json file, if I coded the code generation properly then it should just work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I remove it for now and you are add it later when you want, ok ? Im not understand how to do it correctly anyways..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, seems fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have dev documentation on how to expose new APIs to GDNative, as it's a recurring topic.
@akien-mga I think it's ok for merging now - I've added it correctly + added to Mono. GDNative is up to @karroffel |
Thanks! |
Cherry-picked for 3.1.1. |
I found its kinda a useful math operation. Direction from vector
a
to vectorb
is :(b - a).normalized
so the proposal is to modify it toa.direction_to(b)
- I think it looks more ellegant and understandable(for newbies especially) than writing it in current form. I've added it to both Vector2 and Vector3.