Add Get Center Method for Rect2/Rect2i and AABB.
This commit is contained in:
@@ -517,7 +517,7 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac
|
||||
int index = r_max_alloc++;
|
||||
FaceBVH *_new = &facebvhptr[index];
|
||||
_new->aabb = aabb;
|
||||
_new->center = aabb.position + aabb.size * 0.5;
|
||||
_new->center = aabb.get_center();
|
||||
_new->face = -1;
|
||||
_new->left = left;
|
||||
_new->right = right;
|
||||
@@ -678,7 +678,7 @@ void CSGBrushOperation::MeshMerge::mark_inside_faces() {
|
||||
facebvh[i].aabb.position = points[faces[i].points[0]];
|
||||
facebvh[i].aabb.expand_to(points[faces[i].points[1]]);
|
||||
facebvh[i].aabb.expand_to(points[faces[i].points[2]]);
|
||||
facebvh[i].center = facebvh[i].aabb.position + facebvh[i].aabb.size * 0.5;
|
||||
facebvh[i].center = facebvh[i].aabb.get_center();
|
||||
facebvh[i].aabb.grow_by(vertex_snap);
|
||||
facebvh[i].next = -1;
|
||||
|
||||
|
||||
@@ -66,6 +66,16 @@ namespace Godot
|
||||
return new AABB(topLeft, _size.Abs());
|
||||
}
|
||||
|
||||
/// <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>
|
||||
|
||||
@@ -164,6 +164,16 @@ namespace Godot
|
||||
return _size.x * _size.y;
|
||||
}
|
||||
|
||||
/// <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.
|
||||
|
||||
@@ -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()
|
||||
@@ -159,6 +159,18 @@ namespace Godot
|
||||
return _size.x * _size.y;
|
||||
}
|
||||
|
||||
/// <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.
|
||||
|
||||
Reference in New Issue
Block a user