[Code] Only need to test LengthSquared against ZeroTolerance for vectors to avoid square root calculation
This commit is contained in:
Родитель
eb55baaaba
Коммит
b30d38dd83
|
@ -71,7 +71,7 @@ namespace Xenko.Graphics
|
|||
throw new ArgumentNullException("texture");
|
||||
|
||||
// Skip items with null size
|
||||
if (elementSize.Length() < MathUtil.ZeroTolerance)
|
||||
if (elementSize.LengthSquared() < MathUtil.ZeroTolerance)
|
||||
return;
|
||||
|
||||
// Calculate the information needed to draw.
|
||||
|
|
|
@ -269,7 +269,7 @@ namespace Xenko.Graphics
|
|||
var elementSize = new Vector2(
|
||||
auxiliaryScaling.X * glyph.Subrect.Width / realVirtualResolutionRatio.X,
|
||||
auxiliaryScaling.Y * glyph.Subrect.Height / realVirtualResolutionRatio.Y);
|
||||
if (elementSize.Length() < MathUtil.ZeroTolerance)
|
||||
if (elementSize.LengthSquared() < MathUtil.ZeroTolerance)
|
||||
return;
|
||||
|
||||
var xShift = x;
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace Xenko.Graphics
|
|||
public void DrawRectangle(ref Matrix worldMatrix, ref Vector3 elementSize, ref Color color, int depthBias)
|
||||
{
|
||||
// Skip items with null size
|
||||
if (elementSize.Length() < MathUtil.ZeroTolerance)
|
||||
if (elementSize.LengthSquared() < MathUtil.ZeroTolerance)
|
||||
return;
|
||||
|
||||
// Calculate the information needed to draw.
|
||||
|
@ -277,7 +277,7 @@ namespace Xenko.Graphics
|
|||
private void DrawCube(ref Matrix worldMatrix, ref Vector3 elementSize, ref Color color, int depthBias, bool isReverse)
|
||||
{
|
||||
// Skip items with null size
|
||||
if (elementSize.Length() < MathUtil.ZeroTolerance)
|
||||
if (elementSize.LengthSquared() < MathUtil.ZeroTolerance)
|
||||
return;
|
||||
|
||||
// Calculate the information needed to draw.
|
||||
|
@ -331,7 +331,7 @@ namespace Xenko.Graphics
|
|||
if (texture == null) throw new ArgumentNullException(nameof(texture));
|
||||
|
||||
// Skip items with null size
|
||||
if (elementSize.Length() < MathUtil.ZeroTolerance)
|
||||
if (elementSize.LengthSquared() < MathUtil.ZeroTolerance)
|
||||
return;
|
||||
|
||||
// Calculate the information needed to draw.
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Xenko.Physics
|
|||
Matrix rotationMatrix;
|
||||
var oY = Vector3.Normalize(Normal);
|
||||
var oZ = Vector3.Cross(Vector3.UnitX, oY);
|
||||
if (oZ.Length() > MathUtil.ZeroTolerance)
|
||||
if (oZ.LengthSquared() > MathUtil.ZeroTolerance)
|
||||
{
|
||||
oZ.Normalize();
|
||||
var oX = Vector3.Cross(oY, oZ);
|
||||
|
|
Загрузка…
Ссылка в новой задаче