Fix bounding box size setter

This commit is contained in:
Wojciech Figat
2022-01-17 10:12:05 +01:00
parent abb0a3f0cc
commit 465c857ff2
2 changed files with 17 additions and 48 deletions

View File

@@ -71,9 +71,6 @@ namespace FlaxEngine
/// <summary>
/// Gets or sets the size.
/// </summary>
/// <value>
/// The size.
/// </value>
[NoSerialize]
public Vector3 Size
{
@@ -81,17 +78,15 @@ namespace FlaxEngine
set
{
var center = Center;
Minimum = center - value;
Maximum = center + value;
var sizeHalf = value * 0.5f;
Minimum = center - sizeHalf;
Maximum = center + sizeHalf;
}
}
/// <summary>
/// Gets or sets the center point location.
/// </summary>
/// <value>
/// The center.
/// </value>
[NoSerialize]
public Vector3 Center
{
@@ -156,10 +151,7 @@ namespace FlaxEngine
/// Determines if there is an intersection between the current object and a <see cref="Ray" />.
/// </summary>
/// <param name="ray">The ray to test.</param>
/// <param name="distance">
/// When the method completes, contains the distance of the intersection,
/// or 0 if there was no intersection.
/// </param>
/// <param name="distance">When the method completes, contains the distance of the intersection, or 0 if there was no intersection.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray, out float distance)
{
@@ -170,10 +162,7 @@ namespace FlaxEngine
/// Determines if there is an intersection between the current object and a <see cref="Ray" />.
/// </summary>
/// <param name="ray">The ray to test.</param>
/// <param name="point">
/// When the method completes, contains the point of intersection,
/// or <see cref="Vector3.Zero" /> if there was no intersection.
/// </param>
/// <param name="point">When the method completes, contains the point of intersection, or <see cref="Vector3.Zero" /> if there was no intersection.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray, out Vector3 point)
{
@@ -516,10 +505,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="left">The first value to compare.</param>
/// <param name="right">The second value to compare.</param>
/// <returns>
/// <c>true</c> if <paramref name="left" /> has the same value as <paramref name="right" />; otherwise,
/// <c>false</c>.
/// </returns>
/// <returns><c>true</c> if <paramref name="left" /> has the same value as <paramref name="right" />; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(BoundingBox left, BoundingBox right)
{
@@ -531,10 +517,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="left">The first value to compare.</param>
/// <param name="right">The second value to compare.</param>
/// <returns>
/// <c>true</c> if <paramref name="left" /> has a different value than <paramref name="right" />; otherwise,
/// <c>false</c>.
/// </returns>
/// <returns><c>true</c> if <paramref name="left" /> has a different value than <paramref name="right" />; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(BoundingBox left, BoundingBox right)
{
@@ -544,9 +527,7 @@ namespace FlaxEngine
/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture,
@@ -577,9 +558,7 @@ namespace FlaxEngine
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <param name="formatProvider">The format provider.</param>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
public string ToString(IFormatProvider formatProvider)
{
return string.Format(formatProvider,
@@ -593,9 +572,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="format">The format.</param>
/// <param name="formatProvider">The format provider.</param>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
public string ToString(string format, IFormatProvider formatProvider)
{
if (format == null)
@@ -610,9 +587,7 @@ namespace FlaxEngine
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode()
{
unchecked
@@ -625,9 +600,7 @@ namespace FlaxEngine
/// Determines whether the specified <see cref="Vector4" /> is equal to this instance.
/// </summary>
/// <param name="value">The <see cref="Vector4" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="Vector4" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
/// <returns><c>true</c> if the specified <see cref="Vector4" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref BoundingBox value)
{
@@ -638,9 +611,7 @@ namespace FlaxEngine
/// Determines whether the specified <see cref="Vector4" /> is equal to this instance.
/// </summary>
/// <param name="value">The <see cref="Vector4" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="Vector4" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
/// <returns><c>true</c> if the specified <see cref="Vector4" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(BoundingBox value)
{
@@ -651,14 +622,11 @@ namespace FlaxEngine
/// Determines whether the specified <see cref="System.Object" /> is equal to this instance.
/// </summary>
/// <param name="value">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
/// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.</returns>
public override bool Equals(object value)
{
if (!(value is BoundingBox))
return false;
var strongValue = (BoundingBox)value;
return Equals(ref strongValue);
}

View File

@@ -127,8 +127,9 @@ public:
{
Vector3 center;
GetCenter(center);
Minimum = center - value;
Maximum = center + value;
const Vector3 sizeHalf = value * 0.5f;
Minimum = center - sizeHalf;
Maximum = center + sizeHalf;
}
/// <summary>