Use in over ref modifier in Math functions input parameters

This commit is contained in:
2025-12-06 23:32:47 +02:00
parent ecf074801f
commit bc4b94d2bc
136 changed files with 1824 additions and 1824 deletions

View File

@@ -164,11 +164,11 @@ namespace FlaxEditor.CustomEditors.Dedicated
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
// Deselect
if (isSelected && button1Rect.Contains(ref location))
if (isSelected && button1Rect.Contains(location))
Value = new ModelInstanceActor.MeshReference { Actor = null, LODIndex = -1, MeshIndex = -1 };
// Picker dropdown menu
if ((isSelected ? button2Rect : button1Rect).Contains(ref location))
if ((isSelected ? button2Rect : button1Rect).Contains(location))
ShowDropDownMenu();
return base.OnMouseUp(location, button);

View File

@@ -192,7 +192,7 @@ namespace FlaxEditor.CustomEditors.Editors
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (DropdownRect.Contains(ref location))
if (DropdownRect.Contains(location))
{
Focus();
ShowPicker();
@@ -206,7 +206,7 @@ namespace FlaxEditor.CustomEditors.Editors
{
base.OnMouseMove(location);
if (DropdownRect.Contains(ref location))
if (DropdownRect.Contains(location))
Cursor = CursorType.Default;
else
Cursor = CursorType.IBeam;

View File

@@ -155,7 +155,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
{
_arrangeButtonInUse = true;
Focus();
@@ -371,7 +371,7 @@ namespace FlaxEditor.CustomEditors.Editors
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
{
_arrangeButtonInUse = true;
Focus();

View File

@@ -321,11 +321,11 @@ namespace FlaxEditor.CustomEditors.Editors
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
// Deselect
if (_value != null && button1Rect.Contains(ref location))
if (_value != null && button1Rect.Contains(location))
Value = null;
// Picker dropdown menu
if (_supportsPickDropDown && (isSelected ? button2Rect : button1Rect).Contains(ref location))
if (_supportsPickDropDown && (isSelected ? button2Rect : button1Rect).Contains(location))
{
ShowDropDownMenu();
return true;

View File

@@ -219,11 +219,11 @@ namespace FlaxEditor.CustomEditors.Editors
var button2Rect = new Rectangle(button1Rect.Right + 2, 1, 14, 14);
// Deselect
if (_value && button1Rect.Contains(ref location) && _type == ScriptType.Null)
if (_value && button1Rect.Contains(location) && _type == ScriptType.Null)
Value = ScriptType.Null;
// Picker dropdown menu
if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(ref location))
if ((isSelected && _type == ScriptType.Null ? button2Rect : button1Rect).Contains(location))
ShowDropDownMenu();
return base.OnMouseUp(location, button);

View File

@@ -1056,7 +1056,7 @@ namespace FlaxEditor
if (actor)
{
Internal_GetEditorBoxWithChildren(FlaxEngine.Object.GetUnmanagedPtr(actor), out var box);
BoundingSphere.FromBox(ref box, out sphere);
BoundingSphere.FromBox(box, out sphere);
if (sphere == BoundingSphere.Empty)
sphere = new BoundingSphere(actor.Position, sphere.Radius);
sphere.Radius = Math.Max(sphere.Radius, 15.0f);

View File

@@ -96,7 +96,7 @@ namespace FlaxEditor.GUI
private void DoDrag()
{
// Do the drag drop operation if has selected element
if (new Rectangle(Float2.Zero, Size).Contains(ref _mouseDownPos))
if (new Rectangle(Float2.Zero, Size).Contains(_mouseDownPos))
{
if (Validator.SelectedAsset != null)
DoDragDrop(DragAssets.GetDragData(Validator.SelectedAsset));

View File

@@ -62,7 +62,7 @@ namespace FlaxEditor.GUI
for (int i = 0; i < children.Count; i++)
{
if (children[i] is KeyframePoint p)
p.IsSelected = p.Bounds.Intersects(ref selectionRect);
p.IsSelected = p.Bounds.Intersects(selectionRect);
}
_editor.UpdateTangents();
}
@@ -85,7 +85,7 @@ namespace FlaxEditor.GUI
internal void OnMove(Float2 location)
{
// Skip updating keyframes until move actual starts to be meaningful
if (Float2.Distance(ref _movingSelectionStartPosLock, ref location) < 1.5f)
if (Float2.Distance(_movingSelectionStartPosLock, location) < 1.5f)
return;
_movingSelectionStartPosLock = Float2.Minimum;

View File

@@ -689,8 +689,8 @@ namespace FlaxEditor.GUI
if (selectedOnly && !point.IsSelected)
continue;
var pos = point.Point;
Float2.Min(ref posMin, ref pos, out posMin);
Float2.Max(ref posMax, ref pos, out posMax);
Float2.Min(posMin, pos, out posMin);
Float2.Max(posMax, pos, out posMax);
}
// Apply margin around the area
@@ -703,16 +703,16 @@ namespace FlaxEditor.GUI
PointFromKeyframesToContents(ref posMin, ref viewRect);
PointFromKeyframesToContents(ref posMax, ref viewRect);
var tmp = posMin;
Float2.Min(ref posMin, ref posMax, out posMin);
Float2.Max(ref posMax, ref tmp, out posMax);
Float2.Min(posMin, posMax, out posMin);
Float2.Max(posMax, tmp, out posMax);
var contentsSize = posMax - posMin;
// Convert from Contents to Main Panel
posMin = _contents.PointToParent(posMin);
posMax = _contents.PointToParent(posMax);
tmp = posMin;
Float2.Min(ref posMin, ref posMax, out posMin);
Float2.Max(ref posMax, ref tmp, out posMax);
Float2.Min(posMin, posMax, out posMin);
Float2.Max(posMax, tmp, out posMax);
// Update zoom (leave unchanged when focusing a single point)
var zoomMask = EnableZoom;

View File

@@ -180,7 +180,7 @@ namespace FlaxEditor.GUI.Input
Focus();
float mousePosition = location.X;
if (_thumbRect.Contains(ref location))
if (_thumbRect.Contains(location))
{
// Start sliding
_isSliding = true;

View File

@@ -144,7 +144,7 @@ namespace FlaxEditor.GUI.Timeline
var k = keyframes[i];
var sphere = new BoundingSphere(k.Value, KeyframeSize);
if (sphere.Intersects(ref selectRay))
if (sphere.Intersects(selectRay))
{
SelectKeyframe(_track, i, 0);
return;
@@ -154,7 +154,7 @@ namespace FlaxEditor.GUI.Timeline
{
var t = k.Value + k.TangentIn;
var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize));
if (box.Intersects(ref selectRay))
if (box.Intersects(selectRay))
{
SelectKeyframe(_track, i, 1);
return;
@@ -165,7 +165,7 @@ namespace FlaxEditor.GUI.Timeline
{
var t = k.Value + k.TangentOut;
var box = BoundingBox.FromSphere(new BoundingSphere(t, TangentSize));
if (box.Intersects(ref selectRay))
if (box.Intersects(selectRay))
{
SelectKeyframe(_track, i, 2);
return;

View File

@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
/// <inheritdoc />
public override void OnMouseMove(Float2 location)
{
if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
if (_isMoving && Float2.DistanceSquared(location, _startMovePos) > 25.0f)
{
_startMovePos = Float2.Minimum;
var x = PointToParent(location).X;

View File

@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI
{
if (Children[i] is KeyframePoint p)
{
p.IsSelected = p.Bounds.Intersects(ref selectionRect);
p.IsSelected = p.Bounds.Intersects(selectionRect);
}
}
}
@@ -401,7 +401,7 @@ namespace FlaxEditor.GUI
Cursor = CursorType.Default;
// Check if no move has been made at all
if (Float2.Distance(ref location, ref _rightMouseDownPos) < 2.0f)
if (Float2.Distance(location, _rightMouseDownPos) < 2.0f)
{
var selectionCount = _editor.SelectionCount;
var point = GetChildAt(location) as KeyframePoint;

View File

@@ -50,7 +50,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
var color = (_timeline.IsMovingPositionHandle ? style.SelectionBorder : style.Foreground).AlphaMultiplied(0.6f);
Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1);
var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset);
Matrix3x3.Multiply(ref m1, ref m2, out var m3);
Matrix3x3.Multiply(m1, m2, out var m3);
Render2D.PushTransform(m3);
// TODO: Convert to its own sprite or 9 slice
Render2D.DrawSprite(icon, new Rectangle(new Float2(10, -icon.Size.X * 0.5f - 1), Size + new Float2(0, 1)), color);

View File

@@ -356,7 +356,7 @@ namespace FlaxEditor.GUI.Timeline
{
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, moveColor, moveThickness);
}
else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(ref _mouseLocation))
else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(_mouseLocation))
{
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, Color.Yellow);
}
@@ -364,7 +364,7 @@ namespace FlaxEditor.GUI.Timeline
{
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, moveColor, moveThickness);
}
else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(ref _mouseLocation))
else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(_mouseLocation))
{
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, Color.Yellow);
}
@@ -384,8 +384,8 @@ namespace FlaxEditor.GUI.Timeline
_startMoveLocation = Root.MousePosition;
_startMoveStartFrame = StartFrame;
_startMoveDuration = DurationFrames;
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(ref location) && CanResize;
_startMoveRightEdge = MoveRightEdgeRect.Contains(ref location) && CanResize;
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(location) && CanResize;
_startMoveRightEdge = MoveRightEdgeRect.Contains(location) && CanResize;
StartMouseCapture(true);
if (_startMoveLeftEdge || _startMoveRightEdge)
return true;

View File

@@ -337,7 +337,7 @@ namespace FlaxEditor.GUI.Timeline
DebugDraw.DrawSphere(sphere, selected ? Color.Yellow : Color.Red);
sphere.Radius *= 0.95f;
DebugDraw.DrawSphere(sphere, new Color(1, 0, 0, coveredAlpha), 0, false);
if (select && sphere.Intersects(ref selectRay))
if (select && sphere.Intersects(selectRay))
SelectKeyframeGizmo(curveTrack, i, 0);
if (!k.TangentIn.IsZero)
@@ -349,7 +349,7 @@ namespace FlaxEditor.GUI.Timeline
var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize));
DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue);
DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false);
if (select && box.Intersects(ref selectRay))
if (select && box.Intersects(selectRay))
SelectKeyframeGizmo(curveTrack, i, 2);
}
@@ -362,7 +362,7 @@ namespace FlaxEditor.GUI.Timeline
var box = BoundingBox.FromSphere(new BoundingSphere(t, EditCurveTrackGizmo.TangentSize));
DebugDraw.DrawBox(box, selected ? Color.Yellow : Color.AliceBlue);
DebugDraw.DrawBox(box, Color.AliceBlue.AlphaMultiplied(coveredAlpha), 0, false);
if (select && box.Intersects(ref selectRay))
if (select && box.Intersects(selectRay))
SelectKeyframeGizmo(curveTrack, i, 2);
}

View File

@@ -2078,7 +2078,7 @@ namespace FlaxEditor.GUI.Timeline
if (button == MouseButton.Right && _isRightMouseButtonDown)
{
_isRightMouseButtonDown = false;
if (Float2.Distance(ref location, ref _rightMouseButtonDownPos) < 4.0f)
if (Float2.Distance(location, _rightMouseButtonDownPos) < 4.0f)
ShowContextMenu(location);
}
@@ -2243,7 +2243,7 @@ namespace FlaxEditor.GUI.Timeline
foreach (var media in _tracks[i].Media)
{
if (media.Bounds.Intersects(ref mediaRect))
if (media.Bounds.Intersects(mediaRect))
{
SelectedMedia.Add(media);
selectionChanged = true;

View File

@@ -810,7 +810,7 @@ namespace FlaxEditor.GUI.Timeline
/// <returns>True if hits it.</returns>
protected virtual bool TestHeaderHit(ref Float2 location)
{
return new Rectangle(0, 0, Width, HeaderHeight).Contains(ref location);
return new Rectangle(0, 0, Width, HeaderHeight).Contains(location);
}
/// <summary>

View File

@@ -208,7 +208,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
// Hit-test dot
var size = Height - 2.0f;
var rect = new Rectangle(new Float2(size * -0.5f) + Size * 0.5f, new Float2(size));
return rect.Contains(ref location);
return rect.Contains(location);
}
return base.ContainsPoint(ref location, precise);

View File

@@ -258,7 +258,7 @@ namespace FlaxEditor.GUI.Tree
}
var nodeArea = new Rectangle(pos, child.Size);
if (child.IsExpanded && range.Intersects(ref nodeArea))
if (child.IsExpanded && range.Intersects(nodeArea))
WalkSelectRangeExpandedTree(selection, child, ref range);
}
}

View File

@@ -555,7 +555,7 @@ namespace FlaxEditor.GUI.Tree
/// <returns>True if hits it.</returns>
protected virtual bool TestHeaderHit(ref Float2 location)
{
return _headerRect.Contains(ref location);
return _headerRect.Contains(location);
}
/// <summary>
@@ -871,7 +871,7 @@ namespace FlaxEditor.GUI.Tree
static Rectangle GetChildGlobalRectangle(Control control, ref Matrix3x3 globalTransform)
{
Matrix3x3.Multiply(ref control._cachedTransform, ref globalTransform, out var globalChildTransform);
Matrix3x3.Multiply(control._cachedTransform, globalTransform, out var globalChildTransform);
return new Rectangle(globalChildTransform.M31, globalChildTransform.M32, control.Width * globalChildTransform.M11, control.Height * globalChildTransform.M22);
}
}

View File

@@ -113,8 +113,8 @@ namespace FlaxEditor.Gizmo
if (cb != IntPtr.Zero)
{
var data = new Data();
Matrix.Multiply(ref renderContext.View.View, ref renderContext.View.Projection, out var viewProjection);
Matrix.Transpose(ref viewProjection, out data.ViewProjectionMatrix);
Matrix.Multiply(renderContext.View.View, renderContext.View.Projection, out var viewProjection);
Matrix.Transpose(viewProjection, out data.ViewProjectionMatrix);
data.ViewPos = renderContext.View.WorldPosition;
data.GridColor = options.Viewport.ViewportGridColor;
data.Far = renderContext.View.Far;

View File

@@ -129,7 +129,7 @@ namespace FlaxEditor.Gizmo
if (_selectionParents[i] is ActorNode actorNode)
{
var b = actorNode.Actor.EditorBoxChildren;
BoundingBox.Merge(ref editorBounds, ref b, out editorBounds);
BoundingBox.Merge(editorBounds, b, out editorBounds);
bottomToCenter = Mathf.Min(bottomToCenter, actorNode.Actor.Position.Y - editorBounds.Minimum.Y);
}
}

View File

@@ -135,7 +135,7 @@ namespace FlaxEditor.Gizmo
Mesh sphereMesh = _modelSphere.LODs[0].Meshes[0];
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m3);
Matrix.Multiply(ref m3, ref world, out m1);
Matrix.Multiply(m3, world, out m1);
mx1 = m1;
mx1.M41 += 0.05f;
@@ -149,43 +149,43 @@ namespace FlaxEditor.Gizmo
// X axis
Matrix.RotationY(-Mathf.PiOverTwo, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance xAxisMaterialTransform = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
transAxisMesh.Draw(renderContext, xAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Y axis
Matrix.RotationX(Mathf.PiOverTwo, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance yAxisMaterialTransform = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
transAxisMesh.Draw(renderContext, yAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Z axis
Matrix.RotationX(Mathf.Pi, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance zAxisMaterialTransform = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
transAxisMesh.Draw(renderContext, zAxisMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// XY plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance xyPlaneMaterialTransform = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
cubeMesh.Draw(renderContext, xyPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// ZX plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance zxPlaneMaterialTransform = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
cubeMesh.Draw(renderContext, zxPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// YZ plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance yzPlaneMaterialTransform = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
cubeMesh.Draw(renderContext, yzPlaneMaterialTransform, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Center sphere
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
break;
@@ -199,7 +199,7 @@ namespace FlaxEditor.Gizmo
// X axis
Matrix.RotationZ(Mathf.PiOverTwo, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
rotationAxisMesh.Draw(renderContext, xAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
@@ -209,13 +209,13 @@ namespace FlaxEditor.Gizmo
// Z axis
Matrix.RotationX(-Mathf.PiOverTwo, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
rotationAxisMesh.Draw(renderContext, zAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Center box
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
break;
@@ -229,43 +229,43 @@ namespace FlaxEditor.Gizmo
// X axis
Matrix.RotationY(-Mathf.PiOverTwo, out m2);
Matrix.Multiply(ref m2, ref mx1, out m3);
Matrix.Multiply(m2, mx1, out m3);
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
scaleAxisMesh.Draw(renderContext, xAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Y axis
Matrix.RotationX(Mathf.PiOverTwo, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
scaleAxisMesh.Draw(renderContext, yAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Z axis
Matrix.RotationX(Mathf.Pi, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
scaleAxisMesh.Draw(renderContext, zAxisMaterialRotate, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// XY plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance xyPlaneMaterialScale = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
cubeMesh.Draw(renderContext, xyPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// ZX plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance zxPlaneMaterialScale = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
cubeMesh.Draw(renderContext, zxPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// YZ plane
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
MaterialInstance yzPlaneMaterialScale = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
cubeMesh.Draw(renderContext, yzPlaneMaterialScale, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
// Center box
Matrix.Scaling(gizmoModelsScale2RealGizmoSize, out m2);
Matrix.Multiply(ref m2, ref m1, out m3);
Matrix.Multiply(m2, m1, out m3);
sphereMesh.Draw(renderContext, isCenter ? _materialAxisFocus : _materialSphere, m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
break;

View File

@@ -36,7 +36,7 @@ namespace FlaxEditor.Gizmo
private bool IntersectsRotateCircle(Vector3 normal, ref Ray ray, out Real distance)
{
var plane = new Plane(Vector3.Zero, normal);
if (!plane.Intersects(ref ray, out distance))
if (!plane.Intersects(ray, out distance))
return false;
Vector3 hitPoint = ray.Position + ray.Direction * distance;
Real distanceNormalized = hitPoint.Length / RotateRadiusRaw;
@@ -50,8 +50,8 @@ namespace FlaxEditor.Gizmo
// Transform ray into local space of the gizmo
Ray localRay;
_gizmoWorld.WorldToLocalVector(ref ray.Direction, out localRay.Direction);
_gizmoWorld.WorldToLocal(ref ray.Position, out localRay.Position);
_gizmoWorld.WorldToLocalVector(ray.Direction, out localRay.Direction);
_gizmoWorld.WorldToLocal(ray.Position, out localRay.Position);
// Find gizmo collisions with mouse
Real closestIntersection = Real.MaxValue;
@@ -62,19 +62,19 @@ namespace FlaxEditor.Gizmo
case Mode.Translate:
{
// Axis boxes collision
if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
if (XAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
{
_activeAxis = Axis.X;
closestIntersection = intersection;
}
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
if (YAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
{
_activeAxis = Axis.Y;
closestIntersection = intersection;
}
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
if (ZAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
{
_activeAxis = Axis.Z;
closestIntersection = intersection;
@@ -83,25 +83,25 @@ namespace FlaxEditor.Gizmo
// Quad planes collision
if (closestIntersection >= float.MaxValue)
closestIntersection = float.MinValue;
if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (XYBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.XY;
closestIntersection = intersection;
}
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (XZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.ZX;
closestIntersection = intersection;
}
if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (YZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.YZ;
closestIntersection = intersection;
}
/*// Center
if (CenterBoxRaw.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (CenterBoxRaw.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.Center;
closestIntersection = intersection;
@@ -133,17 +133,17 @@ namespace FlaxEditor.Gizmo
case Mode.Scale:
{
// Boxes collision
if (XAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
if (XAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
{
_activeAxis = Axis.X;
closestIntersection = intersection;
}
if (YAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
if (YAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
{
_activeAxis = Axis.Y;
closestIntersection = intersection;
}
if (ZAxisBox.Intersects(ref localRay, out intersection) && intersection < closestIntersection)
if (ZAxisBox.Intersects(localRay, out intersection) && intersection < closestIntersection)
{
_activeAxis = Axis.Z;
closestIntersection = intersection;
@@ -153,24 +153,24 @@ namespace FlaxEditor.Gizmo
if (closestIntersection >= float.MaxValue)
closestIntersection = float.MinValue;
if (XYBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (XYBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.XY;
closestIntersection = intersection;
}
if (XZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (XZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.ZX;
closestIntersection = intersection;
}
if (YZBox.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (YZBox.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.YZ;
closestIntersection = intersection;
}
// Center
if (CenterBoxRaw.Intersects(ref localRay, out intersection) && intersection > closestIntersection)
if (CenterBoxRaw.Intersects(localRay, out intersection) && intersection > closestIntersection)
{
_activeAxis = Axis.Center;
closestIntersection = intersection;

View File

@@ -212,10 +212,10 @@ namespace FlaxEditor.Gizmo
Vector3 delta = Vector3.Zero;
Ray ray = Owner.MouseRay;
Matrix.RotationQuaternion(ref _gizmoWorld.Orientation, out var rotationMatrix);
Matrix.Invert(ref rotationMatrix, out var invRotationMatrix);
Matrix.RotationQuaternion(_gizmoWorld.Orientation, out var rotationMatrix);
Matrix.Invert(rotationMatrix, out var invRotationMatrix);
ray.Position = Vector3.Transform(ray.Position, invRotationMatrix);
Vector3.TransformNormal(ref ray.Direction, ref invRotationMatrix, out ray.Direction);
Vector3.TransformNormal(ray.Direction, invRotationMatrix, out ray.Direction);
var position = Position;
var planeXY = new Plane(Vector3.Backward, Vector3.Transform(position, invRotationMatrix).Z);
@@ -232,7 +232,7 @@ namespace FlaxEditor.Gizmo
case Axis.X:
{
var plane = planeDotXY > planeDotZX ? planeXY : planeZX;
if (ray.Intersects(ref plane, out intersection))
if (ray.Intersects(plane, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -244,7 +244,7 @@ namespace FlaxEditor.Gizmo
case Axis.Y:
{
var plane = planeDotXY > planeDotYZ ? planeXY : planeYZ;
if (ray.Intersects(ref plane, out intersection))
if (ray.Intersects(plane, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -256,7 +256,7 @@ namespace FlaxEditor.Gizmo
case Axis.Z:
{
var plane = planeDotZX > planeDotYZ ? planeZX : planeYZ;
if (ray.Intersects(ref plane, out intersection))
if (ray.Intersects(plane, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -267,7 +267,7 @@ namespace FlaxEditor.Gizmo
}
case Axis.YZ:
{
if (ray.Intersects(ref planeYZ, out intersection))
if (ray.Intersects(planeYZ, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -288,7 +288,7 @@ namespace FlaxEditor.Gizmo
}
case Axis.XY:
{
if (ray.Intersects(ref planeXY, out intersection))
if (ray.Intersects(planeXY, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -309,7 +309,7 @@ namespace FlaxEditor.Gizmo
}
case Axis.ZX:
{
if (ray.Intersects(ref planeZX, out intersection))
if (ray.Intersects(planeZX, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -332,7 +332,7 @@ namespace FlaxEditor.Gizmo
{
var gizmoToView = Position - Owner.ViewPosition;
var plane = new Plane(-Vector3.Normalize(gizmoToView), gizmoToView.Length);
if (ray.Intersects(ref plane, out intersection))
if (ray.Intersects(plane, out intersection))
{
_intersectPosition = ray.GetPoint(intersection);
if (!_lastIntersectionPosition.IsZero)
@@ -473,11 +473,11 @@ namespace FlaxEditor.Gizmo
dir = Float3.Forward * _gizmoWorld.Orientation;
Float3 viewDir = Owner.ViewPosition - Position;
Float3.Dot(ref viewDir, ref dir, out float dot);
Float3.Dot(viewDir, dir, out float dot);
if (dot < 0.0f)
delta *= -1;
Quaternion.RotationAxis(ref dir, delta, out _rotationDelta);
Quaternion.RotationAxis(dir, delta, out _rotationDelta);
break;
}

View File

@@ -240,7 +240,7 @@ namespace FlaxEditor
{
foreach (var widget in _widgets)
{
if (widget.Bounds.Contains(ref location))
if (widget.Bounds.Contains(location))
{
// Initialize widget movement
_activeWidget = widget;
@@ -326,7 +326,7 @@ namespace FlaxEditor
{
foreach (var widget in _widgets)
{
if (widget.Bounds.Contains(ref location))
if (widget.Bounds.Contains(location))
{
Cursor = widget.Cursor;
cursorChanged = true;
@@ -643,10 +643,10 @@ namespace FlaxEditor
DrawControlWidget(uiControl, ref ur, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, -1), CursorType.SizeNESW);
DrawControlWidget(uiControl, ref bl, ref mousePos, ref widgetHandleSize, viewScale, new Float2(-1, 1), CursorType.SizeNESW);
DrawControlWidget(uiControl, ref br, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, 1), CursorType.SizeNWSE);
Float2.Lerp(ref ul, ref bl, 0.5f, out var el);
Float2.Lerp(ref ur, ref br, 0.5f, out var er);
Float2.Lerp(ref ul, ref ur, 0.5f, out var eu);
Float2.Lerp(ref bl, ref br, 0.5f, out var eb);
Float2.Lerp(ul, bl, 0.5f, out var el);
Float2.Lerp(ur, br, 0.5f, out var er);
Float2.Lerp(ul, ur, 0.5f, out var eu);
Float2.Lerp(bl, br, 0.5f, out var eb);
DrawControlWidget(uiControl, ref el, ref mousePos, ref widgetHandleSize, viewScale, new Float2(-1, 0), CursorType.SizeWE);
DrawControlWidget(uiControl, ref er, ref mousePos, ref widgetHandleSize, viewScale, new Float2(1, 0), CursorType.SizeWE);
DrawControlWidget(uiControl, ref eu, ref mousePos, ref widgetHandleSize, viewScale, new Float2(0, -1), CursorType.SizeNS);
@@ -749,7 +749,7 @@ namespace FlaxEditor
default: break;
}
}
if (rect.Contains(ref mousePos))
if (rect.Contains(mousePos))
{
Render2D.FillRectangle(rect, style.Foreground);
Render2D.DrawRectangle(rect, style.SelectionBorder);

View File

@@ -124,7 +124,7 @@ public sealed class ViewportRubberBandSelector
public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 viewportSpaceLocation)
{
worldSpaceLocation -= _origin;
_viewport.Project(ref worldSpaceLocation, ref _viewProjection, out var projected);
_viewport.Project(worldSpaceLocation, _viewProjection, out var projected);
viewportSpaceLocation = new Float2((float)projected.X, (float)projected.Y);
}
@@ -132,7 +132,7 @@ public sealed class ViewportRubberBandSelector
{
bounds.Minimum -= _origin;
bounds.Maximum -= _origin;
return _frustum.Contains(ref bounds);
return _frustum.Contains(bounds);
}
}

View File

@@ -37,7 +37,7 @@ namespace FlaxEditor.SceneGraph
var center = _actor.Transform.Translation;
ViewportIconsRenderer.GetBounds(center, ray.Ray.Position, out var sphere);
return CollisionsHelper.RayIntersectsSphere(ref ray.Ray, ref sphere, out distance);
return CollisionsHelper.RayIntersectsSphere(ray.Ray, sphere, out distance);
}
}
}

View File

@@ -109,10 +109,10 @@ namespace FlaxEditor.SceneGraph.Actors
// Skin vertex position with the current pose
var position = positionStream.GetFloat3(j);
Float3.Transform(ref position, ref skinningMatrices[indices[0]], out Float3 pos0);
Float3.Transform(ref position, ref skinningMatrices[indices[1]], out Float3 pos1);
Float3.Transform(ref position, ref skinningMatrices[indices[2]], out Float3 pos2);
Float3.Transform(ref position, ref skinningMatrices[indices[3]], out Float3 pos3);
Float3.Transform(position, skinningMatrices[indices[0]], out Float3 pos0);
Float3.Transform(position, skinningMatrices[indices[1]], out Float3 pos1);
Float3.Transform(position, skinningMatrices[indices[2]], out Float3 pos2);
Float3.Transform(position, skinningMatrices[indices[3]], out Float3 pos3);
position = pos0 * weights[0] + pos1 * weights[1] + pos2 * weights[2] + pos3 * weights[3];
// Add vertex to the bone list
@@ -269,8 +269,8 @@ namespace FlaxEditor.SceneGraph.Actors
for (int i = 0; i < boneVertices.Count; i++)
{
var pos = boneTransform.WorldToLocal(boneVertices[i]);
Vector3.Min(ref boneLocalBounds.Minimum, ref pos, out boneLocalBounds.Minimum);
Vector3.Max(ref boneLocalBounds.Maximum, ref pos, out boneLocalBounds.Maximum);
Vector3.Min(boneLocalBounds.Minimum, pos, out boneLocalBounds.Minimum);
Vector3.Max(boneLocalBounds.Maximum, pos, out boneLocalBounds.Maximum);
}
// Add collision shape
@@ -415,7 +415,7 @@ namespace FlaxEditor.SceneGraph.Actors
float bkLength = bk.Length;
if (bkLength > 0.0f)
{
Float3.Transform(ref bk, ref matrix, out Float3 bkA);
Float3.Transform(bk, matrix, out Float3 bkA);
bk = bkA / bkLength;
}
}

View File

@@ -207,7 +207,7 @@ namespace FlaxEditor.SceneGraph.Actors
/// <inheritdoc />
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
{
if (((BoxBrush)_actor).OrientedBox.Intersects(ref ray.Ray))
if (((BoxBrush)_actor).OrientedBox.Intersects(ray.Ray))
{
for (int i = 0; i < ChildNodes.Count; i++)
{

View File

@@ -107,7 +107,7 @@ namespace FlaxEditor.SceneGraph.Actors
{
normal = Vector3.Up;
var sphere = new BoundingSphere(Transform.Translation, 10.0f);
return sphere.Intersects(ref ray.Ray, out distance);
return sphere.Intersects(ray.Ray, out distance);
}
/// <inheritdoc />

View File

@@ -63,7 +63,7 @@ namespace FlaxEditor.SceneGraph.Actors
{
normal = Vector3.Up;
var sphere = new BoundingSphere(Transform.Translation, 10.0f);
return sphere.Intersects(ref ray.Ray, out distance);
return sphere.Intersects(ray.Ray, out distance);
}
/// <inheritdoc />

View File

@@ -177,7 +177,7 @@ namespace FlaxEditor.SceneGraph.Actors
var actor = (Spline)_node.Actor;
var pos = actor.GetSplinePoint(Index);
var nodeSize = NodeSizeByDistance(Transform.Translation, PointNodeSize, ray.View.Position);
return new BoundingSphere(pos, nodeSize).Intersects(ref ray.Ray, out distance);
return new BoundingSphere(pos, nodeSize).Intersects(ray.Ray, out distance);
}
public override void OnDebugDraw(ViewportDebugDrawData data)
@@ -264,7 +264,7 @@ namespace FlaxEditor.SceneGraph.Actors
var actor = (Spline)_node.Actor;
var pos = actor.GetSplineTangent(_index, _isIn).Translation;
var tangentSize = NodeSizeByDistance(Transform.Translation, TangentNodeSize, ray.View.Position);
return new BoundingSphere(pos, tangentSize).Intersects(ref ray.Ray, out distance);
return new BoundingSphere(pos, tangentSize).Intersects(ray.Ray, out distance);
}
public override void OnDebugDraw(ViewportDebugDrawData data)

View File

@@ -37,15 +37,15 @@ namespace FlaxEditor.SceneGraph.Actors
{
var up = Float3.Up;
Float3 translation = transform.Translation;
Matrix.Billboard(ref translation, ref viewPosition, ref up, ref viewDirection, out m2);
Matrix.Multiply(ref m1, ref m2, out m3);
Matrix.Scaling(ref transform.Scale, out m1);
Matrix.Multiply(ref m1, ref m3, out world);
Matrix.Billboard(translation, viewPosition, up, viewDirection, out m2);
Matrix.Multiply(m1, m2, out m3);
Matrix.Scaling(transform.Scale, out m1);
Matrix.Multiply(m1, m3, out world);
}
else
{
transform.GetWorld(out m2);
Matrix.Multiply(ref m1, ref m2, out world);
Matrix.Multiply(m1, m2, out world);
}
OrientedBoundingBox bounds;
@@ -53,7 +53,7 @@ namespace FlaxEditor.SceneGraph.Actors
world.Decompose(out bounds.Transformation);
normal = -ray.Ray.Direction;
return bounds.Intersects(ref ray.Ray, out distance);
return bounds.Intersects(ray.Ray, out distance);
}
/// <inheritdoc />

View File

@@ -96,7 +96,7 @@ namespace FlaxEditor.SceneGraph.Actors
for (int i = 0; i < verts.Length; i++)
{
ref var v = ref verts[i];
var distance = Float3.DistanceSquared(ref pointLocal, ref v);
var distance = Float3.DistanceSquared(pointLocal, v);
if (distance <= minDistance)
{
hit = true;

View File

@@ -64,7 +64,7 @@ namespace FlaxEditor.SceneGraph.Actors
normal = Vector3.Up;
if (Actor is UICanvas uiCanvas && uiCanvas.Is3D)
return uiCanvas.Bounds.Intersects(ref ray.Ray, out distance);
return uiCanvas.Bounds.Intersects(ray.Ray, out distance);
distance = 0;
return false;

View File

@@ -352,7 +352,7 @@ namespace FlaxEditor.SceneGraph
for (int i = 0; i < ChildNodes.Count; i++)
{
ChildNodes[i].GetEditorSphere(out var childSphere);
BoundingSphere.Merge(ref sphere, ref childSphere, out sphere);
BoundingSphere.Merge(sphere, childSphere, out sphere);
}
}

View File

@@ -479,7 +479,7 @@ namespace FlaxEditor.Surface.Archetypes
// Scale debug pointer when it moves to make it more visible when investigating blending
const float debugMaxSize = 2.0f;
float debugScale = Mathf.Saturate(Float2.Distance(ref _debugPos, ref prev) / new Float2(_rangeX.Absolute.ValuesSum, _rangeY.Absolute.ValuesSum).Length * 100.0f) * debugMaxSize + 1.0f;
float debugScale = Mathf.Saturate(Float2.Distance(_debugPos, prev) / new Float2(_rangeX.Absolute.ValuesSum, _rangeY.Absolute.ValuesSum).Length * 100.0f) * debugMaxSize + 1.0f;
float debugBlendSpeed = _debugScale <= debugScale ? 4.0f : 1.0f;
_debugScale = Mathf.Lerp(_debugScale, debugScale, deltaTime * debugBlendSpeed);
}
@@ -1189,9 +1189,9 @@ namespace FlaxEditor.Surface.Archetypes
_triangleColors = new Color[_triangles.Length];
for (int i = 0; i < _triangles.Length; i += 3)
{
var is0 = Float2.NearEqual(ref _triangles[i + 0], ref pos);
var is1 = Float2.NearEqual(ref _triangles[i + 1], ref pos);
var is2 = Float2.NearEqual(ref _triangles[i + 2], ref pos);
var is0 = Float2.NearEqual(_triangles[i + 0], pos);
var is1 = Float2.NearEqual(_triangles[i + 1], pos);
var is2 = Float2.NearEqual(_triangles[i + 2], pos);
if (is0 || is1 || is2)
{
selectedTriangles.Add(_triangles[i + 0]);

View File

@@ -213,7 +213,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDoubleClick(location, button))
return true;
if (_headerRect.Contains(ref location))
if (_headerRect.Contains(location))
{
StartRenaming();
return true;
@@ -382,13 +382,13 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool CanSelect(ref Float2 location)
{
return _dragAreaRect.MakeOffsetted(Location).Contains(ref location);
return _dragAreaRect.MakeOffsetted(Location).Contains(location);
}
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && !_dragAreaRect.Contains(ref location))
if (button == MouseButton.Left && !_dragAreaRect.Contains(location))
{
_isMouseDown = true;
Cursor = CursorType.Hand;
@@ -687,7 +687,7 @@ namespace FlaxEditor.Surface.Archetypes
var upperLeft = bounds.UpperLeft;
var bottomRight = bounds.BottomRight;
bounds = Rectangle.FromPoints(PointToParent(ref upperLeft), PointToParent(ref bottomRight));
CollisionsHelper.ClosestPointRectanglePoint(ref bounds, ref startPos, out endPos);
CollisionsHelper.ClosestPointRectanglePoint(bounds, startPos, out endPos);
}
/// <inheritdoc />
@@ -731,15 +731,15 @@ namespace FlaxEditor.Surface.Archetypes
// Check click over the connection
var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse);
if (!TransitionsRectangle.Contains(ref mousePosition))
if (!TransitionsRectangle.Contains(mousePosition))
return;
for (int i = 0; i < Transitions.Count; i++)
{
var t = Transitions[i];
if (t.Bounds.Contains(ref mousePosition))
if (t.Bounds.Contains(mousePosition))
{
CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
if (Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f)
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point);
if (Float2.DistanceSquared(mousePosition, point) < 25.0f)
{
OnTransitionClicked(t, ref mouse, ref mousePosition, buttons);
handled = true;
@@ -756,15 +756,15 @@ namespace FlaxEditor.Surface.Archetypes
// Check double click over the connection
var mousePosition = Surface.SurfaceRoot.PointFromParent(ref mouse);
if (!TransitionsRectangle.Contains(ref mousePosition))
if (!TransitionsRectangle.Contains(mousePosition))
return;
for (int i = 0; i < Transitions.Count; i++)
{
var t = Transitions[i];
if (t.Bounds.Contains(ref mousePosition))
if (t.Bounds.Contains(mousePosition))
{
CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
if (Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f)
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point);
if (Float2.DistanceSquared(mousePosition, point) < 25.0f)
{
t.EditRule();
handled = true;
@@ -1007,7 +1007,7 @@ namespace FlaxEditor.Surface.Archetypes
var offset = diff ? -6.0f : 6.0f;
var dir = startPos - endPos;
dir.Normalize();
Float2.Perpendicular(ref dir, out var nrm);
Float2.Perpendicular(dir, out var nrm);
nrm *= offset;
startPos += nrm;
endPos += nrm;
@@ -1031,7 +1031,7 @@ namespace FlaxEditor.Surface.Archetypes
t.StartPos = startPos;
t.EndPos = endPos;
Rectangle.FromPoints(ref startPos, ref endPos, out t.Bounds);
Rectangle.FromPoints(startPos, endPos, out t.Bounds);
t.Bounds.Expand(10.0f);
}
@@ -1040,7 +1040,7 @@ namespace FlaxEditor.Surface.Archetypes
TransitionsRectangle = Transitions[0].Bounds;
for (int i = 1; i < Transitions.Count; i++)
{
Rectangle.Union(ref TransitionsRectangle, ref Transitions[i].Bounds, out TransitionsRectangle);
Rectangle.Union(TransitionsRectangle, Transitions[i].Bounds, out TransitionsRectangle);
}
}
else
@@ -1120,7 +1120,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool CanSelect(ref Float2 location)
{
return _dragAreaRect.MakeOffsetted(Location).Contains(ref location);
return _dragAreaRect.MakeOffsetted(Location).Contains(location);
}
/// <inheritdoc />
@@ -1129,7 +1129,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDoubleClick(location, button))
return true;
if (_renameButtonRect.Contains(ref location) || _closeButtonRect.Contains(ref location))
if (_renameButtonRect.Contains(location) || _closeButtonRect.Contains(location))
return true;
return false;
@@ -1138,7 +1138,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && !_dragAreaRect.Contains(ref location))
if (button == MouseButton.Left && !_dragAreaRect.Contains(location))
{
_isMouseDown = true;
Cursor = CursorType.Hand;
@@ -1271,11 +1271,11 @@ namespace FlaxEditor.Surface.Archetypes
for (int i = 0; i < Transitions.Count; i++)
{
var t = Transitions[i];
var isMouseOver = t.Bounds.Contains(ref mousePosition);
var isMouseOver = t.Bounds.Contains(mousePosition);
if (isMouseOver)
{
CollisionsHelper.ClosestPointPointLine(ref mousePosition, ref t.StartPos, ref t.EndPos, out var point);
isMouseOver = Float2.DistanceSquared(ref mousePosition, ref point) < 25.0f;
CollisionsHelper.ClosestPointPointLine(mousePosition, t.StartPos, t.EndPos, out var point);
isMouseOver = Float2.DistanceSquared(mousePosition, point) < 25.0f;
}
var color = isMouseOver ? Color.Wheat : t.LineColor;
SurfaceStyle.DrawStraightConnection(t.StartPos, t.EndPos, color);
@@ -1474,7 +1474,7 @@ namespace FlaxEditor.Surface.Archetypes
return true;
// Rename
if (_renameButtonRect.Contains(ref location))
if (_renameButtonRect.Contains(location))
{
StartRenaming();
return true;

View File

@@ -308,7 +308,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDoubleClick(location, button))
return true;
if (_nameField.Bounds.Contains(ref location) && Surface.CanEdit)
if (_nameField.Bounds.Contains(location) && Surface.CanEdit)
{
StartRenaming();
return true;
@@ -1128,7 +1128,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _headerRect.Contains(ref location))
if (button == MouseButton.Left && _headerRect.Contains(location))
{
// Open function content item if exists
var method = GetMethod(out var scriptType, out _, out _);
@@ -1759,7 +1759,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _headerRect.Contains(ref location))
if (button == MouseButton.Left && _headerRect.Contains(location))
{
OnEditSignature();
return true;

View File

@@ -347,7 +347,7 @@ namespace FlaxEditor.Surface.Archetypes
public override bool CanSelect(ref Float2 location)
{
return base.CanSelect(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(ref location);
return base.CanSelect(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(location);
}
public override void OnSurfaceLoaded(SurfaceNodeActions action)
@@ -414,7 +414,7 @@ namespace FlaxEditor.Surface.Archetypes
if (base.OnMouseDown(location, button))
return true;
if (button == MouseButton.Left && _resizeButtonRect.Contains(ref location) && Surface.CanEdit)
if (button == MouseButton.Left && _resizeButtonRect.Contains(location) && Surface.CanEdit)
{
// Start sliding
_isResizing = true;

View File

@@ -182,7 +182,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
{
_arrangeButtonInUse = true;
Focus();

View File

@@ -191,7 +191,7 @@ namespace FlaxEditor.Surface.Archetypes
// Header
var headerColor = style.BackgroundHighlighted;
if (_headerRect.Contains(ref _mousePosition))
if (_headerRect.Contains(_mousePosition))
headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor);
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);

View File

@@ -169,7 +169,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override void OnMouseMove(Float2 location)
{
if (_isMoving && Float2.DistanceSquared(ref location, ref _startMovePos) > 25.0f)
if (_isMoving && Float2.DistanceSquared(location, _startMovePos) > 25.0f)
{
_startMovePos = Float2.Minimum;
int index = Node._stops.IndexOf(this);
@@ -1076,12 +1076,12 @@ namespace FlaxEditor.Surface.Archetypes
}
/// <inheritdoc />
protected override bool ShowTooltip => !string.IsNullOrEmpty(TooltipText) && _localBounds.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
protected override bool ShowTooltip => !string.IsNullOrEmpty(TooltipText) && _localBounds.Contains(_mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
/// <inheritdoc />
public override bool OnTestTooltipOverControl(ref Float2 location)
{
return _localBounds.Contains(ref location) && ShowTooltip;
return _localBounds.Contains(location) && ShowTooltip;
}
/// <inheritdoc />
@@ -1150,7 +1150,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override bool CanSelect(ref Float2 location)
{
return new Rectangle(Location, DefaultSize).Contains(ref location);
return new Rectangle(Location, DefaultSize).Contains(location);
}
/// <inheritdoc />
@@ -1230,7 +1230,7 @@ namespace FlaxEditor.Surface.Archetypes
/// <inheritdoc />
public override void OnMouseMove(Float2 location)
{
_isMouseInConnectingBounds = IsMouseOver && _localBounds.MakeExpanded(ConnectingBounds).Contains(ref location); // Inner area for connecting, outer area for moving
_isMouseInConnectingBounds = IsMouseOver && _localBounds.MakeExpanded(ConnectingBounds).Contains(location); // Inner area for connecting, outer area for moving
if (!_isMouseInConnectingBounds && !_isMouseDown)
Cursor = CursorType.SizeAll;
else

View File

@@ -156,7 +156,7 @@ namespace FlaxEditor.Surface.Elements
Bezier(ref offsetStart, ref control1, ref control2, ref offsetEnd, t, out p);
// Maybe it would be reasonable to return the point?
CollisionsHelper.ClosestPointPointLine(ref point, ref oldp, ref p, out var result);
CollisionsHelper.ClosestPointPointLine(point, oldp, p, out var result);
if (Float2.DistanceSquared(point, result) <= squaredDistance)
{
return true;
@@ -167,12 +167,12 @@ namespace FlaxEditor.Surface.Elements
private static void Bezier(ref Float2 p0, ref Float2 p1, ref Float2 p2, ref Float2 p3, float alpha, out Float2 result)
{
Float2.Lerp(ref p0, ref p1, alpha, out var p01);
Float2.Lerp(ref p1, ref p2, alpha, out var p12);
Float2.Lerp(ref p2, ref p3, alpha, out var p23);
Float2.Lerp(ref p01, ref p12, alpha, out var p012);
Float2.Lerp(ref p12, ref p23, alpha, out var p123);
Float2.Lerp(ref p012, ref p123, alpha, out result);
Float2.Lerp(p0, p1, alpha, out var p01);
Float2.Lerp(p1, p2, alpha, out var p12);
Float2.Lerp(p2, p3, alpha, out var p23);
Float2.Lerp(p01, p12, alpha, out var p012);
Float2.Lerp(p12, p23, alpha, out var p123);
Float2.Lerp(p012, p123, alpha, out result);
}
/// <summary>

View File

@@ -146,13 +146,13 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override bool CanSelect(ref Float2 location)
{
return _headerRect.MakeOffsetted(Location).Contains(ref location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(ref location);
return _headerRect.MakeOffsetted(Location).Contains(location) && !_resizeButtonRect.MakeOffsetted(Location).Contains(location);
}
/// <inheritdoc />
public override bool IsSelectionIntersecting(ref Rectangle selectionRect)
{
return _headerRect.MakeOffsetted(Location).Intersects(ref selectionRect);
return _headerRect.MakeOffsetted(Location).Intersects(selectionRect);
}
/// <inheritdoc />
@@ -287,7 +287,7 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override bool ContainsPoint(ref Float2 location, bool precise)
{
return _headerRect.Contains(ref location) || _resizeButtonRect.Contains(ref location);
return _headerRect.Contains(location) || _resizeButtonRect.Contains(location);
}
/// <inheritdoc />
@@ -297,7 +297,7 @@ namespace FlaxEditor.Surface
return true;
// Check if can start resizing
if (button == MouseButton.Left && _resizeButtonRect.Contains(ref location) && Surface.CanEdit)
if (button == MouseButton.Left && _resizeButtonRect.Contains(location) && Surface.CanEdit)
{
// Start sliding
_isResizing = true;
@@ -336,7 +336,7 @@ namespace FlaxEditor.Surface
return true;
// Rename
if (_headerRect.Contains(ref location) && Surface.CanEdit)
if (_headerRect.Contains(location) && Surface.CanEdit)
{
StartRenaming();
return true;
@@ -404,14 +404,14 @@ namespace FlaxEditor.Surface
return true;
// Close
if (_closeButtonRect.Contains(ref location) && Surface.CanEdit)
if (_closeButtonRect.Contains(location) && Surface.CanEdit)
{
Surface.Delete(this);
return true;
}
// Color
if (_colorButtonRect.Contains(ref location) && Surface.CanEdit)
if (_colorButtonRect.Contains(location) && Surface.CanEdit)
{
ColorValueBox.ShowPickColorDialog?.Invoke(this, Color, OnColorChanged);
return true;

View File

@@ -93,7 +93,7 @@ namespace FlaxEditor.Surface
/// <returns><c>true</c> if the selection rectangle is intersecting with the selectable parts of the control ; otherwise, <c>false</c>.</returns>
public virtual bool IsSelectionIntersecting(ref Rectangle selectionRect)
{
return Bounds.Intersects(ref selectionRect);
return Bounds.Intersects(selectionRect);
}
/// <summary>

View File

@@ -868,7 +868,7 @@ namespace FlaxEditor.Surface
}
/// <inheritdoc />
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(ref _mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
protected override bool ShowTooltip => base.ShowTooltip && _headerRect.Contains(_mousePosition) && !Surface.IsLeftMouseButtonDown && !Surface.IsRightMouseButtonDown && !Surface.IsPrimaryMenuOpened;
/// <inheritdoc />
public override bool OnShowTooltip(out string text, out Float2 location, out Rectangle area)
@@ -898,13 +898,13 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override bool OnTestTooltipOverControl(ref Float2 location)
{
return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting;
return _headerRect.Contains(location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting;
}
/// <inheritdoc />
public override bool CanSelect(ref Float2 location)
{
return _headerRect.MakeOffsetted(Location).Contains(ref location);
return _headerRect.MakeOffsetted(Location).Contains(location);
}
/// <inheritdoc />
@@ -1056,7 +1056,7 @@ namespace FlaxEditor.Surface
// Header
var headerColor = style.BackgroundHighlighted;
if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting)
if (_headerRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting)
headerColor *= 1.07f;
Render2D.FillRectangle(_headerRect, headerColor);
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
@@ -1099,7 +1099,7 @@ namespace FlaxEditor.Surface
if (base.OnMouseDown(location, button))
return true;
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
if (button == MouseButton.Left && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(location))
return true;
if (button == MouseButton.Right)
mouseDownMousePosition = Input.Mouse.Position;
@@ -1115,7 +1115,7 @@ namespace FlaxEditor.Surface
// Close/ delete
bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection;
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(location))
{
Surface.Delete(this);
return true;

View File

@@ -74,9 +74,9 @@ namespace FlaxEditor.Surface
var child = _children[i];
if (!(child is SurfaceComment) && child.Visible)
{
Matrix3x3.Multiply(ref child._cachedTransform, ref globalTransform, out var globalChildTransform);
Matrix3x3.Multiply(child._cachedTransform, globalTransform, out var globalChildTransform);
var childGlobalRect = new Rectangle(globalChildTransform.M31, globalChildTransform.M32, child.Width * globalChildTransform.M11, child.Height * globalChildTransform.M22);
if (globalClipping.Intersects(ref childGlobalRect))
if (globalClipping.Intersects(childGlobalRect))
{
Render2D.PushTransform(child._cachedTransform);
child.Draw();

View File

@@ -502,7 +502,7 @@ namespace FlaxEditor.Surface
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
if (button == MouseButton.Left && _arrangeButtonRect.Contains(ref location))
if (button == MouseButton.Left && _arrangeButtonRect.Contains(location))
{
_arrangeButtonInUse = true;
Focus();

View File

@@ -191,7 +191,7 @@ namespace FlaxEngine.Tools
for (int i = 0; i < clothParticles.Length; i++)
{
var pos = instanceTransform.LocalToWorld(clothParticles[i]);
var dst = Vector3.Distance(ref pos, ref brushSphere.Center);
var dst = Vector3.Distance(pos, brushSphere.Center);
if (dst > brushSphere.Radius)
continue;
float strength = _gizmoMode.BrushStrength * Mathf.Lerp(1.0f, 1.0f - (float)dst / (float)brushSphere.Radius, _gizmoMode.BrushFalloff);

View File

@@ -104,7 +104,7 @@ namespace FlaxEditor.Tools.Foliage
if (foliage && instanceIndex >= 0 && instanceIndex < foliage.InstancesCount)
{
var instance = foliage.GetInstance(instanceIndex);
BoundingBox.FromSphere(ref instance.Bounds, out bounds);
BoundingBox.FromSphere(instance.Bounds, out bounds);
}
}
@@ -155,8 +155,8 @@ namespace FlaxEditor.Tools.Foliage
}
else
{
Matrix.RotationQuaternion(ref trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(ref rotationDelta, out var deltaWorld);
Matrix.RotationQuaternion(trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(rotationDelta, out var deltaWorld);
Matrix world = transWorld * Matrix.Translation(pivotOffset) * deltaWorld * Matrix.Translation(-pivotOffset);
trans.SetRotation(ref world);
trans.Translation += world.TranslationVector;

View File

@@ -117,7 +117,7 @@ namespace FlaxEditor.Tools.Terrain.Brushes
/// <inheritdoc />
public override float Sample(ref Vector3 brushPosition, ref Vector3 samplePosition)
{
Vector3.DistanceXZ(ref brushPosition, ref samplePosition, out var distanceXZ);
Vector3.DistanceXZ(brushPosition, samplePosition, out var distanceXZ);
float distance = (float)distanceXZ;
float halfSize = Size * 0.5f;
float falloff = halfSize * Falloff;

View File

@@ -93,7 +93,7 @@ namespace FlaxEditor.Tools.Terrain.Paint
var brushBounds = gizmo.CursorBrushBounds;
terrain.GetLocalToWorldMatrix(out p.TerrainWorld);
terrain.GetWorldToLocalMatrix(out var terrainInvWorld);
BoundingBox.Transform(ref brushBounds, ref terrainInvWorld, out var brushBoundsLocal);
BoundingBox.Transform(brushBounds, terrainInvWorld, out var brushBoundsLocal);
// TODO: try caching brush weights before apply to reduce complexity and batch brush sampling

View File

@@ -86,7 +86,7 @@ namespace FlaxEditor.Tools.Terrain.Paint
var src = (Color)p.SourceData[zz * p.HeightmapSize + xx];
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, 0, zz * FlaxEngine.Terrain.UnitsPerVertex);
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
var sample = Mathf.Saturate(p.Brush.Sample(ref brushPosition, ref samplePositionWorld));
var paintAmount = sample * strength;

View File

@@ -314,7 +314,7 @@ namespace FlaxEditor.Tools.Terrain
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
{
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
if (!tmp.Intersects(ref brushBounds))
if (!tmp.Intersects(brushBounds))
continue;
terrain.GetPatchCoord(patchIndex, out var patchCoord);
@@ -323,7 +323,7 @@ namespace FlaxEditor.Tools.Terrain
for (int chunkIndex = 0; chunkIndex < FlaxEngine.Terrain.PatchChunksCount; chunkIndex++)
{
terrain.GetChunkBounds(patchIndex, chunkIndex, out tmp);
if (!tmp.Intersects(ref brushBounds))
if (!tmp.Intersects(brushBounds))
continue;
var chunkCoord = new Int2(chunkIndex % FlaxEngine.Terrain.PatchEdgeChunksCount, chunkIndex / FlaxEngine.Terrain.PatchEdgeChunksCount);

View File

@@ -44,7 +44,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
var sourceHeight = p.SourceHeightMap[zz * p.HeightmapSize + xx];
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, sourceHeight, zz * FlaxEngine.Terrain.UnitsPerVertex);
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld) * strength;

View File

@@ -43,7 +43,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
var sourceMask = p.SourceHolesMask[zz * p.HeightmapSize + xx] != 0 ? 1.0f : 0.0f;
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, 0, zz * FlaxEngine.Terrain.UnitsPerVertex);
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
samplePositionWorld.Y = brushPosition.Y;
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld);

View File

@@ -80,7 +80,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
var brushBounds = gizmo.CursorBrushBounds;
terrain.GetLocalToWorldMatrix(out var terrainWorld);
terrain.GetWorldToLocalMatrix(out var terrainInvWorld);
BoundingBox.Transform(ref brushBounds, ref terrainInvWorld, out var brushBoundsLocal);
BoundingBox.Transform(brushBounds, terrainInvWorld, out var brushBoundsLocal);
// TODO: try caching brush weights before apply to reduce complexity and batch brush sampling

View File

@@ -49,7 +49,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
var sourceHeight = p.SourceHeightMap[zz * p.HeightmapSize + xx];
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, sourceHeight, zz * FlaxEngine.Terrain.UnitsPerVertex);
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
var noiseSample = noise.Sample(xx + patchOffset.X, zz + patchOffset.Y);
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld);

View File

@@ -31,7 +31,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
var sourceHeight = p.SourceHeightMap[zz * p.HeightmapSize + xx];
var samplePositionLocal = p.PatchPositionLocal + new Vector3(xx * FlaxEngine.Terrain.UnitsPerVertex, sourceHeight, zz * FlaxEngine.Terrain.UnitsPerVertex);
Vector3.Transform(ref samplePositionLocal, ref p.TerrainWorld, out Vector3 samplePositionWorld);
Vector3.Transform(samplePositionLocal, p.TerrainWorld, out Vector3 samplePositionWorld);
var paintAmount = p.Brush.Sample(ref brushPosition, ref samplePositionWorld);

View File

@@ -93,7 +93,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
// Calculate brush influence at the current position
var samplePositionLocal = patch.PatchPositionLocal + new Vector3(localCoordX * FlaxEngine.Terrain.UnitsPerVertex, coordHeight, localCoordY * FlaxEngine.Terrain.UnitsPerVertex);
Vector3.Transform(ref samplePositionLocal, ref patch.TerrainWorld, out Vector3 samplePositionWorld);
Vector3.Transform(samplePositionLocal, patch.TerrainWorld, out Vector3 samplePositionWorld);
var paintAmount = patch.Brush.Sample(ref brushPosition, ref samplePositionWorld) * strength;
if (paintAmount == 0)

View File

@@ -333,7 +333,7 @@ namespace FlaxEditor.Tools.Terrain
for (int patchIndex = 0; patchIndex < patchesCount; patchIndex++)
{
terrain.GetPatchBounds(patchIndex, out BoundingBox tmp);
if (!tmp.Intersects(ref brushBounds))
if (!tmp.Intersects(brushBounds))
continue;
terrain.GetPatchCoord(patchIndex, out var patchCoord);
@@ -342,7 +342,7 @@ namespace FlaxEditor.Tools.Terrain
for (int chunkIndex = 0; chunkIndex < FlaxEngine.Terrain.PatchChunksCount; chunkIndex++)
{
terrain.GetChunkBounds(patchIndex, chunkIndex, out tmp);
if (!tmp.Intersects(ref brushBounds))
if (!tmp.Intersects(brushBounds))
continue;
var chunkCoord = new Int2(chunkIndex % FlaxEngine.Terrain.PatchEdgeChunksCount, chunkIndex / FlaxEngine.Terrain.PatchEdgeChunksCount);

View File

@@ -440,7 +440,7 @@ namespace FlaxEditor.Tools
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++)
{
var pos = instanceTransform.LocalToWorld(positionStream.GetFloat3(vertexIndex));
var dst = Vector3.Distance(ref pos, ref brushSphere.Center);
var dst = Vector3.Distance(pos, brushSphere.Center);
if (dst > brushSphere.Radius)
continue;
float strength = _gizmoMode.BrushStrength * Mathf.Lerp(1.0f, 1.0f - (float)dst / (float)brushSphere.Radius, _gizmoMode.BrushFalloff);
@@ -603,7 +603,7 @@ namespace FlaxEditor.Tools
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++)
{
var pos = instanceTransform.LocalToWorld(positionStream.GetFloat3(vertexIndex));
if (brushSphere.Contains(ref pos) == ContainmentType.Disjoint)
if (brushSphere.Contains(pos) == ContainmentType.Disjoint)
continue;
Matrix transform = modelScaleMatrix * Matrix.Translation(pos - viewOrigin);
_brushModel.Draw(renderContext, _verticesPreviewMaterial, transform);

View File

@@ -119,7 +119,7 @@ namespace FlaxEditor
if (!isPlayMode && options.General.AutoRebuildNavMesh && data.Scene != null)
{
// Handle simple case where objects were moved just a little and use one navmesh build request to improve performance
if (data.BeforeBounds.Intersects(ref data.AfterBounds))
if (data.BeforeBounds.Intersects(data.AfterBounds))
{
Navigation.BuildNavMesh(data.Scene, BoundingBox.Merge(data.BeforeBounds, data.AfterBounds), options.General.AutoRebuildNavMeshTimeoutMs);
}

View File

@@ -1041,7 +1041,7 @@ namespace FlaxEditor.Utilities
Vector3 up = Vector3.Up * orientation;
Matrix world = Matrix.CreateWorld(min + vec * 0.5f, dir, up);
world.Decompose(out box.Transformation);
Matrix.Invert(ref world, out Matrix invWorld);
Matrix.Invert(world, out Matrix invWorld);
Vector3 vecLocal = Vector3.TransformNormal(vec * 0.5f, invWorld);
box.Extents.X = margin;
box.Extents.Y = margin;
@@ -1062,24 +1062,24 @@ namespace FlaxEditor.Utilities
var corners = stackalloc Vector3[8];
box.GetCorners(corners);
var minDistance = Vector3.DistanceSquared(ref viewPosition, ref corners[0]);
var minDistance = Vector3.DistanceSquared(viewPosition, corners[0]);
for (int i = 1; i < 8; i++)
minDistance = Mathf.Min(minDistance, Vector3.DistanceSquared(ref viewPosition, ref corners[i]));
minDistance = Mathf.Min(minDistance, Vector3.DistanceSquared(viewPosition, corners[i]));
minDistance = Mathf.Sqrt(minDistance);
var margin = Mathf.Clamp(minDistance / 80.0f, 0.1f, 100.0f);
if (GetWriteBox(ref corners[0], ref corners[1], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[0], ref corners[3], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[0], ref corners[4], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[1], ref corners[2], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[1], ref corners[5], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[2], ref corners[3], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[2], ref corners[6], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[3], ref corners[7], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[4], ref corners[5], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[4], ref corners[7], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[5], ref corners[6], margin).Intersects(ref ray, out distance) ||
GetWriteBox(ref corners[6], ref corners[7], margin).Intersects(ref ray, out distance))
if (GetWriteBox(ref corners[0], ref corners[1], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[0], ref corners[3], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[0], ref corners[4], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[1], ref corners[2], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[1], ref corners[5], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[2], ref corners[3], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[2], ref corners[6], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[3], ref corners[7], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[4], ref corners[5], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[4], ref corners[7], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[5], ref corners[6], margin).Intersects(ray, out distance) ||
GetWriteBox(ref corners[6], ref corners[7], margin).Intersects(ray, out distance))
return true;
distance = 0;

View File

@@ -177,7 +177,7 @@ namespace FlaxEditor.Viewport.Cameras
// Dolly
if (input.IsPanning || input.IsMoving || input.IsRotating)
{
Vector3.Transform(ref moveDelta, ref rotation, out Vector3 move);
Vector3.Transform(moveDelta, rotation, out Vector3 move);
position += move;
}
@@ -239,7 +239,7 @@ namespace FlaxEditor.Viewport.Cameras
Viewport.Pitch = pitch;
if (input.IsOrbiting)
{
float orbitRadius = Mathf.Max((float)Vector3.Distance(ref position, ref TargetPoint), 0.0001f);
float orbitRadius = Mathf.Max((float)Vector3.Distance(position, TargetPoint), 0.0001f);
Vector3 localPosition = Viewport.ViewDirection * (-1 * orbitRadius);
Viewport.ViewPosition = TargetPoint + localPosition;
}

View File

@@ -92,7 +92,7 @@ namespace FlaxEditor.Viewport.Cameras
for (int i = 0; i < selection.Count; i++)
{
selection[i].GetEditorSphere(out var sphere);
BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
BoundingSphere.Merge(mergesSphere, sphere, out mergesSphere);
}
if (mergesSphere == BoundingSphere.Empty)

View File

@@ -354,8 +354,8 @@ namespace FlaxEditor.Viewport
Float3 position = ViewPosition - viewOrigin;
CreateViewMatrix(position, out var view);
CreateProjectionMatrix(out var projection);
Matrix.Multiply(ref view, ref projection, out var viewProjection);
return new BoundingFrustum(ref viewProjection);
Matrix.Multiply(view, projection, out var viewProjection);
return new BoundingFrustum(viewProjection);
}
}
@@ -1444,7 +1444,7 @@ namespace FlaxEditor.Viewport
var target = position + direction;
var right = Mathf.Abs(Float3.Dot(direction, Float3.Up)) < 1.0f - Mathf.Epsilon ? Float3.Normalize(Float3.Cross(Float3.Up, direction)) : Float3.Forward;
var up = Float3.Normalize(Float3.Cross(direction, right));
Matrix.LookAt(ref position, ref target, ref up, out result);
Matrix.LookAt(position, target, up, out result);
}
/// <summary>
@@ -1490,14 +1490,14 @@ namespace FlaxEditor.Viewport
// Create view frustum
CreateProjectionMatrix(out var p);
CreateViewMatrix(position, out var v);
Matrix.Multiply(ref v, ref p, out var ivp);
Matrix.Multiply(v, p, out var ivp);
ivp.Invert();
// Create near and far points
var nearPoint = new Vector3(mousePosition, _nearPlane);
var farPoint = new Vector3(mousePosition, _farPlane);
viewport.Unproject(ref nearPoint, ref ivp, out nearPoint);
viewport.Unproject(ref farPoint, ref ivp, out farPoint);
viewport.Unproject(nearPoint, ivp, out nearPoint);
viewport.Unproject(farPoint, ivp, out farPoint);
return new Ray(nearPoint + viewOrigin, Vector3.Normalize(farPoint - nearPoint));
}
@@ -1517,8 +1517,8 @@ namespace FlaxEditor.Viewport
Float3 position = ViewPosition - viewOrigin;
CreateProjectionMatrix(out var p);
CreateViewMatrix(position, out var v);
Matrix.Multiply(ref v, ref p, out var vp);
viewport.Project(ref worldSpaceLocation, ref vp, out var projected);
Matrix.Multiply(v, p, out var vp);
viewport.Project(worldSpaceLocation, vp, out var projected);
viewportSpaceLocation = new Float2((float)projected.X, (float)projected.Y);
}

View File

@@ -278,7 +278,7 @@ namespace FlaxEditor.Viewport
for (int i = 0; i < selection.Count; i++)
{
selection[i].GetEditorSphere(out var sphere);
BoundingSphere.Merge(ref selectionBounds, ref sphere, out selectionBounds);
BoundingSphere.Merge(selectionBounds, sphere, out selectionBounds);
}
if (ContainsFocus)
@@ -470,8 +470,8 @@ namespace FlaxEditor.Viewport
}
else
{
Matrix.RotationQuaternion(ref trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(ref rotationDelta, out var deltaWorld);
Matrix.RotationQuaternion(trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(rotationDelta, out var deltaWorld);
Matrix world = transWorld * Matrix.Translation(pivotOffset) * deltaWorld * Matrix.Translation(-pivotOffset);
trans.SetRotation(ref world);
trans.Translation += world.TranslationVector;
@@ -567,8 +567,8 @@ namespace FlaxEditor.Viewport
}
else
{
Matrix.RotationQuaternion(ref trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(ref rotationDelta, out var deltaWorld);
Matrix.RotationQuaternion(trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(rotationDelta, out var deltaWorld);
Matrix world = transWorld * Matrix.Translation(pivotOffset) * deltaWorld * Matrix.Translation(-pivotOffset);
trans.SetRotation(ref world);
trans.Translation += world.TranslationVector;
@@ -636,7 +636,7 @@ namespace FlaxEditor.Viewport
protected override void OnLeftMouseButtonUp()
{
// Skip if was controlling mouse or mouse is not over the area
if (_prevInput.IsControllingMouse || !Bounds.Contains(ref _viewMousePos))
if (_prevInput.IsControllingMouse || !Bounds.Contains(_viewMousePos))
return;
// Select rubberbanded rect actor nodes or pick with gizmo
@@ -659,7 +659,7 @@ namespace FlaxEditor.Viewport
return true;
// Handle mouse going up when using rubber band with mouse capture that click up outside the view
if (button == MouseButton.Left && !new Rectangle(Float2.Zero, Size).Contains(ref location))
if (button == MouseButton.Left && !new Rectangle(Float2.Zero, Size).Contains(location))
{
_rubberBandSelector.ReleaseRubberBandSelection();
return true;

View File

@@ -517,8 +517,8 @@ namespace FlaxEditor.Viewport
}
else
{
Matrix.RotationQuaternion(ref trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(ref rotationDelta, out var deltaWorld);
Matrix.RotationQuaternion(trans.Orientation, out var transWorld);
Matrix.RotationQuaternion(rotationDelta, out var deltaWorld);
Matrix world = transWorld * Matrix.Translation(pivotOffset) * deltaWorld * Matrix.Translation(-pivotOffset);
trans.SetRotation(ref world);
trans.Translation += world.TranslationVector;
@@ -540,7 +540,7 @@ namespace FlaxEditor.Viewport
protected override void OnLeftMouseButtonUp()
{
// Skip if was controlling mouse or mouse is not over the area
if (_prevInput.IsControllingMouse || !Bounds.Contains(ref _viewMousePos))
if (_prevInput.IsControllingMouse || !Bounds.Contains(_viewMousePos))
return;
if (TransformGizmo.IsActive)

View File

@@ -379,7 +379,7 @@ namespace FlaxEditor.Viewport.Previews
float screenMultiple = 0.5f * Mathf.Max(projectionMatrix.M11, projectionMatrix.M22);
var sphere = PreviewActor.Sphere;
var viewOrigin = ViewPosition;
var distSqr = Vector3.DistanceSquared(ref sphere.Center, ref viewOrigin);
var distSqr = Vector3.DistanceSquared(sphere.Center, viewOrigin);
var screenRadiusSquared = Mathf.Square(screenMultiple * sphere.Radius) / Mathf.Max(1.0f, distSqr);
screenSize = Mathf.Sqrt((float)screenRadiusSquared) * 2.0f;

View File

@@ -95,7 +95,7 @@ namespace FlaxEditor.Viewport.Previews
float screenMultiple = 0.5f * Mathf.Max(projectionMatrix.M11, projectionMatrix.M22);
var sphere = PreviewActor.Sphere;
var viewOrigin = ViewPosition;
var distSqr = Vector3.DistanceSquared(ref sphere.Center, ref viewOrigin);
var distSqr = Vector3.DistanceSquared(sphere.Center, viewOrigin);
var screenRadiusSquared = Mathf.Square(screenMultiple * sphere.Radius) / Mathf.Max(1.0f, distSqr);
screenSize = Mathf.Sqrt((float)screenRadiusSquared) * 2.0f;

View File

@@ -153,7 +153,7 @@ namespace FlaxEditor.Viewport
hitLocation = ray.Position + ray.Direction * closest;
hitNormal = normal;
}
else if (girdGizmo != null && girdGizmo.Enabled && CollisionsHelper.RayIntersectsPlane(ref ray, ref gridPlane, out closest) && closest < 4000.0f)
else if (girdGizmo != null && girdGizmo.Enabled && CollisionsHelper.RayIntersectsPlane(ray, gridPlane, out closest) && closest < 4000.0f)
{
// Use grid location
hitLocation = ray.Position + ray.Direction * closest;

View File

@@ -664,7 +664,7 @@ namespace FlaxEditor.Windows.Assets
Float2 uv2 = texCoordStream.GetFloat2((int)i2) * uvScale;
// Don't draw too small triangles
float area = Float2.TriangleArea(ref uv0, ref uv1, ref uv2);
float area = Float2.TriangleArea(uv0, uv1, uv2);
if (area > 10.0f)
{
// Draw triangle

View File

@@ -41,7 +41,7 @@ namespace FlaxEditor.Windows
// Draw children with scale
var scaling = new Float3(ContentScale, ContentScale, 1);
Matrix3x3.Scaling(ref scaling, out Matrix3x3 scale);
Matrix3x3.Scaling(scaling, out Matrix3x3 scale);
Render2D.PushTransform(scale);
if (ClipChildren)
{

View File

@@ -151,17 +151,17 @@ namespace FlaxEngine
public void Linear(ref Vector2 a, ref Vector2 b, float alpha, out Vector2 result)
{
Vector2.Lerp(ref a, ref b, alpha, out result);
Vector2.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Vector2 p0, ref Vector2 p1, ref Vector2 p2, ref Vector2 p3, float alpha, out Vector2 result)
{
Vector2.Lerp(ref p0, ref p1, alpha, out var p01);
Vector2.Lerp(ref p1, ref p2, alpha, out var p12);
Vector2.Lerp(ref p2, ref p3, alpha, out var p23);
Vector2.Lerp(ref p01, ref p12, alpha, out var p012);
Vector2.Lerp(ref p12, ref p23, alpha, out var p123);
Vector2.Lerp(ref p012, ref p123, alpha, out result);
Vector2.Lerp(p0, p1, alpha, out var p01);
Vector2.Lerp(p1, p2, alpha, out var p12);
Vector2.Lerp(p2, p3, alpha, out var p23);
Vector2.Lerp(p01, p12, alpha, out var p012);
Vector2.Lerp(p12, p23, alpha, out var p123);
Vector2.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Vector3 value, ref Vector3 tangent, float tangentScale, out Vector3 result)
@@ -171,17 +171,17 @@ namespace FlaxEngine
public void Linear(ref Vector3 a, ref Vector3 b, float alpha, out Vector3 result)
{
Vector3.Lerp(ref a, ref b, alpha, out result);
Vector3.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Vector3 p0, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, float alpha, out Vector3 result)
{
Vector3.Lerp(ref p0, ref p1, alpha, out var p01);
Vector3.Lerp(ref p1, ref p2, alpha, out var p12);
Vector3.Lerp(ref p2, ref p3, alpha, out var p23);
Vector3.Lerp(ref p01, ref p12, alpha, out var p012);
Vector3.Lerp(ref p12, ref p23, alpha, out var p123);
Vector3.Lerp(ref p012, ref p123, alpha, out result);
Vector3.Lerp(p0, p1, alpha, out var p01);
Vector3.Lerp(p1, p2, alpha, out var p12);
Vector3.Lerp(p2, p3, alpha, out var p23);
Vector3.Lerp(p01, p12, alpha, out var p012);
Vector3.Lerp(p12, p23, alpha, out var p123);
Vector3.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Vector4 value, ref Vector4 tangent, float tangentScale, out Vector4 result)
@@ -191,17 +191,17 @@ namespace FlaxEngine
public void Linear(ref Vector4 a, ref Vector4 b, float alpha, out Vector4 result)
{
Vector4.Lerp(ref a, ref b, alpha, out result);
Vector4.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Vector4 p0, ref Vector4 p1, ref Vector4 p2, ref Vector4 p3, float alpha, out Vector4 result)
{
Vector4.Lerp(ref p0, ref p1, alpha, out var p01);
Vector4.Lerp(ref p1, ref p2, alpha, out var p12);
Vector4.Lerp(ref p2, ref p3, alpha, out var p23);
Vector4.Lerp(ref p01, ref p12, alpha, out var p012);
Vector4.Lerp(ref p12, ref p23, alpha, out var p123);
Vector4.Lerp(ref p012, ref p123, alpha, out result);
Vector4.Lerp(p0, p1, alpha, out var p01);
Vector4.Lerp(p1, p2, alpha, out var p12);
Vector4.Lerp(p2, p3, alpha, out var p23);
Vector4.Lerp(p01, p12, alpha, out var p012);
Vector4.Lerp(p12, p23, alpha, out var p123);
Vector4.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Float2 value, ref Float2 tangent, float tangentScale, out Float2 result)
@@ -211,17 +211,17 @@ namespace FlaxEngine
public void Linear(ref Float2 a, ref Float2 b, float alpha, out Float2 result)
{
Float2.Lerp(ref a, ref b, alpha, out result);
Float2.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Float2 p0, ref Float2 p1, ref Float2 p2, ref Float2 p3, float alpha, out Float2 result)
{
Float2.Lerp(ref p0, ref p1, alpha, out var p01);
Float2.Lerp(ref p1, ref p2, alpha, out var p12);
Float2.Lerp(ref p2, ref p3, alpha, out var p23);
Float2.Lerp(ref p01, ref p12, alpha, out var p012);
Float2.Lerp(ref p12, ref p23, alpha, out var p123);
Float2.Lerp(ref p012, ref p123, alpha, out result);
Float2.Lerp(p0, p1, alpha, out var p01);
Float2.Lerp(p1, p2, alpha, out var p12);
Float2.Lerp(p2, p3, alpha, out var p23);
Float2.Lerp(p01, p12, alpha, out var p012);
Float2.Lerp(p12, p23, alpha, out var p123);
Float2.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Float3 value, ref Float3 tangent, float tangentScale, out Float3 result)
@@ -231,17 +231,17 @@ namespace FlaxEngine
public void Linear(ref Float3 a, ref Float3 b, float alpha, out Float3 result)
{
Float3.Lerp(ref a, ref b, alpha, out result);
Float3.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Float3 p0, ref Float3 p1, ref Float3 p2, ref Float3 p3, float alpha, out Float3 result)
{
Float3.Lerp(ref p0, ref p1, alpha, out var p01);
Float3.Lerp(ref p1, ref p2, alpha, out var p12);
Float3.Lerp(ref p2, ref p3, alpha, out var p23);
Float3.Lerp(ref p01, ref p12, alpha, out var p012);
Float3.Lerp(ref p12, ref p23, alpha, out var p123);
Float3.Lerp(ref p012, ref p123, alpha, out result);
Float3.Lerp(p0, p1, alpha, out var p01);
Float3.Lerp(p1, p2, alpha, out var p12);
Float3.Lerp(p2, p3, alpha, out var p23);
Float3.Lerp(p01, p12, alpha, out var p012);
Float3.Lerp(p12, p23, alpha, out var p123);
Float3.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Float4 value, ref Float4 tangent, float tangentScale, out Float4 result)
@@ -251,17 +251,17 @@ namespace FlaxEngine
public void Linear(ref Float4 a, ref Float4 b, float alpha, out Float4 result)
{
Float4.Lerp(ref a, ref b, alpha, out result);
Float4.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Float4 p0, ref Float4 p1, ref Float4 p2, ref Float4 p3, float alpha, out Float4 result)
{
Float4.Lerp(ref p0, ref p1, alpha, out var p01);
Float4.Lerp(ref p1, ref p2, alpha, out var p12);
Float4.Lerp(ref p2, ref p3, alpha, out var p23);
Float4.Lerp(ref p01, ref p12, alpha, out var p012);
Float4.Lerp(ref p12, ref p23, alpha, out var p123);
Float4.Lerp(ref p012, ref p123, alpha, out result);
Float4.Lerp(p0, p1, alpha, out var p01);
Float4.Lerp(p1, p2, alpha, out var p12);
Float4.Lerp(p2, p3, alpha, out var p23);
Float4.Lerp(p01, p12, alpha, out var p012);
Float4.Lerp(p12, p23, alpha, out var p123);
Float4.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Double2 value, ref Double2 tangent, float tangentScale, out Double2 result)
@@ -271,17 +271,17 @@ namespace FlaxEngine
public void Linear(ref Double2 a, ref Double2 b, float alpha, out Double2 result)
{
Double2.Lerp(ref a, ref b, alpha, out result);
Double2.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Double2 p0, ref Double2 p1, ref Double2 p2, ref Double2 p3, float alpha, out Double2 result)
{
Double2.Lerp(ref p0, ref p1, alpha, out var p01);
Double2.Lerp(ref p1, ref p2, alpha, out var p12);
Double2.Lerp(ref p2, ref p3, alpha, out var p23);
Double2.Lerp(ref p01, ref p12, alpha, out var p012);
Double2.Lerp(ref p12, ref p23, alpha, out var p123);
Double2.Lerp(ref p012, ref p123, alpha, out result);
Double2.Lerp(p0, p1, alpha, out var p01);
Double2.Lerp(p1, p2, alpha, out var p12);
Double2.Lerp(p2, p3, alpha, out var p23);
Double2.Lerp(p01, p12, alpha, out var p012);
Double2.Lerp(p12, p23, alpha, out var p123);
Double2.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Double3 value, ref Double3 tangent, float tangentScale, out Double3 result)
@@ -291,17 +291,17 @@ namespace FlaxEngine
public void Linear(ref Double3 a, ref Double3 b, float alpha, out Double3 result)
{
Double3.Lerp(ref a, ref b, alpha, out result);
Double3.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Double3 p0, ref Double3 p1, ref Double3 p2, ref Double3 p3, float alpha, out Double3 result)
{
Double3.Lerp(ref p0, ref p1, alpha, out var p01);
Double3.Lerp(ref p1, ref p2, alpha, out var p12);
Double3.Lerp(ref p2, ref p3, alpha, out var p23);
Double3.Lerp(ref p01, ref p12, alpha, out var p012);
Double3.Lerp(ref p12, ref p23, alpha, out var p123);
Double3.Lerp(ref p012, ref p123, alpha, out result);
Double3.Lerp(p0, p1, alpha, out var p01);
Double3.Lerp(p1, p2, alpha, out var p12);
Double3.Lerp(p2, p3, alpha, out var p23);
Double3.Lerp(p01, p12, alpha, out var p012);
Double3.Lerp(p12, p23, alpha, out var p123);
Double3.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Double4 value, ref Double4 tangent, float tangentScale, out Double4 result)
@@ -311,37 +311,37 @@ namespace FlaxEngine
public void Linear(ref Double4 a, ref Double4 b, float alpha, out Double4 result)
{
Double4.Lerp(ref a, ref b, alpha, out result);
Double4.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Double4 p0, ref Double4 p1, ref Double4 p2, ref Double4 p3, float alpha, out Double4 result)
{
Double4.Lerp(ref p0, ref p1, alpha, out var p01);
Double4.Lerp(ref p1, ref p2, alpha, out var p12);
Double4.Lerp(ref p2, ref p3, alpha, out var p23);
Double4.Lerp(ref p01, ref p12, alpha, out var p012);
Double4.Lerp(ref p12, ref p23, alpha, out var p123);
Double4.Lerp(ref p012, ref p123, alpha, out result);
Double4.Lerp(p0, p1, alpha, out var p01);
Double4.Lerp(p1, p2, alpha, out var p12);
Double4.Lerp(p2, p3, alpha, out var p23);
Double4.Lerp(p01, p12, alpha, out var p012);
Double4.Lerp(p12, p23, alpha, out var p123);
Double4.Lerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Quaternion value, ref Quaternion tangent, float tangentScale, out Quaternion result)
{
Quaternion.Slerp(ref value, ref tangent, 1.0f / 3.0f, out result);
Quaternion.Slerp(value, tangent, 1.0f / 3.0f, out result);
}
public void Linear(ref Quaternion a, ref Quaternion b, float alpha, out Quaternion result)
{
Quaternion.Slerp(ref a, ref b, alpha, out result);
Quaternion.Slerp(a, b, alpha, out result);
}
public void Bezier(ref Quaternion p0, ref Quaternion p1, ref Quaternion p2, ref Quaternion p3, float alpha, out Quaternion result)
{
Quaternion.Slerp(ref p0, ref p1, alpha, out var p01);
Quaternion.Slerp(ref p1, ref p2, alpha, out var p12);
Quaternion.Slerp(ref p2, ref p3, alpha, out var p23);
Quaternion.Slerp(ref p01, ref p12, alpha, out var p012);
Quaternion.Slerp(ref p12, ref p23, alpha, out var p123);
Quaternion.Slerp(ref p012, ref p123, alpha, out result);
Quaternion.Slerp(p0, p1, alpha, out var p01);
Quaternion.Slerp(p1, p2, alpha, out var p12);
Quaternion.Slerp(p2, p3, alpha, out var p23);
Quaternion.Slerp(p01, p12, alpha, out var p012);
Quaternion.Slerp(p12, p23, alpha, out var p123);
Quaternion.Slerp(p012, p123, alpha, out result);
}
public void GetTangent(ref Color32 value, ref Color32 tangent, float tangentScale, out Color32 result)
@@ -371,17 +371,17 @@ namespace FlaxEngine
public void Linear(ref Color a, ref Color b, float alpha, out Color result)
{
Color.Lerp(ref a, ref b, alpha, out result);
Color.Lerp(a, b, alpha, out result);
}
public void Bezier(ref Color p0, ref Color p1, ref Color p2, ref Color p3, float alpha, out Color result)
{
Color.Lerp(ref p0, ref p1, alpha, out var p01);
Color.Lerp(ref p1, ref p2, alpha, out var p12);
Color.Lerp(ref p2, ref p3, alpha, out var p23);
Color.Lerp(ref p01, ref p12, alpha, out var p012);
Color.Lerp(ref p12, ref p23, alpha, out var p123);
Color.Lerp(ref p012, ref p123, alpha, out result);
Color.Lerp(p0, p1, alpha, out var p01);
Color.Lerp(p1, p2, alpha, out var p12);
Color.Lerp(p2, p3, alpha, out var p23);
Color.Lerp(p01, p12, alpha, out var p012);
Color.Lerp(p12, p23, alpha, out var p123);
Color.Lerp(p012, p123, alpha, out result);
}
}

View File

@@ -147,9 +147,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="ray">The ray to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray)
public bool Intersects(in Ray ray)
{
return CollisionsHelper.RayIntersectsBox(ref ray, ref this, out Real _);
return CollisionsHelper.RayIntersectsBox(ray, this, out Real _);
}
/// <summary>
@@ -158,9 +158,9 @@ namespace FlaxEngine
/// <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>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray, out Real distance)
public bool Intersects(in Ray ray, out Real distance)
{
return CollisionsHelper.RayIntersectsBox(ref ray, ref this, out distance);
return CollisionsHelper.RayIntersectsBox(ray, this, out distance);
}
#if USE_LARGE_WORLDS
@@ -172,9 +172,9 @@ namespace FlaxEngine
/// <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>
[Obsolete("Use Intersects with 'out Real distance' parameter instead")]
public bool Intersects(ref Ray ray, out float distance)
public bool Intersects(in Ray ray, out float distance)
{
var result = CollisionsHelper.RayIntersectsBox(ref ray, ref this, out Real dst);
var result = CollisionsHelper.RayIntersectsBox(ray, this, out Real dst);
distance = (float)dst;
return result;
}
@@ -186,9 +186,9 @@ namespace FlaxEngine
/// <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>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray, out Vector3 point)
public bool Intersects(in Ray ray, out Vector3 point)
{
return CollisionsHelper.RayIntersectsBox(ref ray, ref this, out point);
return CollisionsHelper.RayIntersectsBox(ray, this, out point);
}
/// <summary>
@@ -196,9 +196,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="plane">The plane to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public PlaneIntersectionType Intersects(ref Plane plane)
public PlaneIntersectionType Intersects(in Plane plane)
{
return CollisionsHelper.PlaneIntersectsBox(ref plane, ref this);
return CollisionsHelper.PlaneIntersectsBox(plane, this);
}
/* This implementation is wrong
@@ -209,7 +209,7 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public bool Intersects(in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
return Collision.BoxIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3);
}
@@ -220,9 +220,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref BoundingBox box)
public bool Intersects(in BoundingBox box)
{
return CollisionsHelper.BoxIntersectsBox(ref this, ref box);
return CollisionsHelper.BoxIntersectsBox(this, box);
}
/// <summary>
@@ -232,7 +232,7 @@ namespace FlaxEngine
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(BoundingBox box)
{
return Intersects(ref box);
return Intersects(in box);
}
/// <summary>
@@ -240,9 +240,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref BoundingSphere sphere)
public bool Intersects(in BoundingSphere sphere)
{
return CollisionsHelper.BoxIntersectsSphere(ref this, ref sphere);
return CollisionsHelper.BoxIntersectsSphere(this, sphere);
}
/// <summary>
@@ -252,7 +252,7 @@ namespace FlaxEngine
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(BoundingSphere sphere)
{
return Intersects(ref sphere);
return Intersects(in sphere);
}
/// <summary>
@@ -260,9 +260,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="point">The point to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref Vector3 point)
public ContainmentType Contains(in Vector3 point)
{
return CollisionsHelper.BoxContainsPoint(ref this, ref point);
return CollisionsHelper.BoxContainsPoint(this, point);
}
/// <summary>
@@ -272,7 +272,7 @@ namespace FlaxEngine
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(Vector3 point)
{
return Contains(ref point);
return Contains(in point);
}
/* This implementation is wrong
@@ -283,7 +283,7 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public ContainmentType Contains(in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
return Collision.BoxContainsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3);
}
@@ -294,9 +294,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref BoundingBox box)
public ContainmentType Contains(in BoundingBox box)
{
return CollisionsHelper.BoxContainsBox(ref this, ref box);
return CollisionsHelper.BoxContainsBox(this, box);
}
/// <summary>
@@ -306,7 +306,7 @@ namespace FlaxEngine
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(BoundingBox box)
{
return Contains(ref box);
return Contains(in box);
}
/// <summary>
@@ -314,9 +314,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref BoundingSphere sphere)
public ContainmentType Contains(in BoundingSphere sphere)
{
return CollisionsHelper.BoxContainsSphere(ref this, ref sphere);
return CollisionsHelper.BoxContainsSphere(this, sphere);
}
/// <summary>
@@ -326,7 +326,7 @@ namespace FlaxEngine
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(BoundingSphere sphere)
{
return Contains(ref sphere);
return Contains(in sphere);
}
/// <summary>
@@ -343,8 +343,8 @@ namespace FlaxEngine
var max = Vector3.Minimum;
for (var i = 0; i < points.Length; ++i)
{
Vector3.Min(ref min, ref points[i], out min);
Vector3.Max(ref max, ref points[i], out max);
Vector3.Min(min, points[i], out min);
Vector3.Max(max, points[i], out max);
}
result = new BoundingBox(min, max);
}
@@ -375,8 +375,8 @@ namespace FlaxEngine
var max = Float3.Minimum;
for (var i = 0; i < points.Length; ++i)
{
Float3.Min(ref min, ref points[i], out min);
Float3.Max(ref max, ref points[i], out max);
Float3.Min(min, points[i], out min);
Float3.Max(max, points[i], out max);
}
result = new BoundingBox(min, max);
}
@@ -386,7 +386,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere that will designate the extents of the box.</param>
/// <param name="result">When the method completes, contains the newly constructed bounding box.</param>
public static void FromSphere(ref BoundingSphere sphere, out BoundingBox result)
public static void FromSphere(in BoundingSphere sphere, out BoundingBox result)
{
result.Minimum = new Vector3(sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius);
result.Maximum = new Vector3(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius);
@@ -411,10 +411,10 @@ namespace FlaxEngine
/// <param name="value1">The first box to merge.</param>
/// <param name="value2">The second box to merge.</param>
/// <param name="result">When the method completes, contains the newly constructed bounding box.</param>
public static void Merge(ref BoundingBox value1, ref BoundingBox value2, out BoundingBox result)
public static void Merge(in BoundingBox value1, in BoundingBox value2, out BoundingBox result)
{
Vector3.Min(ref value1.Minimum, ref value2.Minimum, out result.Minimum);
Vector3.Max(ref value1.Maximum, ref value2.Maximum, out result.Maximum);
Vector3.Min(value1.Minimum, value2.Minimum, out result.Minimum);
Vector3.Max(value1.Maximum, value2.Maximum, out result.Maximum);
}
/// <summary>
@@ -426,8 +426,8 @@ namespace FlaxEngine
public static BoundingBox Merge(BoundingBox value1, BoundingBox value2)
{
BoundingBox box;
Vector3.Min(ref value1.Minimum, ref value2.Minimum, out box.Minimum);
Vector3.Max(ref value1.Maximum, ref value2.Maximum, out box.Maximum);
Vector3.Min(value1.Minimum, value2.Minimum, out box.Minimum);
Vector3.Max(value1.Maximum, value2.Maximum, out box.Maximum);
return box;
}
@@ -437,10 +437,10 @@ namespace FlaxEngine
/// <param name="value1">The box to merge.</param>
/// <param name="value2">The point to merge.</param>
/// <param name="result">When the method completes, contains the newly constructed bounding box.</param>
public static void Merge(ref BoundingBox value1, ref Vector3 value2, out BoundingBox result)
public static void Merge(in BoundingBox value1, in Vector3 value2, out BoundingBox result)
{
Vector3.Min(ref value1.Minimum, ref value2, out result.Minimum);
Vector3.Max(ref value1.Maximum, ref value2, out result.Maximum);
Vector3.Min(value1.Minimum, value2, out result.Minimum);
Vector3.Max(value1.Maximum, value2, out result.Maximum);
}
/// <summary>
@@ -451,8 +451,8 @@ namespace FlaxEngine
public BoundingBox Merge(Vector3 value2)
{
BoundingBox result;
Vector3.Min(ref Minimum, ref value2, out result.Minimum);
Vector3.Max(ref Maximum, ref value2, out result.Maximum);
Vector3.Min(Minimum, value2, out result.Minimum);
Vector3.Max(Maximum, value2, out result.Maximum);
return result;
}
@@ -464,7 +464,7 @@ namespace FlaxEngine
/// <returns>The result of the transformation.</returns>
public static BoundingBox Transform(BoundingBox box, Matrix transform)
{
Transform(ref box, ref transform, out BoundingBox result);
Transform(box, transform, out BoundingBox result);
return result;
}
@@ -474,7 +474,7 @@ namespace FlaxEngine
/// <param name="box">The bounding box to transform.</param>
/// <param name="transform">The transformation matrix.</param>
/// <param name="result">The result of the transformation.</param>
public static void Transform(ref BoundingBox box, ref Matrix transform, out BoundingBox result)
public static void Transform(in BoundingBox box, in Matrix transform, out BoundingBox result)
{
// Reference: http://dev.theomader.com/transform-bounding-boxes/
@@ -504,7 +504,7 @@ namespace FlaxEngine
/// <returns>The result of the transformation.</returns>
public static BoundingBox Transform(BoundingBox box, Transform transform)
{
Transform(ref box, ref transform, out BoundingBox result);
Transform(box, transform, out BoundingBox result);
return result;
}
@@ -514,7 +514,7 @@ namespace FlaxEngine
/// <param name="box">The bounding box to transform.</param>
/// <param name="transform">The transformation.</param>
/// <param name="result">The result of the transformation.</param>
public static void Transform(ref BoundingBox box, ref Transform transform, out BoundingBox result)
public static void Transform(in BoundingBox box, in Transform transform, out BoundingBox result)
{
// Reference: http://dev.theomader.com/transform-bounding-boxes/
@@ -543,8 +543,8 @@ namespace FlaxEngine
public BoundingBox MakeOffsetted(Vector3 offset)
{
BoundingBox result;
Vector3.Add(ref Minimum, ref offset, out result.Minimum);
Vector3.Add(ref Maximum, ref offset, out result.Maximum);
Vector3.Add(Minimum, offset, out result.Minimum);
Vector3.Add(Maximum, offset, out result.Maximum);
return result;
}
@@ -554,11 +554,11 @@ namespace FlaxEngine
/// <param name="box">The box.</param>
/// <param name="offset">The bounds offset.</param>
/// <returns>The offsetted bounds.</returns>
public static BoundingBox MakeOffsetted(ref BoundingBox box, ref Vector3 offset)
public static BoundingBox MakeOffsetted(in BoundingBox box, in Vector3 offset)
{
BoundingBox result;
Vector3.Add(ref box.Minimum, ref offset, out result.Minimum);
Vector3.Add(ref box.Maximum, ref offset, out result.Maximum);
Vector3.Add(box.Minimum, offset, out result.Minimum);
Vector3.Add(box.Maximum, offset, out result.Maximum);
return result;
}
@@ -568,9 +568,9 @@ namespace FlaxEngine
/// <param name="box">The box.</param>
/// <param name="scale">The bounds scale.</param>
/// <returns>The scaled bounds.</returns>
public static BoundingBox MakeScaled(ref BoundingBox box, Real scale)
public static BoundingBox MakeScaled(in BoundingBox box, Real scale)
{
Vector3.Subtract(ref box.Maximum, ref box.Minimum, out var size);
Vector3.Subtract(box.Maximum, box.Minimum, out var size);
Vector3 sizeHalf = size * 0.5f;
Vector3 center = box.Minimum + sizeHalf;
sizeHalf *= scale;
@@ -586,7 +586,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static BoundingBox operator *(BoundingBox box, Matrix transform)
{
Transform(ref box, ref transform, out BoundingBox result);
Transform(box, transform, out BoundingBox result);
return result;
}
@@ -599,7 +599,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(BoundingBox left, BoundingBox right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -611,7 +611,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(BoundingBox left, BoundingBox right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -676,7 +676,7 @@ namespace FlaxEngine
/// <param name="other">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>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref BoundingBox other)
public bool Equals(in BoundingBox other)
{
return Minimum == other.Minimum && Maximum == other.Maximum;
}
@@ -689,7 +689,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(BoundingBox other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -699,7 +699,7 @@ namespace FlaxEngine
/// <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)
{
return value is BoundingBox other && Equals(ref other);
return value is BoundingBox other && Equals(in other);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace FlaxEngine
set
{
pMatrix = value;
GetPlanesFromMatrix(ref pMatrix, out pNear, out pFar, out pLeft, out pRight, out pTop, out pBottom);
GetPlanesFromMatrix(in pMatrix, out pNear, out pFar, out pLeft, out pRight, out pTop, out pBottom);
}
}
@@ -101,17 +101,17 @@ namespace FlaxEngine
public BoundingFrustum(Matrix matrix)
{
pMatrix = matrix;
GetPlanesFromMatrix(ref pMatrix, out pNear, out pFar, out pLeft, out pRight, out pTop, out pBottom);
GetPlanesFromMatrix(in pMatrix, out pNear, out pFar, out pLeft, out pRight, out pTop, out pBottom);
}
/// <summary>
/// Creates a new instance of BoundingFrustum.
/// </summary>
/// <param name="matrix">Combined matrix that usually takes view × projection matrix.</param>
public BoundingFrustum(ref Matrix matrix)
public BoundingFrustum(in Matrix matrix)
{
pMatrix = matrix;
GetPlanesFromMatrix(ref pMatrix, out pNear, out pFar, out pLeft, out pRight, out pTop, out pBottom);
GetPlanesFromMatrix(in pMatrix, out pNear, out pFar, out pLeft, out pRight, out pTop, out pBottom);
}
/// <summary>
@@ -129,7 +129,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="BoundingFrustum" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="BoundingFrustum" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref BoundingFrustum other)
public bool Equals(in BoundingFrustum other)
{
return pMatrix == other.pMatrix;
}
@@ -142,7 +142,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(BoundingFrustum other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -152,7 +152,7 @@ namespace FlaxEngine
/// <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 obj)
{
return obj is BoundingFrustum other && Equals(ref other);
return obj is BoundingFrustum other && Equals(in other);
}
/// <summary>
@@ -164,7 +164,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(BoundingFrustum left, BoundingFrustum right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -176,7 +176,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(BoundingFrustum left, BoundingFrustum right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -198,7 +198,7 @@ namespace FlaxEngine
}
}
private static void GetPlanesFromMatrix(ref Matrix matrix, out Plane near, out Plane far, out Plane left, out Plane right, out Plane top, out Plane bottom)
private static void GetPlanesFromMatrix(in Matrix matrix, out Plane near, out Plane far, out Plane left, out Plane right, out Plane top, out Plane bottom)
{
//http://www.chadvernon.com/blog/resources/directx9/frustum-culling/
@@ -245,14 +245,14 @@ namespace FlaxEngine
far.Normalize();
}
private static Vector3 Get3PlanesInterPoint(ref Plane p1, ref Plane p2, ref Plane p3)
private static Vector3 Get3PlanesInterPoint(in Plane p1, in Plane p2, in Plane p3)
{
Vector3.Cross(ref p2.Normal, ref p3.Normal, out var n2Xn3);
Vector3.Cross(ref p3.Normal, ref p1.Normal, out var n3Xn1);
Vector3.Cross(ref p1.Normal, ref p2.Normal, out var n1Xn2);
var div1 = Vector3.Dot(ref p1.Normal, ref n2Xn3);
var div2 = Vector3.Dot(ref p2.Normal, ref n3Xn1);
var div3 = Vector3.Dot(ref p3.Normal, ref n1Xn2);
Vector3.Cross(p2.Normal, p3.Normal, out var n2Xn3);
Vector3.Cross(p3.Normal, p1.Normal, out var n3Xn1);
Vector3.Cross(p1.Normal, p2.Normal, out var n1Xn2);
var div1 = Vector3.Dot(p1.Normal, n2Xn3);
var div2 = Vector3.Dot(p2.Normal, n3Xn1);
var div3 = Vector3.Dot(p3.Normal, n1Xn2);
if (Mathf.IsZero(div1 * div2 * div3))
return Vector3.Zero;
return n2Xn3 * (-p1.D / div1) - n3Xn1 * (p2.D / div2) - n1Xn2 * (p3.D / div3);
@@ -346,14 +346,14 @@ namespace FlaxEngine
/// <returns>The 8 corners of the frustum</returns>
public void GetCorners(Vector3[] corners)
{
corners[0] = Get3PlanesInterPoint(ref pNear, ref pBottom, ref pRight); //Near1
corners[1] = Get3PlanesInterPoint(ref pNear, ref pTop, ref pRight); //Near2
corners[2] = Get3PlanesInterPoint(ref pNear, ref pTop, ref pLeft); //Near3
corners[3] = Get3PlanesInterPoint(ref pNear, ref pBottom, ref pLeft); //Near3
corners[4] = Get3PlanesInterPoint(ref pFar, ref pBottom, ref pRight); //Far1
corners[5] = Get3PlanesInterPoint(ref pFar, ref pTop, ref pRight); //Far2
corners[6] = Get3PlanesInterPoint(ref pFar, ref pTop, ref pLeft); //Far3
corners[7] = Get3PlanesInterPoint(ref pFar, ref pBottom, ref pLeft); //Far3
corners[0] = Get3PlanesInterPoint(in pNear, in pBottom, in pRight); //Near1
corners[1] = Get3PlanesInterPoint(in pNear, in pTop, in pRight); //Near2
corners[2] = Get3PlanesInterPoint(in pNear, in pTop, in pLeft); //Near3
corners[3] = Get3PlanesInterPoint(in pNear, in pBottom, in pLeft); //Near3
corners[4] = Get3PlanesInterPoint(in pFar, in pBottom, in pRight); //Far1
corners[5] = Get3PlanesInterPoint(in pFar, in pTop, in pRight); //Far2
corners[6] = Get3PlanesInterPoint(in pFar, in pTop, in pLeft); //Far3
corners[7] = Get3PlanesInterPoint(in pFar, in pBottom, in pLeft); //Far3
}
/// <summary>
@@ -361,7 +361,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="point">The point.</param>
/// <returns>Type of the containment</returns>
public ContainmentType Contains(ref Vector3 point)
public ContainmentType Contains(in Vector3 point)
{
var result = PlaneIntersectionType.Front;
var planeResult = PlaneIntersectionType.Front;
@@ -370,22 +370,22 @@ namespace FlaxEngine
switch (i)
{
case 0:
planeResult = pNear.Intersects(ref point);
planeResult = pNear.Intersects(point);
break;
case 1:
planeResult = pFar.Intersects(ref point);
planeResult = pFar.Intersects(point);
break;
case 2:
planeResult = pLeft.Intersects(ref point);
planeResult = pLeft.Intersects(point);
break;
case 3:
planeResult = pRight.Intersects(ref point);
planeResult = pRight.Intersects(point);
break;
case 4:
planeResult = pTop.Intersects(ref point);
planeResult = pTop.Intersects(point);
break;
case 5:
planeResult = pBottom.Intersects(ref point);
planeResult = pBottom.Intersects(point);
break;
}
switch (planeResult)
@@ -410,10 +410,10 @@ namespace FlaxEngine
/// <returns>Type of the containment</returns>
public ContainmentType Contains(Vector3 point)
{
return Contains(ref point);
return Contains(in point);
}
private void GetBoxToPlanePVertexNVertex(ref BoundingBox box, ref Vector3 planeNormal, out Vector3 p, out Vector3 n)
private void GetBoxToPlanePVertexNVertex(in BoundingBox box, in Vector3 planeNormal, out Vector3 p, out Vector3 n)
{
p = box.Minimum;
if (planeNormal.X >= 0)
@@ -437,17 +437,17 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box.</param>
/// <returns>Type of the containment</returns>
public ContainmentType Contains(ref BoundingBox box)
public ContainmentType Contains(in BoundingBox box)
{
var result = ContainmentType.Contains;
for (var i = 0; i < 6; i++)
{
var plane = GetPlane(i);
GetBoxToPlanePVertexNVertex(ref box, ref plane.Normal, out var p, out var n);
if (CollisionsHelper.PlaneIntersectsPoint(ref plane, ref p) == PlaneIntersectionType.Back)
GetBoxToPlanePVertexNVertex(in box, in plane.Normal, out var p, out var n);
if (CollisionsHelper.PlaneIntersectsPoint(plane, p) == PlaneIntersectionType.Back)
return ContainmentType.Disjoint;
if (CollisionsHelper.PlaneIntersectsPoint(ref plane, ref n) == PlaneIntersectionType.Back)
if (CollisionsHelper.PlaneIntersectsPoint(plane, n) == PlaneIntersectionType.Back)
result = ContainmentType.Intersects;
}
return result;
@@ -460,7 +460,7 @@ namespace FlaxEngine
/// <returns>Type of the containment</returns>
public ContainmentType Contains(BoundingBox box)
{
return Contains(ref box);
return Contains(in box);
}
/// <summary>
@@ -468,9 +468,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box.</param>
/// <param name="result">Type of the containment.</param>
public void Contains(ref BoundingBox box, out ContainmentType result)
public void Contains(in BoundingBox box, out ContainmentType result)
{
result = Contains(ref box);
result = Contains(in box);
}
/// <summary>
@@ -478,7 +478,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere.</param>
/// <returns>Type of the containment</returns>
public ContainmentType Contains(ref BoundingSphere sphere)
public ContainmentType Contains(in BoundingSphere sphere)
{
var result = PlaneIntersectionType.Front;
var planeResult = PlaneIntersectionType.Front;
@@ -487,22 +487,22 @@ namespace FlaxEngine
switch (i)
{
case 0:
planeResult = pNear.Intersects(ref sphere);
planeResult = pNear.Intersects(sphere);
break;
case 1:
planeResult = pFar.Intersects(ref sphere);
planeResult = pFar.Intersects(sphere);
break;
case 2:
planeResult = pLeft.Intersects(ref sphere);
planeResult = pLeft.Intersects(sphere);
break;
case 3:
planeResult = pRight.Intersects(ref sphere);
planeResult = pRight.Intersects(sphere);
break;
case 4:
planeResult = pTop.Intersects(ref sphere);
planeResult = pTop.Intersects(sphere);
break;
case 5:
planeResult = pBottom.Intersects(ref sphere);
planeResult = pBottom.Intersects(sphere);
break;
}
switch (planeResult)
@@ -527,7 +527,7 @@ namespace FlaxEngine
/// <returns>Type of the containment</returns>
public ContainmentType Contains(BoundingSphere sphere)
{
return Contains(ref sphere);
return Contains(in sphere);
}
/// <summary>
@@ -535,9 +535,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere.</param>
/// <param name="result">Type of the containment.</param>
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
public void Contains(in BoundingSphere sphere, out ContainmentType result)
{
result = Contains(ref sphere);
result = Contains(in sphere);
}
/// <summary>
@@ -545,9 +545,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere.</param>
/// <returns>Type of the containment</returns>
public bool Intersects(ref BoundingSphere sphere)
public bool Intersects(in BoundingSphere sphere)
{
return Contains(ref sphere) != ContainmentType.Disjoint;
return Contains(in sphere) != ContainmentType.Disjoint;
}
/// <summary>
@@ -555,9 +555,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere.</param>
/// <param name="result">Set to <c>true</c> if the current BoundingFrustum intersects a BoundingSphere.</param>
public void Intersects(ref BoundingSphere sphere, out bool result)
public void Intersects(in BoundingSphere sphere, out bool result)
{
result = Contains(ref sphere) != ContainmentType.Disjoint;
result = Contains(in sphere) != ContainmentType.Disjoint;
}
/// <summary>
@@ -565,9 +565,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box.</param>
/// <returns><c>true</c> if the current BoundingFrustum intersects a BoundingSphere.</returns>
public bool Intersects(ref BoundingBox box)
public bool Intersects(in BoundingBox box)
{
return Contains(ref box) != ContainmentType.Disjoint;
return Contains(in box) != ContainmentType.Disjoint;
}
/// <summary>
@@ -575,16 +575,16 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box.</param>
/// <param name="result"><c>true</c> if the current BoundingFrustum intersects a BoundingSphere.</param>
public void Intersects(ref BoundingBox box, out bool result)
public void Intersects(in BoundingBox box, out bool result)
{
result = Contains(ref box) != ContainmentType.Disjoint;
result = Contains(in box) != ContainmentType.Disjoint;
}
private PlaneIntersectionType PlaneIntersectsPoints(ref Plane plane, Vector3[] points)
private PlaneIntersectionType PlaneIntersectsPoints(in Plane plane, Vector3[] points)
{
PlaneIntersectionType result = CollisionsHelper.PlaneIntersectsPoint(ref plane, ref points[0]);
PlaneIntersectionType result = CollisionsHelper.PlaneIntersectsPoint(plane, points[0]);
for (var i = 1; i < points.Length; i++)
if (CollisionsHelper.PlaneIntersectsPoint(ref plane, ref points[i]) != result)
if (CollisionsHelper.PlaneIntersectsPoint(plane, points[i]) != result)
return PlaneIntersectionType.Intersecting;
return result;
}
@@ -594,9 +594,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="plane">The plane.</param>
/// <returns>Plane intersection type.</returns>
public PlaneIntersectionType Intersects(ref Plane plane)
public PlaneIntersectionType Intersects(in Plane plane)
{
return PlaneIntersectsPoints(ref plane, GetCorners());
return PlaneIntersectsPoints(in plane, GetCorners());
}
/// <summary>
@@ -604,9 +604,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="plane">The plane.</param>
/// <param name="result">Plane intersection type.</param>
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
public void Intersects(in Plane plane, out PlaneIntersectionType result)
{
result = PlaneIntersectsPoints(ref plane, GetCorners());
result = PlaneIntersectsPoints(in plane, GetCorners());
}
/// <summary>
@@ -648,9 +648,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="ray">The ray.</param>
/// <returns><c>true</c> if the current BoundingFrustum intersects the specified Ray.</returns>
public bool Intersects(ref Ray ray)
public bool Intersects(in Ray ray)
{
return Intersects(ref ray, out _, out _);
return Intersects(in ray, out _, out _);
}
/// <summary>
@@ -660,7 +660,7 @@ namespace FlaxEngine
/// <param name="inDistance">The distance at which the ray enters the frustum if there is an intersection and the ray starts outside the frustum.</param>
/// <param name="outDistance">The distance at which the ray exits the frustum if there is an intersection.</param>
/// <returns><c>true</c> if the current BoundingFrustum intersects the specified Ray.</returns>
public bool Intersects(ref Ray ray, out Real? inDistance, out Real? outDistance)
public bool Intersects(in Ray ray, out Real? inDistance, out Real? outDistance)
{
if (Contains(ray.Position) != ContainmentType.Disjoint)
{
@@ -668,7 +668,7 @@ namespace FlaxEngine
for (var i = 0; i < 6; i++)
{
Plane plane = GetPlane(i);
if (CollisionsHelper.RayIntersectsPlane(ref ray, ref plane, out Real distance) && (distance < nearstPlaneDistance))
if (CollisionsHelper.RayIntersectsPlane(ray, plane, out Real distance) && (distance < nearstPlaneDistance))
nearstPlaneDistance = distance;
}
@@ -684,7 +684,7 @@ namespace FlaxEngine
for (var i = 0; i < 6; i++)
{
Plane plane = GetPlane(i);
if (CollisionsHelper.RayIntersectsPlane(ref ray, ref plane, out Real distance))
if (CollisionsHelper.RayIntersectsPlane(ray, plane, out Real distance))
{
minDist = Mathf.Min(minDist, distance);
maxDist = Mathf.Max(maxDist, distance);
@@ -694,7 +694,7 @@ namespace FlaxEngine
Vector3 minPoint = ray.Position + ray.Direction * minDist;
Vector3 maxPoint = ray.Position + ray.Direction * maxDist;
Vector3 center = (minPoint + maxPoint) / 2f;
if (Contains(ref center) != ContainmentType.Disjoint)
if (Contains(in center) != ContainmentType.Disjoint)
{
inDistance = minDist;
outDistance = maxDist;
@@ -725,10 +725,10 @@ namespace FlaxEngine
var maxPointDist = Real.MinValue;
for (var i = 0; i < points.Length; i++)
{
var pointDist = CollisionsHelper.DistancePlanePoint(ref ioFrustrum.pTop, ref points[i]);
pointDist = Mathf.Max(pointDist, CollisionsHelper.DistancePlanePoint(ref ioFrustrum.pBottom, ref points[i]));
pointDist = Mathf.Max(pointDist, CollisionsHelper.DistancePlanePoint(ref ioFrustrum.pLeft, ref points[i]) * horizontalToVerticalMapping);
pointDist = Mathf.Max(pointDist, CollisionsHelper.DistancePlanePoint(ref ioFrustrum.pRight, ref points[i]) * horizontalToVerticalMapping);
var pointDist = CollisionsHelper.DistancePlanePoint(ioFrustrum.pTop, points[i]);
pointDist = Mathf.Max(pointDist, CollisionsHelper.DistancePlanePoint(ioFrustrum.pBottom, points[i]));
pointDist = Mathf.Max(pointDist, CollisionsHelper.DistancePlanePoint(ioFrustrum.pLeft, points[i]) * horizontalToVerticalMapping);
pointDist = Mathf.Max(pointDist, CollisionsHelper.DistancePlanePoint(ioFrustrum.pRight, points[i]) * horizontalToVerticalMapping);
maxPointDist = Mathf.Max(maxPointDist, pointDist);
}
return -maxPointDist / vSin;
@@ -741,7 +741,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="boundingBox">The bounding box.</param>
/// <returns>The zoom to fit distance</returns>
public Real GetZoomToExtentsShiftDistance(ref BoundingBox boundingBox)
public Real GetZoomToExtentsShiftDistance(in BoundingBox boundingBox)
{
return GetZoomToExtentsShiftDistance(boundingBox.GetCorners());
}
@@ -760,7 +760,7 @@ namespace FlaxEngine
/// Get the vector shift which when added to camera position will do the effect of zoom to extents (zoom to fit) operation, so all the passed points will fit in the current view.</summary>
/// <param name="boundingBox">The bounding box.</param>
/// <returns>The zoom to fit vector</returns>
public Vector3 GetZoomToExtentsShiftVector(ref BoundingBox boundingBox)
public Vector3 GetZoomToExtentsShiftVector(in BoundingBox boundingBox)
{
return GetZoomToExtentsShiftDistance(boundingBox.GetCorners()) * pNear.Normal;
}

View File

@@ -85,9 +85,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="ray">The ray to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray)
public bool Intersects(in Ray ray)
{
return CollisionsHelper.RayIntersectsSphere(ref ray, ref this, out Real _);
return CollisionsHelper.RayIntersectsSphere(ray, this, out Real _);
}
/// <summary>
@@ -96,9 +96,9 @@ namespace FlaxEngine
/// <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>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray, out Real distance)
public bool Intersects(in Ray ray, out Real distance)
{
return CollisionsHelper.RayIntersectsSphere(ref ray, ref this, out distance);
return CollisionsHelper.RayIntersectsSphere(ray, this, out distance);
}
/// <summary>
@@ -107,9 +107,9 @@ namespace FlaxEngine
/// <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>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Ray ray, out Vector3 point)
public bool Intersects(in Ray ray, out Vector3 point)
{
return CollisionsHelper.RayIntersectsSphere(ref ray, ref this, out point);
return CollisionsHelper.RayIntersectsSphere(ray, this, out point);
}
/// <summary>
@@ -117,9 +117,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="plane">The plane to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public PlaneIntersectionType Intersects(ref Plane plane)
public PlaneIntersectionType Intersects(in Plane plane)
{
return CollisionsHelper.PlaneIntersectsSphere(ref plane, ref this);
return CollisionsHelper.PlaneIntersectsSphere(plane, this);
}
/// <summary>
@@ -129,9 +129,9 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public bool Intersects(in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
return CollisionsHelper.SphereIntersectsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3);
return CollisionsHelper.SphereIntersectsTriangle(this, vertex1, vertex2, vertex3);
}
/// <summary>
@@ -139,9 +139,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref BoundingBox box)
public bool Intersects(in BoundingBox box)
{
return CollisionsHelper.BoxIntersectsSphere(ref box, ref this);
return CollisionsHelper.BoxIntersectsSphere(box, this);
}
/// <summary>
@@ -151,7 +151,7 @@ namespace FlaxEngine
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(BoundingBox box)
{
return Intersects(ref box);
return Intersects(in box);
}
/// <summary>
@@ -159,9 +159,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(ref BoundingSphere sphere)
public bool Intersects(in BoundingSphere sphere)
{
return CollisionsHelper.SphereIntersectsSphere(ref this, ref sphere);
return CollisionsHelper.SphereIntersectsSphere(this, sphere);
}
/// <summary>
@@ -171,7 +171,7 @@ namespace FlaxEngine
/// <returns>Whether the two objects intersected.</returns>
public bool Intersects(BoundingSphere sphere)
{
return Intersects(ref sphere);
return Intersects(in sphere);
}
/// <summary>
@@ -179,9 +179,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="point">The point to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref Vector3 point)
public ContainmentType Contains(in Vector3 point)
{
return CollisionsHelper.SphereContainsPoint(ref this, ref point);
return CollisionsHelper.SphereContainsPoint(this, point);
}
/// <summary>
@@ -191,9 +191,9 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public ContainmentType Contains(in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
return CollisionsHelper.SphereContainsTriangle(ref this, ref vertex1, ref vertex2, ref vertex3);
return CollisionsHelper.SphereContainsTriangle(this, vertex1, vertex2, vertex3);
}
/// <summary>
@@ -201,9 +201,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref BoundingBox box)
public ContainmentType Contains(in BoundingBox box)
{
return CollisionsHelper.SphereContainsBox(ref this, ref box);
return CollisionsHelper.SphereContainsBox(this, box);
}
/// <summary>
@@ -211,9 +211,9 @@ namespace FlaxEngine
/// </summary>
/// <param name="sphere">The sphere to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public ContainmentType Contains(ref BoundingSphere sphere)
public ContainmentType Contains(in BoundingSphere sphere)
{
return CollisionsHelper.SphereContainsSphere(ref this, ref sphere);
return CollisionsHelper.SphereContainsSphere(this, sphere);
}
/// <summary>
@@ -239,7 +239,7 @@ namespace FlaxEngine
// Find the center of all points
Vector3 center = Vector3.Zero;
for (int i = start; i < upperEnd; ++i)
Vector3.Add(ref points[i], ref center, out center);
Vector3.Add(points[i], center, out center);
center /= (Real)count;
// Find the radius of the sphere
@@ -247,7 +247,7 @@ namespace FlaxEngine
for (int i = start; i < upperEnd; ++i)
{
// We are doing a relative distance comparison to find the maximum distance from the center of our sphere
Vector3.DistanceSquared(ref center, ref points[i], out Real distance);
Vector3.DistanceSquared(center, points[i], out Real distance);
if (distance > radius)
radius = distance;
}
@@ -285,7 +285,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="box">The box that will designate the extents of the sphere.</param>
/// <param name="result">When the method completes, the newly constructed bounding sphere.</param>
public static void FromBox(ref BoundingBox box, out BoundingSphere result)
public static void FromBox(in BoundingBox box, out BoundingSphere result)
{
var x = box.Maximum.X - box.Minimum.X;
var y = box.Maximum.Y - box.Minimum.Y;
@@ -303,7 +303,7 @@ namespace FlaxEngine
/// <returns>The newly constructed bounding sphere.</returns>
public static BoundingSphere FromBox(BoundingBox box)
{
FromBox(ref box, out var result);
FromBox(in box, out var result);
return result;
}
@@ -314,7 +314,7 @@ namespace FlaxEngine
/// <param name="value1">The first sphere to merge.</param>
/// <param name="value2">The second sphere to merge.</param>
/// <param name="result">When the method completes, contains the newly constructed bounding sphere.</param>
public static void Merge(ref BoundingSphere value1, ref BoundingSphere value2, out BoundingSphere result)
public static void Merge(in BoundingSphere value1, in BoundingSphere value2, out BoundingSphere result)
{
// Pre-exit if one of the bounding sphere by assuming that a merge with an empty sphere is equivalent at taking the non-empty sphere
if (value1 == Empty)
@@ -365,7 +365,7 @@ namespace FlaxEngine
/// <returns>The newly constructed bounding sphere.</returns>
public static BoundingSphere Merge(BoundingSphere value1, BoundingSphere value2)
{
Merge(ref value1, ref value2, out var result);
Merge(in value1, in value2, out var result);
return result;
}
@@ -377,7 +377,7 @@ namespace FlaxEngine
/// <remarks>The result transformed sphere.</remarks>
public static BoundingSphere Transform(BoundingSphere sphere, Matrix matrix)
{
Transform(ref sphere, ref matrix, out var result);
Transform(in sphere, in matrix, out var result);
return result;
}
@@ -387,9 +387,9 @@ namespace FlaxEngine
/// <param name="sphere">The sphere.</param>
/// <param name="matrix">The matrix.</param>
/// <param name="result">The result transformed sphere.</param>
public static void Transform(ref BoundingSphere sphere, ref Matrix matrix, out BoundingSphere result)
public static void Transform(in BoundingSphere sphere, in Matrix matrix, out BoundingSphere result)
{
Vector3.Transform(ref sphere.Center, ref matrix, out result.Center);
Vector3.Transform(sphere.Center, matrix, out result.Center);
result.Radius = sphere.Radius * matrix.ScaleVector.Absolute.MaxValue;
}
@@ -402,7 +402,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(BoundingSphere left, BoundingSphere right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -414,7 +414,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(BoundingSphere left, BoundingSphere right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -490,7 +490,7 @@ namespace FlaxEngine
/// <param name="other">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>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref BoundingSphere other)
public bool Equals(in BoundingSphere other)
{
return Center == other.Center && Radius == other.Radius;
}
@@ -503,7 +503,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(BoundingSphere other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -513,7 +513,7 @@ namespace FlaxEngine
/// <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)
{
return value is BoundingSphere other && Equals(ref other);
return value is BoundingSphere other && Equals(in other);
}
}
}

View File

@@ -136,7 +136,7 @@ namespace FlaxEngine
/// <param name="p0">The line first point.</param>
/// <param name="p1">The line second point.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
public static void ClosestPointPointLine(ref Float2 point, ref Float2 p0, ref Float2 p1, out Float2 result)
public static void ClosestPointPointLine(in Float2 point, in Float2 p0, in Float2 p1, out Float2 result)
{
var p = point - p0;
var n = p1 - p0;
@@ -175,7 +175,7 @@ namespace FlaxEngine
/// <param name="p0">The line first point.</param>
/// <param name="p1">The line second point.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
public static void ClosestPointPointLine(ref Vector3 point, ref Vector3 p0, ref Vector3 p1, out Vector3 result)
public static void ClosestPointPointLine(in Vector3 point, in Vector3 p0, in Vector3 p1, out Vector3 result)
{
Vector3 p = point - p0;
Vector3 n = p1 - p0;
@@ -186,7 +186,7 @@ namespace FlaxEngine
return;
}
n /= length;
Real dot = Vector3.Dot(ref n, ref p);
Real dot = Vector3.Dot(n, p);
if (dot <= 0.0f)
{
result = p0;
@@ -208,7 +208,7 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex to test.</param>
/// <param name="vertex3">The third vertex to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
public static void ClosestPointPointTriangle(ref Vector3 point, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 result)
public static void ClosestPointPointTriangle(in Vector3 point, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3, out Vector3 result)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 136
@@ -286,12 +286,12 @@ namespace FlaxEngine
/// <param name="plane">The plane to test.</param>
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
public static void ClosestPointPlanePoint(ref Plane plane, ref Vector3 point, out Vector3 result)
public static void ClosestPointPlanePoint(in Plane plane, in Vector3 point, out Vector3 result)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 126
Vector3.Dot(ref plane.Normal, ref point, out Real dot);
Vector3.Dot(plane.Normal, point, out Real dot);
Real t = dot - plane.D;
result = point - t * plane.Normal;
@@ -303,13 +303,13 @@ namespace FlaxEngine
/// <param name="box">The box to test.</param>
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
public static void ClosestPointBoxPoint(ref BoundingBox box, ref Vector3 point, out Vector3 result)
public static void ClosestPointBoxPoint(in BoundingBox box, in Vector3 point, out Vector3 result)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 130
Vector3.Max(ref point, ref box.Minimum, out Vector3 temp);
Vector3.Min(ref temp, ref box.Maximum, out result);
Vector3.Max(point, box.Minimum, out Vector3 temp);
Vector3.Min(temp, box.Maximum, out result);
}
/// <summary>
@@ -318,11 +318,11 @@ namespace FlaxEngine
/// <param name="rect">The rectangle to test.</param>
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects.</param>
public static void ClosestPointRectanglePoint(ref Rectangle rect, ref Float2 point, out Float2 result)
public static void ClosestPointRectanglePoint(in Rectangle rect, in Float2 point, out Float2 result)
{
Float2 end = rect.Location + rect.Size;
Float2.Max(ref point, ref rect.Location, out var temp);
Float2.Min(ref temp, ref end, out result);
Float2.Max(point, rect.Location, out var temp);
Float2.Min(temp, end, out result);
}
/// <summary>
@@ -332,13 +332,13 @@ namespace FlaxEngine
/// <param name="point">The point to test.</param>
/// <param name="result">When the method completes, contains the closest point between the two objects; or, if the point is directly in the center of the sphere, contains <see cref="Vector3.Zero" />.
/// </param>
public static void ClosestPointSpherePoint(ref BoundingSphere sphere, ref Vector3 point, out Vector3 result)
public static void ClosestPointSpherePoint(in BoundingSphere sphere, in Vector3 point, out Vector3 result)
{
//Source: Jorgy343
//Reference: None
//Get the unit direction from the sphere's center to the point.
Vector3.Subtract(ref point, ref sphere.Center, out result);
Vector3.Subtract(point, sphere.Center, out result);
result.Normalize();
//Multiply the unit direction by the sphere's radius to get a vector
@@ -360,13 +360,13 @@ namespace FlaxEngine
/// is the 'closest' point of intersection. This can also be considered is the deepest point of
/// intersection.
/// </remarks>
public static void ClosestPointSphereSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2, out Vector3 result)
public static void ClosestPointSphereSphere(in BoundingSphere sphere1, in BoundingSphere sphere2, out Vector3 result)
{
//Source: Jorgy343
//Reference: None
//Get the unit direction from the first sphere's center to the second sphere's center.
Vector3.Subtract(ref sphere2.Center, ref sphere1.Center, out result);
Vector3.Subtract(sphere2.Center, sphere1.Center, out result);
result.Normalize();
//Multiply the unit direction by the first sphere's radius to get a vector
@@ -383,12 +383,12 @@ namespace FlaxEngine
/// <param name="plane">The plane to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>The distance between the two objects.</returns>
public static Real DistancePlanePoint(ref Plane plane, ref Vector3 point)
public static Real DistancePlanePoint(in Plane plane, in Vector3 point)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 127
Vector3.Dot(ref plane.Normal, ref point, out Real dot);
Vector3.Dot(plane.Normal, point, out Real dot);
return dot - plane.D;
}
@@ -398,7 +398,7 @@ namespace FlaxEngine
/// <param name="box">The box to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>The distance between the two objects.</returns>
public static Real DistanceBoxPoint(ref BoundingBox box, ref Vector3 point)
public static Real DistanceBoxPoint(in BoundingBox box, in Vector3 point)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 131
@@ -428,7 +428,7 @@ namespace FlaxEngine
/// <param name="box1">The first box to test.</param>
/// <param name="box2">The second box to test.</param>
/// <returns>The distance between the two objects.</returns>
public static Real DistanceBoxBox(ref BoundingBox box1, ref BoundingBox box2)
public static Real DistanceBoxBox(in BoundingBox box1, in BoundingBox box2)
{
//Source:
//Reference:
@@ -480,12 +480,12 @@ namespace FlaxEngine
/// <param name="sphere">The sphere to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>The distance between the two objects.</returns>
public static Real DistanceSpherePoint(ref BoundingSphere sphere, ref Vector3 point)
public static Real DistanceSpherePoint(in BoundingSphere sphere, in Vector3 point)
{
//Source: Jorgy343
//Reference: None
Vector3.Distance(ref sphere.Center, ref point, out Real distance);
Vector3.Distance(sphere.Center, point, out Real distance);
distance -= sphere.Radius;
return Math.Max(distance, 0f);
}
@@ -496,12 +496,12 @@ namespace FlaxEngine
/// <param name="sphere1">The first sphere to test.</param>
/// <param name="sphere2">The second sphere to test.</param>
/// <returns>The distance between the two objects.</returns>
public static Real DistanceSphereSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2)
public static Real DistanceSphereSphere(in BoundingSphere sphere1, in BoundingSphere sphere2)
{
//Source: Jorgy343
//Reference: None
Vector3.Distance(ref sphere1.Center, ref sphere2.Center, out Real distance);
Vector3.Distance(sphere1.Center, sphere2.Center, out Real distance);
distance -= sphere1.Radius + sphere2.Radius;
return Math.Max(distance, 0f);
}
@@ -512,12 +512,12 @@ namespace FlaxEngine
/// <param name="ray">The ray to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>Whether the two objects intersect.</returns>
public static bool RayIntersectsPoint(ref Ray ray, ref Vector3 point)
public static bool RayIntersectsPoint(in Ray ray, in Vector3 point)
{
//Source: RayIntersectsSphere
//Reference: None
Vector3.Subtract(ref ray.Position, ref point, out Vector3 m);
Vector3.Subtract(ray.Position, point, out Vector3 m);
//Same thing as RayIntersectsSphere except that the radius of the sphere (point) is the epsilon for zero.
Real b = Vector3.Dot(m, ray.Direction);
@@ -547,12 +547,12 @@ namespace FlaxEngine
/// of the second ray, det denotes the determinant of a matrix, x denotes the cross
/// product, [ ] denotes a matrix, and || || denotes the length or magnitude of a vector.
/// </remarks>
public static bool RayIntersectsRay(ref Ray ray1, ref Ray ray2, out Vector3 point)
public static bool RayIntersectsRay(in Ray ray1, in Ray ray2, out Vector3 point)
{
//Source: Real-Time Rendering, Third Edition
//Reference: Page 780
Vector3.Cross(ref ray1.Direction, ref ray2.Direction, out Vector3 cross);
Vector3.Cross(ray1.Direction, ray2.Direction, out Vector3 cross);
Real denominator = cross.Length;
//Lines are parallel.
@@ -629,18 +629,18 @@ namespace FlaxEngine
/// <param name="plane">The plane to test.</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 intersect.</returns>
public static bool RayIntersectsPlane(ref Ray ray, ref Plane plane, out Real distance)
public static bool RayIntersectsPlane(in Ray ray, in Plane plane, out Real distance)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 175
Vector3.Dot(ref plane.Normal, ref ray.Direction, out Real direction);
Vector3.Dot(plane.Normal, ray.Direction, out Real direction);
if (Mathf.IsZero(direction))
{
distance = 0f;
return false;
}
Vector3.Dot(ref plane.Normal, ref ray.Position, out Real position);
Vector3.Dot(plane.Normal, ray.Position, out Real position);
distance = (-plane.D - position) / direction;
if (distance < 0f)
{
@@ -660,18 +660,18 @@ namespace FlaxEngine
/// <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 intersect.</returns>
[Obsolete("Use RayIntersectsPlane with 'out Real distance' parameter instead")]
public static bool RayIntersectsPlane(ref Ray ray, ref Plane plane, out float distance)
public static bool RayIntersectsPlane(in Ray ray, in Plane plane, out float distance)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 175
Vector3.Dot(ref plane.Normal, ref ray.Direction, out Real direction);
Vector3.Dot(plane.Normal, ray.Direction, out Real direction);
if (Mathf.IsZero(direction))
{
distance = 0f;
return false;
}
Vector3.Dot(ref plane.Normal, ref ray.Position, out Real position);
Vector3.Dot(plane.Normal, ray.Position, out Real position);
distance = (float)((-plane.D - position) / direction);
if (distance < 0f)
{
@@ -689,11 +689,11 @@ namespace FlaxEngine
/// <param name="plane">The plane 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>
/// <returns>Whether the two objects intersected.</returns>
public static bool RayIntersectsPlane(ref Ray ray, ref Plane plane, out Vector3 point)
public static bool RayIntersectsPlane(in Ray ray, in Plane plane, out Vector3 point)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 175
if (!RayIntersectsPlane(ref ray, ref plane, out Real distance))
if (!RayIntersectsPlane(ray, plane, out Real distance))
{
point = Vector3.Zero;
return false;
@@ -718,7 +718,7 @@ namespace FlaxEngine
/// the ray, no intersection is assumed to have happened. In both cases of assumptions,
/// this method returns false.
/// </remarks>
public static bool RayIntersectsTriangle(ref Ray ray, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Real distance)
public static bool RayIntersectsTriangle(in Ray ray, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3, out Real distance)
{
//Source: Fast Minimum Storage Ray / Triangle Intersection
//Reference: http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf
@@ -818,9 +818,9 @@ namespace FlaxEngine
/// <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 static bool RayIntersectsTriangle(ref Ray ray, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3, out Vector3 point)
public static bool RayIntersectsTriangle(in Ray ray, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3, out Vector3 point)
{
if (!RayIntersectsTriangle(ref ray, ref vertex1, ref vertex2, ref vertex3, out Real distance))
if (!RayIntersectsTriangle(ray, vertex1, vertex2, vertex3, out Real distance))
{
point = Vector3.Zero;
return false;
@@ -837,7 +837,7 @@ namespace FlaxEngine
/// <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 static bool RayIntersectsBox(ref Ray ray, ref BoundingBox box, out Real distance)
public static bool RayIntersectsBox(in Ray ray, in BoundingBox box, out Real distance)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 179
@@ -948,9 +948,9 @@ namespace FlaxEngine
/// <param name="box">The box 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>
/// <returns>Whether the two objects intersected.</returns>
public static bool RayIntersectsBox(ref Ray ray, ref BoundingBox box, out Vector3 point)
public static bool RayIntersectsBox(in Ray ray, in BoundingBox box, out Vector3 point)
{
if (!RayIntersectsBox(ref ray, ref box, out Real distance))
if (!RayIntersectsBox(ray, box, out Real distance))
{
point = Vector3.Zero;
return false;
@@ -967,12 +967,12 @@ namespace FlaxEngine
/// <param name="sphere">The sphere to test.</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 static bool RayIntersectsSphere(ref Ray ray, ref BoundingSphere sphere, out Real distance)
public static bool RayIntersectsSphere(in Ray ray, in BoundingSphere sphere, out Real distance)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 177
Vector3.Subtract(ref ray.Position, ref sphere.Center, out Vector3 m);
Vector3.Subtract(ray.Position, sphere.Center, out Vector3 m);
Real b = Vector3.Dot(m, ray.Direction);
Real c = Vector3.Dot(m, m) - sphere.Radius * sphere.Radius;
@@ -1006,9 +1006,9 @@ namespace FlaxEngine
/// <param name="sphere">The sphere 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>
/// <returns>Whether the two objects intersected.</returns>
public static bool RayIntersectsSphere(ref Ray ray, ref BoundingSphere sphere, out Vector3 point)
public static bool RayIntersectsSphere(in Ray ray, in BoundingSphere sphere, out Vector3 point)
{
if (!RayIntersectsSphere(ref ray, ref sphere, out Real distance))
if (!RayIntersectsSphere(ray, sphere, out Real distance))
{
point = Vector3.Zero;
return false;
@@ -1024,9 +1024,9 @@ namespace FlaxEngine
/// <param name="plane">The plane to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static PlaneIntersectionType PlaneIntersectsPoint(ref Plane plane, ref Vector3 point)
public static PlaneIntersectionType PlaneIntersectsPoint(in Plane plane, in Vector3 point)
{
Vector3.Dot(ref plane.Normal, ref point, out Real distance);
Vector3.Dot(plane.Normal, point, out Real distance);
distance += plane.D;
if (distance > 0f)
@@ -1044,13 +1044,13 @@ namespace FlaxEngine
/// <param name="plane1">The first plane to test.</param>
/// <param name="plane2">The second plane to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static bool PlaneIntersectsPlane(ref Plane plane1, ref Plane plane2)
public static bool PlaneIntersectsPlane(in Plane plane1, in Plane plane2)
{
Vector3.Cross(ref plane1.Normal, ref plane2.Normal, out Vector3 direction);
Vector3.Cross(plane1.Normal, plane2.Normal, out Vector3 direction);
//If direction is the zero vector, the planes are parallel and possibly
//coincident. It is not an intersection. The dot product will tell us.
Vector3.Dot(ref direction, ref direction, out Real denominator);
Vector3.Dot(direction, direction, out Real denominator);
if (Mathf.IsZero(denominator))
return false;
@@ -1070,16 +1070,16 @@ namespace FlaxEngine
/// a line in three dimensions which has no real origin. The ray is considered valid when
/// both the positive direction is used and when the negative direction is used.
/// </remarks>
public static bool PlaneIntersectsPlane(ref Plane plane1, ref Plane plane2, out Ray line)
public static bool PlaneIntersectsPlane(in Plane plane1, in Plane plane2, out Ray line)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 207
Vector3.Cross(ref plane1.Normal, ref plane2.Normal, out Vector3 direction);
Vector3.Cross(plane1.Normal, plane2.Normal, out Vector3 direction);
//If direction is the zero vector, the planes are parallel and possibly
//coincident. It is not an intersection. The dot product will tell us.
Vector3.Dot(ref direction, ref direction, out Real denominator);
Vector3.Dot(direction, direction, out Real denominator);
//We assume the planes are normalized, therefore the denominator
//only serves as a parallel and coincident check. Otherwise we need
@@ -1091,7 +1091,7 @@ namespace FlaxEngine
}
Vector3 temp = plane1.D * plane2.Normal - plane2.D * plane1.Normal;
Vector3.Cross(ref temp, ref direction, out Vector3 point);
Vector3.Cross(temp, direction, out Vector3 point);
line.Position = point;
line.Direction = direction;
@@ -1108,14 +1108,14 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static PlaneIntersectionType PlaneIntersectsTriangle(ref Plane plane, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public static PlaneIntersectionType PlaneIntersectsTriangle(in Plane plane, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 207
PlaneIntersectionType test1 = PlaneIntersectsPoint(ref plane, ref vertex1);
PlaneIntersectionType test2 = PlaneIntersectsPoint(ref plane, ref vertex2);
PlaneIntersectionType test3 = PlaneIntersectsPoint(ref plane, ref vertex3);
PlaneIntersectionType test1 = PlaneIntersectsPoint(plane, vertex1);
PlaneIntersectionType test2 = PlaneIntersectsPoint(plane, vertex2);
PlaneIntersectionType test3 = PlaneIntersectsPoint(plane, vertex3);
if ((test1 == PlaneIntersectionType.Front) && (test2 == PlaneIntersectionType.Front) && (test3 == PlaneIntersectionType.Front))
return PlaneIntersectionType.Front;
@@ -1132,7 +1132,7 @@ namespace FlaxEngine
/// <param name="plane">The plane to test.</param>
/// <param name="box">The box to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static PlaneIntersectionType PlaneIntersectsBox(ref Plane plane, ref BoundingBox box)
public static PlaneIntersectionType PlaneIntersectsBox(in Plane plane, in BoundingBox box)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 161
@@ -1147,7 +1147,7 @@ namespace FlaxEngine
min.Y = plane.Normal.Y >= 0.0f ? box.Maximum.Y : box.Minimum.Y;
min.Z = plane.Normal.Z >= 0.0f ? box.Maximum.Z : box.Minimum.Z;
Vector3.Dot(ref plane.Normal, ref max, out Real distance);
Vector3.Dot(plane.Normal, max, out Real distance);
if (distance + plane.D > 0.0f)
return PlaneIntersectionType.Front;
@@ -1166,12 +1166,12 @@ namespace FlaxEngine
/// <param name="plane">The plane to test.</param>
/// <param name="sphere">The sphere to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static PlaneIntersectionType PlaneIntersectsSphere(ref Plane plane, ref BoundingSphere sphere)
public static PlaneIntersectionType PlaneIntersectsSphere(in Plane plane, in BoundingSphere sphere)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 160
Vector3.Dot(ref plane.Normal, ref sphere.Center, out Real distance);
Vector3.Dot(plane.Normal, sphere.Center, out Real distance);
distance += plane.D;
if (distance > sphere.Radius)
@@ -1192,7 +1192,7 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static bool BoxIntersectsTriangle(ref BoundingBox box, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public static bool BoxIntersectsTriangle(in BoundingBox box, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
if (BoxContainsPoint(ref box, ref vertex1) == ContainmentType.Contains)
return true;
@@ -1213,7 +1213,7 @@ namespace FlaxEngine
/// <param name="box1">The first box to test.</param>
/// <param name="box2">The second box to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static bool BoxIntersectsBox(ref BoundingBox box1, ref BoundingBox box2)
public static bool BoxIntersectsBox(in BoundingBox box1, in BoundingBox box2)
{
if ((box1.Minimum.X > box2.Maximum.X) || (box2.Minimum.X > box1.Maximum.X))
return false;
@@ -1233,13 +1233,13 @@ namespace FlaxEngine
/// <param name="box">The box to test.</param>
/// <param name="sphere">The sphere to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static bool BoxIntersectsSphere(ref BoundingBox box, ref BoundingSphere sphere)
public static bool BoxIntersectsSphere(in BoundingBox box, in BoundingSphere sphere)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 166
Vector3.Clamp(ref sphere.Center, ref box.Minimum, ref box.Maximum, out Vector3 vector);
Real distance = Vector3.DistanceSquared(ref sphere.Center, ref vector);
Vector3.Clamp(sphere.Center, box.Minimum, box.Maximum, out Vector3 vector);
Real distance = Vector3.DistanceSquared(sphere.Center, vector);
return distance <= sphere.Radius * sphere.Radius;
}
@@ -1251,15 +1251,15 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static bool SphereIntersectsTriangle(ref BoundingSphere sphere, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public static bool SphereIntersectsTriangle(in BoundingSphere sphere, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
//Source: Real-Time Collision Detection by Christer Ericson
//Reference: Page 167
ClosestPointPointTriangle(ref sphere.Center, ref vertex1, ref vertex2, ref vertex3, out Vector3 point);
ClosestPointPointTriangle(sphere.Center, vertex1, vertex2, vertex3, out Vector3 point);
Vector3 v = point - sphere.Center;
Vector3.Dot(ref v, ref v, out Real dot);
Vector3.Dot(v, v, out Real dot);
return dot <= sphere.Radius * sphere.Radius;
}
@@ -1271,10 +1271,10 @@ namespace FlaxEngine
/// <param name="sphere1">First sphere to test.</param>
/// <param name="sphere2">Second sphere to test.</param>
/// <returns>Whether the two objects intersected.</returns>
public static bool SphereIntersectsSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2)
public static bool SphereIntersectsSphere(in BoundingSphere sphere1, in BoundingSphere sphere2)
{
Real radiisum = sphere1.Radius + sphere2.Radius;
return Vector3.DistanceSquared(ref sphere1.Center, ref sphere2.Center) <= radiisum * radiisum;
return Vector3.DistanceSquared(sphere1.Center, sphere2.Center) <= radiisum * radiisum;
}
/// <summary>
@@ -1283,7 +1283,7 @@ namespace FlaxEngine
/// <param name="box">The box to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType BoxContainsPoint(ref BoundingBox box, ref Vector3 point)
public static ContainmentType BoxContainsPoint(in BoundingBox box, in Vector3 point)
{
if ((box.Minimum.X <= point.X) && (box.Maximum.X >= point.X) &&
(box.Minimum.Y <= point.Y) && (box.Maximum.Y >= point.Y) &&
@@ -1302,7 +1302,7 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType BoxContainsTriangle(ref BoundingBox box, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public static ContainmentType BoxContainsTriangle(in BoundingBox box, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
ContainmentType test1 = BoxContainsPoint(ref box, ref vertex1);
ContainmentType test2 = BoxContainsPoint(ref box, ref vertex2);
@@ -1324,7 +1324,7 @@ namespace FlaxEngine
/// <param name="box1">The first box to test.</param>
/// <param name="box2">The second box to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType BoxContainsBox(ref BoundingBox box1, ref BoundingBox box2)
public static ContainmentType BoxContainsBox(in BoundingBox box1, in BoundingBox box2)
{
if ((box1.Maximum.X < box2.Minimum.X) || (box1.Minimum.X > box2.Maximum.X))
return ContainmentType.Disjoint;
@@ -1347,10 +1347,10 @@ namespace FlaxEngine
/// <param name="box">The box to test.</param>
/// <param name="sphere">The sphere to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType BoxContainsSphere(ref BoundingBox box, ref BoundingSphere sphere)
public static ContainmentType BoxContainsSphere(in BoundingBox box, in BoundingSphere sphere)
{
Vector3.Clamp(ref sphere.Center, ref box.Minimum, ref box.Maximum, out Vector3 vector);
Real distance = Vector3.DistanceSquared(ref sphere.Center, ref vector);
Vector3.Clamp(sphere.Center, box.Minimum, box.Maximum, out Vector3 vector);
Real distance = Vector3.DistanceSquared(sphere.Center, vector);
if (distance > sphere.Radius * sphere.Radius)
return ContainmentType.Disjoint;
@@ -1367,9 +1367,9 @@ namespace FlaxEngine
/// <param name="sphere">The sphere to test.</param>
/// <param name="point">The point to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType SphereContainsPoint(ref BoundingSphere sphere, ref Vector3 point)
public static ContainmentType SphereContainsPoint(in BoundingSphere sphere, in Vector3 point)
{
if (Vector3.DistanceSquared(ref point, ref sphere.Center) <= sphere.Radius * sphere.Radius)
if (Vector3.DistanceSquared(point, sphere.Center) <= sphere.Radius * sphere.Radius)
return ContainmentType.Contains;
return ContainmentType.Disjoint;
@@ -1383,19 +1383,19 @@ namespace FlaxEngine
/// <param name="vertex2">The second vertex of the triangle to test.</param>
/// <param name="vertex3">The third vertex of the triangle to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType SphereContainsTriangle(ref BoundingSphere sphere, ref Vector3 vertex1, ref Vector3 vertex2, ref Vector3 vertex3)
public static ContainmentType SphereContainsTriangle(in BoundingSphere sphere, in Vector3 vertex1, in Vector3 vertex2, in Vector3 vertex3)
{
//Source: Jorgy343
//Reference: None
ContainmentType test1 = SphereContainsPoint(ref sphere, ref vertex1);
ContainmentType test2 = SphereContainsPoint(ref sphere, ref vertex2);
ContainmentType test3 = SphereContainsPoint(ref sphere, ref vertex3);
ContainmentType test1 = SphereContainsPoint(sphere, vertex1);
ContainmentType test2 = SphereContainsPoint(sphere, vertex2);
ContainmentType test3 = SphereContainsPoint(sphere, vertex3);
if ((test1 == ContainmentType.Contains) && (test2 == ContainmentType.Contains) && (test3 == ContainmentType.Contains))
return ContainmentType.Contains;
if (SphereIntersectsTriangle(ref sphere, ref vertex1, ref vertex2, ref vertex3))
if (SphereIntersectsTriangle(sphere, vertex1, vertex2, vertex3))
return ContainmentType.Intersects;
return ContainmentType.Disjoint;
@@ -1407,11 +1407,11 @@ namespace FlaxEngine
/// <param name="sphere">The sphere to test.</param>
/// <param name="box">The box to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType SphereContainsBox(ref BoundingSphere sphere, ref BoundingBox box)
public static ContainmentType SphereContainsBox(in BoundingSphere sphere, in BoundingBox box)
{
Vector3 vector;
if (!BoxIntersectsSphere(ref box, ref sphere))
if (!BoxIntersectsSphere(box, sphere))
return ContainmentType.Disjoint;
Real radiusSquared = sphere.Radius * sphere.Radius;
@@ -1473,9 +1473,9 @@ namespace FlaxEngine
/// <param name="sphere1">The first sphere to test.</param>
/// <param name="sphere2">The second sphere to test.</param>
/// <returns>The type of containment the two objects have.</returns>
public static ContainmentType SphereContainsSphere(ref BoundingSphere sphere1, ref BoundingSphere sphere2)
public static ContainmentType SphereContainsSphere(in BoundingSphere sphere1, in BoundingSphere sphere2)
{
Real distance = Vector3.Distance(ref sphere1.Center, ref sphere2.Center);
Real distance = Vector3.Distance(sphere1.Center, sphere2.Center);
if (sphere1.Radius + sphere2.Radius < distance)
return ContainmentType.Disjoint;
@@ -1494,7 +1494,7 @@ namespace FlaxEngine
/// <param name="l2p1">The second line point 0.</param>
/// <param name="l2p2">The second line point 1.</param>
/// <returns>True if line intersects with the other line</returns>
public static bool LineIntersectsLine(ref Float2 l1p1, ref Float2 l1p2, ref Float2 l2p1, ref Float2 l2p2)
public static bool LineIntersectsLine(in Float2 l1p1, in Float2 l1p2, in Float2 l2p1, in Float2 l2p2)
{
float q = (l1p1.Y - l2p1.Y) * (l2p2.X - l2p1.X) - (l1p1.X - l2p1.X) * (l2p2.Y - l2p1.Y);
float d = (l1p2.X - l1p1.X) * (l2p2.Y - l2p1.Y) - (l1p2.Y - l1p1.Y) * (l2p2.X - l2p1.X);
@@ -1513,17 +1513,17 @@ namespace FlaxEngine
/// <param name="p2">The line point 1.</param>
/// <param name="rect">The rectangle.</param>
/// <returns>True if line intersects with the rectangle</returns>
public static bool LineIntersectsRect(ref Float2 p1, ref Float2 p2, ref Rectangle rect)
public static bool LineIntersectsRect(in Float2 p1, in Float2 p2, in Rectangle rect)
{
// TODO: optimize it
var pA = new Float2(rect.Right, rect.Y);
var pB = new Float2(rect.Right, rect.Bottom);
var pC = new Float2(rect.X, rect.Bottom);
return LineIntersectsLine(ref p1, ref p2, ref rect.Location, ref pA) ||
LineIntersectsLine(ref p1, ref p2, ref pA, ref pB) ||
LineIntersectsLine(ref p1, ref p2, ref pB, ref pC) ||
LineIntersectsLine(ref p1, ref p2, ref pC, ref rect.Location) ||
(rect.Contains(ref p1) && rect.Contains(ref p2));
return LineIntersectsLine(in p1, in p2, in rect.Location, in pA) ||
LineIntersectsLine(in p1, in p2, in pA, in pB) ||
LineIntersectsLine(in p1, in p2, in pB, in pC) ||
LineIntersectsLine(in p1, in p2, in pC, in rect.Location) ||
(rect.Contains(p1) && rect.Contains(p2));
}
/// <summary>
@@ -1534,7 +1534,7 @@ namespace FlaxEngine
/// <param name="b">The second vertex of the triangle.</param>
/// <param name="c">The third vertex of the triangle.</param>
/// <returns><c>true</c> if point is inside the triangle; otherwise, <c>false</c>.</returns>
public static bool IsPointInTriangle(ref Float2 point, ref Float2 a, ref Float2 b, ref Float2 c)
public static bool IsPointInTriangle(in Float2 point, in Float2 a, in Float2 b, in Float2 c)
{
var an = a - point;
var bn = b - point;

View File

@@ -199,7 +199,7 @@ namespace FlaxEngine
/// <inheritdoc />
public override bool Equals(object value)
{
return value is Color other && Equals(ref other);
return value is Color other && Equals(in other);
}
/// <summary>
@@ -208,7 +208,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Color" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Color" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Color other)
public bool Equals(in Color other)
{
return R == other.R && G == other.G && B == other.B && A == other.A;
}
@@ -628,7 +628,7 @@ namespace FlaxEngine
/// <param name="b">Color b</param>
/// <param name="t">Float for combining a and b</param>
/// <param name="result">The result.</param>
public static void Lerp(ref Color a, ref Color b, float t, out Color result)
public static void Lerp(in Color a, in Color b, float t, out Color result)
{
result = new Color(a.R + (b.R - a.R) * t, a.G + (b.G - a.G) * t, a.B + (b.B - a.B) * t, a.A + (b.A - a.A) * t);
}
@@ -663,7 +663,7 @@ namespace FlaxEngine
/// <returns>True if colors are equal, otherwise false.</returns>
public static bool operator ==(Color left, Color right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -674,7 +674,7 @@ namespace FlaxEngine
/// <returns>True if colors are not equal, otherwise false.</returns>
public static bool operator !=(Color left, Color right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -910,7 +910,7 @@ namespace FlaxEngine
/// <param name="value">The color whose contrast is to be adjusted.</param>
/// <param name="contrast">The amount by which to adjust the contrast.</param>
/// <param name="result">When the method completes, contains the adjusted color.</param>
public static void AdjustContrast(ref Color value, float contrast, out Color result)
public static void AdjustContrast(in Color value, float contrast, out Color result)
{
result.A = value.A;
result.R = 0.5f + contrast * (value.R - 0.5f);
@@ -939,7 +939,7 @@ namespace FlaxEngine
/// <param name="value">The color whose saturation is to be adjusted.</param>
/// <param name="saturation">The amount by which to adjust the saturation.</param>
/// <param name="result">When the method completes, contains the adjusted color.</param>
public static void AdjustSaturation(ref Color value, float saturation, out Color result)
public static void AdjustSaturation(in Color value, float saturation, out Color result)
{
float grey = value.R * 0.2125f + value.G * 0.7154f + value.B * 0.0721f;
@@ -982,7 +982,7 @@ namespace FlaxEngine
/// <param name="left">The first source color.</param>
/// <param name="right">The second source color.</param>
/// <param name="result">When the method completes, contains an new color composed of the largest components of the source colors.</param>
public static void Max(ref Color left, ref Color right, out Color result)
public static void Max(in Color left, in Color right, out Color result)
{
result = new Color(
Mathf.Max(left.R, right.R),
@@ -1000,7 +1000,7 @@ namespace FlaxEngine
/// <returns>A color containing the largest components of the source colors.</returns>
public static Color Max(Color left, Color right)
{
Max(ref left, ref right, out var result);
Max(in left, in right, out var result);
return result;
}
@@ -1010,7 +1010,7 @@ namespace FlaxEngine
/// <param name="left">The first source color.</param>
/// <param name="right">The second source color.</param>
/// <param name="result">When the method completes, contains an new color composed of the smallest components of the source colors.</param>
public static void Min(ref Color left, ref Color right, out Color result)
public static void Min(in Color left, in Color right, out Color result)
{
result = new Color(
Mathf.Min(left.R, right.R),
@@ -1028,7 +1028,7 @@ namespace FlaxEngine
/// <returns>A color containing the smallest components of the source colors.</returns>
public static Color Min(Color left, Color right)
{
Min(ref left, ref right, out var result);
Min(in left, in right, out var result);
return result;
}
@@ -1039,7 +1039,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Color value, ref Color min, ref Color max, out Color result)
public static void Clamp(in Color value, in Color min, in Color max, out Color result)
{
result = new Color(
Mathf.Clamp(value.R, min.R, max.R),
@@ -1058,7 +1058,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Color Clamp(Color value, Color min, Color max)
{
Clamp(ref value, ref min, ref max, out Color result);
Clamp(in value, in min, in max, out Color result);
return result;
}

View File

@@ -291,7 +291,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Double2 left, ref Double2 right, out Double2 result)
public static void Add(in Double2 left, in Double2 right, out Double2 result)
{
result = new Double2(left.X + right.X, left.Y + right.Y);
}
@@ -313,7 +313,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Double2 left, ref double right, out Double2 result)
public static void Add(in Double2 left, double right, out Double2 result)
{
result = new Double2(left.X + right, left.Y + right);
}
@@ -335,7 +335,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Double2 left, ref Double2 right, out Double2 result)
public static void Subtract(in Double2 left, in Double2 right, out Double2 result)
{
result = new Double2(left.X - right.X, left.Y - right.Y);
}
@@ -357,7 +357,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Double2 left, ref double right, out Double2 result)
public static void Subtract(in Double2 left, double right, out Double2 result)
{
result = new Double2(left.X - right, left.Y - right);
}
@@ -379,7 +379,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref double left, ref Double2 right, out Double2 result)
public static void Subtract(double left, in Double2 right, out Double2 result)
{
result = new Double2(left - right.X, left - right.Y);
}
@@ -401,7 +401,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Double2 value, double scale, out Double2 result)
public static void Multiply(in Double2 value, double scale, out Double2 result)
{
result = new Double2(value.X * scale, value.Y * scale);
}
@@ -423,7 +423,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Double2 left, ref Double2 right, out Double2 result)
public static void Multiply(in Double2 left, in Double2 right, out Double2 result)
{
result = new Double2(left.X * right.X, left.Y * right.Y);
}
@@ -445,7 +445,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Double2 value, double scale, out Double2 result)
public static void Divide(in Double2 value, double scale, out Double2 result)
{
result = new Double2(value.X / scale, value.Y / scale);
}
@@ -467,7 +467,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(double scale, ref Double2 value, out Double2 result)
public static void Divide(double scale, in Double2 value, out Double2 result)
{
result = new Double2(scale / value.X, scale / value.Y);
}
@@ -488,7 +488,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Double2 value, out Double2 result)
public static void Negate(in Double2 value, out Double2 result)
{
result = new Double2(-value.X, -value.Y);
}
@@ -513,7 +513,7 @@ namespace FlaxEngine
/// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2" />).</param>
/// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3" />).</param>
/// <param name="result">When the method completes, contains the 2D Cartesian coordinates of the specified point.</param>
public static void Barycentric(ref Double2 value1, ref Double2 value2, ref Double2 value3, double amount1, double amount2, out Double2 result)
public static void Barycentric(in Double2 value1, in Double2 value2, in Double2 value3, double amount1, double amount2, out Double2 result)
{
result = new Double2(value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X),
value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y));
@@ -531,7 +531,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Double2" /> containing the 2D Cartesian coordinates of the specified point.</returns>
public static Double2 Barycentric(Double2 value1, Double2 value2, Double2 value3, double amount1, double amount2)
{
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out Double2 result);
Barycentric(in value1, in value2, in value3, amount1, amount2, out Double2 result);
return result;
}
@@ -542,7 +542,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Double2 value, ref Double2 min, ref Double2 max, out Double2 result)
public static void Clamp(in Double2 value, in Double2 min, in Double2 max, out Double2 result)
{
double x = value.X;
x = x > max.X ? max.X : x;
@@ -562,7 +562,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Double2 Clamp(Double2 value, Double2 min, Double2 max)
{
Clamp(ref value, ref min, ref max, out Double2 result);
Clamp(in value, in min, in max, out Double2 result);
return result;
}
@@ -582,7 +582,7 @@ namespace FlaxEngine
/// <param name="v1">The second triangle vertex.</param>
/// <param name="v2">The third triangle vertex.</param>
/// <returns>The triangle area.</returns>
public static double TriangleArea(ref Double2 v0, ref Double2 v1, ref Double2 v2)
public static double TriangleArea(in Double2 v0, in Double2 v1, in Double2 v2)
{
return Math.Abs((v0.X * (v1.Y - v2.Y) + v1.X * (v2.Y - v0.Y) + v2.X * (v0.Y - v1.Y)) / 2);
}
@@ -593,8 +593,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Double2.DistanceSquared(ref Double2, ref Double2, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Double2 value1, ref Double2 value2, out double result)
/// <remarks><see cref="Double2.DistanceSquared(in Double2, in Double2, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Double2 value1, in Double2 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -621,8 +621,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns>The distance between the two vectors.</returns>
/// <remarks><see cref="Double2.DistanceSquared(ref Double2, ref Double2, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static double Distance(ref Double2 value1, ref Double2 value2)
/// <remarks><see cref="Double2.DistanceSquared(in Double2, in Double2, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static double Distance(in Double2 value1, in Double2 value2)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -635,7 +635,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors.</param>
public static void DistanceSquared(ref Double2 value1, ref Double2 value2, out double result)
public static void DistanceSquared(in Double2 value1, in Double2 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -648,7 +648,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <returns>The squared distance between the two vectors.</returns>
public static double DistanceSquared(ref Double2 value1, ref Double2 value2)
public static double DistanceSquared(in Double2 value1, in Double2 value2)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -677,7 +677,7 @@ namespace FlaxEngine
/// <returns><c>true</c> if left and right are near, <c>false</c> otherwise</returns>
public static bool NearEqual(Double2 left, Double2 right, double epsilon = Mathd.Epsilon)
{
return NearEqual(ref left, ref right, epsilon);
return NearEqual(in left, in right, epsilon);
}
/// <summary>
@@ -687,7 +687,7 @@ namespace FlaxEngine
/// <param name="right">The right vector.</param>
/// <param name="epsilon">The epsilon.</param>
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(ref Double2 left, ref Double2 right, double epsilon = Mathd.Epsilon)
public static bool NearEqual(in Double2 left, in Double2 right, double epsilon = Mathd.Epsilon)
{
return Mathd.WithinEpsilon(left.X, right.X, epsilon) && Mathd.WithinEpsilon(left.Y, right.Y, epsilon);
}
@@ -698,7 +698,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Double2 left, ref Double2 right, out double result)
public static void Dot(in Double2 left, in Double2 right, out double result)
{
result = left.X * right.X + left.Y * right.Y;
}
@@ -709,7 +709,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <returns>The dot product of the two vectors.</returns>
public static double Dot(ref Double2 left, ref Double2 right)
public static double Dot(in Double2 left, in Double2 right)
{
return left.X * right.X + left.Y * right.Y;
}
@@ -731,7 +731,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the cross product of the two vectors.</param>
public static void Cross(ref Double2 left, ref Double2 right, out double result)
public static void Cross(in Double2 left, in Double2 right, out double result)
{
result = left.X * right.Y - left.Y * right.X;
}
@@ -742,7 +742,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <returns>The cross product of the two vectors.</returns>
public static double Cross(ref Double2 left, ref Double2 right)
public static double Cross(in Double2 left, in Double2 right)
{
return left.X * right.Y - left.Y * right.X;
}
@@ -763,7 +763,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to normalize.</param>
/// <param name="result">When the method completes, contains the normalized vector.</param>
public static void Normalize(ref Double2 value, out Double2 result)
public static void Normalize(in Double2 value, out Double2 result)
{
result = value;
result.Normalize();
@@ -865,7 +865,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Double2 start, ref Double2 end, double amount, out Double2 result)
public static void Lerp(in Double2 start, in Double2 end, double amount, out Double2 result)
{
result.X = Mathd.Lerp(start.X, end.X, amount);
result.Y = Mathd.Lerp(start.Y, end.Y, amount);
@@ -881,7 +881,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Double2 Lerp(Double2 start, Double2 end, double amount)
{
Lerp(ref start, ref end, amount, out Double2 result);
Lerp(in start, in end, amount, out Double2 result);
return result;
}
@@ -893,7 +893,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Double2 start, ref Double2 end, ref Double2 amount, out Double2 result)
public static void Lerp(in Double2 start, in Double2 end, in Double2 amount, out Double2 result)
{
result.X = Mathd.Lerp(start.X, end.X, amount.X);
result.Y = Mathd.Lerp(start.Y, end.Y, amount.Y);
@@ -909,7 +909,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Double2 Lerp(Double2 start, Double2 end, Double2 amount)
{
Lerp(ref start, ref end, ref amount, out Double2 result);
Lerp(in start, in end, in amount, out Double2 result);
return result;
}
@@ -920,10 +920,10 @@ namespace FlaxEngine
/// <param name="end">End vector.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
public static void SmoothStep(ref Double2 start, ref Double2 end, double amount, out Double2 result)
public static void SmoothStep(in Double2 start, in Double2 end, double amount, out Double2 result)
{
amount = Mathd.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(in start, in end, amount, out result);
}
/// <summary>
@@ -935,7 +935,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns>
public static Double2 SmoothStep(Double2 start, Double2 end, double amount)
{
SmoothStep(ref start, ref end, amount, out Double2 result);
SmoothStep(in start, in end, amount, out Double2 result);
return result;
}
@@ -948,7 +948,7 @@ namespace FlaxEngine
/// <param name="tangent2">Second source tangent vector.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
public static void Hermite(ref Double2 value1, ref Double2 tangent1, ref Double2 value2, ref Double2 tangent2, double amount, out Double2 result)
public static void Hermite(in Double2 value1, in Double2 tangent1, in Double2 value2, in Double2 tangent2, double amount, out Double2 result)
{
double squared = amount * amount;
double cubed = amount * squared;
@@ -971,7 +971,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns>
public static Double2 Hermite(Double2 value1, Double2 tangent1, Double2 value2, Double2 tangent2, double amount)
{
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out Double2 result);
Hermite(in value1, in tangent1, in value2, in tangent2, amount, out Double2 result);
return result;
}
@@ -990,7 +990,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="inDirection">The in direction.</param>
/// <param name="result">When the method completes, contains the result of the calculation.</param>
public static void Perpendicular(ref Double2 inDirection, out Double2 result)
public static void Perpendicular(in Double2 inDirection, out Double2 result)
{
result = new Double2(-inDirection.Y, inDirection.X);
}
@@ -1004,7 +1004,7 @@ namespace FlaxEngine
/// <param name="value4">The fourth position in the interpolation.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
public static void CatmullRom(ref Double2 value1, ref Double2 value2, ref Double2 value3, ref Double2 value4, double amount, out Double2 result)
public static void CatmullRom(in Double2 value1, in Double2 value2, in Double2 value3, in Double2 value4, double amount, out Double2 result)
{
double squared = amount * amount;
double cubed = amount * squared;
@@ -1027,7 +1027,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Double2 CatmullRom(Double2 value1, Double2 value2, Double2 value3, Double2 value4, double amount)
{
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out Double2 result);
CatmullRom(in value1, in value2, in value3, in value4, amount, out Double2 result);
return result;
}
@@ -1037,7 +1037,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Double2 left, ref Double2 right, out Double2 result)
public static void Max(in Double2 left, in Double2 right, out Double2 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -1051,7 +1051,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Double2 Max(Double2 left, Double2 right)
{
Max(ref left, ref right, out Double2 result);
Max(in left, in right, out Double2 result);
return result;
}
@@ -1061,7 +1061,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Double2 left, ref Double2 right, out Double2 result)
public static void Min(in Double2 left, in Double2 right, out Double2 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -1075,7 +1075,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Double2 Min(Double2 left, Double2 right)
{
Min(ref left, ref right, out Double2 result);
Min(in left, in right, out Double2 result);
return result;
}
@@ -1096,7 +1096,7 @@ namespace FlaxEngine
/// <param name="normal">Normal of the surface.</param>
/// <param name="result">When the method completes, contains the reflected vector.</param>
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static void Reflect(ref Double2 vector, ref Double2 normal, out Double2 result)
public static void Reflect(in Double2 vector, in Double2 normal, out Double2 result)
{
double dot = vector.X * normal.X + vector.Y * normal.Y;
result.X = vector.X - 2.0 * dot * normal.X;
@@ -1112,7 +1112,7 @@ namespace FlaxEngine
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static Double2 Reflect(Double2 vector, Double2 normal)
{
Reflect(ref vector, ref normal, out Double2 result);
Reflect(in vector, in normal, out Double2 result);
return result;
}
@@ -1122,7 +1122,7 @@ namespace FlaxEngine
/// <param name="vector">The vector to rotate.</param>
/// <param name="rotation">The <see cref="Quaternion" /> rotation to apply.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double4" />.</param>
public static void Transform(ref Double2 vector, ref Quaternion rotation, out Double2 result)
public static void Transform(in Double2 vector, in Quaternion rotation, out Double2 result)
{
double x = rotation.X + rotation.X;
double y = rotation.Y + rotation.Y;
@@ -1143,7 +1143,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double4" />.</returns>
public static Double2 Transform(Double2 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out Double2 result);
Transform(in vector, in rotation, out Double2 result);
return result;
}
@@ -1153,7 +1153,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double4" />.</param>
public static void Transform(ref Double2 vector, ref Matrix transform, out Double4 result)
public static void Transform(in Double2 vector, in Matrix transform, out Double4 result)
{
result = new Double4(vector.X * transform.M11 + vector.Y * transform.M21 + transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + transform.M42,
@@ -1169,7 +1169,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double4" />.</returns>
public static Double4 Transform(Double2 vector, Matrix transform)
{
Transform(ref vector, ref transform, out Double4 result);
Transform(in vector, in transform, out Double4 result);
return result;
}
@@ -1186,7 +1186,7 @@ namespace FlaxEngine
/// therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
/// with coordinates as the w component can safely be ignored.
/// </remarks>
public static void TransformCoordinate(ref Double2 coordinate, ref Matrix transform, out Double2 result)
public static void TransformCoordinate(in Double2 coordinate, in Matrix transform, out Double2 result)
{
var vector = new Double4
{
@@ -1213,7 +1213,7 @@ namespace FlaxEngine
/// </remarks>
public static Double2 TransformCoordinate(Double2 coordinate, Matrix transform)
{
TransformCoordinate(ref coordinate, ref transform, out Double2 result);
TransformCoordinate(in coordinate, in transform, out Double2 result);
return result;
}
@@ -1230,7 +1230,7 @@ namespace FlaxEngine
/// apply. This is often preferred for normal vectors as normals purely represent direction
/// rather than location because normal vectors should not be translated.
/// </remarks>
public static void TransformNormal(ref Double2 normal, ref Matrix transform, out Double2 result)
public static void TransformNormal(in Double2 normal, in Matrix transform, out Double2 result)
{
result = new Double2(normal.X * transform.M11 + normal.Y * transform.M21,
normal.X * transform.M12 + normal.Y * transform.M22);
@@ -1251,7 +1251,7 @@ namespace FlaxEngine
/// </remarks>
public static Double2 TransformNormal(Double2 normal, Matrix transform)
{
TransformNormal(ref normal, ref transform, out Double2 result);
TransformNormal(in normal, in transform, out Double2 result);
return result;
}
@@ -1282,7 +1282,7 @@ namespace FlaxEngine
}
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(ref Double2,ref Double2,out Double2)" />.
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(in Double2,in Double2,out Double2)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -1464,7 +1464,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Double2 left, Double2 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -1476,7 +1476,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Double2 left, Double2 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1580,7 +1580,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Double2" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Double2" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Double2 other)
public bool Equals(in Double2 other)
{
return X == other.X && Y == other.Y;
}
@@ -1588,9 +1588,9 @@ namespace FlaxEngine
/// <summary>
/// Determines whether the specified <see cref="Double2"/> are equal.
/// </summary>
public static bool Equals(ref Double2 a, ref Double2 b)
public static bool Equals(in Double2 a, in Double2 b)
{
return a.Equals(ref b);
return a.Equals(in b);
}
/// <summary>
@@ -1601,7 +1601,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Double2 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1611,7 +1611,7 @@ namespace FlaxEngine
/// <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)
{
return value is Double2 other && Equals(ref other);
return value is Double2 other && Equals(in other);
}
}
}

View File

@@ -380,7 +380,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Double3 left, ref Double3 right, out Double3 result)
public static void Add(in Double3 left, in Double3 right, out Double3 result)
{
result = new Double3(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
}
@@ -402,7 +402,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Double3 left, ref double right, out Double3 result)
public static void Add(in Double3 left, double right, out Double3 result)
{
result = new Double3(left.X + right, left.Y + right, left.Z + right);
}
@@ -424,7 +424,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Double3 left, ref Double3 right, out Double3 result)
public static void Subtract(in Double3 left, in Double3 right, out Double3 result)
{
result = new Double3(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
}
@@ -446,7 +446,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Double3 left, ref double right, out Double3 result)
public static void Subtract(in Double3 left, double right, out Double3 result)
{
result = new Double3(left.X - right, left.Y - right, left.Z - right);
}
@@ -468,7 +468,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector.</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref double left, ref Double3 right, out Double3 result)
public static void Subtract(double left, in Double3 right, out Double3 result)
{
result = new Double3(left - right.X, left - right.Y, left - right.Z);
}
@@ -490,7 +490,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Double3 value, double scale, out Double3 result)
public static void Multiply(in Double3 value, double scale, out Double3 result)
{
result = new Double3(value.X * scale, value.Y * scale, value.Z * scale);
}
@@ -512,7 +512,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Double3 left, ref Double3 right, out Double3 result)
public static void Multiply(in Double3 left, in Double3 right, out Double3 result)
{
result = new Double3(left.X * right.X, left.Y * right.Y, left.Z * right.Z);
}
@@ -534,7 +534,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector (per component).</param>
/// <param name="result">When the method completes, contains the divided vector.</param>
public static void Divide(ref Double3 value, ref Double3 scale, out Double3 result)
public static void Divide(in Double3 value, in Double3 scale, out Double3 result)
{
result = new Double3(value.X / scale.X, value.Y / scale.Y, value.Z / scale.Z);
}
@@ -556,7 +556,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Double3 value, double scale, out Double3 result)
public static void Divide(in Double3 value, double scale, out Double3 result)
{
result = new Double3(value.X / scale, value.Y / scale, value.Z / scale);
}
@@ -578,7 +578,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(double scale, ref Double3 value, out Double3 result)
public static void Divide(double scale, in Double3 value, out Double3 result)
{
result = new Double3(scale / value.X, scale / value.Y, scale / value.Z);
}
@@ -599,7 +599,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Double3 value, out Double3 result)
public static void Negate(in Double3 value, out Double3 result)
{
result = new Double3(-value.X, -value.Y, -value.Z);
}
@@ -623,7 +623,7 @@ namespace FlaxEngine
/// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2" />).</param>
/// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3" />).</param>
/// <param name="result">When the method completes, contains the 3D Cartesian coordinates of the specified point.</param>
public static void Barycentric(ref Double3 value1, ref Double3 value2, ref Double3 value3, double amount1, double amount2, out Double3 result)
public static void Barycentric(in Double3 value1, in Double3 value2, in Double3 value3, double amount1, double amount2, out Double3 result)
{
result = new Double3(value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X),
value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y),
@@ -641,7 +641,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Double3" /> containing the 3D Cartesian coordinates of the specified point.</returns>
public static Double3 Barycentric(Double3 value1, Double3 value2, Double3 value3, double amount1, double amount2)
{
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out var result);
Barycentric(in value1, in value2, in value3, amount1, amount2, out var result);
return result;
}
@@ -652,7 +652,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Double3 value, ref Double3 min, ref Double3 max, out Double3 result)
public static void Clamp(in Double3 value, in Double3 min, in Double3 max, out Double3 result)
{
double x = value.X;
x = x > max.X ? max.X : x;
@@ -675,7 +675,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Double3 Clamp(Double3 value, Double3 min, Double3 max)
{
Clamp(ref value, ref min, ref max, out var result);
Clamp(in value, in min, in max, out var result);
return result;
}
@@ -685,7 +685,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains he cross product of the two vectors.</param>
public static void Cross(ref Double3 left, ref Double3 right, out Double3 result)
public static void Cross(in Double3 left, in Double3 right, out Double3 result)
{
result = new Double3(left.Y * right.Z - left.Z * right.Y,
left.Z * right.X - left.X * right.Z,
@@ -700,7 +700,7 @@ namespace FlaxEngine
/// <returns>The cross product of the two vectors.</returns>
public static Double3 Cross(Double3 left, Double3 right)
{
Cross(ref left, ref right, out var result);
Cross(in left, in right, out var result);
return result;
}
@@ -710,8 +710,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Double3.DistanceSquared(ref Double3, ref Double3, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Double3 value1, ref Double3 value2, out double result)
/// <remarks><see cref="Double3.DistanceSquared(in Double3, in Double3, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Double3 value1, in Double3 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -725,8 +725,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns>The distance between the two vectors.</returns>
/// <remarks><see cref="Double3.DistanceSquared(ref Double3, ref Double3, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static double Distance(ref Double3 value1, ref Double3 value2)
/// <remarks><see cref="Double3.DistanceSquared(in Double3, in Double3, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static double Distance(in Double3 value1, in Double3 value2)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -755,7 +755,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors.</param>
public static void DistanceSquared(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceSquared(in Double3 value1, in Double3 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -769,7 +769,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns>The squared distance between the two vectors.</returns>
public static double DistanceSquared(ref Double3 value1, ref Double3 value2)
public static double DistanceSquared(in Double3 value1, in Double3 value2)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -797,7 +797,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the XY plane.</param>
public static void DistanceXY(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceXY(in Double3 value1, in Double3 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -810,7 +810,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the XY plane.</param>
public static void DistanceXYSquared(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceXYSquared(in Double3 value1, in Double3 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -823,7 +823,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the XY plane.</param>
public static void DistanceXZ(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceXZ(in Double3 value1, in Double3 value2, out double result)
{
double x = value1.X - value2.X;
double z = value1.Z - value2.Z;
@@ -836,7 +836,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the XY plane.</param>
public static void DistanceXZSquared(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceXZSquared(in Double3 value1, in Double3 value2, out double result)
{
double x = value1.X - value2.X;
double z = value1.Z - value2.Z;
@@ -849,7 +849,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the YZ plane.</param>
public static void DistanceYZ(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceYZ(in Double3 value1, in Double3 value2, out double result)
{
double y = value1.Y - value2.Y;
double z = value1.Z - value2.Z;
@@ -862,7 +862,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the YZ plane.</param>
public static void DistanceYZSquared(ref Double3 value1, ref Double3 value2, out double result)
public static void DistanceYZSquared(in Double3 value1, in Double3 value2, out double result)
{
double y = value1.Y - value2.Y;
double z = value1.Z - value2.Z;
@@ -878,7 +878,7 @@ namespace FlaxEngine
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(Double3 left, Double3 right, double epsilon = Mathd.Epsilon)
{
return NearEqual(ref left, ref right, epsilon);
return NearEqual(in left, in right, epsilon);
}
/// <summary>
@@ -888,7 +888,7 @@ namespace FlaxEngine
/// <param name="right">The right vector.</param>
/// <param name="epsilon">The epsilon.</param>
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(ref Double3 left, ref Double3 right, double epsilon = Mathd.Epsilon)
public static bool NearEqual(in Double3 left, in Double3 right, double epsilon = Mathd.Epsilon)
{
return Mathd.WithinEpsilon(left.X, right.X, epsilon) && Mathd.WithinEpsilon(left.Y, right.Y, epsilon) && Mathd.WithinEpsilon(left.Z, right.Z, epsilon);
}
@@ -899,7 +899,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Double3 left, ref Double3 right, out double result)
public static void Dot(in Double3 left, in Double3 right, out double result)
{
result = left.X * right.X + left.Y * right.Y + left.Z * right.Z;
}
@@ -910,7 +910,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <returns>The dot product of the two vectors.</returns>
public static double Dot(ref Double3 left, ref Double3 right)
public static double Dot(in Double3 left, in Double3 right)
{
return left.X * right.X + left.Y * right.Y + left.Z * right.Z;
}
@@ -931,7 +931,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to normalize.</param>
/// <param name="result">When the method completes, contains the normalized vector.</param>
public static void Normalize(ref Double3 value, out Double3 result)
public static void Normalize(in Double3 value, out Double3 result)
{
result = value;
result.Normalize();
@@ -1007,7 +1007,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Double3 start, ref Double3 end, double amount, out Double3 result)
public static void Lerp(in Double3 start, in Double3 end, double amount, out Double3 result)
{
result.X = Mathd.Lerp(start.X, end.X, amount);
result.Y = Mathd.Lerp(start.Y, end.Y, amount);
@@ -1024,7 +1024,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Double3 Lerp(Double3 start, Double3 end, double amount)
{
Lerp(ref start, ref end, amount, out var result);
Lerp(in start, in end, amount, out var result);
return result;
}
@@ -1035,10 +1035,10 @@ namespace FlaxEngine
/// <param name="end">End vector.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
public static void SmoothStep(ref Double3 start, ref Double3 end, double amount, out Double3 result)
public static void SmoothStep(in Double3 start, in Double3 end, double amount, out Double3 result)
{
amount = Mathd.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(in start, in end, amount, out result);
}
/// <summary>
@@ -1050,7 +1050,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns>
public static Double3 SmoothStep(Double3 start, Double3 end, double amount)
{
SmoothStep(ref start, ref end, amount, out var result);
SmoothStep(in start, in end, amount, out var result);
return result;
}
@@ -1080,7 +1080,7 @@ namespace FlaxEngine
/// <param name="tangent2">Second source tangent vector.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
public static void Hermite(ref Double3 value1, ref Double3 tangent1, ref Double3 value2, ref Double3 tangent2, double amount, out Double3 result)
public static void Hermite(in Double3 value1, in Double3 tangent1, in Double3 value2, in Double3 tangent2, double amount, out Double3 result)
{
double squared = amount * amount;
double cubed = amount * squared;
@@ -1104,7 +1104,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns>
public static Double3 Hermite(Double3 value1, Double3 tangent1, Double3 value2, Double3 tangent2, double amount)
{
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out var result);
Hermite(in value1, in tangent1, in value2, in tangent2, amount, out var result);
return result;
}
@@ -1117,7 +1117,7 @@ namespace FlaxEngine
/// <param name="value4">The fourth position in the interpolation.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
public static void CatmullRom(ref Double3 value1, ref Double3 value2, ref Double3 value3, ref Double3 value4, double amount, out Double3 result)
public static void CatmullRom(in Double3 value1, in Double3 value2, in Double3 value3, in Double3 value4, double amount, out Double3 result)
{
double squared = amount * amount;
double cubed = amount * squared;
@@ -1143,7 +1143,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Double3 CatmullRom(Double3 value1, Double3 value2, Double3 value3, Double3 value4, double amount)
{
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out var result);
CatmullRom(in value1, in value2, in value3, in value4, amount, out var result);
return result;
}
@@ -1153,7 +1153,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Double3 left, ref Double3 right, out Double3 result)
public static void Max(in Double3 left, in Double3 right, out Double3 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -1168,7 +1168,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Double3 Max(Double3 left, Double3 right)
{
Max(ref left, ref right, out var result);
Max(in left, in right, out var result);
return result;
}
@@ -1178,7 +1178,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Double3 left, ref Double3 right, out Double3 result)
public static void Min(in Double3 left, in Double3 right, out Double3 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -1193,7 +1193,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Double3 Min(Double3 left, Double3 right)
{
Min(ref left, ref right, out var result);
Min(in left, in right, out var result);
return result;
}
@@ -1258,9 +1258,9 @@ namespace FlaxEngine
/// <param name="maxZ">The maximum depth of the viewport.</param>
/// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
/// <param name="result">When the method completes, contains the vector in screen space.</param>
public static void Project(ref Double3 vector, double x, double y, double width, double height, double minZ, double maxZ, ref Matrix worldViewProjection, out Double3 result)
public static void Project(in Double3 vector, double x, double y, double width, double height, double minZ, double maxZ, ref Matrix worldViewProjection, out Double3 result)
{
TransformCoordinate(ref vector, ref worldViewProjection, out var v);
TransformCoordinate(in vector, in worldViewProjection, out var v);
result = new Double3((1.0 + v.X) * 0.5f * width + x, (1.0 - v.Y) * 0.5f * height + y, v.Z * (maxZ - minZ) + minZ);
}
@@ -1278,7 +1278,7 @@ namespace FlaxEngine
/// <returns>The vector in screen space.</returns>
public static Double3 Project(Double3 vector, double x, double y, double width, double height, double minZ, double maxZ, Matrix worldViewProjection)
{
Project(ref vector, x, y, width, height, minZ, maxZ, ref worldViewProjection, out var result);
Project(in vector, x, y, width, height, minZ, maxZ, ref worldViewProjection, out var result);
return result;
}
@@ -1294,16 +1294,16 @@ namespace FlaxEngine
/// <param name="maxZ">The maximum depth of the viewport.</param>
/// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
/// <param name="result">When the method completes, contains the vector in object space.</param>
public static void Unproject(ref Double3 vector, double x, double y, double width, double height, double minZ, double maxZ, ref Matrix worldViewProjection, out Double3 result)
public static void Unproject(in Double3 vector, double x, double y, double width, double height, double minZ, double maxZ, ref Matrix worldViewProjection, out Double3 result)
{
Matrix.Invert(ref worldViewProjection, out var matrix);
Matrix.Invert(worldViewProjection, out var matrix);
var v = new Double3
{
X = (vector.X - x) / width * 2.0 - 1.0,
Y = -((vector.Y - y) / height * 2.0 - 1.0),
Z = (vector.Z - minZ) / (maxZ - minZ)
};
TransformCoordinate(ref v, ref matrix, out result);
TransformCoordinate(in v, in matrix, out result);
}
/// <summary>
@@ -1320,7 +1320,7 @@ namespace FlaxEngine
/// <returns>The vector in object space.</returns>
public static Double3 Unproject(Double3 vector, double x, double y, double width, double height, double minZ, double maxZ, Matrix worldViewProjection)
{
Unproject(ref vector, x, y, width, height, minZ, maxZ, ref worldViewProjection, out var result);
Unproject(in vector, x, y, width, height, minZ, maxZ, ref worldViewProjection, out var result);
return result;
}
@@ -1331,7 +1331,7 @@ namespace FlaxEngine
/// <param name="normal">Normal of the surface.</param>
/// <param name="result">When the method completes, contains the reflected vector.</param>
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static void Reflect(ref Double3 vector, ref Double3 normal, out Double3 result)
public static void Reflect(in Double3 vector, in Double3 normal, out Double3 result)
{
double dot = vector.X * normal.X + vector.Y * normal.Y + vector.Z * normal.Z;
result.X = vector.X - 2.0 * dot * normal.X;
@@ -1348,7 +1348,7 @@ namespace FlaxEngine
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static Double3 Reflect(Double3 vector, Double3 normal)
{
Reflect(ref vector, ref normal, out var result);
Reflect(in vector, in normal, out var result);
return result;
}
@@ -1358,7 +1358,7 @@ namespace FlaxEngine
/// <param name="vector">The vector to rotate.</param>
/// <param name="rotation">The <see cref="Quaternion" /> rotation to apply.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double3" />.</param>
public static void Transform(ref Double3 vector, ref Quaternion rotation, out Double3 result)
public static void Transform(in Double3 vector, in Quaternion rotation, out Double3 result)
{
double x = rotation.X + rotation.X;
double y = rotation.Y + rotation.Y;
@@ -1385,7 +1385,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double3" />.</returns>
public static Double3 Transform(Double3 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out var result);
Transform(in vector, in rotation, out var result);
return result;
}
@@ -1395,7 +1395,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix3x3"/>.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double3"/>.</param>
public static void Transform(ref Double3 vector, ref Matrix3x3 transform, out Double3 result)
public static void Transform(in Double3 vector, in Matrix3x3 transform, out Double3 result)
{
result = new Double3((vector.X * transform.M11) + (vector.Y * transform.M21) + (vector.Z * transform.M31),
(vector.X * transform.M12) + (vector.Y * transform.M22) + (vector.Z * transform.M32),
@@ -1410,7 +1410,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double3"/>.</returns>
public static Double3 Transform(Double3 vector, Matrix3x3 transform)
{
Transform(ref vector, ref transform, out var result);
Transform(in vector, in transform, out var result);
return result;
}
@@ -1420,7 +1420,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double3" />.</param>
public static void Transform(ref Double3 vector, ref Matrix transform, out Double3 result)
public static void Transform(in Double3 vector, in Matrix transform, out Double3 result)
{
result = new Double3(vector.X * transform.M11 + vector.Y * transform.M21 + vector.Z * transform.M31 + transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + vector.Z * transform.M32 + transform.M42,
@@ -1433,7 +1433,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double4" />.</param>
public static void Transform(ref Double3 vector, ref Matrix transform, out Double4 result)
public static void Transform(in Double3 vector, in Matrix transform, out Double4 result)
{
result = new Double4(vector.X * transform.M11 + vector.Y * transform.M21 + vector.Z * transform.M31 + transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + vector.Z * transform.M32 + transform.M42,
@@ -1449,7 +1449,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double4" />.</returns>
public static Double3 Transform(Double3 vector, Matrix transform)
{
Transform(ref vector, ref transform, out Double3 result);
Transform(in vector, in transform, out Double3 result);
return result;
}
@@ -1466,7 +1466,7 @@ namespace FlaxEngine
/// therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
/// with coordinates as the w component can safely be ignored.
/// </remarks>
public static void TransformCoordinate(ref Double3 coordinate, ref Matrix transform, out Double3 result)
public static void TransformCoordinate(in Double3 coordinate, in Matrix transform, out Double3 result)
{
var vector = new Double4
{
@@ -1493,7 +1493,7 @@ namespace FlaxEngine
/// </remarks>
public static Double3 TransformCoordinate(Double3 coordinate, Matrix transform)
{
TransformCoordinate(ref coordinate, ref transform, out var result);
TransformCoordinate(in coordinate, in transform, out var result);
return result;
}
@@ -1510,7 +1510,7 @@ namespace FlaxEngine
/// apply. This is often preferred for normal vectors as normals purely represent direction
/// rather than location because normal vectors should not be translated.
/// </remarks>
public static void TransformNormal(ref Double3 normal, ref Matrix transform, out Double3 result)
public static void TransformNormal(in Double3 normal, in Matrix transform, out Double3 result)
{
result = new Double3(normal.X * transform.M11 + normal.Y * transform.M21 + normal.Z * transform.M31,
normal.X * transform.M12 + normal.Y * transform.M22 + normal.Z * transform.M32,
@@ -1532,7 +1532,7 @@ namespace FlaxEngine
/// </remarks>
public static Double3 TransformNormal(Double3 normal, Matrix transform)
{
TransformNormal(ref normal, ref transform, out var result);
TransformNormal(in normal, in transform, out var result);
return result;
}
@@ -1565,7 +1565,7 @@ namespace FlaxEngine
}
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(ref Double3,ref Double3,out Double3)" />.
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(in Double3,in Double3,out Double3)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -1614,7 +1614,7 @@ namespace FlaxEngine
/// <returns>The scaled vector.</returns>
public static Double3 operator *(Double3 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out var result);
Transform(in vector, in rotation, out var result);
return result;
}
@@ -1759,7 +1759,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Double3 left, Double3 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -1771,7 +1771,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Double3 left, Double3 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1878,7 +1878,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Double3" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Double3" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Double3 other)
public bool Equals(in Double3 other)
{
return X == other.X && Y == other.Y && Z == other.Z;
}
@@ -1891,7 +1891,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Double3 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1901,7 +1901,7 @@ namespace FlaxEngine
/// <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)
{
return value is Double3 other && Equals(ref other);
return value is Double3 other && Equals(in other);
}
}
}

View File

@@ -348,7 +348,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Double4 left, ref Double4 right, out Double4 result)
public static void Add(in Double4 left, in Double4 right, out Double4 result)
{
result = new Double4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
}
@@ -370,7 +370,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Double4 left, ref double right, out Double4 result)
public static void Add(in Double4 left, double right, out Double4 result)
{
result = new Double4(left.X + right, left.Y + right, left.Z + right, left.W + right);
}
@@ -392,7 +392,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Double4 left, ref Double4 right, out Double4 result)
public static void Subtract(in Double4 left, in Double4 right, out Double4 result)
{
result = new Double4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
}
@@ -414,7 +414,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Double4 left, ref double right, out Double4 result)
public static void Subtract(in Double4 left, double right, out Double4 result)
{
result = new Double4(left.X - right, left.Y - right, left.Z - right, left.W - right);
}
@@ -436,7 +436,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector.</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref double left, ref Double4 right, out Double4 result)
public static void Subtract(double left, in Double4 right, out Double4 result)
{
result = new Double4(left - right.X, left - right.Y, left - right.Z, left - right.W);
}
@@ -458,7 +458,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Double4 value, double scale, out Double4 result)
public static void Multiply(in Double4 value, double scale, out Double4 result)
{
result = new Double4(value.X * scale, value.Y * scale, value.Z * scale, value.W * scale);
}
@@ -480,7 +480,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Double4 left, ref Double4 right, out Double4 result)
public static void Multiply(in Double4 left, in Double4 right, out Double4 result)
{
result = new Double4(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W);
}
@@ -502,7 +502,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Double4 value, double scale, out Double4 result)
public static void Divide(in Double4 value, double scale, out Double4 result)
{
result = new Double4(value.X / scale, value.Y / scale, value.Z / scale, value.W / scale);
}
@@ -524,7 +524,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(double scale, ref Double4 value, out Double4 result)
public static void Divide(double scale, in Double4 value, out Double4 result)
{
result = new Double4(scale / value.X, scale / value.Y, scale / value.Z, scale / value.W);
}
@@ -545,7 +545,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Double4 value, out Double4 result)
public static void Negate(in Double4 value, out Double4 result)
{
result = new Double4(-value.X, -value.Y, -value.Z, -value.W);
}
@@ -569,7 +569,7 @@ namespace FlaxEngine
/// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2" />).</param>
/// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3" />).</param>
/// <param name="result">When the method completes, contains the 4D Cartesian coordinates of the specified point.</param>
public static void Barycentric(ref Double4 value1, ref Double4 value2, ref Double4 value3, double amount1, double amount2, out Double4 result)
public static void Barycentric(in Double4 value1, in Double4 value2, in Double4 value3, double amount1, double amount2, out Double4 result)
{
result = new Double4(value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X),
value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y),
@@ -588,7 +588,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Double4" /> containing the 4D Cartesian coordinates of the specified point.</returns>
public static Double4 Barycentric(Double4 value1, Double4 value2, Double4 value3, double amount1, double amount2)
{
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out Double4 result);
Barycentric(in value1, in value2, in value3, amount1, amount2, out Double4 result);
return result;
}
@@ -599,7 +599,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Double4 value, ref Double4 min, ref Double4 max, out Double4 result)
public static void Clamp(in Double4 value, in Double4 min, in Double4 max, out Double4 result)
{
double x = value.X;
x = x > max.X ? max.X : x;
@@ -625,7 +625,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Double4 Clamp(Double4 value, Double4 min, Double4 max)
{
Clamp(ref value, ref min, ref max, out Double4 result);
Clamp(in value, in min, in max, out Double4 result);
return result;
}
@@ -635,8 +635,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Double4.DistanceSquared(ref Double4, ref Double4, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Double4 value1, ref Double4 value2, out double result)
/// <remarks><see cref="Double4.DistanceSquared(in Double4, in Double4, out double)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Double4 value1, in Double4 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -667,7 +667,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors.</param>
public static void DistanceSquared(ref Double4 value1, ref Double4 value2, out double result)
public static void DistanceSquared(in Double4 value1, in Double4 value2, out double result)
{
double x = value1.X - value2.X;
double y = value1.Y - value2.Y;
@@ -700,7 +700,7 @@ namespace FlaxEngine
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(Double4 left, Double4 right, double epsilon = Mathd.Epsilon)
{
return NearEqual(ref left, ref right, epsilon);
return NearEqual(in left, in right, epsilon);
}
/// <summary>
@@ -710,7 +710,7 @@ namespace FlaxEngine
/// <param name="right">The right vector.</param>
/// <param name="epsilon">The epsilon.</param>
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(ref Double4 left, ref Double4 right, double epsilon = Mathd.Epsilon)
public static bool NearEqual(in Double4 left, in Double4 right, double epsilon = Mathd.Epsilon)
{
return Mathd.WithinEpsilon(left.X, right.X, epsilon) && Mathd.WithinEpsilon(left.Y, right.Y, epsilon) && Mathd.WithinEpsilon(left.Z, right.Z, epsilon) && Mathd.WithinEpsilon(left.W, right.W, epsilon);
}
@@ -721,7 +721,7 @@ namespace FlaxEngine
/// <param name="left">First source vector</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Double4 left, ref Double4 right, out double result)
public static void Dot(in Double4 left, in Double4 right, out double result)
{
result = left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
}
@@ -742,7 +742,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to normalize.</param>
/// <param name="result">When the method completes, contains the normalized vector.</param>
public static void Normalize(ref Double4 value, out Double4 result)
public static void Normalize(in Double4 value, out Double4 result)
{
result = value;
result.Normalize();
@@ -818,7 +818,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Double4 start, ref Double4 end, double amount, out Double4 result)
public static void Lerp(in Double4 start, in Double4 end, double amount, out Double4 result)
{
result.X = Mathd.Lerp(start.X, end.X, amount);
result.Y = Mathd.Lerp(start.Y, end.Y, amount);
@@ -836,7 +836,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Double4 Lerp(Double4 start, Double4 end, double amount)
{
Lerp(ref start, ref end, amount, out Double4 result);
Lerp(in start, in end, amount, out Double4 result);
return result;
}
@@ -847,10 +847,10 @@ namespace FlaxEngine
/// <param name="end">End vector.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
public static void SmoothStep(ref Double4 start, ref Double4 end, double amount, out Double4 result)
public static void SmoothStep(in Double4 start, in Double4 end, double amount, out Double4 result)
{
amount = Mathd.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(in start, in end, amount, out result);
}
/// <summary>
@@ -862,7 +862,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns>
public static Double4 SmoothStep(Double4 start, Double4 end, double amount)
{
SmoothStep(ref start, ref end, amount, out Double4 result);
SmoothStep(in start, in end, amount, out Double4 result);
return result;
}
@@ -875,7 +875,7 @@ namespace FlaxEngine
/// <param name="tangent2">Second source tangent vector.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
public static void Hermite(ref Double4 value1, ref Double4 tangent1, ref Double4 value2, ref Double4 tangent2, double amount, out Double4 result)
public static void Hermite(in Double4 value1, in Double4 tangent1, in Double4 value2, in Double4 tangent2, double amount, out Double4 result)
{
double squared = amount * amount;
double cubed = amount * squared;
@@ -900,7 +900,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns>
public static Double4 Hermite(Double4 value1, Double4 tangent1, Double4 value2, Double4 tangent2, double amount)
{
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out Double4 result);
Hermite(in value1, in tangent1, in value2, in tangent2, amount, out Double4 result);
return result;
}
@@ -913,7 +913,7 @@ namespace FlaxEngine
/// <param name="value4">The fourth position in the interpolation.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
public static void CatmullRom(ref Double4 value1, ref Double4 value2, ref Double4 value3, ref Double4 value4, double amount, out Double4 result)
public static void CatmullRom(in Double4 value1, in Double4 value2, in Double4 value3, in Double4 value4, double amount, out Double4 result)
{
double squared = amount * amount;
double cubed = amount * squared;
@@ -934,7 +934,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Double4 CatmullRom(Double4 value1, Double4 value2, Double4 value3, Double4 value4, double amount)
{
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out Double4 result);
CatmullRom(in value1, in value2, in value3, in value4, amount, out Double4 result);
return result;
}
@@ -944,7 +944,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Double4 left, ref Double4 right, out Double4 result)
public static void Max(in Double4 left, in Double4 right, out Double4 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -960,7 +960,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Double4 Max(Double4 left, Double4 right)
{
Max(ref left, ref right, out Double4 result);
Max(in left, in right, out Double4 result);
return result;
}
@@ -970,7 +970,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Double4 left, ref Double4 right, out Double4 result)
public static void Min(in Double4 left, in Double4 right, out Double4 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -986,7 +986,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Double4 Min(Double4 left, Double4 right)
{
Min(ref left, ref right, out Double4 result);
Min(in left, in right, out Double4 result);
return result;
}
@@ -1006,7 +1006,7 @@ namespace FlaxEngine
/// <param name="vector">The vector to rotate.</param>
/// <param name="rotation">The <see cref="Quaternion" /> rotation to apply.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double4" />.</param>
public static void Transform(ref Double4 vector, ref Quaternion rotation, out Double4 result)
public static void Transform(in Double4 vector, in Quaternion rotation, out Double4 result)
{
double x = rotation.X + rotation.X;
double y = rotation.Y + rotation.Y;
@@ -1034,7 +1034,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double4" />.</returns>
public static Double4 Transform(Double4 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out Double4 result);
Transform(in vector, in rotation, out Double4 result);
return result;
}
@@ -1044,7 +1044,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Double4" />.</param>
public static void Transform(ref Double4 vector, ref Matrix transform, out Double4 result)
public static void Transform(in Double4 vector, in Matrix transform, out Double4 result)
{
result = new Double4(vector.X * transform.M11 + vector.Y * transform.M21 + vector.Z * transform.M31 + vector.W * transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + vector.Z * transform.M32 + vector.W * transform.M42,
@@ -1060,7 +1060,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Double4" />.</returns>
public static Double4 Transform(Double4 vector, Matrix transform)
{
Transform(ref vector, ref transform, out Double4 result);
Transform(in vector, in transform, out Double4 result);
return result;
}
@@ -1076,7 +1076,7 @@ namespace FlaxEngine
}
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(ref Double4,ref Double4,out Double4)" />.
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(in Double4,in Double4,out Double4)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -1258,7 +1258,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Double4 left, Double4 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -1270,7 +1270,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Double4 left, Double4 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1377,7 +1377,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="other">The <see cref="Double4" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Double4" /> is equal to this instance; otherwise, <c>false</c>.</returns>
public bool Equals(ref Double4 other)
public bool Equals(in Double4 other)
{
return X == other.X && Y == other.Y && Z == other.Z && W == other.W;
}
@@ -1390,7 +1390,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Double4 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1400,7 +1400,7 @@ namespace FlaxEngine
/// <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)
{
return value is Double4 other && Equals(ref other);
return value is Double4 other && Equals(in other);
}
}
}

View File

@@ -309,7 +309,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Float2 left, ref Float2 right, out Float2 result)
public static void Add(in Float2 left, in Float2 right, out Float2 result)
{
result = new Float2(left.X + right.X, left.Y + right.Y);
}
@@ -331,7 +331,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Float2 left, ref float right, out Float2 result)
public static void Add(in Float2 left, float right, out Float2 result)
{
result = new Float2(left.X + right, left.Y + right);
}
@@ -353,7 +353,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Float2 left, ref Float2 right, out Float2 result)
public static void Subtract(in Float2 left, in Float2 right, out Float2 result)
{
result = new Float2(left.X - right.X, left.Y - right.Y);
}
@@ -375,7 +375,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Float2 left, ref float right, out Float2 result)
public static void Subtract(in Float2 left, float right, out Float2 result)
{
result = new Float2(left.X - right, left.Y - right);
}
@@ -397,7 +397,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref float left, ref Float2 right, out Float2 result)
public static void Subtract(float left, in Float2 right, out Float2 result)
{
result = new Float2(left - right.X, left - right.Y);
}
@@ -419,7 +419,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Float2 value, float scale, out Float2 result)
public static void Multiply(in Float2 value, float scale, out Float2 result)
{
result = new Float2(value.X * scale, value.Y * scale);
}
@@ -441,7 +441,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Float2 left, ref Float2 right, out Float2 result)
public static void Multiply(in Float2 left, in Float2 right, out Float2 result)
{
result = new Float2(left.X * right.X, left.Y * right.Y);
}
@@ -463,7 +463,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Float2 value, float scale, out Float2 result)
public static void Divide(in Float2 value, float scale, out Float2 result)
{
result = new Float2(value.X / scale, value.Y / scale);
}
@@ -485,7 +485,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(float scale, ref Float2 value, out Float2 result)
public static void Divide(float scale, in Float2 value, out Float2 result)
{
result = new Float2(scale / value.X, scale / value.Y);
}
@@ -506,7 +506,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Float2 value, out Float2 result)
public static void Negate(in Float2 value, out Float2 result)
{
result = new Float2(-value.X, -value.Y);
}
@@ -531,7 +531,7 @@ namespace FlaxEngine
/// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2" />).</param>
/// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3" />).</param>
/// <param name="result">When the method completes, contains the 2D Cartesian coordinates of the specified point.</param>
public static void Barycentric(ref Float2 value1, ref Float2 value2, ref Float2 value3, float amount1, float amount2, out Float2 result)
public static void Barycentric(in Float2 value1, in Float2 value2, in Float2 value3, float amount1, float amount2, out Float2 result)
{
result = new Float2(value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X),
value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y));
@@ -549,7 +549,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Float2" /> containing the 2D Cartesian coordinates of the specified point.</returns>
public static Float2 Barycentric(Float2 value1, Float2 value2, Float2 value3, float amount1, float amount2)
{
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out Float2 result);
Barycentric(in value1, in value2, in value3, amount1, amount2, out Float2 result);
return result;
}
@@ -560,7 +560,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Float2 value, ref Float2 min, ref Float2 max, out Float2 result)
public static void Clamp(in Float2 value, in Float2 min, in Float2 max, out Float2 result)
{
float x = value.X;
x = x > max.X ? max.X : x;
@@ -580,7 +580,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Float2 Clamp(Float2 value, Float2 min, Float2 max)
{
Clamp(ref value, ref min, ref max, out Float2 result);
Clamp(in value, in min, in max, out Float2 result);
return result;
}
@@ -600,7 +600,7 @@ namespace FlaxEngine
/// <param name="v1">The second triangle vertex.</param>
/// <param name="v2">The third triangle vertex.</param>
/// <returns>The triangle area.</returns>
public static float TriangleArea(ref Float2 v0, ref Float2 v1, ref Float2 v2)
public static float TriangleArea(in Float2 v0, in Float2 v1, in Float2 v2)
{
return Mathf.Abs((v0.X * (v1.Y - v2.Y) + v1.X * (v2.Y - v0.Y) + v2.X * (v0.Y - v1.Y)) / 2);
}
@@ -611,8 +611,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Float2.DistanceSquared(ref Float2, ref Float2, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Float2 value1, ref Float2 value2, out float result)
/// <remarks><see cref="Float2.DistanceSquared(in Float2, in Float2, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Float2 value1, in Float2 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -639,8 +639,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns>The distance between the two vectors.</returns>
/// <remarks><see cref="Float2.DistanceSquared(ref Float2, ref Float2, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static float Distance(ref Float2 value1, ref Float2 value2)
/// <remarks><see cref="Float2.DistanceSquared(in Float2, in Float2, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static float Distance(in Float2 value1, in Float2 value2)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -653,7 +653,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors.</param>
public static void DistanceSquared(ref Float2 value1, ref Float2 value2, out float result)
public static void DistanceSquared(in Float2 value1, in Float2 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -666,7 +666,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <returns>The squared distance between the two vectors.</returns>
public static float DistanceSquared(ref Float2 value1, ref Float2 value2)
public static float DistanceSquared(in Float2 value1, in Float2 value2)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -695,7 +695,7 @@ namespace FlaxEngine
/// <returns><c>true</c> if left and right are near, <c>false</c> otherwise</returns>
public static bool NearEqual(Float2 left, Float2 right, float epsilon = Mathf.Epsilon)
{
return NearEqual(ref left, ref right, epsilon);
return NearEqual(in left, in right, epsilon);
}
/// <summary>
@@ -705,7 +705,7 @@ namespace FlaxEngine
/// <param name="right">The right vector.</param>
/// <param name="epsilon">The epsilon.</param>
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(ref Float2 left, ref Float2 right, float epsilon = Mathf.Epsilon)
public static bool NearEqual(in Float2 left, in Float2 right, float epsilon = Mathf.Epsilon)
{
return Mathf.WithinEpsilon(left.X, right.X, epsilon) && Mathf.WithinEpsilon(left.Y, right.Y, epsilon);
}
@@ -716,7 +716,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Float2 left, ref Float2 right, out float result)
public static void Dot(in Float2 left, in Float2 right, out float result)
{
result = left.X * right.X + left.Y * right.Y;
}
@@ -727,7 +727,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <returns>The dot product of the two vectors.</returns>
public static float Dot(ref Float2 left, ref Float2 right)
public static float Dot(in Float2 left, in Float2 right)
{
return left.X * right.X + left.Y * right.Y;
}
@@ -749,7 +749,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the cross product of the two vectors.</param>
public static void Cross(ref Float2 left, ref Float2 right, out float result)
public static void Cross(in Float2 left, in Float2 right, out float result)
{
result = left.X * right.Y - left.Y * right.X;
}
@@ -760,7 +760,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <returns>The cross product of the two vectors.</returns>
public static float Cross(ref Float2 left, ref Float2 right)
public static float Cross(in Float2 left, in Float2 right)
{
return left.X * right.Y - left.Y * right.X;
}
@@ -781,7 +781,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to normalize.</param>
/// <param name="result">When the method completes, contains the normalized vector.</param>
public static void Normalize(ref Float2 value, out Float2 result)
public static void Normalize(in Float2 value, out Float2 result)
{
result = value;
result.Normalize();
@@ -893,7 +893,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Float2 start, ref Float2 end, float amount, out Float2 result)
public static void Lerp(in Float2 start, in Float2 end, float amount, out Float2 result)
{
result.X = Mathf.Lerp(start.X, end.X, amount);
result.Y = Mathf.Lerp(start.Y, end.Y, amount);
@@ -909,7 +909,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Float2 Lerp(Float2 start, Float2 end, float amount)
{
Lerp(ref start, ref end, amount, out Float2 result);
Lerp(in start, in end, amount, out Float2 result);
return result;
}
@@ -921,7 +921,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Float2 start, ref Float2 end, ref Float2 amount, out Float2 result)
public static void Lerp(in Float2 start, in Float2 end, in Float2 amount, out Float2 result)
{
result.X = Mathf.Lerp(start.X, end.X, amount.X);
result.Y = Mathf.Lerp(start.Y, end.Y, amount.Y);
@@ -937,7 +937,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Float2 Lerp(Float2 start, Float2 end, Float2 amount)
{
Lerp(ref start, ref end, ref amount, out Float2 result);
Lerp(in start, in end, in amount, out Float2 result);
return result;
}
@@ -948,10 +948,10 @@ namespace FlaxEngine
/// <param name="end">End vector.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
public static void SmoothStep(ref Float2 start, ref Float2 end, float amount, out Float2 result)
public static void SmoothStep(in Float2 start, in Float2 end, float amount, out Float2 result)
{
amount = Mathf.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(in start, in end, amount, out result);
}
/// <summary>
@@ -963,7 +963,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns>
public static Float2 SmoothStep(Float2 start, Float2 end, float amount)
{
SmoothStep(ref start, ref end, amount, out Float2 result);
SmoothStep(in start, in end, amount, out Float2 result);
return result;
}
@@ -976,7 +976,7 @@ namespace FlaxEngine
/// <param name="tangent2">Second source tangent vector.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
public static void Hermite(ref Float2 value1, ref Float2 tangent1, ref Float2 value2, ref Float2 tangent2, float amount, out Float2 result)
public static void Hermite(in Float2 value1, in Float2 tangent1, in Float2 value2, in Float2 tangent2, float amount, out Float2 result)
{
float squared = amount * amount;
float cubed = amount * squared;
@@ -999,7 +999,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns>
public static Float2 Hermite(Float2 value1, Float2 tangent1, Float2 value2, Float2 tangent2, float amount)
{
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out Float2 result);
Hermite(in value1, in tangent1, in value2, in tangent2, amount, out Float2 result);
return result;
}
@@ -1018,7 +1018,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="inDirection">The in direction.</param>
/// <param name="result">When the method completes, contains the result of the calculation.</param>
public static void Perpendicular(ref Float2 inDirection, out Float2 result)
public static void Perpendicular(in Float2 inDirection, out Float2 result)
{
result = new Float2(-inDirection.Y, inDirection.X);
}
@@ -1032,7 +1032,7 @@ namespace FlaxEngine
/// <param name="value4">The fourth position in the interpolation.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
public static void CatmullRom(ref Float2 value1, ref Float2 value2, ref Float2 value3, ref Float2 value4, float amount, out Float2 result)
public static void CatmullRom(in Float2 value1, in Float2 value2, in Float2 value3, in Float2 value4, float amount, out Float2 result)
{
float squared = amount * amount;
float cubed = amount * squared;
@@ -1055,7 +1055,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Float2 CatmullRom(Float2 value1, Float2 value2, Float2 value3, Float2 value4, float amount)
{
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out Float2 result);
CatmullRom(in value1, in value2, in value3, in value4, amount, out Float2 result);
return result;
}
@@ -1065,7 +1065,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Float2 left, ref Float2 right, out Float2 result)
public static void Max(in Float2 left, in Float2 right, out Float2 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -1079,7 +1079,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Float2 Max(Float2 left, Float2 right)
{
Max(ref left, ref right, out Float2 result);
Max(in left, in right, out Float2 result);
return result;
}
@@ -1089,7 +1089,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Float2 left, ref Float2 right, out Float2 result)
public static void Min(in Float2 left, in Float2 right, out Float2 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -1103,7 +1103,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Float2 Min(Float2 left, Float2 right)
{
Min(ref left, ref right, out Float2 result);
Min(in left, in right, out Float2 result);
return result;
}
@@ -1124,7 +1124,7 @@ namespace FlaxEngine
/// <param name="normal">Normal of the surface.</param>
/// <param name="result">When the method completes, contains the reflected vector.</param>
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static void Reflect(ref Float2 vector, ref Float2 normal, out Float2 result)
public static void Reflect(in Float2 vector, in Float2 normal, out Float2 result)
{
float dot = vector.X * normal.X + vector.Y * normal.Y;
result.X = vector.X - 2.0f * dot * normal.X;
@@ -1140,7 +1140,7 @@ namespace FlaxEngine
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static Float2 Reflect(Float2 vector, Float2 normal)
{
Reflect(ref vector, ref normal, out Float2 result);
Reflect(in vector, in normal, out Float2 result);
return result;
}
@@ -1150,7 +1150,7 @@ namespace FlaxEngine
/// <param name="vector">The vector to rotate.</param>
/// <param name="rotation">The <see cref="Quaternion" /> rotation to apply.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float2" />.</param>
public static void Transform(ref Float2 vector, ref Quaternion rotation, out Float2 result)
public static void Transform(in Float2 vector, in Quaternion rotation, out Float2 result)
{
float x = rotation.X + rotation.X;
float y = rotation.Y + rotation.Y;
@@ -1171,7 +1171,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float2" />.</returns>
public static Float2 Transform(Float2 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out Float2 result);
Transform(in vector, in rotation, out Float2 result);
return result;
}
@@ -1181,7 +1181,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float4" />.</param>
public static void Transform(ref Float2 vector, ref Matrix transform, out Float4 result)
public static void Transform(in Float2 vector, in Matrix transform, out Float4 result)
{
result = new Float4(vector.X * transform.M11 + vector.Y * transform.M21 + transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + transform.M42,
@@ -1197,7 +1197,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float4" />.</returns>
public static Float4 Transform(Float2 vector, Matrix transform)
{
Transform(ref vector, ref transform, out Float4 result);
Transform(in vector, in transform, out Float4 result);
return result;
}
@@ -1214,7 +1214,7 @@ namespace FlaxEngine
/// therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
/// with coordinates as the w component can safely be ignored.
/// </remarks>
public static void TransformCoordinate(ref Float2 coordinate, ref Matrix transform, out Float2 result)
public static void TransformCoordinate(in Float2 coordinate, in Matrix transform, out Float2 result)
{
var vector = new Float4
{
@@ -1241,7 +1241,7 @@ namespace FlaxEngine
/// </remarks>
public static Float2 TransformCoordinate(Float2 coordinate, Matrix transform)
{
TransformCoordinate(ref coordinate, ref transform, out Float2 result);
TransformCoordinate(in coordinate, in transform, out Float2 result);
return result;
}
@@ -1258,7 +1258,7 @@ namespace FlaxEngine
/// apply. This is often preferred for normal vectors as normals purely represent direction
/// rather than location because normal vectors should not be translated.
/// </remarks>
public static void TransformNormal(ref Float2 normal, ref Matrix transform, out Float2 result)
public static void TransformNormal(in Float2 normal, in Matrix transform, out Float2 result)
{
result = new Float2(normal.X * transform.M11 + normal.Y * transform.M21,
normal.X * transform.M12 + normal.Y * transform.M22);
@@ -1279,7 +1279,7 @@ namespace FlaxEngine
/// </remarks>
public static Float2 TransformNormal(Float2 normal, Matrix transform)
{
TransformNormal(ref normal, ref transform, out Float2 result);
TransformNormal(in normal, in transform, out Float2 result);
return result;
}
@@ -1310,7 +1310,7 @@ namespace FlaxEngine
}
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(ref Float2,ref Float2,out Float2)" />.
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(in Float2,in Float2,out Float2)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -1540,7 +1540,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Float2 left, Float2 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -1552,7 +1552,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Float2 left, Float2 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1656,7 +1656,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Float2" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Float2" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Float2 other)
public bool Equals(in Float2 other)
{
return X == other.X && Y == other.Y;
}
@@ -1664,9 +1664,9 @@ namespace FlaxEngine
/// <summary>
/// Determines whether the specified <see cref="Float2"/> are equal.
/// </summary>
public static bool Equals(ref Float2 a, ref Float2 b)
public static bool Equals(in Float2 a, in Float2 b)
{
return a.Equals(ref b);
return a.Equals(in b);
}
/// <summary>
@@ -1677,7 +1677,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Float2 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1687,7 +1687,7 @@ namespace FlaxEngine
/// <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)
{
return value is Float2 other && Equals(ref other);
return value is Float2 other && Equals(in other);
}
}
}

View File

@@ -364,7 +364,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Float3 left, ref Float3 right, out Float3 result)
public static void Add(in Float3 left, in Float3 right, out Float3 result)
{
result = new Float3(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
}
@@ -386,7 +386,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Float3 left, ref float right, out Float3 result)
public static void Add(in Float3 left, float right, out Float3 result)
{
result = new Float3(left.X + right, left.Y + right, left.Z + right);
}
@@ -408,7 +408,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Float3 left, ref Float3 right, out Float3 result)
public static void Subtract(in Float3 left, in Float3 right, out Float3 result)
{
result = new Float3(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
}
@@ -430,7 +430,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Float3 left, ref float right, out Float3 result)
public static void Subtract(in Float3 left, float right, out Float3 result)
{
result = new Float3(left.X - right, left.Y - right, left.Z - right);
}
@@ -452,7 +452,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector.</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref float left, ref Float3 right, out Float3 result)
public static void Subtract(float left, in Float3 right, out Float3 result)
{
result = new Float3(left - right.X, left - right.Y, left - right.Z);
}
@@ -474,7 +474,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Float3 value, float scale, out Float3 result)
public static void Multiply(in Float3 value, float scale, out Float3 result)
{
result = new Float3(value.X * scale, value.Y * scale, value.Z * scale);
}
@@ -496,7 +496,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Float3 left, ref Float3 right, out Float3 result)
public static void Multiply(in Float3 left, in Float3 right, out Float3 result)
{
result = new Float3(left.X * right.X, left.Y * right.Y, left.Z * right.Z);
}
@@ -518,7 +518,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector (per component).</param>
/// <param name="result">When the method completes, contains the divided vector.</param>
public static void Divide(ref Float3 value, ref Float3 scale, out Float3 result)
public static void Divide(in Float3 value, in Float3 scale, out Float3 result)
{
result = new Float3(value.X / scale.X, value.Y / scale.Y, value.Z / scale.Z);
}
@@ -540,7 +540,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Float3 value, float scale, out Float3 result)
public static void Divide(in Float3 value, float scale, out Float3 result)
{
result = new Float3(value.X / scale, value.Y / scale, value.Z / scale);
}
@@ -562,7 +562,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(float scale, ref Float3 value, out Float3 result)
public static void Divide(float scale, in Float3 value, out Float3 result)
{
result = new Float3(scale / value.X, scale / value.Y, scale / value.Z);
}
@@ -583,7 +583,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Float3 value, out Float3 result)
public static void Negate(in Float3 value, out Float3 result)
{
result = new Float3(-value.X, -value.Y, -value.Z);
}
@@ -607,7 +607,7 @@ namespace FlaxEngine
/// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2" />).</param>
/// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3" />).</param>
/// <param name="result">When the method completes, contains the 3D Cartesian coordinates of the specified point.</param>
public static void Barycentric(ref Float3 value1, ref Float3 value2, ref Float3 value3, float amount1, float amount2, out Float3 result)
public static void Barycentric(in Float3 value1, in Float3 value2, in Float3 value3, float amount1, float amount2, out Float3 result)
{
result = new Float3(value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X),
value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y),
@@ -625,7 +625,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Float3" /> containing the 3D Cartesian coordinates of the specified point.</returns>
public static Float3 Barycentric(Float3 value1, Float3 value2, Float3 value3, float amount1, float amount2)
{
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out var result);
Barycentric(in value1, in value2, in value3, amount1, amount2, out var result);
return result;
}
@@ -636,7 +636,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Float3 value, ref Float3 min, ref Float3 max, out Float3 result)
public static void Clamp(in Float3 value, in Float3 min, in Float3 max, out Float3 result)
{
float x = value.X;
x = x > max.X ? max.X : x;
@@ -659,7 +659,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Float3 Clamp(Float3 value, Float3 min, Float3 max)
{
Clamp(ref value, ref min, ref max, out var result);
Clamp(in value, in min, in max, out var result);
return result;
}
@@ -669,7 +669,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains he cross product of the two vectors.</param>
public static void Cross(ref Float3 left, ref Float3 right, out Float3 result)
public static void Cross(in Float3 left, in Float3 right, out Float3 result)
{
result = new Float3(left.Y * right.Z - left.Z * right.Y,
left.Z * right.X - left.X * right.Z,
@@ -684,7 +684,7 @@ namespace FlaxEngine
/// <returns>The cross product of the two vectors.</returns>
public static Float3 Cross(Float3 left, Float3 right)
{
Cross(ref left, ref right, out var result);
Cross(left, right, out var result);
return result;
}
@@ -694,8 +694,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Float3.DistanceSquared(ref Float3, ref Float3, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Float3 value1, ref Float3 value2, out float result)
/// <remarks><see cref="Float3.DistanceSquared(in Float3, in Float3, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Float3 value1, in Float3 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -709,8 +709,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns>The distance between the two vectors.</returns>
/// <remarks><see cref="Float3.DistanceSquared(ref Float3, ref Float3, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static float Distance(ref Float3 value1, ref Float3 value2)
/// <remarks><see cref="Float3.DistanceSquared(in Float3, in Float3, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static float Distance(in Float3 value1, in Float3 value2)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -739,7 +739,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors.</param>
public static void DistanceSquared(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceSquared(in Float3 value1, in Float3 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -753,7 +753,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <returns>The squared distance between the two vectors.</returns>
public static float DistanceSquared(ref Float3 value1, ref Float3 value2)
public static float DistanceSquared(in Float3 value1, in Float3 value2)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -781,7 +781,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the XY plane.</param>
public static void DistanceXY(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceXY(in Float3 value1, in Float3 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -794,7 +794,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the XY plane.</param>
public static void DistanceXYSquared(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceXYSquared(in Float3 value1, in Float3 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -807,7 +807,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the XY plane.</param>
public static void DistanceXZ(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceXZ(in Float3 value1, in Float3 value2, out float result)
{
float x = value1.X - value2.X;
float z = value1.Z - value2.Z;
@@ -820,7 +820,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the XY plane.</param>
public static void DistanceXZSquared(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceXZSquared(in Float3 value1, in Float3 value2, out float result)
{
float x = value1.X - value2.X;
float z = value1.Z - value2.Z;
@@ -833,7 +833,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the YZ plane.</param>
public static void DistanceYZ(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceYZ(in Float3 value1, in Float3 value2, out float result)
{
float y = value1.Y - value2.Y;
float z = value1.Z - value2.Z;
@@ -846,7 +846,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the YZ plane.</param>
public static void DistanceYZSquared(ref Float3 value1, ref Float3 value2, out float result)
public static void DistanceYZSquared(in Float3 value1, in Float3 value2, out float result)
{
float y = value1.Y - value2.Y;
float z = value1.Z - value2.Z;
@@ -862,7 +862,7 @@ namespace FlaxEngine
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(Float3 left, Float3 right, float epsilon = Mathf.Epsilon)
{
return NearEqual(ref left, ref right, epsilon);
return NearEqual(in left, in right, epsilon);
}
/// <summary>
@@ -872,7 +872,7 @@ namespace FlaxEngine
/// <param name="right">The right vector.</param>
/// <param name="epsilon">The epsilon.</param>
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(ref Float3 left, ref Float3 right, float epsilon = Mathf.Epsilon)
public static bool NearEqual(in Float3 left, in Float3 right, float epsilon = Mathf.Epsilon)
{
return Mathf.WithinEpsilon(left.X, right.X, epsilon) && Mathf.WithinEpsilon(left.Y, right.Y, epsilon) && Mathf.WithinEpsilon(left.Z, right.Z, epsilon);
}
@@ -883,7 +883,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Float3 left, ref Float3 right, out float result)
public static void Dot(in Float3 left, in Float3 right, out float result)
{
result = left.X * right.X + left.Y * right.Y + left.Z * right.Z;
}
@@ -894,7 +894,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <returns>The dot product of the two vectors.</returns>
public static float Dot(ref Float3 left, ref Float3 right)
public static float Dot(in Float3 left, in Float3 right)
{
return left.X * right.X + left.Y * right.Y + left.Z * right.Z;
}
@@ -915,7 +915,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to normalize.</param>
/// <param name="result">When the method completes, contains the normalized vector.</param>
public static void Normalize(ref Float3 value, out Float3 result)
public static void Normalize(in Float3 value, out Float3 result)
{
result = value;
result.Normalize();
@@ -991,7 +991,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Float3 start, ref Float3 end, float amount, out Float3 result)
public static void Lerp(in Float3 start, in Float3 end, float amount, out Float3 result)
{
result.X = Mathf.Lerp(start.X, end.X, amount);
result.Y = Mathf.Lerp(start.Y, end.Y, amount);
@@ -1008,7 +1008,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Float3 Lerp(Float3 start, Float3 end, float amount)
{
Lerp(ref start, ref end, amount, out var result);
Lerp(in start, in end, amount, out var result);
return result;
}
@@ -1019,10 +1019,10 @@ namespace FlaxEngine
/// <param name="end">End vector.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
public static void SmoothStep(ref Float3 start, ref Float3 end, float amount, out Float3 result)
public static void SmoothStep(in Float3 start, in Float3 end, float amount, out Float3 result)
{
amount = Mathf.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(in start, in end, amount, out result);
}
/// <summary>
@@ -1034,7 +1034,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns>
public static Float3 SmoothStep(Float3 start, Float3 end, float amount)
{
SmoothStep(ref start, ref end, amount, out var result);
SmoothStep(in start, in end, amount, out var result);
return result;
}
@@ -1064,7 +1064,7 @@ namespace FlaxEngine
/// <param name="tangent2">Second source tangent vector.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
public static void Hermite(ref Float3 value1, ref Float3 tangent1, ref Float3 value2, ref Float3 tangent2, float amount, out Float3 result)
public static void Hermite(in Float3 value1, in Float3 tangent1, in Float3 value2, in Float3 tangent2, float amount, out Float3 result)
{
float squared = amount * amount;
float cubed = amount * squared;
@@ -1088,7 +1088,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns>
public static Float3 Hermite(Float3 value1, Float3 tangent1, Float3 value2, Float3 tangent2, float amount)
{
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out var result);
Hermite(in value1, in tangent1, in value2, in tangent2, amount, out var result);
return result;
}
@@ -1101,7 +1101,7 @@ namespace FlaxEngine
/// <param name="value4">The fourth position in the interpolation.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
public static void CatmullRom(ref Float3 value1, ref Float3 value2, ref Float3 value3, ref Float3 value4, float amount, out Float3 result)
public static void CatmullRom(in Float3 value1, in Float3 value2, in Float3 value3, in Float3 value4, float amount, out Float3 result)
{
float squared = amount * amount;
float cubed = amount * squared;
@@ -1127,7 +1127,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Float3 CatmullRom(Float3 value1, Float3 value2, Float3 value3, Float3 value4, float amount)
{
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out var result);
CatmullRom(in value1, in value2, in value3, in value4, amount, out var result);
return result;
}
@@ -1137,7 +1137,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Float3 left, ref Float3 right, out Float3 result)
public static void Max(in Float3 left, in Float3 right, out Float3 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -1152,7 +1152,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Float3 Max(Float3 left, Float3 right)
{
Max(ref left, ref right, out var result);
Max(in left, in right, out var result);
return result;
}
@@ -1162,7 +1162,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Float3 left, ref Float3 right, out Float3 result)
public static void Min(in Float3 left, in Float3 right, out Float3 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -1177,7 +1177,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Float3 Min(Float3 left, Float3 right)
{
Min(ref left, ref right, out var result);
Min(in left, in right, out var result);
return result;
}
@@ -1242,9 +1242,9 @@ namespace FlaxEngine
/// <param name="maxZ">The maximum depth of the viewport.</param>
/// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
/// <param name="result">When the method completes, contains the vector in screen space.</param>
public static void Project(ref Float3 vector, float x, float y, float width, float height, float minZ, float maxZ, ref Matrix worldViewProjection, out Float3 result)
public static void Project(in Float3 vector, float x, float y, float width, float height, float minZ, float maxZ, in Matrix worldViewProjection, out Float3 result)
{
TransformCoordinate(ref vector, ref worldViewProjection, out var v);
TransformCoordinate(in vector, in worldViewProjection, out var v);
result = new Float3((1.0f + v.X) * 0.5f * width + x, (1.0f - v.Y) * 0.5f * height + y, v.Z * (maxZ - minZ) + minZ);
}
@@ -1262,7 +1262,7 @@ namespace FlaxEngine
/// <returns>The vector in screen space.</returns>
public static Float3 Project(Float3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection)
{
Project(ref vector, x, y, width, height, minZ, maxZ, ref worldViewProjection, out var result);
Project(in vector, x, y, width, height, minZ, maxZ, in worldViewProjection, out var result);
return result;
}
@@ -1278,16 +1278,16 @@ namespace FlaxEngine
/// <param name="maxZ">The maximum depth of the viewport.</param>
/// <param name="worldViewProjection">The combined world-view-projection matrix.</param>
/// <param name="result">When the method completes, contains the vector in object space.</param>
public static void Unproject(ref Float3 vector, float x, float y, float width, float height, float minZ, float maxZ, ref Matrix worldViewProjection, out Float3 result)
public static void Unproject(in Float3 vector, float x, float y, float width, float height, float minZ, float maxZ, in Matrix worldViewProjection, out Float3 result)
{
Matrix.Invert(ref worldViewProjection, out var matrix);
Matrix.Invert(worldViewProjection, out var matrix);
var v = new Float3
{
X = (vector.X - x) / width * 2.0f - 1.0f,
Y = -((vector.Y - y) / height * 2.0f - 1.0f),
Z = (vector.Z - minZ) / (maxZ - minZ)
};
TransformCoordinate(ref v, ref matrix, out result);
TransformCoordinate(in v, in matrix, out result);
}
/// <summary>
@@ -1304,7 +1304,7 @@ namespace FlaxEngine
/// <returns>The vector in object space.</returns>
public static Float3 Unproject(Float3 vector, float x, float y, float width, float height, float minZ, float maxZ, Matrix worldViewProjection)
{
Unproject(ref vector, x, y, width, height, minZ, maxZ, ref worldViewProjection, out var result);
Unproject(in vector, x, y, width, height, minZ, maxZ, in worldViewProjection, out var result);
return result;
}
@@ -1315,7 +1315,7 @@ namespace FlaxEngine
/// <param name="normal">Normal of the surface.</param>
/// <param name="result">When the method completes, contains the reflected vector.</param>
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static void Reflect(ref Float3 vector, ref Float3 normal, out Float3 result)
public static void Reflect(in Float3 vector, in Float3 normal, out Float3 result)
{
float dot = vector.X * normal.X + vector.Y * normal.Y + vector.Z * normal.Z;
result.X = vector.X - 2.0f * dot * normal.X;
@@ -1332,7 +1332,7 @@ namespace FlaxEngine
/// <remarks>Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.</remarks>
public static Float3 Reflect(Float3 vector, Float3 normal)
{
Reflect(ref vector, ref normal, out var result);
Reflect(in vector, in normal, out var result);
return result;
}
@@ -1342,7 +1342,7 @@ namespace FlaxEngine
/// <param name="vector">The vector to rotate.</param>
/// <param name="rotation">The <see cref="Quaternion" /> rotation to apply.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float3" />.</param>
public static void Transform(ref Float3 vector, ref Quaternion rotation, out Float3 result)
public static void Transform(in Float3 vector, in Quaternion rotation, out Float3 result)
{
float x = rotation.X + rotation.X;
float y = rotation.Y + rotation.Y;
@@ -1369,7 +1369,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float3" />.</returns>
public static Float3 Transform(Float3 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out var result);
Transform(in vector, in rotation, out var result);
return result;
}
@@ -1379,7 +1379,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix3x3"/>.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float3"/>.</param>
public static void Transform(ref Float3 vector, ref Matrix3x3 transform, out Float3 result)
public static void Transform(in Float3 vector, in Matrix3x3 transform, out Float3 result)
{
result = new Float3((vector.X * transform.M11) + (vector.Y * transform.M21) + (vector.Z * transform.M31),
(vector.X * transform.M12) + (vector.Y * transform.M22) + (vector.Z * transform.M32),
@@ -1394,7 +1394,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float3"/>.</returns>
public static Float3 Transform(Float3 vector, Matrix3x3 transform)
{
Transform(ref vector, ref transform, out var result);
Transform(in vector, in transform, out var result);
return result;
}
@@ -1404,7 +1404,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float3" />.</param>
public static void Transform(ref Float3 vector, ref Matrix transform, out Float3 result)
public static void Transform(in Float3 vector, in Matrix transform, out Float3 result)
{
result = new Float3(vector.X * transform.M11 + vector.Y * transform.M21 + vector.Z * transform.M31 + transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + vector.Z * transform.M32 + transform.M42,
@@ -1417,7 +1417,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float4" />.</param>
public static void Transform(ref Float3 vector, ref Matrix transform, out Float4 result)
public static void Transform(in Float3 vector, in Matrix transform, out Float4 result)
{
result = new Float4(vector.X * transform.M11 + vector.Y * transform.M21 + vector.Z * transform.M31 + transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + vector.Z * transform.M32 + transform.M42,
@@ -1433,7 +1433,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float3" />.</returns>
public static Float3 Transform(Float3 vector, Matrix transform)
{
Transform(ref vector, ref transform, out Float3 result);
Transform(in vector, in transform, out Float3 result);
return result;
}
@@ -1450,7 +1450,7 @@ namespace FlaxEngine
/// therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
/// with coordinates as the w component can safely be ignored.
/// </remarks>
public static void TransformCoordinate(ref Float3 coordinate, ref Matrix transform, out Float3 result)
public static void TransformCoordinate(in Float3 coordinate, in Matrix transform, out Float3 result)
{
var vector = new Float4
{
@@ -1477,7 +1477,7 @@ namespace FlaxEngine
/// </remarks>
public static Float3 TransformCoordinate(Float3 coordinate, Matrix transform)
{
TransformCoordinate(ref coordinate, ref transform, out var result);
TransformCoordinate(in coordinate, in transform, out var result);
return result;
}
@@ -1494,7 +1494,7 @@ namespace FlaxEngine
/// apply. This is often preferred for normal vectors as normals purely represent direction
/// rather than location because normal vectors should not be translated.
/// </remarks>
public static void TransformNormal(ref Float3 normal, ref Matrix transform, out Float3 result)
public static void TransformNormal(in Float3 normal, in Matrix transform, out Float3 result)
{
result = new Float3(normal.X * transform.M11 + normal.Y * transform.M21 + normal.Z * transform.M31,
normal.X * transform.M12 + normal.Y * transform.M22 + normal.Z * transform.M32,
@@ -1516,7 +1516,7 @@ namespace FlaxEngine
/// </remarks>
public static Float3 TransformNormal(Float3 normal, Matrix transform)
{
TransformNormal(ref normal, ref transform, out var result);
TransformNormal(in normal, in transform, out var result);
return result;
}
@@ -1549,7 +1549,7 @@ namespace FlaxEngine
}
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(ref Float3,ref Float3,out Float3)" />.
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(in Float3,in Float3,out Float3)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -1598,7 +1598,7 @@ namespace FlaxEngine
/// <returns>The scaled vector.</returns>
public static Float3 operator *(Float3 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out var result);
Transform(in vector, in rotation, out var result);
return result;
}
@@ -1791,7 +1791,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Float3 left, Float3 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -1803,7 +1803,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Float3 left, Float3 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1910,7 +1910,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Float3" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Float3" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Float3 other)
public bool Equals(in Float3 other)
{
return X == other.X && Y == other.Y && Z == other.Z;
}
@@ -1923,7 +1923,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Float3 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1933,7 +1933,7 @@ namespace FlaxEngine
/// <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)
{
return value is Float3 other && Equals(ref other);
return value is Float3 other && Equals(in other);
}
}
}

View File

@@ -330,7 +330,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Float4 left, ref Float4 right, out Float4 result)
public static void Add(in Float4 left, in Float4 right, out Float4 result)
{
result = new Float4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
}
@@ -352,7 +352,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Float4 left, ref float right, out Float4 result)
public static void Add(in Float4 left, float right, out Float4 result)
{
result = new Float4(left.X + right, left.Y + right, left.Z + right, left.W + right);
}
@@ -374,7 +374,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Float4 left, ref Float4 right, out Float4 result)
public static void Subtract(in Float4 left, in Float4 right, out Float4 result)
{
result = new Float4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
}
@@ -396,7 +396,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Float4 left, ref float right, out Float4 result)
public static void Subtract(in Float4 left, float right, out Float4 result)
{
result = new Float4(left.X - right, left.Y - right, left.Z - right, left.W - right);
}
@@ -418,7 +418,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector.</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref float left, ref Float4 right, out Float4 result)
public static void Subtract(float left, in Float4 right, out Float4 result)
{
result = new Float4(left - right.X, left - right.Y, left - right.Z, left - right.W);
}
@@ -440,7 +440,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Float4 value, float scale, out Float4 result)
public static void Multiply(in Float4 value, float scale, out Float4 result)
{
result = new Float4(value.X * scale, value.Y * scale, value.Z * scale, value.W * scale);
}
@@ -462,7 +462,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Float4 left, ref Float4 right, out Float4 result)
public static void Multiply(in Float4 left, in Float4 right, out Float4 result)
{
result = new Float4(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W);
}
@@ -484,7 +484,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Float4 value, float scale, out Float4 result)
public static void Divide(in Float4 value, float scale, out Float4 result)
{
result = new Float4(value.X / scale, value.Y / scale, value.Z / scale, value.W / scale);
}
@@ -506,7 +506,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(float scale, ref Float4 value, out Float4 result)
public static void Divide(float scale, in Float4 value, out Float4 result)
{
result = new Float4(scale / value.X, scale / value.Y, scale / value.Z, scale / value.W);
}
@@ -527,7 +527,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Float4 value, out Float4 result)
public static void Negate(in Float4 value, out Float4 result)
{
result = new Float4(-value.X, -value.Y, -value.Z, -value.W);
}
@@ -551,7 +551,7 @@ namespace FlaxEngine
/// <param name="amount1">Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in <paramref name="value2" />).</param>
/// <param name="amount2">Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in <paramref name="value3" />).</param>
/// <param name="result">When the method completes, contains the 4D Cartesian coordinates of the specified point.</param>
public static void Barycentric(ref Float4 value1, ref Float4 value2, ref Float4 value3, float amount1, float amount2, out Float4 result)
public static void Barycentric(in Float4 value1, in Float4 value2, in Float4 value3, float amount1, float amount2, out Float4 result)
{
result = new Float4(value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X),
value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y),
@@ -570,7 +570,7 @@ namespace FlaxEngine
/// <returns>A new <see cref="Float4" /> containing the 4D Cartesian coordinates of the specified point.</returns>
public static Float4 Barycentric(Float4 value1, Float4 value2, Float4 value3, float amount1, float amount2)
{
Barycentric(ref value1, ref value2, ref value3, amount1, amount2, out Float4 result);
Barycentric(in value1, in value2, in value3, amount1, amount2, out Float4 result);
return result;
}
@@ -581,7 +581,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Float4 value, ref Float4 min, ref Float4 max, out Float4 result)
public static void Clamp(in Float4 value, in Float4 min, in Float4 max, out Float4 result)
{
float x = value.X;
x = x > max.X ? max.X : x;
@@ -607,7 +607,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Float4 Clamp(Float4 value, Float4 min, Float4 max)
{
Clamp(ref value, ref min, ref max, out Float4 result);
Clamp(in value, in min, in max, out Float4 result);
return result;
}
@@ -617,8 +617,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Float4.DistanceSquared(ref Float4, ref Float4, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Float4 value1, ref Float4 value2, out float result)
/// <remarks><see cref="Float4.DistanceSquared(in Float4, in Float4, out float)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Float4 value1, in Float4 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -649,7 +649,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors.</param>
public static void DistanceSquared(ref Float4 value1, ref Float4 value2, out float result)
public static void DistanceSquared(in Float4 value1, in Float4 value2, out float result)
{
float x = value1.X - value2.X;
float y = value1.Y - value2.Y;
@@ -682,7 +682,7 @@ namespace FlaxEngine
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(Float4 left, Float4 right, float epsilon = Mathf.Epsilon)
{
return NearEqual(ref left, ref right, epsilon);
return NearEqual(in left, in right, epsilon);
}
/// <summary>
@@ -692,7 +692,7 @@ namespace FlaxEngine
/// <param name="right">The right vector.</param>
/// <param name="epsilon">The epsilon.</param>
/// <returns><c>true</c> if left and right are near another, <c>false</c> otherwise</returns>
public static bool NearEqual(ref Float4 left, ref Float4 right, float epsilon = Mathf.Epsilon)
public static bool NearEqual(in Float4 left, in Float4 right, float epsilon = Mathf.Epsilon)
{
return Mathf.WithinEpsilon(left.X, right.X, epsilon) && Mathf.WithinEpsilon(left.Y, right.Y, epsilon) && Mathf.WithinEpsilon(left.Z, right.Z, epsilon) && Mathf.WithinEpsilon(left.W, right.W, epsilon);
}
@@ -703,7 +703,7 @@ namespace FlaxEngine
/// <param name="left">First source vector</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Float4 left, ref Float4 right, out float result)
public static void Dot(in Float4 left, in Float4 right, out float result)
{
result = left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
}
@@ -724,7 +724,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to normalize.</param>
/// <param name="result">When the method completes, contains the normalized vector.</param>
public static void Normalize(ref Float4 value, out Float4 result)
public static void Normalize(in Float4 value, out Float4 result)
{
result = value;
result.Normalize();
@@ -800,7 +800,7 @@ namespace FlaxEngine
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the linear interpolation of the two vectors.</param>
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static void Lerp(ref Float4 start, ref Float4 end, float amount, out Float4 result)
public static void Lerp(in Float4 start, in Float4 end, float amount, out Float4 result)
{
result.X = Mathf.Lerp(start.X, end.X, amount);
result.Y = Mathf.Lerp(start.Y, end.Y, amount);
@@ -818,7 +818,7 @@ namespace FlaxEngine
/// <remarks>Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1 will cause <paramref name="end" /> to be returned.</remarks>
public static Float4 Lerp(Float4 start, Float4 end, float amount)
{
Lerp(ref start, ref end, amount, out Float4 result);
Lerp(in start, in end, amount, out Float4 result);
return result;
}
@@ -829,10 +829,10 @@ namespace FlaxEngine
/// <param name="end">End vector.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two vectors.</param>
public static void SmoothStep(ref Float4 start, ref Float4 end, float amount, out Float4 result)
public static void SmoothStep(in Float4 start, in Float4 end, float amount, out Float4 result)
{
amount = Mathf.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(in start, in end, amount, out result);
}
/// <summary>
@@ -844,7 +844,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two vectors.</returns>
public static Float4 SmoothStep(Float4 start, Float4 end, float amount)
{
SmoothStep(ref start, ref end, amount, out Float4 result);
SmoothStep(in start, in end, amount, out Float4 result);
return result;
}
@@ -857,7 +857,7 @@ namespace FlaxEngine
/// <param name="tangent2">Second source tangent vector.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Hermite spline interpolation.</param>
public static void Hermite(ref Float4 value1, ref Float4 tangent1, ref Float4 value2, ref Float4 tangent2, float amount, out Float4 result)
public static void Hermite(in Float4 value1, in Float4 tangent1, in Float4 value2, in Float4 tangent2, float amount, out Float4 result)
{
float squared = amount * amount;
float cubed = amount * squared;
@@ -882,7 +882,7 @@ namespace FlaxEngine
/// <returns>The result of the Hermite spline interpolation.</returns>
public static Float4 Hermite(Float4 value1, Float4 tangent1, Float4 value2, Float4 tangent2, float amount)
{
Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out Float4 result);
Hermite(in value1, in tangent1, in value2, in tangent2, amount, out Float4 result);
return result;
}
@@ -895,7 +895,7 @@ namespace FlaxEngine
/// <param name="value4">The fourth position in the interpolation.</param>
/// <param name="amount">Weighting factor.</param>
/// <param name="result">When the method completes, contains the result of the Catmull-Rom interpolation.</param>
public static void CatmullRom(ref Float4 value1, ref Float4 value2, ref Float4 value3, ref Float4 value4, float amount, out Float4 result)
public static void CatmullRom(in Float4 value1, in Float4 value2, in Float4 value3, in Float4 value4, float amount, out Float4 result)
{
float squared = amount * amount;
float cubed = amount * squared;
@@ -916,7 +916,7 @@ namespace FlaxEngine
/// <returns>A vector that is the result of the Catmull-Rom interpolation.</returns>
public static Float4 CatmullRom(Float4 value1, Float4 value2, Float4 value3, Float4 value4, float amount)
{
CatmullRom(ref value1, ref value2, ref value3, ref value4, amount, out Float4 result);
CatmullRom(in value1, in value2, in value3, in value4, amount, out Float4 result);
return result;
}
@@ -926,7 +926,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Float4 left, ref Float4 right, out Float4 result)
public static void Max(in Float4 left, in Float4 right, out Float4 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -942,7 +942,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Float4 Max(Float4 left, Float4 right)
{
Max(ref left, ref right, out Float4 result);
Max(in left, in right, out Float4 result);
return result;
}
@@ -952,7 +952,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Float4 left, ref Float4 right, out Float4 result)
public static void Min(in Float4 left, in Float4 right, out Float4 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -968,7 +968,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Float4 Min(Float4 left, Float4 right)
{
Min(ref left, ref right, out Float4 result);
Min(in left, in right, out Float4 result);
return result;
}
@@ -988,7 +988,7 @@ namespace FlaxEngine
/// <param name="vector">The vector to rotate.</param>
/// <param name="rotation">The <see cref="Quaternion" /> rotation to apply.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float4" />.</param>
public static void Transform(ref Float4 vector, ref Quaternion rotation, out Float4 result)
public static void Transform(in Float4 vector, in Quaternion rotation, out Float4 result)
{
float x = rotation.X + rotation.X;
float y = rotation.Y + rotation.Y;
@@ -1016,7 +1016,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float4" />.</returns>
public static Float4 Transform(Float4 vector, Quaternion rotation)
{
Transform(ref vector, ref rotation, out Float4 result);
Transform(in vector, in rotation, out Float4 result);
return result;
}
@@ -1026,7 +1026,7 @@ namespace FlaxEngine
/// <param name="vector">The source vector.</param>
/// <param name="transform">The transformation <see cref="Matrix" />.</param>
/// <param name="result">When the method completes, contains the transformed <see cref="Float4" />.</param>
public static void Transform(ref Float4 vector, ref Matrix transform, out Float4 result)
public static void Transform(in Float4 vector, in Matrix transform, out Float4 result)
{
result = new Float4(vector.X * transform.M11 + vector.Y * transform.M21 + vector.Z * transform.M31 + vector.W * transform.M41,
vector.X * transform.M12 + vector.Y * transform.M22 + vector.Z * transform.M32 + vector.W * transform.M42,
@@ -1042,7 +1042,7 @@ namespace FlaxEngine
/// <returns>The transformed <see cref="Float4" />.</returns>
public static Float4 Transform(Float4 vector, Matrix transform)
{
Transform(ref vector, ref transform, out Float4 result);
Transform(in vector, in transform, out Float4 result);
return result;
}
@@ -1058,7 +1058,7 @@ namespace FlaxEngine
}
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(ref Float4,ref Float4,out Float4)" />.
/// Multiplies a vector with another by performing component-wise multiplication equivalent to <see cref="Multiply(in Float4,in Float4,out Float4)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -1288,7 +1288,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Float4 left, Float4 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -1300,7 +1300,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Float4 left, Float4 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1417,7 +1417,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="other">The <see cref="Float4" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Float4" /> is equal to this instance; otherwise, <c>false</c>.</returns>
public bool Equals(ref Float4 other)
public bool Equals(in Float4 other)
{
return X == other.X && Y == other.Y && Z == other.Z && W == other.W;
}
@@ -1430,7 +1430,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Float4 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1440,7 +1440,7 @@ namespace FlaxEngine
/// <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)
{
return value is Float4 other && Equals(ref other);
return value is Float4 other && Equals(in other);
}
}
}

View File

@@ -136,7 +136,7 @@ namespace FlaxEngine
/// <param name="value1" />
/// <param name="value2" />
/// <returns><c>true</c> if <paramref name = "value1" /> is the same instance as <paramref name = "value2" /> or if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
public static bool Equals(ref FloatR10G10B10A2 value1, ref FloatR10G10B10A2 value2)
public static bool Equals(in FloatR10G10B10A2 value1, in FloatR10G10B10A2 value2)
{
return value1.rawValue == value2.rawValue;
}

View File

@@ -114,7 +114,7 @@ namespace FlaxEngine
/// <param name="value1" />
/// <param name="value2" />
/// <returns><c>true</c> if <paramref name="value1" /> is the same instance as <paramref name="value2" /> or if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
public static bool Equals(ref FloatR11G11B10 value1, ref FloatR11G11B10 value2)
public static bool Equals(in FloatR11G11B10 value1, in FloatR11G11B10 value2)
{
return value1.rawValue == value2.rawValue;
}

View File

@@ -213,7 +213,7 @@ namespace FlaxEngine
/// <param name = "value1" />
/// <param name = "value2" />
/// <returns><c>true</c> if <paramref name = "value1" /> is the same instance as <paramref name = "value2" /> or if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
public static bool Equals(ref Half value1, ref Half value2)
public static bool Equals(in Half value1, in Half value2)
{
return value1.rawValue == value2.rawValue;
}

View File

@@ -100,7 +100,7 @@ namespace FlaxEngine
/// <c>true</c> if <paramref name="left" /> has the same value as <paramref name="right" />; otherwise, <c>false</c>.</returns>
public static bool operator ==(Half2 left, Half2 right)
{
return Equals(ref left, ref right);
return Equals(in left, in right);
}
/// <summary>
@@ -113,7 +113,7 @@ namespace FlaxEngine
[return: MarshalAs(UnmanagedType.U1)]
public static bool operator !=(Half2 left, Half2 right)
{
return !Equals(ref left, ref right);
return !Equals(in left, in right);
}
/// <summary>
@@ -133,7 +133,7 @@ namespace FlaxEngine
/// <returns>
/// <c>true</c> if <paramref name="value1" /> is the same instance as <paramref name="value2" /> or
/// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
public static bool Equals(ref Half2 value1, ref Half2 value2)
public static bool Equals(in Half2 value1, in Half2 value2)
{
return ((value1.X == value2.X) && (value1.Y == value2.Y));
}

View File

@@ -112,7 +112,7 @@ namespace FlaxEngine
/// <c>true</c> if <paramref name="left" /> has the same value as <paramref name="right" />; otherwise, <c>false</c>.</returns>
public static bool operator ==(Half3 left, Half3 right)
{
return Equals(ref left, ref right);
return Equals(in left, in right);
}
/// <summary>
@@ -125,7 +125,7 @@ namespace FlaxEngine
[return: MarshalAs(UnmanagedType.U1)]
public static bool operator !=(Half3 left, Half3 right)
{
return !Equals(ref left, ref right);
return !Equals(in left, in right);
}
/// <summary>
@@ -146,7 +146,7 @@ namespace FlaxEngine
/// <returns>
/// <c>true</c> if <paramref name="value1" /> is the same instance as <paramref name="value2" /> or
/// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
public static bool Equals(ref Half3 value1, ref Half3 value2)
public static bool Equals(in Half3 value1, in Half3 value2)
{
return (((value1.X == value2.X) && (value1.Y == value2.Y)) && (value1.Z == value2.Z));
}

View File

@@ -97,7 +97,7 @@ namespace FlaxEngine
/// <c>true</c> if <paramref name="left" /> has the same value as <paramref name="right" />; otherwise, <c>false</c>.</returns>
public static bool operator ==(Half4 left, Half4 right)
{
return Equals(ref left, ref right);
return Equals(in left, in right);
}
/// <summary>
@@ -109,7 +109,7 @@ namespace FlaxEngine
/// <c>true</c> if <paramref name="left" /> has a different value than <paramref name="right" />; otherwise, <c>false</c>.</returns>
public static bool operator !=(Half4 left, Half4 right)
{
return !Equals(ref left, ref right);
return !Equals(in left, in right);
}
/// <summary>
@@ -131,7 +131,7 @@ namespace FlaxEngine
/// <returns>
/// <c>true</c> if <paramref name="value1" /> is the same instance as <paramref name="value2" /> or
/// if both are <c>null</c> references or if <c>value1.Equals(value2)</c> returns <c>true</c>; otherwise, <c>false</c>.</returns>
public static bool Equals(ref Half4 value1, ref Half4 value2)
public static bool Equals(in Half4 value1, in Half4 value2)
{
return (((value1.X == value2.X) && (value1.Y == value2.Y)) && ((value1.Z == value2.Z) && (value1.W == value2.W)));
}

View File

@@ -198,7 +198,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Int2 left, ref Int2 right, out Int2 result)
public static void Add(in Int2 left, in Int2 right, out Int2 result)
{
result = new Int2(left.X + right.X, left.Y + right.Y);
}
@@ -220,7 +220,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Int2 left, ref int right, out Int2 result)
public static void Add(in Int2 left, int right, out Int2 result)
{
result = new Int2(left.X + right, left.Y + right);
}
@@ -242,7 +242,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Int2 left, ref Int2 right, out Int2 result)
public static void Subtract(in Int2 left, in Int2 right, out Int2 result)
{
result = new Int2(left.X - right.X, left.Y - right.Y);
}
@@ -264,7 +264,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Int2 left, ref int right, out Int2 result)
public static void Subtract(in Int2 left, int right, out Int2 result)
{
result = new Int2(left.X - right, left.Y - right);
}
@@ -286,7 +286,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref int left, ref Int2 right, out Int2 result)
public static void Subtract(int left, in Int2 right, out Int2 result)
{
result = new Int2(left - right.X, left - right.Y);
}
@@ -308,7 +308,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Int2 value, int scale, out Int2 result)
public static void Multiply(in Int2 value, int scale, out Int2 result)
{
result = new Int2(value.X * scale, value.Y * scale);
}
@@ -330,7 +330,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Int2 left, ref Int2 right, out Int2 result)
public static void Multiply(in Int2 left, in Int2 right, out Int2 result)
{
result = new Int2(left.X * right.X, left.Y * right.Y);
}
@@ -352,7 +352,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Int2 value, int scale, out Int2 result)
public static void Divide(in Int2 value, int scale, out Int2 result)
{
result = new Int2(value.X / scale, value.Y / scale);
}
@@ -374,7 +374,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(int scale, ref Int2 value, out Int2 result)
public static void Divide(int scale, in Int2 value, out Int2 result)
{
result = new Int2(scale / value.X, scale / value.Y);
}
@@ -395,7 +395,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Int2 value, out Int2 result)
public static void Negate(in Int2 value, out Int2 result)
{
result = new Int2(-value.X, -value.Y);
}
@@ -417,7 +417,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Int2 value, ref Int2 min, ref Int2 max, out Int2 result)
public static void Clamp(in Int2 value, in Int2 min, in Int2 max, out Int2 result)
{
int x = value.X;
x = x > max.X ? max.X : x;
@@ -439,7 +439,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Int2 Clamp(Int2 value, Int2 min, Int2 max)
{
Clamp(ref value, ref min, ref max, out Int2 result);
Clamp(in value, in min, in max, out Int2 result);
return result;
}
@@ -449,8 +449,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Int2.DistanceSquared(ref Int2, ref Int2, out int)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Int2 value1, ref Int2 value2, out float result)
/// <remarks><see cref="Int2.DistanceSquared(in Int2, in Int2, out int)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Int2 value1, in Int2 value2, out float result)
{
int x = value1.X - value2.X;
int y = value1.Y - value2.Y;
@@ -485,7 +485,7 @@ namespace FlaxEngine
/// involves two square roots, which are computationally expensive. However, using distance squared
/// provides the same information and avoids calculating two square roots.
/// </remarks>
public static void DistanceSquared(ref Int2 value1, ref Int2 value2, out int result)
public static void DistanceSquared(in Int2 value1, in Int2 value2, out int result)
{
int x = value1.X - value2.X;
int y = value1.Y - value2.Y;
@@ -520,7 +520,7 @@ namespace FlaxEngine
/// <param name="left">First source vector.</param>
/// <param name="right">Second source vector.</param>
/// <param name="result">When the method completes, contains the dot product of the two vectors.</param>
public static void Dot(ref Int2 left, ref Int2 right, out int result)
public static void Dot(in Int2 left, in Int2 right, out int result)
{
result = left.X * right.X + left.Y * right.Y;
}
@@ -542,7 +542,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Int2 left, ref Int2 right, out Int2 result)
public static void Max(in Int2 left, in Int2 right, out Int2 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -556,7 +556,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Int2 Max(Int2 left, Int2 right)
{
Max(ref left, ref right, out Int2 result);
Max(in left, in right, out Int2 result);
return result;
}
@@ -566,7 +566,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Int2 left, ref Int2 right, out Int2 result)
public static void Min(in Int2 left, in Int2 right, out Int2 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -580,7 +580,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Int2 Min(Int2 left, Int2 right)
{
Min(ref left, ref right, out Int2 result);
Min(in left, in right, out Int2 result);
return result;
}
@@ -607,7 +607,7 @@ namespace FlaxEngine
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to
/// <see cref="Multiply(ref Int2,ref Int2,out Int2)" />.
/// <see cref="Multiply(in Int2,in Int2,out Int2)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -789,7 +789,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Int2 left, Int2 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -801,7 +801,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Int2 left, Int2 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -946,7 +946,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Int2" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Int2" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Int2 other)
public bool Equals(in Int2 other)
{
return other.X == X && other.Y == Y;
}
@@ -954,7 +954,7 @@ namespace FlaxEngine
/// <summary>
/// Determines whether the specified <see cref="Int2"/> are equal.
/// </summary>
public static bool Equals(ref Int2 a, ref Int2 b)
public static bool Equals(in Int2 a, in Int2 b)
{
return a.X == b.X && a.Y == b.Y;
}
@@ -967,7 +967,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Int2 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -977,7 +977,7 @@ namespace FlaxEngine
/// <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)
{
return value is Int2 other && Equals(ref other);
return value is Int2 other && Equals(in other);
}
}
}

View File

@@ -215,7 +215,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Int3 left, ref Int3 right, out Int3 result)
public static void Add(in Int3 left, in Int3 right, out Int3 result)
{
result = new Int3(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
}
@@ -237,7 +237,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Int3 left, ref int right, out Int3 result)
public static void Add(in Int3 left, int right, out Int3 result)
{
result = new Int3(left.X + right, left.Y + right, left.Z + right);
}
@@ -259,7 +259,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Int3 left, ref Int3 right, out Int3 result)
public static void Subtract(in Int3 left, in Int3 right, out Int3 result)
{
result = new Int3(left.X - right.X, left.Y - right.Y, left.Z - right.Z);
}
@@ -281,7 +281,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Int3 left, ref int right, out Int3 result)
public static void Subtract(in Int3 left, int right, out Int3 result)
{
result = new Int3(left.X - right, left.Y - right, left.Z - right);
}
@@ -303,7 +303,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector.</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref int left, ref Int3 right, out Int3 result)
public static void Subtract(int left, in Int3 right, out Int3 result)
{
result = new Int3(left - right.X, left - right.Y, left - right.Z);
}
@@ -325,7 +325,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Int3 value, int scale, out Int3 result)
public static void Multiply(in Int3 value, int scale, out Int3 result)
{
result = new Int3(value.X * scale, value.Y * scale, value.Z * scale);
}
@@ -347,7 +347,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Int3 left, ref Int3 right, out Int3 result)
public static void Multiply(in Int3 left, in Int3 right, out Int3 result)
{
result = new Int3(left.X * right.X, left.Y * right.Y, left.Z * right.Z);
}
@@ -369,7 +369,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector (per component).</param>
/// <param name="result">When the method completes, contains the divided vector.</param>
public static void Divide(ref Int3 value, ref Int3 scale, out Int3 result)
public static void Divide(in Int3 value, in Int3 scale, out Int3 result)
{
result = new Int3(value.X / scale.X, value.Y / scale.Y, value.Z / scale.Z);
}
@@ -391,7 +391,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Int3 value, int scale, out Int3 result)
public static void Divide(in Int3 value, int scale, out Int3 result)
{
result = new Int3(value.X / scale, value.Y / scale, value.Z / scale);
}
@@ -413,7 +413,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(int scale, ref Int3 value, out Int3 result)
public static void Divide(int scale, in Int3 value, out Int3 result)
{
result = new Int3(scale / value.X, scale / value.Y, scale / value.Z);
}
@@ -434,7 +434,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Int3 value, out Int3 result)
public static void Negate(in Int3 value, out Int3 result)
{
result = new Int3(-value.X, -value.Y, -value.Z);
}
@@ -456,7 +456,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Int3 value, ref Int3 min, ref Int3 max, out Int3 result)
public static void Clamp(in Int3 value, in Int3 min, in Int3 max, out Int3 result)
{
int x = value.X;
x = x > max.X ? max.X : x;
@@ -482,7 +482,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Int3 Clamp(Int3 value, Int3 min, Int3 max)
{
Clamp(ref value, ref min, ref max, out Int3 result);
Clamp(in value, in min, in max, out Int3 result);
return result;
}
@@ -492,8 +492,8 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors.</param>
/// <remarks><see cref="Int3.DistanceSquared(ref Int3, ref Int3, out int)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(ref Int3 value1, ref Int3 value2, out float result)
/// <remarks><see cref="Int3.DistanceSquared(in Int3, in Int3, out int)" /> may be preferred when only the relative distance is needed and speed is of the essence.</remarks>
public static void Distance(in Int3 value1, in Int3 value2, out float result)
{
int x = value1.X - value2.X;
int y = value1.Y - value2.Y;
@@ -530,7 +530,7 @@ namespace FlaxEngine
/// involves two square roots, which are computationally expensive. However, using distance squared
/// provides the same information and avoids calculating two square roots.
/// </remarks>
public static void DistanceSquared(ref Int3 value1, ref Int3 value2, out int result)
public static void DistanceSquared(in Int3 value1, in Int3 value2, out int result)
{
int x = value1.X - value2.X;
int y = value1.Y - value2.Y;
@@ -566,7 +566,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector.</param>
/// <param name="result">When the method completes, contains the distance between the two vectors in the XZ plane.</param>
public static void Distance2D(ref Int2 value1, ref Int2 value2, out float result)
public static void Distance2D(in Int2 value1, in Int2 value2, out float result)
{
int x = value1.X - value2.X;
int y = value1.Y - value2.Y;
@@ -592,7 +592,7 @@ namespace FlaxEngine
/// <param name="value1">The first vector.</param>
/// <param name="value2">The second vector</param>
/// <param name="result">When the method completes, contains the squared distance between the two vectors in the XZ plane.</param>
public static void Distance2DSquared(ref Int2 value1, ref Int2 value2, out int result)
public static void Distance2DSquared(in Int2 value1, in Int2 value2, out int result)
{
int x = value1.X - value2.X;
int y = value1.Y - value2.Y;
@@ -620,7 +620,7 @@ namespace FlaxEngine
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.
/// </param>
public static void Max(ref Int3 left, ref Int3 right, out Int3 result)
public static void Max(in Int3 left, in Int3 right, out Int3 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -635,7 +635,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Int3 Max(Int3 left, Int3 right)
{
Max(ref left, ref right, out Int3 result);
Max(in left, in right, out Int3 result);
return result;
}
@@ -645,7 +645,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Int3 left, ref Int3 right, out Int3 result)
public static void Min(in Int3 left, in Int3 right, out Int3 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -660,7 +660,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Int3 Min(Int3 left, Int3 right)
{
Min(ref left, ref right, out Int3 result);
Min(in left, in right, out Int3 result);
return result;
}
@@ -687,7 +687,7 @@ namespace FlaxEngine
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to
/// <see cref="Multiply(ref Int3,ref Int3,out Int3)" />.
/// <see cref="Multiply(in Int3,in Int3,out Int3)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -869,7 +869,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Int3 left, Int3 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -881,7 +881,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Int3 left, Int3 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -1029,7 +1029,7 @@ namespace FlaxEngine
/// <param name="other">The <see cref="Int3" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Int3" /> is equal to this instance; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ref Int3 other)
public bool Equals(in Int3 other)
{
return other.X == X && other.Y == Y && other.Z == Z;
}
@@ -1042,7 +1042,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Int3 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -1052,7 +1052,7 @@ namespace FlaxEngine
/// <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)
{
return value is Int3 other && Equals(ref other);
return value is Int3 other && Equals(in other);
}
}
}

View File

@@ -216,7 +216,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to add.</param>
/// <param name="right">The second vector to add.</param>
/// <param name="result">When the method completes, contains the sum of the two vectors.</param>
public static void Add(ref Int4 left, ref Int4 right, out Int4 result)
public static void Add(in Int4 left, in Int4 right, out Int4 result)
{
result = new Int4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
}
@@ -238,7 +238,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be added to elements</param>
/// <param name="result">The vector with added scalar for each element.</param>
public static void Add(ref Int4 left, ref int right, out Int4 result)
public static void Add(in Int4 left, int right, out Int4 result)
{
result = new Int4(left.X + right, left.Y + right, left.Z + right, left.W + right);
}
@@ -260,7 +260,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to subtract.</param>
/// <param name="right">The second vector to subtract.</param>
/// <param name="result">When the method completes, contains the difference of the two vectors.</param>
public static void Subtract(ref Int4 left, ref Int4 right, out Int4 result)
public static void Subtract(in Int4 left, in Int4 right, out Int4 result)
{
result = new Int4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
}
@@ -282,7 +282,7 @@ namespace FlaxEngine
/// <param name="left">The input vector</param>
/// <param name="right">The scalar value to be subtracted from elements</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref Int4 left, ref int right, out Int4 result)
public static void Subtract(in Int4 left, int right, out Int4 result)
{
result = new Int4(left.X - right, left.Y - right, left.Z - right, left.W - right);
}
@@ -304,7 +304,7 @@ namespace FlaxEngine
/// <param name="left">The scalar value to be subtracted from elements</param>
/// <param name="right">The input vector.</param>
/// <param name="result">The vector with subtracted scalar for each element.</param>
public static void Subtract(ref int left, ref Int4 right, out Int4 result)
public static void Subtract(int left, in Int4 right, out Int4 result)
{
result = new Int4(left - right.X, left - right.Y, left - right.Z, left - right.W);
}
@@ -326,7 +326,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Multiply(ref Int4 value, int scale, out Int4 result)
public static void Multiply(in Int4 value, int scale, out Int4 result)
{
result = new Int4(value.X * scale, value.Y * scale, value.Z * scale, value.W * scale);
}
@@ -348,7 +348,7 @@ namespace FlaxEngine
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
/// <param name="result">When the method completes, contains the multiplied vector.</param>
public static void Multiply(ref Int4 left, ref Int4 right, out Int4 result)
public static void Multiply(in Int4 left, in Int4 right, out Int4 result)
{
result = new Int4(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W);
}
@@ -370,7 +370,7 @@ namespace FlaxEngine
/// <param name="value">The vector to scale.</param>
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(ref Int4 value, int scale, out Int4 result)
public static void Divide(in Int4 value, int scale, out Int4 result)
{
result = new Int4(value.X / scale, value.Y / scale, value.Z / scale, value.W / scale);
}
@@ -392,7 +392,7 @@ namespace FlaxEngine
/// <param name="scale">The amount by which to scale the vector.</param>
/// <param name="value">The vector to scale.</param>
/// <param name="result">When the method completes, contains the scaled vector.</param>
public static void Divide(int scale, ref Int4 value, out Int4 result)
public static void Divide(int scale, in Int4 value, out Int4 result)
{
result = new Int4(scale / value.X, scale / value.Y, scale / value.Z, scale / value.W);
}
@@ -413,7 +413,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The vector to negate.</param>
/// <param name="result">When the method completes, contains a vector facing in the opposite direction.</param>
public static void Negate(ref Int4 value, out Int4 result)
public static void Negate(in Int4 value, out Int4 result)
{
result = new Int4(-value.X, -value.Y, -value.Z, -value.W);
}
@@ -435,7 +435,7 @@ namespace FlaxEngine
/// <param name="min">The minimum value.</param>
/// <param name="max">The maximum value.</param>
/// <param name="result">When the method completes, contains the clamped value.</param>
public static void Clamp(ref Int4 value, ref Int4 min, ref Int4 max, out Int4 result)
public static void Clamp(in Int4 value, in Int4 min, in Int4 max, out Int4 result)
{
int x = value.X;
x = x > max.X ? max.X : x;
@@ -465,7 +465,7 @@ namespace FlaxEngine
/// <returns>The clamped value.</returns>
public static Int4 Clamp(Int4 value, Int4 min, Int4 max)
{
Clamp(ref value, ref min, ref max, out Int4 result);
Clamp(in value, in min, in max, out Int4 result);
return result;
}
@@ -475,7 +475,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
public static void Max(ref Int4 left, ref Int4 right, out Int4 result)
public static void Max(in Int4 left, in Int4 right, out Int4 result)
{
result.X = left.X > right.X ? left.X : right.X;
result.Y = left.Y > right.Y ? left.Y : right.Y;
@@ -491,7 +491,7 @@ namespace FlaxEngine
/// <returns>A vector containing the largest components of the source vectors.</returns>
public static Int4 Max(Int4 left, Int4 right)
{
Max(ref left, ref right, out Int4 result);
Max(in left, in right, out Int4 result);
return result;
}
@@ -501,7 +501,7 @@ namespace FlaxEngine
/// <param name="left">The first source vector.</param>
/// <param name="right">The second source vector.</param>
/// <param name="result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
public static void Min(ref Int4 left, ref Int4 right, out Int4 result)
public static void Min(in Int4 left, in Int4 right, out Int4 result)
{
result.X = left.X < right.X ? left.X : right.X;
result.Y = left.Y < right.Y ? left.Y : right.Y;
@@ -517,7 +517,7 @@ namespace FlaxEngine
/// <returns>A vector containing the smallest components of the source vectors.</returns>
public static Int4 Min(Int4 left, Int4 right)
{
Min(ref left, ref right, out Int4 result);
Min(in left, in right, out Int4 result);
return result;
}
@@ -544,7 +544,7 @@ namespace FlaxEngine
/// <summary>
/// Multiplies a vector with another by performing component-wise multiplication equivalent to
/// <see cref="Multiply(ref Int4,ref Int4,out Int4)" />.
/// <see cref="Multiply(in Int4,in Int4,out Int4)" />.
/// </summary>
/// <param name="left">The first vector to multiply.</param>
/// <param name="right">The second vector to multiply.</param>
@@ -726,7 +726,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Int4 left, Int4 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -738,7 +738,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Int4 left, Int4 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -886,7 +886,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="other">The <see cref="Int4" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Int4" /> is equal to this instance; otherwise, <c>false</c>.</returns>
public bool Equals(ref Int4 other)
public bool Equals(in Int4 other)
{
return other.X == X && other.Y == Y && other.Z == Z && other.W == W;
}
@@ -899,7 +899,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Int4 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -909,7 +909,7 @@ namespace FlaxEngine
/// <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)
{
return value is Int4 other && Equals(ref other);
return value is Int4 other && Equals(in other);
}
}
}

View File

@@ -644,7 +644,7 @@ namespace FlaxEngine
/// </summary>
public void Invert()
{
Invert(ref this, out this);
Invert(this, out this);
}
/// <summary>
@@ -652,7 +652,7 @@ namespace FlaxEngine
/// </summary>
public void Transpose()
{
Transpose(ref this, out this);
Transpose(this, out this);
}
/// <summary>
@@ -677,7 +677,7 @@ namespace FlaxEngine
/// </remarks>
public void Orthogonalize()
{
Orthogonalize(ref this, out this);
Orthogonalize(this, out this);
}
/// <summary>
@@ -704,7 +704,7 @@ namespace FlaxEngine
/// </remarks>
public void Orthonormalize()
{
Orthonormalize(ref this, out this);
Orthonormalize(this, out this);
}
/// <summary>
@@ -716,7 +716,7 @@ namespace FlaxEngine
{
Matrix temp = this;
temp.Transpose();
Orthonormalize(ref temp, out Q);
Orthonormalize(temp, out Q);
Q.Transpose();
R = new Matrix
@@ -744,7 +744,7 @@ namespace FlaxEngine
/// <param name="Q">When the method completes, contains the orthonormalized matrix of the decomposition.</param>
public void DecomposeLQ(out Matrix L, out Matrix Q)
{
Orthonormalize(ref this, out Q);
Orthonormalize(this, out Q);
L = new Matrix
{
@@ -772,7 +772,7 @@ namespace FlaxEngine
public void Decompose(out Transform transform)
{
Decompose(out transform.Scale, out Matrix3x3 rotationMatrix, out Float3 translation);
Quaternion.RotationMatrix(ref rotationMatrix, out transform.Orientation);
Quaternion.RotationMatrix(rotationMatrix, out transform.Orientation);
transform.Translation = translation;
}
@@ -842,7 +842,7 @@ namespace FlaxEngine
public void Decompose(out Float3 scale, out Quaternion rotation, out Float3 translation)
{
Decompose(out scale, out Matrix3x3 rotationMatrix, out translation);
Quaternion.RotationMatrix(ref rotationMatrix, out rotation);
Quaternion.RotationMatrix(rotationMatrix, out rotation);
}
/// <summary>
@@ -885,7 +885,7 @@ namespace FlaxEngine
M33 = M33 * invScale,
M44 = 1f
};
Quaternion.RotationMatrix(ref rotationMatrix, out rotation);
Quaternion.RotationMatrix(rotationMatrix, out rotation);
}
/// <summary>
@@ -989,7 +989,7 @@ namespace FlaxEngine
/// <param name="left">The first matrix to add.</param>
/// <param name="right">The second matrix to add.</param>
/// <param name="result">When the method completes, contains the sum of the two matrices.</param>
public static void Add(ref Matrix left, ref Matrix right, out Matrix result)
public static void Add(in Matrix left, in Matrix right, out Matrix result)
{
result.M11 = left.M11 + right.M11;
result.M12 = left.M12 + right.M12;
@@ -1017,7 +1017,7 @@ namespace FlaxEngine
/// <returns>The sum of the two matrices.</returns>
public static Matrix Add(Matrix left, Matrix right)
{
Add(ref left, ref right, out var result);
Add(left, right, out var result);
return result;
}
@@ -1027,7 +1027,7 @@ namespace FlaxEngine
/// <param name="left">The first matrix to subtract.</param>
/// <param name="right">The second matrix to subtract.</param>
/// <param name="result">When the method completes, contains the difference between the two matrices.</param>
public static void Subtract(ref Matrix left, ref Matrix right, out Matrix result)
public static void Subtract(in Matrix left, in Matrix right, out Matrix result)
{
result.M11 = left.M11 - right.M11;
result.M12 = left.M12 - right.M12;
@@ -1055,7 +1055,7 @@ namespace FlaxEngine
/// <returns>The difference between the two matrices.</returns>
public static Matrix Subtract(Matrix left, Matrix right)
{
Subtract(ref left, ref right, out var result);
Subtract(left, right, out var result);
return result;
}
@@ -1065,7 +1065,7 @@ namespace FlaxEngine
/// <param name="left">The matrix to scale.</param>
/// <param name="right">The amount by which to scale.</param>
/// <param name="result">When the method completes, contains the scaled matrix.</param>
public static void Multiply(ref Matrix left, float right, out Matrix result)
public static void Multiply(in Matrix left, float right, out Matrix result)
{
result.M11 = left.M11 * right;
result.M12 = left.M12 * right;
@@ -1093,7 +1093,7 @@ namespace FlaxEngine
/// <returns>The scaled matrix.</returns>
public static Matrix Multiply(Matrix left, float right)
{
Multiply(ref left, right, out var result);
Multiply(left, right, out var result);
return result;
}
@@ -1103,7 +1103,7 @@ namespace FlaxEngine
/// <param name="left">The first matrix to multiply.</param>
/// <param name="right">The second matrix to multiply.</param>
/// <param name="result">The product of the two matrices.</param>
public static void Multiply(ref Matrix left, ref Matrix right, out Matrix result)
public static void Multiply(in Matrix left, in Matrix right, out Matrix result)
{
result = new Matrix
{
@@ -1134,7 +1134,7 @@ namespace FlaxEngine
/// <returns>The product of the two matrices.</returns>
public static Matrix Multiply(Matrix left, Matrix right)
{
Multiply(ref left, ref right, out var result);
Multiply(left, right, out var result);
return result;
}
@@ -1144,7 +1144,7 @@ namespace FlaxEngine
/// <param name="left">The matrix to scale.</param>
/// <param name="right">The amount by which to scale.</param>
/// <param name="result">When the method completes, contains the scaled matrix.</param>
public static void Divide(ref Matrix left, float right, out Matrix result)
public static void Divide(in Matrix left, float right, out Matrix result)
{
float inv = 1.0f / right;
result.M11 = left.M11 * inv;
@@ -1173,7 +1173,7 @@ namespace FlaxEngine
/// <returns>The scaled matrix.</returns>
public static Matrix Divide(Matrix left, float right)
{
Divide(ref left, right, out var result);
Divide(left, right, out var result);
return result;
}
@@ -1183,7 +1183,7 @@ namespace FlaxEngine
/// <param name="left">The first matrix to divide.</param>
/// <param name="right">The second matrix to divide.</param>
/// <param name="result">When the method completes, contains the quotient of the two matrices.</param>
public static void Divide(ref Matrix left, ref Matrix right, out Matrix result)
public static void Divide(in Matrix left, in Matrix right, out Matrix result)
{
result.M11 = left.M11 / right.M11;
result.M12 = left.M12 / right.M12;
@@ -1211,7 +1211,7 @@ namespace FlaxEngine
/// <returns>The quotient of the two matrices.</returns>
public static Matrix Divide(Matrix left, Matrix right)
{
Divide(ref left, ref right, out var result);
Divide(left, right, out var result);
return result;
}
@@ -1222,7 +1222,7 @@ namespace FlaxEngine
/// <param name="exponent">The exponent to raise the matrix to.</param>
/// <param name="result">When the method completes, contains the exponential matrix.</param>
/// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="exponent" /> is negative.</exception>
public static void Exponent(ref Matrix value, int exponent, out Matrix result)
public static void Exponent(in Matrix value, int exponent, out Matrix result)
{
// Source: http://rosettacode.org
// Reference: http://rosettacode.org/wiki/Matrix-exponentiation_operator
@@ -1268,7 +1268,7 @@ namespace FlaxEngine
/// <exception cref="System.ArgumentOutOfRangeException">Thrown when the <paramref name="exponent" /> is negative.</exception>
public static Matrix Exponent(Matrix value, int exponent)
{
Exponent(ref value, exponent, out var result);
Exponent(value, exponent, out var result);
return result;
}
@@ -1277,7 +1277,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The matrix to be negated.</param>
/// <param name="result">When the method completes, contains the negated matrix.</param>
public static void Negate(ref Matrix value, out Matrix result)
public static void Negate(in Matrix value, out Matrix result)
{
result.M11 = -value.M11;
result.M12 = -value.M12;
@@ -1304,7 +1304,7 @@ namespace FlaxEngine
/// <returns>The negated matrix.</returns>
public static Matrix Negate(Matrix value)
{
Negate(ref value, out var result);
Negate(value, out var result);
return result;
}
@@ -1319,7 +1319,7 @@ namespace FlaxEngine
/// Passing <paramref name="amount" /> a value of 0 will cause <paramref name="start" /> to be returned; a value of 1
/// will cause <paramref name="end" /> to be returned.
/// </remarks>
public static void Lerp(ref Matrix start, ref Matrix end, float amount, out Matrix result)
public static void Lerp(in Matrix start, in Matrix end, float amount, out Matrix result)
{
result.M11 = Mathf.Lerp(start.M11, end.M11, amount);
result.M12 = Mathf.Lerp(start.M12, end.M12, amount);
@@ -1352,7 +1352,7 @@ namespace FlaxEngine
/// </remarks>
public static Matrix Lerp(Matrix start, Matrix end, float amount)
{
Lerp(ref start, ref end, amount, out var result);
Lerp(start, end, amount, out var result);
return result;
}
@@ -1363,10 +1363,10 @@ namespace FlaxEngine
/// <param name="end">End matrix.</param>
/// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end" />.</param>
/// <param name="result">When the method completes, contains the cubic interpolation of the two matrices.</param>
public static void SmoothStep(ref Matrix start, ref Matrix end, float amount, out Matrix result)
public static void SmoothStep(in Matrix start, in Matrix end, float amount, out Matrix result)
{
amount = Mathf.SmoothStep(amount);
Lerp(ref start, ref end, amount, out result);
Lerp(start, end, amount, out result);
}
/// <summary>
@@ -1378,7 +1378,7 @@ namespace FlaxEngine
/// <returns>The cubic interpolation of the two matrices.</returns>
public static Matrix SmoothStep(Matrix start, Matrix end, float amount)
{
SmoothStep(ref start, ref end, amount, out var result);
SmoothStep(start, end, amount, out var result);
return result;
}
@@ -1387,7 +1387,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The matrix whose transpose is to be calculated.</param>
/// <param name="result">When the method completes, contains the transpose of the specified matrix.</param>
public static void Transpose(ref Matrix value, out Matrix result)
public static void Transpose(in Matrix value, out Matrix result)
{
result = new Matrix
{
@@ -1415,7 +1415,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The matrix whose transpose is to be calculated.</param>
/// <param name="result">When the method completes, contains the transpose of the specified matrix.</param>
public static void TransposeByRef(ref Matrix value, ref Matrix result)
public static void TransposeByRef(in Matrix value, out Matrix result)
{
result.M11 = value.M11;
result.M12 = value.M21;
@@ -1442,7 +1442,7 @@ namespace FlaxEngine
/// <returns>The transpose of the specified matrix.</returns>
public static Matrix Transpose(Matrix value)
{
Transpose(ref value, out var result);
Transpose(value, out var result);
return result;
}
@@ -1451,7 +1451,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The matrix whose inverse is to be calculated.</param>
/// <param name="result">When the method completes, contains the inverse of the specified matrix.</param>
public static void Invert(ref Matrix value, out Matrix result)
public static void Invert(in Matrix value, out Matrix result)
{
float b0 = value.M31 * value.M42 - value.M32 * value.M41;
float b1 = value.M31 * value.M43 - value.M33 * value.M41;
@@ -1547,7 +1547,7 @@ namespace FlaxEngine
/// input and than transpose the output.
/// </para>
/// </remarks>
public static void Orthogonalize(ref Matrix value, out Matrix result)
public static void Orthogonalize(in Matrix value, out Matrix result)
{
//Uses the modified Gram-Schmidt process.
//q1 = m1
@@ -1592,7 +1592,7 @@ namespace FlaxEngine
/// </remarks>
public static Matrix Orthogonalize(Matrix value)
{
Orthogonalize(ref value, out var result);
Orthogonalize(value, out var result);
return result;
}
@@ -1620,7 +1620,7 @@ namespace FlaxEngine
/// input and than transpose the output.
/// </para>
/// </remarks>
public static void Orthonormalize(ref Matrix value, out Matrix result)
public static void Orthonormalize(in Matrix value, out Matrix result)
{
//Uses the modified Gram-Schmidt process.
//Because we are making unit vectors, we can optimize the math for orthonormalization
@@ -1674,7 +1674,7 @@ namespace FlaxEngine
/// </remarks>
public static Matrix Orthonormalize(Matrix value)
{
Orthonormalize(ref value, out var result);
Orthonormalize(value, out var result);
return result;
}
@@ -1689,7 +1689,7 @@ namespace FlaxEngine
/// of linear equations, than this often means that either no solution exists or an infinite
/// number of solutions exist.
/// </remarks>
public static void UpperTriangularForm(ref Matrix value, out Matrix result)
public static void UpperTriangularForm(in Matrix value, out Matrix result)
{
// Adapted from the row echelon code
result = value;
@@ -1749,7 +1749,7 @@ namespace FlaxEngine
/// </remarks>
public static Matrix UpperTriangularForm(Matrix value)
{
UpperTriangularForm(ref value, out var result);
UpperTriangularForm(value, out var result);
return result;
}
@@ -1764,11 +1764,11 @@ namespace FlaxEngine
/// of linear equations, than this often means that either no solution exists or an infinite
/// number of solutions exist.
/// </remarks>
public static void LowerTriangularForm(ref Matrix value, out Matrix result)
public static void LowerTriangularForm(in Matrix value, out Matrix result)
{
// Adapted from the row echelon code
Matrix temp = value;
Transpose(ref temp, out result);
Transpose(temp, out result);
var lead = 0;
var rowCount = 4;
@@ -1812,7 +1812,7 @@ namespace FlaxEngine
lead++;
}
Transpose(ref result, out result);
Transpose(result, out result);
}
/// <summary>
@@ -1828,7 +1828,7 @@ namespace FlaxEngine
/// </remarks>
public static Matrix LowerTriangularForm(Matrix value)
{
LowerTriangularForm(ref value, out var result);
LowerTriangularForm(value, out var result);
return result;
}
@@ -1837,7 +1837,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The matrix to put into row echelon form.</param>
/// <param name="result">When the method completes, contains the row echelon form of the matrix.</param>
public static void RowEchelonForm(ref Matrix value, out Matrix result)
public static void RowEchelonForm(in Matrix value, out Matrix result)
{
// Source: Wikipedia pseudo code
// Reference: http://en.wikipedia.org/wiki/Row_echelon_form#Pseudocode
@@ -1897,7 +1897,7 @@ namespace FlaxEngine
/// <returns>When the method completes, contains the row echelon form of the matrix.</returns>
public static Matrix RowEchelonForm(Matrix value)
{
RowEchelonForm(ref value, out var result);
RowEchelonForm(value, out var result);
return result;
}
@@ -1924,7 +1924,7 @@ namespace FlaxEngine
/// to analyze both the input and the result to determine if a solution really exists.
/// </para>
/// </remarks>
public static void ReducedRowEchelonForm(ref Matrix value, ref Float4 augment, out Matrix result, out Float4 augmentResult)
public static void ReducedRowEchelonForm(in Matrix value, in Float4 augment, out Matrix result, out Float4 augmentResult)
{
// Source: http://rosettacode.org
// Reference: http://rosettacode.org/wiki/Reduced_row_echelon_form
@@ -2037,7 +2037,7 @@ namespace FlaxEngine
/// <param name="cameraUpFloat">The up vector of the camera.</param>
/// <param name="cameraForwardFloat">The forward vector of the camera.</param>
/// <param name="result">When the method completes, contains the created billboard matrix.</param>
public static void Billboard(ref Float3 objectPosition, ref Float3 cameraPosition, ref Float3 cameraUpFloat, ref Float3 cameraForwardFloat, out Matrix result)
public static void Billboard(in Float3 objectPosition, in Float3 cameraPosition, in Float3 cameraUpFloat, in Float3 cameraForwardFloat, out Matrix result)
{
Float3 difference = cameraPosition - objectPosition;
@@ -2047,9 +2047,9 @@ namespace FlaxEngine
else
difference *= (float)(1.0 / Math.Sqrt(lengthSq));
Float3.Cross(ref cameraUpFloat, ref difference, out var crossed);
Float3.Cross(cameraUpFloat, difference, out var crossed);
crossed.Normalize();
Float3.Cross(ref difference, ref crossed, out var final);
Float3.Cross(difference, crossed, out var final);
result.M11 = crossed.X;
result.M12 = crossed.Y;
@@ -2079,7 +2079,7 @@ namespace FlaxEngine
/// <returns>The created billboard matrix.</returns>
public static Matrix Billboard(Float3 objectPosition, Float3 cameraPosition, Float3 cameraUpFloat, Float3 cameraForwardFloat)
{
Billboard(ref objectPosition, ref cameraPosition, ref cameraUpFloat, ref cameraForwardFloat, out var result);
Billboard(objectPosition, cameraPosition, cameraUpFloat, cameraForwardFloat, out var result);
return result;
}
@@ -2090,13 +2090,13 @@ namespace FlaxEngine
/// <param name="target">The camera look-at target.</param>
/// <param name="up">The camera's up vector.</param>
/// <param name="result">When the method completes, contains the created look-at matrix.</param>
public static void LookAt(ref Float3 eye, ref Float3 target, ref Float3 up, out Matrix result)
public static void LookAt(in Float3 eye, in Float3 target, in Float3 up, out Matrix result)
{
Float3.Subtract(ref target, ref eye, out var zaxis);
Float3.Subtract(target, eye, out var zaxis);
zaxis.Normalize();
Float3.Cross(ref up, ref zaxis, out var xaxis);
Float3.Cross(up, zaxis, out var xaxis);
xaxis.Normalize();
Float3.Cross(ref zaxis, ref xaxis, out var yaxis);
Float3.Cross(zaxis, xaxis, out var yaxis);
result = Identity;
result.M11 = xaxis.X;
@@ -2109,9 +2109,9 @@ namespace FlaxEngine
result.M23 = zaxis.Y;
result.M33 = zaxis.Z;
Float3.Dot(ref xaxis, ref eye, out result.M41);
Float3.Dot(ref yaxis, ref eye, out result.M42);
Float3.Dot(ref zaxis, ref eye, out result.M43);
Float3.Dot(xaxis, eye, out result.M41);
Float3.Dot(yaxis, eye, out result.M42);
Float3.Dot(zaxis, eye, out result.M43);
result.M41 = -result.M41;
result.M42 = -result.M42;
@@ -2127,7 +2127,7 @@ namespace FlaxEngine
/// <returns>The created look-at matrix.</returns>
public static Matrix LookAt(Float3 eye, Float3 target, Float3 up)
{
LookAt(ref eye, ref target, ref up, out var result);
LookAt(eye, target, up, out var result);
return result;
}
@@ -2309,7 +2309,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="scale">Scaling factor for all three axes.</param>
/// <param name="result">When the method completes, contains the created scaling matrix.</param>
public static void Scaling(ref Float3 scale, out Matrix result)
public static void Scaling(in Float3 scale, out Matrix result)
{
Scaling(scale.X, scale.Y, scale.Z, out result);
}
@@ -2321,7 +2321,7 @@ namespace FlaxEngine
/// <returns>The created scaling matrix.</returns>
public static Matrix Scaling(Float3 scale)
{
Scaling(ref scale, out var result);
Scaling(scale, out var result);
return result;
}
@@ -2480,7 +2480,7 @@ namespace FlaxEngine
/// <param name="axis">The axis around which to rotate. This parameter is assumed to be normalized.</param>
/// <param name="angle">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.</param>
/// <param name="result">When the method completes, contains the created rotation matrix.</param>
public static void RotationAxis(ref Float3 axis, float angle, out Matrix result)
public static void RotationAxis(in Float3 axis, float angle, out Matrix result)
{
float x = axis.X;
float y = axis.Y;
@@ -2514,7 +2514,7 @@ namespace FlaxEngine
/// <returns>The created rotation matrix.</returns>
public static Matrix RotationAxis(Float3 axis, float angle)
{
RotationAxis(ref axis, angle, out var result);
RotationAxis(axis, angle, out var result);
return result;
}
@@ -2523,7 +2523,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="rotation">The quaternion to use to build the matrix.</param>
/// <param name="result">The created rotation matrix.</param>
public static void RotationQuaternion(ref Quaternion rotation, out Matrix result)
public static void RotationQuaternion(in Quaternion rotation, out Matrix result)
{
float xx = rotation.X * rotation.X;
float yy = rotation.Y * rotation.Y;
@@ -2554,7 +2554,7 @@ namespace FlaxEngine
/// <returns>The created rotation matrix.</returns>
public static Matrix RotationQuaternion(Quaternion rotation)
{
RotationQuaternion(ref rotation, out var result);
RotationQuaternion(rotation, out var result);
return result;
}
@@ -2568,7 +2568,7 @@ namespace FlaxEngine
public static void RotationYawPitchRoll(float yaw, float pitch, float roll, out Matrix result)
{
Quaternion.RotationYawPitchRoll(yaw, pitch, roll, out var quaternion);
RotationQuaternion(ref quaternion, out result);
RotationQuaternion(quaternion, out result);
}
/// <summary>
@@ -2589,7 +2589,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The offset for all three coordinate planes.</param>
/// <param name="result">When the method completes, contains the created translation matrix.</param>
public static void Translation(ref Float3 value, out Matrix result)
public static void Translation(in Float3 value, out Matrix result)
{
Translation(value.X, value.Y, value.Z, out result);
}
@@ -2601,7 +2601,7 @@ namespace FlaxEngine
/// <returns>The created translation matrix.</returns>
public static Matrix Translation(Float3 value)
{
Translation(ref value, out var result);
Translation(value, out var result);
return result;
}
@@ -2643,15 +2643,15 @@ namespace FlaxEngine
/// <param name="rotationVec">The rotation vector</param>
/// <param name="transVec">The translation vector</param>
/// <param name="matrix">Contains the created skew/shear matrix. </param>
public static void Skew(float angle, ref Float3 rotationVec, ref Float3 transVec, out Matrix matrix)
public static void Skew(float angle, in Float3 rotationVec, in Float3 transVec, out Matrix matrix)
{
// http://elckerlyc.ewi.utwente.nl/browser/Elckerlyc/Hmi/HmiMath/src/hmi/math/Mat3f.java
var MINIMAL_SKEW_ANGLE = 0.000001f;
Float3 e0 = rotationVec;
Float3 e1 = Float3.Normalize(transVec);
Float3.Dot(ref rotationVec, ref e1, out var rv1);
Float3.Dot(rotationVec, e1, out var rv1);
e0 += rv1 * e1;
Float3.Dot(ref rotationVec, ref e0, out var rv0);
Float3.Dot(rotationVec, e0, out var rv0);
var cosA = (float)Math.Cos(angle);
var sinA = (float)Math.Sin(angle);
float rr0 = rv0 * cosA - rv1 * sinA;
@@ -2678,7 +2678,7 @@ namespace FlaxEngine
/// <param name="rotation">The rotation of the transformation.</param>
/// <param name="translation">The translation factor of the transformation.</param>
/// <param name="result">When the method completes, contains the created affine transformation matrix.</param>
public static void AffineTransformation(float scaling, ref Quaternion rotation, ref Float3 translation, out Matrix result)
public static void AffineTransformation(float scaling, in Quaternion rotation, in Float3 translation, out Matrix result)
{
result = Scaling(scaling) * RotationQuaternion(rotation) * Translation(translation);
}
@@ -2692,7 +2692,7 @@ namespace FlaxEngine
/// <returns>The created affine transformation matrix.</returns>
public static Matrix AffineTransformation(float scaling, Quaternion rotation, Float3 translation)
{
AffineTransformation(scaling, ref rotation, ref translation, out var result);
AffineTransformation(scaling, rotation, translation, out var result);
return result;
}
@@ -2704,7 +2704,7 @@ namespace FlaxEngine
/// <param name="rotation">The rotation of the transformation.</param>
/// <param name="translation">The translation factor of the transformation.</param>
/// <param name="result">When the method completes, contains the created affine transformation matrix.</param>
public static void AffineTransformation(float scaling, ref Float3 rotationCenter, ref Quaternion rotation, ref Float3 translation, out Matrix result)
public static void AffineTransformation(float scaling, in Float3 rotationCenter, in Quaternion rotation, in Float3 translation, out Matrix result)
{
result = Scaling(scaling) * Translation(-rotationCenter) * RotationQuaternion(rotation) *
Translation(rotationCenter) * Translation(translation);
@@ -2720,7 +2720,7 @@ namespace FlaxEngine
/// <returns>The created affine transformation matrix.</returns>
public static Matrix AffineTransformation(float scaling, Float3 rotationCenter, Quaternion rotation, Float3 translation)
{
AffineTransformation(scaling, ref rotationCenter, ref rotation, ref translation, out var result);
AffineTransformation(scaling, rotationCenter, rotation, translation, out var result);
return result;
}
@@ -2731,7 +2731,7 @@ namespace FlaxEngine
/// <param name="rotation">The rotation of the transformation.</param>
/// <param name="translation">The translation factor of the transformation.</param>
/// <param name="result">When the method completes, contains the created affine transformation matrix.</param>
public static void AffineTransformation2D(float scaling, float rotation, ref Float2 translation, out Matrix result)
public static void AffineTransformation2D(float scaling, float rotation, in Float2 translation, out Matrix result)
{
result = Scaling(scaling, scaling, 1.0f) * RotationZ(rotation) * Translation((Float3)translation);
}
@@ -2745,7 +2745,7 @@ namespace FlaxEngine
/// <returns>The created affine transformation matrix.</returns>
public static Matrix AffineTransformation2D(float scaling, float rotation, Float2 translation)
{
AffineTransformation2D(scaling, rotation, ref translation, out var result);
AffineTransformation2D(scaling, rotation, translation, out var result);
return result;
}
@@ -2757,7 +2757,7 @@ namespace FlaxEngine
/// <param name="rotation">The rotation of the transformation.</param>
/// <param name="translation">The translation factor of the transformation.</param>
/// <param name="result">When the method completes, contains the created affine transformation matrix.</param>
public static void AffineTransformation2D(float scaling, ref Float2 rotationCenter, float rotation, ref Float2 translation, out Matrix result)
public static void AffineTransformation2D(float scaling, in Float2 rotationCenter, float rotation, in Float2 translation, out Matrix result)
{
result = Scaling(scaling, scaling, 1.0f) * Translation((Float3)(-rotationCenter)) * RotationZ(rotation) * Translation((Float3)rotationCenter) * Translation((Float3)translation);
}
@@ -2772,7 +2772,7 @@ namespace FlaxEngine
/// <returns>The created affine transformation matrix.</returns>
public static Matrix AffineTransformation2D(float scaling, Float2 rotationCenter, float rotation, Float2 translation)
{
AffineTransformation2D(scaling, ref rotationCenter, rotation, ref translation, out var result);
AffineTransformation2D(scaling, rotationCenter, rotation, translation, out var result);
return result;
}
@@ -2785,7 +2785,7 @@ namespace FlaxEngine
/// <returns>The created transformation matrix.</returns>
public static Matrix Transformation(Float3 scaling, Quaternion rotation, Float3 translation)
{
Transformation(ref scaling, ref rotation, ref translation, out var result);
Transformation(scaling, rotation, translation, out var result);
return result;
}
@@ -2796,7 +2796,7 @@ namespace FlaxEngine
/// <param name="rotation">Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.</param>
/// <param name="scaling">The scaling.</param>
/// <param name="result">When the method completes, contains the created transformation matrix.</param>
public static void Transformation(ref Float3 scaling, ref Quaternion rotation, ref Float3 translation, out Matrix result)
public static void Transformation(in Float3 scaling, in Quaternion rotation, in Float3 translation, out Matrix result)
{
// Equivalent to:
//result =
@@ -2858,7 +2858,7 @@ namespace FlaxEngine
/// <param name="rotation">The rotation of the transformation.</param>
/// <param name="translation">The translation factor of the transformation.</param>
/// <param name="result">When the method completes, contains the created transformation matrix.</param>
public static void Transformation(ref Float3 scalingCenter, ref Quaternion scalingRotation, ref Float3 scaling, ref Float3 rotationCenter, ref Quaternion rotation, ref Float3 translation, out Matrix result)
public static void Transformation(in Float3 scalingCenter, in Quaternion scalingRotation, in Float3 scaling, in Float3 rotationCenter, in Quaternion rotation, in Float3 translation, out Matrix result)
{
Matrix sr = RotationQuaternion(scalingRotation);
result = Translation(-scalingCenter) * Transpose(sr) * Scaling(scaling) * sr * Translation(scalingCenter) * Translation(-rotationCenter) * RotationQuaternion(rotation) * Translation(rotationCenter) * Translation(translation);
@@ -2876,7 +2876,7 @@ namespace FlaxEngine
/// <returns>The created transformation matrix.</returns>
public static Matrix Transformation(Float3 scalingCenter, Quaternion scalingRotation, Float3 scaling, Float3 rotationCenter, Quaternion rotation, Float3 translation)
{
Transformation(ref scalingCenter, ref scalingRotation, ref scaling, ref rotationCenter, ref rotation, ref translation, out var result);
Transformation(scalingCenter, scalingRotation, scaling, rotationCenter, rotation, translation, out var result);
return result;
}
@@ -2890,7 +2890,7 @@ namespace FlaxEngine
/// <param name="rotation">The rotation of the transformation.</param>
/// <param name="translation">The translation factor of the transformation.</param>
/// <param name="result">When the method completes, contains the created transformation matrix.</param>
public static void Transformation2D(ref Float2 scalingCenter, float scalingRotation, ref Float2 scaling, ref Float2 rotationCenter, float rotation, ref Float2 translation, out Matrix result)
public static void Transformation2D(in Float2 scalingCenter, float scalingRotation, in Float2 scaling, in Float2 rotationCenter, float rotation, in Float2 translation, out Matrix result)
{
result = Translation((Float3)(-scalingCenter)) * RotationZ(-scalingRotation) * Scaling((Float3)scaling) * RotationZ(scalingRotation) * Translation((Float3)scalingCenter) * Translation((Float3)(-rotationCenter)) * RotationZ(rotation) * Translation((Float3)rotationCenter) * Translation((Float3)translation);
result.M33 = 1f;
@@ -2909,7 +2909,7 @@ namespace FlaxEngine
/// <returns>The created transformation matrix.</returns>
public static Matrix Transformation2D(Float2 scalingCenter, float scalingRotation, Float2 scaling, Float2 rotationCenter, float rotation, Float2 translation)
{
Transformation2D(ref scalingCenter, scalingRotation, ref scaling, ref rotationCenter, rotation, ref translation, out var result);
Transformation2D(scalingCenter, scalingRotation, scaling, rotationCenter, rotation, translation, out var result);
return result;
}
@@ -2922,7 +2922,7 @@ namespace FlaxEngine
/// <returns>The created world matrix of given transformation world</returns>
public static Matrix CreateWorld(Float3 position, Float3 forward, Float3 up)
{
CreateWorld(ref position, ref forward, ref up, out var result);
CreateWorld(position, forward, up, out var result);
return result;
}
@@ -2933,13 +2933,13 @@ namespace FlaxEngine
/// <param name="forward">The forward direction of the object.</param>
/// <param name="up">The upward direction of the object; usually [0, 1, 0].</param>
/// <param name="result">>When the method completes, contains the created world matrix of given transformation world.</param>
public static void CreateWorld(ref Float3 position, ref Float3 forward, ref Float3 up, out Matrix result)
public static void CreateWorld(in Float3 position, in Float3 forward, in Float3 up, out Matrix result)
{
Float3.Normalize(ref forward, out var vector3);
Float3.Normalize(forward, out var vector3);
vector3 = vector3.Negative;
Float3 vector31 = Float3.Cross(up, vector3);
vector31.Normalize();
Float3.Cross(ref vector3, ref vector31, out var vector32);
Float3.Cross(vector3, vector31, out var vector32);
result = new Matrix
(
vector31.X,
@@ -2969,7 +2969,7 @@ namespace FlaxEngine
/// <returns>The created rotation matrix.</returns>
public static Matrix CreateFromAxisAngle(Float3 axis, float angle)
{
CreateFromAxisAngle(ref axis, angle, out var result);
CreateFromAxisAngle(axis, angle, out var result);
return result;
}
@@ -2979,7 +2979,7 @@ namespace FlaxEngine
/// <param name="axis">The axis to rotate around.</param>
/// <param name="angle">The angle to rotate around the vector.</param>
/// <param name="result">When the method completes, contains the created rotation matrix.</param>
public static void CreateFromAxisAngle(ref Float3 axis, float angle, out Matrix result)
public static void CreateFromAxisAngle(in Float3 axis, float angle, out Matrix result)
{
float x = axis.X;
float y = axis.Y;
@@ -3021,7 +3021,7 @@ namespace FlaxEngine
/// <returns>The sum of the two matrices.</returns>
public static Matrix operator +(Matrix left, Matrix right)
{
Add(ref left, ref right, out var result);
Add(left, right, out var result);
return result;
}
@@ -3043,7 +3043,7 @@ namespace FlaxEngine
/// <returns>The difference between the two matrices.</returns>
public static Matrix operator -(Matrix left, Matrix right)
{
Subtract(ref left, ref right, out var result);
Subtract(left, right, out var result);
return result;
}
@@ -3054,7 +3054,7 @@ namespace FlaxEngine
/// <returns>The negated matrix.</returns>
public static Matrix operator -(Matrix value)
{
Negate(ref value, out var result);
Negate(value, out var result);
return result;
}
@@ -3066,7 +3066,7 @@ namespace FlaxEngine
/// <returns>The scaled matrix.</returns>
public static Matrix operator *(float left, Matrix right)
{
Multiply(ref right, left, out var result);
Multiply(right, left, out var result);
return result;
}
@@ -3078,7 +3078,7 @@ namespace FlaxEngine
/// <returns>The scaled matrix.</returns>
public static Matrix operator *(Matrix left, float right)
{
Multiply(ref left, right, out var result);
Multiply(left, right, out var result);
return result;
}
@@ -3090,7 +3090,7 @@ namespace FlaxEngine
/// <returns>The product of the two matrices.</returns>
public static Matrix operator *(Matrix left, Matrix right)
{
Multiply(ref left, ref right, out var result);
Multiply(left, right, out var result);
return result;
}
@@ -3102,7 +3102,7 @@ namespace FlaxEngine
/// <returns>The scaled matrix.</returns>
public static Matrix operator /(Matrix left, float right)
{
Divide(ref left, right, out var result);
Divide(left, right, out var result);
return result;
}
@@ -3114,7 +3114,7 @@ namespace FlaxEngine
/// <returns>The quotient of the two matrices.</returns>
public static Matrix operator /(Matrix left, Matrix right)
{
Divide(ref left, ref right, out var result);
Divide(left, right, out var result);
return result;
}
@@ -3127,7 +3127,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Matrix left, Matrix right)
{
return left.Equals(ref right);
return left.Equals(right);
}
/// <summary>
@@ -3139,7 +3139,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Matrix left, Matrix right)
{
return !left.Equals(ref right);
return !left.Equals(right);
}
/// <summary>
@@ -3234,7 +3234,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="other">The <see cref="Matrix" /> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Matrix" /> is equal to this instance; otherwise, <c>false</c>.</returns>
public bool Equals(ref Matrix other)
public bool Equals(in Matrix other)
{
return other.M11 == M11 &&
other.M12 == M12 &&
@@ -3262,7 +3262,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Matrix other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
@@ -3272,7 +3272,7 @@ namespace FlaxEngine
/// <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)
{
return value is Matrix other && Equals(ref other);
return value is Matrix other && Equals(other);
}
}
}

View File

@@ -292,7 +292,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="scale">The scale vector.</param>
/// <param name="result">The result.</param>
public static void Scale(ref Float2 scale, out Matrix2x2 result)
public static void Scale(in Float2 scale, out Matrix2x2 result)
{
result = new Matrix2x2(scale.X, 0, 0, scale.Y);
}
@@ -304,7 +304,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="shearAngles">The shear angles.</param>
/// <param name="result">The result.</param>
public static void Shear(ref Float2 shearAngles, out Matrix2x2 result)
public static void Shear(in Float2 shearAngles, out Matrix2x2 result)
{
float shearX = shearAngles.X == 0 ? 0 : (1.0f / Mathf.Tan(Mathf.DegreesToRadians * (90 - Mathf.Clamp(shearAngles.X, -89.0f, 89.0f))));
float shearY = shearAngles.Y == 0 ? 0 : (1.0f / Mathf.Tan(Mathf.DegreesToRadians * (90 - Mathf.Clamp(shearAngles.Y, -89.0f, 89.0f))));
@@ -329,7 +329,7 @@ namespace FlaxEngine
/// <param name="vector">The vector.</param>
/// <param name="matrix">The matrix.</param>
/// <param name="result">The result.</param>
public static void Transform(ref Float2 vector, ref Matrix2x2 matrix, out Float2 result)
public static void Transform(in Float2 vector, in Matrix2x2 matrix, out Float2 result)
{
result = new Float2(vector.X * matrix.M11 + vector.Y * matrix.M21, vector.X * matrix.M12 + vector.Y * matrix.M22);
}
@@ -340,7 +340,7 @@ namespace FlaxEngine
/// <param name="left">The first Matrix2x2 to multiply.</param>
/// <param name="right">The second Matrix2x2 to multiply.</param>
/// <param name="result">The product of the two matrices.</param>
public static void Multiply(ref Matrix2x2 left, ref Matrix2x2 right, out Matrix2x2 result)
public static void Multiply(in Matrix2x2 left, in Matrix2x2 right, out Matrix2x2 result)
{
result = new Matrix2x2((left.M11 * right.M11) + (left.M12 * right.M21), (left.M11 * right.M12) + (left.M12 * right.M22), (left.M21 * right.M11) + (left.M22 * right.M21), (left.M21 * right.M12) + (left.M22 * right.M22));
}
@@ -350,7 +350,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="value">The Matrix2x2 whose inverse is to be calculated.</param>
/// <param name="result">When the method completes, contains the inverse of the specified Matrix2x2.</param>
public static void Invert(ref Matrix2x2 value, out Matrix2x2 result)
public static void Invert(in Matrix2x2 value, out Matrix2x2 result)
{
float invDet = value.InverseDeterminant();
result = new Matrix2x2(value.M22 * invDet, -value.M12 * invDet, -value.M21 * invDet, value.M11 * invDet);
@@ -365,7 +365,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Matrix2x2 left, Matrix2x2 right)
{
return left.Equals(ref right);
return left.Equals(in right);
}
/// <summary>
@@ -377,7 +377,7 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Matrix2x2 left, Matrix2x2 right)
{
return !left.Equals(ref right);
return !left.Equals(in right);
}
/// <summary>
@@ -481,7 +481,7 @@ namespace FlaxEngine
/// </summary>
/// <param name="other">The <see cref="Matrix2x2"/> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="Matrix2x2"/> is equal to this instance; otherwise, <c>false</c>.</returns>
public bool Equals(ref Matrix2x2 other)
public bool Equals(in Matrix2x2 other)
{
return M11 == other.M11 && M12 == other.M12 && M21 == other.M21 && M22 == other.M22;
}
@@ -494,15 +494,15 @@ namespace FlaxEngine
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Matrix2x2 other)
{
return Equals(ref other);
return Equals(in other);
}
/// <summary>
/// Determines whether the specified <see cref="Matrix2x2"/> are equal.
/// </summary>
public static bool Equals(ref Matrix2x2 a, ref Matrix2x2 b)
public static bool Equals(in Matrix2x2 a, in Matrix2x2 b)
{
return a.Equals(ref b);
return a.Equals(in b);
}
/// <summary>
@@ -512,7 +512,7 @@ namespace FlaxEngine
/// <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)
{
return value is Matrix2x2 other && Equals(ref other);
return value is Matrix2x2 other && Equals(in other);
}
}
}

Some files were not shown because too many files have changed in this diff Show More