diff --git a/OpenRA.Game/Graphics/ModelRenderer.cs b/OpenRA.Game/Graphics/ModelRenderer.cs index 4d14775e1d..25db339089 100644 --- a/OpenRA.Game/Graphics/ModelRenderer.cs +++ b/OpenRA.Game/Graphics/ModelRenderer.cs @@ -79,8 +79,8 @@ namespace OpenRA.Graphics } public ModelRenderProxy RenderAsync( - WorldRenderer wr, IEnumerable models, WRot camera, float scale, - float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, + WorldRenderer wr, IEnumerable models, in WRot camera, float scale, + float[] groundNormal, in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, PaletteReference color, PaletteReference normals, PaletteReference shadowPalette) { if (!isInFrame) diff --git a/OpenRA.Game/WRot.cs b/OpenRA.Game/WRot.cs index cf79184638..3a129db9ea 100644 --- a/OpenRA.Game/WRot.cs +++ b/OpenRA.Game/WRot.cs @@ -16,7 +16,7 @@ namespace OpenRA /// /// 3d World rotation. /// - public struct WRot : IEquatable + public readonly struct WRot : IEquatable { // The Euler angle representation is a lot more intuitive for public use public readonly WAngle Roll, Pitch, Yaw; @@ -84,11 +84,11 @@ namespace OpenRA public static WRot FromFacing(int facing) { return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing)); } public static WRot FromYaw(WAngle yaw) { return new WRot(WAngle.Zero, WAngle.Zero, yaw); } - public static WRot operator +(WRot a, WRot b) { return new WRot(a.Roll + b.Roll, a.Pitch + b.Pitch, a.Yaw + b.Yaw); } - public static WRot operator -(WRot a, WRot b) { return new WRot(a.Roll - b.Roll, a.Pitch - b.Pitch, a.Yaw - b.Yaw); } - public static WRot operator -(WRot a) { return new WRot(-a.x, -a.y, -a.z, a.w, -a.Roll, -a.Pitch, -a.Yaw); } + public static WRot operator +(in WRot a, in WRot b) { return new WRot(a.Roll + b.Roll, a.Pitch + b.Pitch, a.Yaw + b.Yaw); } + public static WRot operator -(in WRot a, in WRot b) { return new WRot(a.Roll - b.Roll, a.Pitch - b.Pitch, a.Yaw - b.Yaw); } + public static WRot operator -(in WRot a) { return new WRot(-a.x, -a.y, -a.z, a.w, -a.Roll, -a.Pitch, -a.Yaw); } - public WRot Rotate(WRot rot) + public WRot Rotate(in WRot rot) { if (this == None) return rot; @@ -104,12 +104,12 @@ namespace OpenRA return new WRot((int)rx, (int)ry, (int)rz, (int)rw); } - public static bool operator ==(WRot me, WRot other) + public static bool operator ==(in WRot me, in WRot other) { return me.Roll == other.Roll && me.Pitch == other.Pitch && me.Yaw == other.Yaw; } - public static bool operator !=(WRot me, WRot other) { return !(me == other); } + public static bool operator !=(in WRot me, in WRot other) { return !(me == other); } public WRot WithRoll(WAngle roll) { diff --git a/OpenRA.Game/WVec.cs b/OpenRA.Game/WVec.cs index 1a449d70a0..82269111ca 100644 --- a/OpenRA.Game/WVec.cs +++ b/OpenRA.Game/WVec.cs @@ -44,7 +44,7 @@ namespace OpenRA public long VerticalLengthSquared { get { return (long)Z * Z; } } public int VerticalLength { get { return (int)Exts.ISqrt(VerticalLengthSquared); } } - public WVec Rotate(WRot rot) + public WVec Rotate(in WRot rot) { rot.AsMatrix(out var mtx); return Rotate(ref mtx); diff --git a/OpenRA.Mods.Common/Graphics/ModelRenderable.cs b/OpenRA.Mods.Common/Graphics/ModelRenderable.cs index 5a59f454ea..1b34236543 100644 --- a/OpenRA.Mods.Common/Graphics/ModelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/ModelRenderable.cs @@ -33,8 +33,8 @@ namespace OpenRA.Mods.Common.Graphics readonly float3 tint; public ModelRenderable( - IEnumerable models, WPos pos, int zOffset, WRot camera, float scale, - WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, + IEnumerable models, WPos pos, int zOffset, in WRot camera, float scale, + in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, PaletteReference color, PaletteReference normals, PaletteReference shadow) : this(models, pos, zOffset, camera, scale, lightSource, lightAmbientColor, lightDiffuseColor, @@ -42,8 +42,8 @@ namespace OpenRA.Mods.Common.Graphics float3.Ones) { } public ModelRenderable( - IEnumerable models, WPos pos, int zOffset, WRot camera, float scale, - WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, + IEnumerable models, WPos pos, int zOffset, in WRot camera, float scale, + in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, PaletteReference color, PaletteReference normals, PaletteReference shadow, float3 tint) { diff --git a/OpenRA.Mods.Common/Graphics/UIModelRenderable.cs b/OpenRA.Mods.Common/Graphics/UIModelRenderable.cs index d39b8fad4c..649d4d6d4f 100644 --- a/OpenRA.Mods.Common/Graphics/UIModelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/UIModelRenderable.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Graphics public UIModelRenderable( IEnumerable models, WPos effectiveWorldPos, int2 screenPos, int zOffset, - WRot camera, float scale, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, + in WRot camera, float scale, in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor, PaletteReference color, PaletteReference normals, PaletteReference shadow) { this.models = models; diff --git a/OpenRA.Mods.Common/Traits/BodyOrientation.cs b/OpenRA.Mods.Common/Traits/BodyOrientation.cs index b4589b224f..2a7071644b 100644 --- a/OpenRA.Mods.Common/Traits/BodyOrientation.cs +++ b/OpenRA.Mods.Common/Traits/BodyOrientation.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits return new WVec(vec.Y, -CameraPitch.Sin() * vec.X / 1024, vec.Z); } - public WRot QuantizeOrientation(WRot orientation, int facings) + public WRot QuantizeOrientation(in WRot orientation, int facings) { // Quantization disabled if (facings == 0) @@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits return info.LocalToWorld(vec); } - public WRot QuantizeOrientation(Actor self, WRot orientation) + public WRot QuantizeOrientation(Actor self, in WRot orientation) { return info.QuantizeOrientation(orientation, quantizedFacings.Value); }