diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-26 18:58:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-26 18:58:25 +0200 |
commit | 140e7e5edf33adaf12c8a1f4050256f3fe54b4ce (patch) | |
tree | 07a82900ccbd1df8dad6c38bba86ce594440833c /modules/gdnative | |
parent | 39579d2a6d1a59edfd49d054804f173f0d25d900 (diff) | |
parent | bf237f651c09f4670baa84610ec41e2a36b1a6a4 (diff) |
Merge pull request #30788 from Chaosus/direction_to_gdnative
Added Vector2/3.direction_to methods to GDNative
Diffstat (limited to 'modules/gdnative')
-rw-r--r-- | modules/gdnative/gdnative/vector2.cpp | 8 | ||||
-rw-r--r-- | modules/gdnative/gdnative/vector3.cpp | 8 | ||||
-rw-r--r-- | modules/gdnative/gdnative_api.json | 16 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/vector2.h | 2 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/vector3.h | 2 |
5 files changed, 36 insertions, 0 deletions
diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index a2ac61b35e..d82f2c692d 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -77,6 +77,14 @@ godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self) { return self->is_normalized(); } +godot_vector2 GDAPI godot_vector2_direction_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { + godot_vector2 dest; + const Vector2 *self = (const Vector2 *)p_self; + const Vector2 *to = (const Vector2 *)p_to; + *((Vector2 *)&dest) = self->direction_to(*to); + return dest; +} + godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to) { const Vector2 *self = (const Vector2 *)p_self; const Vector2 *to = (const Vector2 *)p_to; diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index 894683ab38..15a8ef9a2e 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -182,6 +182,14 @@ godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self) { return dest; } +godot_vector3 GDAPI godot_vector3_direction_to(const godot_vector3 *p_self, const godot_vector3 *p_to) { + godot_vector3 dest; + const Vector3 *self = (const Vector3 *)p_self; + const Vector3 *to = (const Vector3 *)p_to; + *((Vector3 *)&dest) = self->direction_to(*to); + return dest; +} + godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b) { const Vector3 *self = (const Vector3 *)p_self; const Vector3 *b = (const Vector3 *)p_b; diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 7372990d5f..8dcea26a7b 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -64,6 +64,22 @@ ["godot_int", "p_from"], ["godot_int", "p_to"] ] + }, + { + "name": "godot_vector3_direction_to", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_to"] + ] + }, + { + "name": "godot_vector2_direction_to", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_to"] + ] } ] }, diff --git a/modules/gdnative/include/gdnative/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 7a5ae6afa9..15a6c80887 100644 --- a/modules/gdnative/include/gdnative/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -71,6 +71,8 @@ godot_real GDAPI godot_vector2_length_squared(const godot_vector2 *p_self); godot_bool GDAPI godot_vector2_is_normalized(const godot_vector2 *p_self); +godot_vector2 GDAPI godot_vector2_direction_to(const godot_vector2 *p_self, const godot_vector2 *p_b); + godot_real GDAPI godot_vector2_distance_to(const godot_vector2 *p_self, const godot_vector2 *p_to); godot_real GDAPI godot_vector2_distance_squared_to(const godot_vector2 *p_self, const godot_vector2 *p_to); diff --git a/modules/gdnative/include/gdnative/vector3.h b/modules/gdnative/include/gdnative/vector3.h index 70ec6422ac..ee7d029028 100644 --- a/modules/gdnative/include/gdnative/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -106,6 +106,8 @@ godot_vector3 GDAPI godot_vector3_floor(const godot_vector3 *p_self); godot_vector3 GDAPI godot_vector3_ceil(const godot_vector3 *p_self); +godot_vector3 GDAPI godot_vector3_direction_to(const godot_vector3 *p_self, const godot_vector3 *p_b); + godot_real GDAPI godot_vector3_distance_to(const godot_vector3 *p_self, const godot_vector3 *p_b); godot_real GDAPI godot_vector3_distance_squared_to(const godot_vector3 *p_self, const godot_vector3 *p_b); |