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

Added method to retrieve a direction vector from one point to another #27452

Merged
merged 1 commit into from
Apr 8, 2019

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Mar 27, 2019

I found its kinda a useful math operation. Direction from vector a to vector b is : (b - a).normalized so the proposal is to modify it to a.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.

@Chaosus Chaosus requested review from reduz and a team as code owners March 27, 2019 10:57
@Chaosus Chaosus added this to the 3.2 milestone Mar 27, 2019
@Chaosus Chaosus changed the title Added direction_to method to vectors Added method to retrieve a direction of two vectors Mar 27, 2019
@Chaosus Chaosus changed the title Added method to retrieve a direction of two vectors Added method to retrieve a direction from one vector to another Mar 27, 2019
@Chaosus Chaosus changed the title Added method to retrieve a direction from one vector to another Added method to retrieve a direction vector from one point to another Mar 27, 2019
@reduz
Copy link
Member

reduz commented Apr 4, 2019

This looks ok, guess it will also need to be added to C# and GDnative :P

doc/classes/Vector2.xml Outdated Show resolved Hide resolved
@Chaosus
Copy link
Member Author

Chaosus commented Apr 4, 2019

Added to C#, GDNative and fixed "directed from current" to "pointing from this" :)

@Chaosus Chaosus force-pushed the direction_to branch 4 times, most recently from 4468de3 to 634729d Compare April 4, 2019 17:31
modules/mono/glue/Managed/Files/Vector2.cs Outdated Show resolved Hide resolved
modules/mono/glue/Managed/Files/Vector3.cs Outdated Show resolved Hide resolved
@@ -538,6 +538,14 @@
["const godot_vector2 *", "p_self"]
]
},
{
"name": "godot_vector2_direction_to",
Copy link
Contributor

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!

Copy link
Member Author

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 ?

Copy link
Contributor

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.

Copy link
Member Author

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..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems fine

Copy link
Member

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.

modules/gdnative/gdnative_api.json Outdated Show resolved Hide resolved
@Chaosus
Copy link
Member Author

Chaosus commented Apr 8, 2019

@akien-mga I think it's ok for merging now - I've added it correctly + added to Mono. GDNative is up to @karroffel

@Chaosus Chaosus dismissed karroffel’s stale review April 8, 2019 06:14

I removed GDNative version

@akien-mga akien-mga merged commit 7f3373d into godotengine:master Apr 8, 2019
@akien-mga
Copy link
Member

Thanks!

@Chaosus Chaosus deleted the direction_to branch April 8, 2019 10:01
@hpvb
Copy link
Member

hpvb commented Apr 20, 2019

Cherry-picked for 3.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants