Make WRot readonly and use in parameter modifier
This commit is contained in:
@@ -79,8 +79,8 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ModelRenderProxy RenderAsync(
|
public ModelRenderProxy RenderAsync(
|
||||||
WorldRenderer wr, IEnumerable<ModelAnimation> models, WRot camera, float scale,
|
WorldRenderer wr, IEnumerable<ModelAnimation> models, in WRot camera, float scale,
|
||||||
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
float[] groundNormal, in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||||
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
|
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
|
||||||
{
|
{
|
||||||
if (!isInFrame)
|
if (!isInFrame)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRA
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 3d World rotation.
|
/// 3d World rotation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct WRot : IEquatable<WRot>
|
public readonly struct WRot : IEquatable<WRot>
|
||||||
{
|
{
|
||||||
// The Euler angle representation is a lot more intuitive for public use
|
// The Euler angle representation is a lot more intuitive for public use
|
||||||
public readonly WAngle Roll, Pitch, Yaw;
|
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 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 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 +(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 -(WRot a, 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 -(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) { 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)
|
if (this == None)
|
||||||
return rot;
|
return rot;
|
||||||
@@ -104,12 +104,12 @@ namespace OpenRA
|
|||||||
return new WRot((int)rx, (int)ry, (int)rz, (int)rw);
|
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;
|
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)
|
public WRot WithRoll(WAngle roll)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
|||||||
public long VerticalLengthSquared { get { return (long)Z * Z; } }
|
public long VerticalLengthSquared { get { return (long)Z * Z; } }
|
||||||
public int VerticalLength { get { return (int)Exts.ISqrt(VerticalLengthSquared); } }
|
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);
|
rot.AsMatrix(out var mtx);
|
||||||
return Rotate(ref mtx);
|
return Rotate(ref mtx);
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
readonly float3 tint;
|
readonly float3 tint;
|
||||||
|
|
||||||
public ModelRenderable(
|
public ModelRenderable(
|
||||||
IEnumerable<ModelAnimation> models, WPos pos, int zOffset, WRot camera, float scale,
|
IEnumerable<ModelAnimation> models, WPos pos, int zOffset, in WRot camera, float scale,
|
||||||
WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||||
PaletteReference color, PaletteReference normals, PaletteReference shadow)
|
PaletteReference color, PaletteReference normals, PaletteReference shadow)
|
||||||
: this(models, pos, zOffset, camera, scale,
|
: this(models, pos, zOffset, camera, scale,
|
||||||
lightSource, lightAmbientColor, lightDiffuseColor,
|
lightSource, lightAmbientColor, lightDiffuseColor,
|
||||||
@@ -42,8 +42,8 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
float3.Ones) { }
|
float3.Ones) { }
|
||||||
|
|
||||||
public ModelRenderable(
|
public ModelRenderable(
|
||||||
IEnumerable<ModelAnimation> models, WPos pos, int zOffset, WRot camera, float scale,
|
IEnumerable<ModelAnimation> models, WPos pos, int zOffset, in WRot camera, float scale,
|
||||||
WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
in WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||||
PaletteReference color, PaletteReference normals, PaletteReference shadow,
|
PaletteReference color, PaletteReference normals, PaletteReference shadow,
|
||||||
float3 tint)
|
float3 tint)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
|
|
||||||
public UIModelRenderable(
|
public UIModelRenderable(
|
||||||
IEnumerable<ModelAnimation> models, WPos effectiveWorldPos, int2 screenPos, int zOffset,
|
IEnumerable<ModelAnimation> 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)
|
PaletteReference color, PaletteReference normals, PaletteReference shadow)
|
||||||
{
|
{
|
||||||
this.models = models;
|
this.models = models;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new WVec(vec.Y, -CameraPitch.Sin() * vec.X / 1024, vec.Z);
|
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
|
// Quantization disabled
|
||||||
if (facings == 0)
|
if (facings == 0)
|
||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return info.LocalToWorld(vec);
|
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);
|
return info.QuantizeOrientation(orientation, quantizedFacings.Value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user