diff options
author | Anilforextra <anilforextra@gmail.com> | 2021-09-21 00:33:52 +0545 |
---|---|---|
committer | Anilforextra <anilforextra@gmail.com> | 2021-09-21 21:14:17 +0545 |
commit | 90908cd67d3f44ba70cc4b7b32f024ce508cc0ee (patch) | |
tree | 4c3f64aa550e6dc763b9776dded65560b67db2cc /modules/mono/glue | |
parent | 87de2e7c4a38b1258d9a554c7f50cdbd8ac825fa (diff) |
Add Get Center Method for Rect2/Rect2i and AABB.
Diffstat (limited to 'modules/mono/glue')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs | 10 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs | 10 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs | 14 |
3 files changed, 33 insertions, 1 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs index 8b12537f7f..70a2cf5695 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/AABB.cs @@ -67,6 +67,16 @@ namespace Godot } /// <summary> + /// Returns the center of the <see cref="AABB"/>, which is equal + /// to <see cref="Position"/> + (<see cref="Size"/> / 2). + /// </summary> + /// <returns>The center.</returns> + public Vector3 GetCenter() + { + return _position + (_size * 0.5f); + } + + /// <summary> /// Returns <see langword="true"/> if this <see cref="AABB"/> completely encloses another one. /// </summary> /// <param name="with">The other <see cref="AABB"/> that may be enclosed.</param> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs index 1d001fba2d..af94484577 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2.cs @@ -165,6 +165,16 @@ namespace Godot } /// <summary> + /// Returns the center of the <see cref="Rect2"/>, which is equal + /// to <see cref="Position"/> + (<see cref="Size"/> / 2). + /// </summary> + /// <returns>The center.</returns> + public Vector2 GetCenter() + { + return _position + (_size * 0.5f); + } + + /// <summary> /// Returns a copy of the <see cref="Rect2"/> grown by the specified amount /// on all sides. /// </summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs index 250b0d0baf..03f406a910 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Rect2i.cs @@ -151,7 +151,7 @@ namespace Godot } /// <summary> - /// Returns the area of the <see cref="Rect2"/>. + /// Returns the area of the <see cref="Rect2i"/>. /// </summary> /// <returns>The area.</returns> public int GetArea() @@ -160,6 +160,18 @@ namespace Godot } /// <summary> + /// Returns the center of the <see cref="Rect2i"/>, which is equal + /// to <see cref="Position"/> + (<see cref="Size"/> / 2). + /// If <see cref="Size"/> is an odd number, the returned center + /// value will be rounded towards <see cref="Position"/>. + /// </summary> + /// <returns>The center.</returns> + public Vector2i GetCenter() + { + return _position + (_size / 2); + } + + /// <summary> /// Returns a copy of the <see cref="Rect2i"/> grown by the specified amount /// on all sides. /// </summary> |