Merge pull request #63848 from aaronfranke/cs-from-scale

Replace Vector3.ToDiagonalMatrix with Basis.FromScale in C#
This commit is contained in:
Rémi Verschelde 2022-08-04 07:36:32 +02:00 committed by GitHub
commit 0418e81b5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 17 deletions

View File

@ -827,6 +827,22 @@ namespace Godot
Row2 = new Vector3(xz, yz, zz);
}
/// <summary>
/// Constructs a pure scale basis matrix with no rotation or shearing.
/// The scale values are set as the main diagonal of the matrix,
/// and all of the other parts of the matrix are zero.
/// </summary>
/// <param name="scale">The scale Vector3.</param>
/// <returns>A pure scale Basis matrix.</returns>
public static Basis FromScale(Vector3 scale)
{
return new Basis(
scale.x, 0, 0,
0, scale.y, 0,
0, 0, scale.z
);
}
/// <summary>
/// Composes these two basis matrices by multiplying them
/// together. This has the effect of transforming the second basis

View File

@ -235,7 +235,7 @@ namespace Godot
/// <returns>The scaled transformation matrix.</returns>
public Transform3D ScaledLocal(Vector3 scale)
{
Basis tmpBasis = new Basis(new Vector3(scale.x, 0, 0), new Vector3(0, scale.y, 0), new Vector3(0, 0, scale.z));
Basis tmpBasis = Basis.FromScale(scale);
return new Transform3D(basis * tmpBasis, origin);
}

View File

@ -620,22 +620,6 @@ namespace Godot
);
}
/// <summary>
/// Returns a diagonal matrix with the vector as main diagonal.
///
/// This is equivalent to a <see cref="Basis"/> with no rotation or shearing and
/// this vector's components set as the scale.
/// </summary>
/// <returns>A <see cref="Basis"/> with the vector as its main diagonal.</returns>
public Basis ToDiagonalMatrix()
{
return new Basis(
x, 0, 0,
0, y, 0,
0, 0, z
);
}
// Constants
private static readonly Vector3 _zero = new Vector3(0, 0, 0);
private static readonly Vector3 _one = new Vector3(1, 1, 1);