Update float3 to readonly and use in modifier for parameters.
This commit is contained in:
@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public interface ITintableRenderable
|
public interface ITintableRenderable
|
||||||
{
|
{
|
||||||
IRenderable WithTint(float3 newTint);
|
IRenderable WithTint(in float3 newTint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IFinalizedRenderable
|
public interface IFinalizedRenderable
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Graphics
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawLine(float3 start, float3 end, float width, Color startColor, Color endColor)
|
public void DrawLine(in float3 start, in float3 end, float width, Color startColor, Color endColor)
|
||||||
{
|
{
|
||||||
var delta = (end - start) / (end - start).XY.Length;
|
var delta = (end - start) / (end - start).XY.Length;
|
||||||
var corner = width / 2 * new float3(-delta.Y, delta.X, delta.Z);
|
var corner = width / 2 * new float3(-delta.Y, delta.X, delta.Z);
|
||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawRGBAVertices(vertices);
|
parent.DrawRGBAVertices(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawLine(float3 start, float3 end, float width, Color color)
|
public void DrawLine(in float3 start, in float3 end, float width, Color color)
|
||||||
{
|
{
|
||||||
var delta = (end - start) / (end - start).XY.Length;
|
var delta = (end - start) / (end - start).XY.Length;
|
||||||
var corner = width / 2 * new float2(-delta.Y, delta.X);
|
var corner = width / 2 * new float2(-delta.Y, delta.X);
|
||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Graphics
|
|||||||
/// Will behave badly if the lines are parallel.
|
/// Will behave badly if the lines are parallel.
|
||||||
/// Z position is the average of a and b (ignores actual intersection point if it exists)
|
/// Z position is the average of a and b (ignores actual intersection point if it exists)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
float3 IntersectionOf(float3 a, float3 da, float3 b, float3 db)
|
float3 IntersectionOf(in float3 a, in float3 da, in float3 b, in float3 db)
|
||||||
{
|
{
|
||||||
var crossA = a.X * (a.Y + da.Y) - a.Y * (a.X + da.X);
|
var crossA = a.X * (a.Y + da.Y) - a.Y * (a.X + da.X);
|
||||||
var crossB = b.X * (b.Y + db.Y) - b.Y * (b.X + db.X);
|
var crossB = b.X * (b.Y + db.Y) - b.Y * (b.X + db.X);
|
||||||
@@ -193,14 +193,14 @@ namespace OpenRA.Graphics
|
|||||||
DrawConnectedLine(vertices.Select(v => new float3(v, 0)).ToArray(), width, color, true);
|
DrawConnectedLine(vertices.Select(v => new float3(v, 0)).ToArray(), width, color, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawRect(float3 tl, float3 br, float width, Color color)
|
public void DrawRect(in float3 tl, in float3 br, float width, Color color)
|
||||||
{
|
{
|
||||||
var tr = new float3(br.X, tl.Y, tl.Z);
|
var tr = new float3(br.X, tl.Y, tl.Z);
|
||||||
var bl = new float3(tl.X, br.Y, br.Z);
|
var bl = new float3(tl.X, br.Y, br.Z);
|
||||||
DrawPolygon(new[] { tl, tr, br, bl }, width, color);
|
DrawPolygon(new[] { tl, tr, br, bl }, width, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FillTriangle(float3 a, float3 b, float3 c, Color color)
|
public void FillTriangle(in float3 a, in float3 b, in float3 c, Color color)
|
||||||
{
|
{
|
||||||
color = Util.PremultiplyAlpha(color);
|
color = Util.PremultiplyAlpha(color);
|
||||||
var cr = color.R / 255.0f;
|
var cr = color.R / 255.0f;
|
||||||
@@ -214,14 +214,14 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawRGBAVertices(vertices);
|
parent.DrawRGBAVertices(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FillRect(float3 tl, float3 br, Color color)
|
public void FillRect(in float3 tl, in float3 br, Color color)
|
||||||
{
|
{
|
||||||
var tr = new float3(br.X, tl.Y, tl.Z);
|
var tr = new float3(br.X, tl.Y, tl.Z);
|
||||||
var bl = new float3(tl.X, br.Y, br.Z);
|
var bl = new float3(tl.X, br.Y, br.Z);
|
||||||
FillRect(tl, tr, br, bl, color);
|
FillRect(tl, tr, br, bl, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FillRect(float3 a, float3 b, float3 c, float3 d, Color color)
|
public void FillRect(in float3 a, in float3 b, in float3 c, in float3 d, Color color)
|
||||||
{
|
{
|
||||||
color = Util.PremultiplyAlpha(color);
|
color = Util.PremultiplyAlpha(color);
|
||||||
var cr = color.R / 255.0f;
|
var cr = color.R / 255.0f;
|
||||||
@@ -238,7 +238,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawRGBAVertices(vertices);
|
parent.DrawRGBAVertices(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FillRect(float3 a, float3 b, float3 c, float3 d, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor)
|
public void FillRect(in float3 a, in float3 b, in float3 c, in float3 d, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor)
|
||||||
{
|
{
|
||||||
vertices[0] = VertexWithColor(a + Offset, topLeftColor);
|
vertices[0] = VertexWithColor(a + Offset, topLeftColor);
|
||||||
vertices[1] = VertexWithColor(b + Offset, topRightColor);
|
vertices[1] = VertexWithColor(b + Offset, topRightColor);
|
||||||
@@ -250,7 +250,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawRGBAVertices(vertices);
|
parent.DrawRGBAVertices(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vertex VertexWithColor(float3 xyz, Color color)
|
static Vertex VertexWithColor(in float3 xyz, Color color)
|
||||||
{
|
{
|
||||||
color = Util.PremultiplyAlpha(color);
|
color = Util.PremultiplyAlpha(color);
|
||||||
var cr = color.R / 255.0f;
|
var cr = color.R / 255.0f;
|
||||||
@@ -261,7 +261,7 @@ namespace OpenRA.Graphics
|
|||||||
return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
|
return new Vertex(xyz, cr, cg, cb, ca, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FillEllipse(float3 tl, float3 br, Color color, int vertices = 32)
|
public void FillEllipse(in float3 tl, in float3 br, Color color, int vertices = 32)
|
||||||
{
|
{
|
||||||
// TODO: Create an ellipse polygon instead
|
// TODO: Create an ellipse polygon instead
|
||||||
var a = (br.X - tl.X) / 2;
|
var a = (br.X - tl.X) / 2;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Graphics
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float3 location, float3 size)
|
public void DrawSprite(Sprite s, in float3 location, in float3 size)
|
||||||
{
|
{
|
||||||
if (s.Channel != TextureChannel.RGBA)
|
if (s.Channel != TextureChannel.RGBA)
|
||||||
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawSprite(s, location, 0, size);
|
parent.DrawSprite(s, location, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float3 location)
|
public void DrawSprite(Sprite s, in float3 location)
|
||||||
{
|
{
|
||||||
if (s.Channel != TextureChannel.RGBA)
|
if (s.Channel != TextureChannel.RGBA)
|
||||||
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawSprite(s, location, 0, s.Size);
|
parent.DrawSprite(s, location, 0, s.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float3 a, float3 b, float3 c, float3 d)
|
public void DrawSprite(Sprite s, in float3 a, in float3 b, in float3 c, in float3 d)
|
||||||
{
|
{
|
||||||
if (s.Channel != TextureChannel.RGBA)
|
if (s.Channel != TextureChannel.RGBA)
|
||||||
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawSprite(s, a, b, c, d);
|
parent.DrawSprite(s, a, b, c, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSpriteWithTint(Sprite s, float3 location, float3 size, float3 tint)
|
public void DrawSpriteWithTint(Sprite s, in float3 location, in float3 size, in float3 tint)
|
||||||
{
|
{
|
||||||
if (s.Channel != TextureChannel.RGBA)
|
if (s.Channel != TextureChannel.RGBA)
|
||||||
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Graphics
|
|||||||
parent.DrawSpriteWithTint(s, location, 0, size, tint);
|
parent.DrawSpriteWithTint(s, location, 0, size, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSpriteWithTint(Sprite s, float3 a, float3 b, float3 c, float3 d, float3 tint)
|
public void DrawSpriteWithTint(Sprite s, in float3 a, in float3 b, in float3 c, in float3 d, in float3 tint)
|
||||||
{
|
{
|
||||||
if (s.Channel != TextureChannel.RGBA)
|
if (s.Channel != TextureChannel.RGBA)
|
||||||
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public Sprite Add(ISpriteFrame frame) { return Add(frame.Data, frame.Size, 0, frame.Offset); }
|
public Sprite Add(ISpriteFrame frame) { return Add(frame.Data, frame.Size, 0, frame.Offset); }
|
||||||
public Sprite Add(byte[] src, Size size) { return Add(src, size, 0, float3.Zero); }
|
public Sprite Add(byte[] src, Size size) { return Add(src, size, 0, float3.Zero); }
|
||||||
public Sprite Add(byte[] src, Size size, float zRamp, float3 spriteOffset)
|
public Sprite Add(byte[] src, Size size, float zRamp, in float3 spriteOffset)
|
||||||
{
|
{
|
||||||
// Don't bother allocating empty sprites
|
// Don't bother allocating empty sprites
|
||||||
if (size.Width == 0 || size.Height == 0)
|
if (size.Width == 0 || size.Height == 0)
|
||||||
@@ -115,7 +115,7 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Sprite Allocate(Size imageSize, float scale = 1f) { return Allocate(imageSize, 0, float3.Zero, scale); }
|
public Sprite Allocate(Size imageSize, float scale = 1f) { return Allocate(imageSize, 0, float3.Zero, scale); }
|
||||||
public Sprite Allocate(Size imageSize, float zRamp, float3 spriteOffset, float scale = 1f)
|
public Sprite Allocate(Size imageSize, float zRamp, in float3 spriteOffset, float scale = 1f)
|
||||||
{
|
{
|
||||||
if (imageSize.Width + p.X + margin > current.Size.Width)
|
if (imageSize.Width + p.X + margin > current.Size.Width)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Graphics
|
|||||||
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel, float scale = 1)
|
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel, float scale = 1)
|
||||||
: this(sheet, bounds, 0, float2.Zero, channel, BlendMode.Alpha, scale) { }
|
: this(sheet, bounds, 0, float2.Zero, channel, BlendMode.Alpha, scale) { }
|
||||||
|
|
||||||
public Sprite(Sheet sheet, Rectangle bounds, float zRamp, float3 offset, TextureChannel channel, BlendMode blendMode = BlendMode.Alpha, float scale = 1f)
|
public Sprite(Sheet sheet, Rectangle bounds, float zRamp, in float3 offset, TextureChannel channel, BlendMode blendMode = BlendMode.Alpha, float scale = 1f)
|
||||||
{
|
{
|
||||||
Sheet = sheet;
|
Sheet = sheet;
|
||||||
Bounds = bounds;
|
Bounds = bounds;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Graphics
|
|||||||
public IRenderable OffsetBy(WVec vec) { return new SpriteRenderable(sprite, pos + vec, offset, zOffset, palette, scale, tint, isDecoration, ignoreWorldTint); }
|
public IRenderable OffsetBy(WVec vec) { return new SpriteRenderable(sprite, pos + vec, offset, zOffset, palette, scale, tint, isDecoration, ignoreWorldTint); }
|
||||||
public IRenderable AsDecoration() { return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, tint, true, ignoreWorldTint); }
|
public IRenderable AsDecoration() { return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, tint, true, ignoreWorldTint); }
|
||||||
|
|
||||||
public IRenderable WithTint(float3 newTint) { return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, newTint, isDecoration, ignoreWorldTint); }
|
public IRenderable WithTint(in float3 newTint) { return new SpriteRenderable(sprite, pos, offset, zOffset, palette, scale, newTint, isDecoration, ignoreWorldTint); }
|
||||||
|
|
||||||
float3 ScreenPosition(WorldRenderer wr)
|
float3 ScreenPosition(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -108,43 +108,43 @@ namespace OpenRA.Graphics
|
|||||||
return new int2(sheetIndex, secondarySheetIndex);
|
return new int2(sheetIndex, secondarySheetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DrawSprite(Sprite s, float3 location, float paletteTextureIndex, float3 size)
|
internal void DrawSprite(Sprite s, in float3 location, float paletteTextureIndex, in float3 size)
|
||||||
{
|
{
|
||||||
var samplers = SetRenderStateForSprite(s);
|
var samplers = SetRenderStateForSprite(s);
|
||||||
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, samplers, paletteTextureIndex, nv, size, float3.Ones);
|
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, samplers, paletteTextureIndex, nv, size, float3.Ones);
|
||||||
nv += 6;
|
nv += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float3 location, PaletteReference pal)
|
public void DrawSprite(Sprite s, in float3 location, PaletteReference pal)
|
||||||
{
|
{
|
||||||
DrawSprite(s, location, pal.TextureIndex, s.Size);
|
DrawSprite(s, location, pal.TextureIndex, s.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float3 location, PaletteReference pal, float3 size)
|
public void DrawSprite(Sprite s, in float3 location, PaletteReference pal, float3 size)
|
||||||
{
|
{
|
||||||
DrawSprite(s, location, pal.TextureIndex, size);
|
DrawSprite(s, location, pal.TextureIndex, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float3 a, float3 b, float3 c, float3 d)
|
public void DrawSprite(Sprite s, in float3 a, in float3 b, in float3 c, in float3 d)
|
||||||
{
|
{
|
||||||
var samplers = SetRenderStateForSprite(s);
|
var samplers = SetRenderStateForSprite(s);
|
||||||
Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, 0, float3.Ones, nv);
|
Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, 0, float3.Ones, nv);
|
||||||
nv += 6;
|
nv += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DrawSpriteWithTint(Sprite s, float3 location, float paletteTextureIndex, float3 size, float3 tint)
|
internal void DrawSpriteWithTint(Sprite s, in float3 location, float paletteTextureIndex, in float3 size, in float3 tint)
|
||||||
{
|
{
|
||||||
var samplers = SetRenderStateForSprite(s);
|
var samplers = SetRenderStateForSprite(s);
|
||||||
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, samplers, paletteTextureIndex, nv, size, tint);
|
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, samplers, paletteTextureIndex, nv, size, tint);
|
||||||
nv += 6;
|
nv += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSpriteWithTint(Sprite s, float3 location, PaletteReference pal, float3 size, float3 tint)
|
public void DrawSpriteWithTint(Sprite s, in float3 location, PaletteReference pal, in float3 size, in float3 tint)
|
||||||
{
|
{
|
||||||
DrawSpriteWithTint(s, location, pal.TextureIndex, size, tint);
|
DrawSpriteWithTint(s, location, pal.TextureIndex, size, tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSpriteWithTint(Sprite s, float3 a, float3 b, float3 c, float3 d, float3 tint)
|
public void DrawSpriteWithTint(Sprite s, in float3 a, in float3 b, in float3 c, in float3 d, in float3 tint)
|
||||||
{
|
{
|
||||||
var samplers = SetRenderStateForSprite(s);
|
var samplers = SetRenderStateForSprite(s);
|
||||||
Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, 0, tint, nv);
|
Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, 0, tint, nv);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace OpenRA.Graphics
|
|||||||
dirtyRows.Add(uv.V);
|
dirtyRows.Add(uv.V);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(MPos uv, Sprite sprite, float3 pos, bool ignoreTint)
|
public void Update(MPos uv, Sprite sprite, in float3 pos, bool ignoreTint)
|
||||||
{
|
{
|
||||||
if (sprite != null)
|
if (sprite != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Graphics
|
|||||||
// yes, our channel order is nuts.
|
// yes, our channel order is nuts.
|
||||||
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
|
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
|
||||||
|
|
||||||
public static void FastCreateQuad(Vertex[] vertices, float3 o, Sprite r, int2 samplers, float paletteTextureIndex, int nv, float3 size, float3 tint)
|
public static void FastCreateQuad(Vertex[] vertices, in float3 o, Sprite r, int2 samplers, float paletteTextureIndex, int nv, in float3 size, in float3 tint)
|
||||||
{
|
{
|
||||||
var b = new float3(o.X + size.X, o.Y, o.Z);
|
var b = new float3(o.X + size.X, o.Y, o.Z);
|
||||||
var c = new float3(o.X + size.X, o.Y + size.Y, o.Z + size.Z);
|
var c = new float3(o.X + size.X, o.Y + size.Y, o.Z + size.Z);
|
||||||
@@ -29,9 +29,9 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void FastCreateQuad(Vertex[] vertices,
|
public static void FastCreateQuad(Vertex[] vertices,
|
||||||
float3 a, float3 b, float3 c, float3 d,
|
in float3 a, in float3 b, in float3 c, in float3 d,
|
||||||
Sprite r, int2 samplers, float paletteTextureIndex,
|
Sprite r, int2 samplers, float paletteTextureIndex,
|
||||||
float3 tint, int nv)
|
in float3 tint, int nv)
|
||||||
{
|
{
|
||||||
float sl = 0;
|
float sl = 0;
|
||||||
float st = 0;
|
float st = 0;
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ namespace OpenRA.Graphics
|
|||||||
// Color tint
|
// Color tint
|
||||||
public readonly float R, G, B;
|
public readonly float R, G, B;
|
||||||
|
|
||||||
public Vertex(float3 xyz, float s, float t, float u, float v, float p, float c)
|
public Vertex(in float3 xyz, float s, float t, float u, float v, float p, float c)
|
||||||
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c, float3.Ones) { }
|
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c, float3.Ones) { }
|
||||||
|
|
||||||
public Vertex(float3 xyz, float s, float t, float u, float v, float p, float c, float3 tint)
|
public Vertex(in float3 xyz, float s, float t, float u, float v, float p, float c, in float3 tint)
|
||||||
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c, tint.X, tint.Y, tint.Z) { }
|
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c, tint.X, tint.Y, tint.Z) { }
|
||||||
|
|
||||||
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c, float3 tint)
|
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c, in float3 tint)
|
||||||
: this(x, y, z, s, t, u, v, p, c, tint.X, tint.Y, tint.Z) { }
|
: this(x, y, z, s, t, u, v, p, c, tint.X, tint.Y, tint.Z) { }
|
||||||
|
|
||||||
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c, float r, float g, float b)
|
public Vertex(float x, float y, float z, float s, float t, float u, float v, float p, float c, float r, float g, float b)
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public int2 ViewToWorldPx(int2 view) { return (graphicSettings.UIScale / Zoom * view.ToFloat2()).ToInt2() + TopLeft; }
|
public int2 ViewToWorldPx(int2 view) { return (graphicSettings.UIScale / Zoom * view.ToFloat2()).ToInt2() + TopLeft; }
|
||||||
public int2 WorldToViewPx(int2 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).ToFloat2()).ToInt2(); }
|
public int2 WorldToViewPx(int2 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).ToFloat2()).ToInt2(); }
|
||||||
public int2 WorldToViewPx(float3 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).XY).ToInt2(); }
|
public int2 WorldToViewPx(in float3 world) { return ((Zoom / graphicSettings.UIScale) * (world - TopLeft).XY).ToInt2(); }
|
||||||
|
|
||||||
public void Center(IEnumerable<Actor> actors)
|
public void Center(IEnumerable<Actor> actors)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
|
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Mimic a built-in type alias.")]
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct float3 : IEquatable<float3>
|
public readonly struct float3 : IEquatable<float3>
|
||||||
{
|
{
|
||||||
public readonly float X, Y, Z;
|
public readonly float X, Y, Z;
|
||||||
public float2 XY { get { return new float2(X, Y); } }
|
public float2 XY { get { return new float2(X, Y); } }
|
||||||
@@ -28,13 +28,13 @@ namespace OpenRA
|
|||||||
public static implicit operator float3(int2 src) { return new float3(src.X, src.Y, 0); }
|
public static implicit operator float3(int2 src) { return new float3(src.X, src.Y, 0); }
|
||||||
public static implicit operator float3(float2 src) { return new float3(src.X, src.Y, 0); }
|
public static implicit operator float3(float2 src) { return new float3(src.X, src.Y, 0); }
|
||||||
|
|
||||||
public static float3 operator +(float3 a, float3 b) { return new float3(a.X + b.X, a.Y + b.Y, a.Z + b.Z); }
|
public static float3 operator +(in float3 a, in float3 b) { return new float3(a.X + b.X, a.Y + b.Y, a.Z + b.Z); }
|
||||||
public static float3 operator -(float3 a, float3 b) { return new float3(a.X - b.X, a.Y - b.Y, a.Z - b.Z); }
|
public static float3 operator -(in float3 a, in float3 b) { return new float3(a.X - b.X, a.Y - b.Y, a.Z - b.Z); }
|
||||||
public static float3 operator -(float3 a) { return new float3(-a.X, -a.Y, -a.Z); }
|
public static float3 operator -(in float3 a) { return new float3(-a.X, -a.Y, -a.Z); }
|
||||||
public static float3 operator *(float3 a, float3 b) { return new float3(a.X * b.X, a.Y * b.Y, a.Z * b.Z); }
|
public static float3 operator *(in float3 a, in float3 b) { return new float3(a.X * b.X, a.Y * b.Y, a.Z * b.Z); }
|
||||||
public static float3 operator *(float a, float3 b) { return new float3(a * b.X, a * b.Y, a * b.Z); }
|
public static float3 operator *(float a, in float3 b) { return new float3(a * b.X, a * b.Y, a * b.Z); }
|
||||||
public static float3 operator /(float3 a, float3 b) { return new float3(a.X / b.X, a.Y / b.Y, a.Z / b.Z); }
|
public static float3 operator /(in float3 a, in float3 b) { return new float3(a.X / b.X, a.Y / b.Y, a.Z / b.Z); }
|
||||||
public static float3 operator /(float3 a, float b) { return new float3(a.X / b, a.Y / b, a.Z / b); }
|
public static float3 operator /(in float3 a, float b) { return new float3(a.X / b, a.Y / b, a.Z / b); }
|
||||||
|
|
||||||
public static float3 Lerp(float3 a, float3 b, float t)
|
public static float3 Lerp(float3 a, float3 b, float t)
|
||||||
{
|
{
|
||||||
@@ -44,8 +44,8 @@ namespace OpenRA
|
|||||||
float2.Lerp(a.Z, b.Z, t));
|
float2.Lerp(a.Z, b.Z, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(float3 me, float3 other) { return me.X == other.X && me.Y == other.Y && me.Z == other.Z; }
|
public static bool operator ==(in float3 me, in float3 other) { return me.X == other.X && me.Y == other.Y && me.Z == other.Z; }
|
||||||
public static bool operator !=(float3 me, float3 other) { return !(me == other); }
|
public static bool operator !=(in float3 me, in float3 other) { return !(me == other); }
|
||||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }
|
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }
|
||||||
|
|
||||||
public bool Equals(float3 other)
|
public bool Equals(float3 other)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
IEnumerable<ModelAnimation> models, WPos pos, int zOffset, in WRot camera, float scale,
|
IEnumerable<ModelAnimation> models, WPos pos, int zOffset, in WRot camera, float scale,
|
||||||
in 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)
|
in float3 tint)
|
||||||
{
|
{
|
||||||
this.models = models;
|
this.models = models;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
|
|
||||||
public IRenderable AsDecoration() { return this; }
|
public IRenderable AsDecoration() { return this; }
|
||||||
|
|
||||||
public IRenderable WithTint(float3 newTint)
|
public IRenderable WithTint(in float3 newTint)
|
||||||
{
|
{
|
||||||
return new ModelRenderable(
|
return new ModelRenderable(
|
||||||
models, pos, zOffset, camera, scale,
|
models, pos, zOffset, camera, scale,
|
||||||
@@ -195,7 +195,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
static readonly uint[] CornerXIndex = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 };
|
static readonly uint[] CornerXIndex = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 };
|
||||||
static readonly uint[] CornerYIndex = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 };
|
static readonly uint[] CornerYIndex = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 };
|
||||||
static readonly uint[] CornerZIndex = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 };
|
static readonly uint[] CornerZIndex = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 };
|
||||||
static void DrawBoundsBox(WorldRenderer wr, float3 pxPos, float[] transform, float[] bounds, float width, Color c)
|
static void DrawBoundsBox(WorldRenderer wr, in float3 pxPos, float[] transform, float[] bounds, float width, Color c)
|
||||||
{
|
{
|
||||||
var cr = Game.Renderer.RgbaColorRenderer;
|
var cr = Game.Renderer.RgbaColorRenderer;
|
||||||
var corners = new float2[8];
|
var corners = new float2[8];
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly float Intensity;
|
public readonly float Intensity;
|
||||||
public readonly float3 Tint;
|
public readonly float3 Tint;
|
||||||
|
|
||||||
public LightSource(WPos pos, CPos cell, WDist range, float intensity, float3 tint)
|
public LightSource(WPos pos, CPos cell, WDist range, float intensity, in float3 tint)
|
||||||
{
|
{
|
||||||
Pos = pos;
|
Pos = pos;
|
||||||
Cell = cell;
|
Cell = cell;
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new Rectangle(c.X - r, c.Y - r, 2 * r, 2 * r);
|
return new Rectangle(c.X - r, c.Y - r, 2 * r, 2 * r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AddLightSource(WPos pos, WDist range, float intensity, float3 tint)
|
public int AddLightSource(WPos pos, WDist range, float intensity, in float3 tint)
|
||||||
{
|
{
|
||||||
var token = nextLightSourceToken++;
|
var token = nextLightSourceToken++;
|
||||||
var source = new LightSource(pos, map.CellContaining(pos), range, intensity, tint);
|
var source = new LightSource(pos, map.CellContaining(pos), range, intensity, tint);
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly float3 ScreenPosition;
|
public readonly float3 ScreenPosition;
|
||||||
public readonly byte Variant;
|
public readonly byte Variant;
|
||||||
|
|
||||||
public TileInfo(float3 screenPosition, byte variant)
|
public TileInfo(in float3 screenPosition, byte variant)
|
||||||
{
|
{
|
||||||
ScreenPosition = screenPosition;
|
ScreenPosition = screenPosition;
|
||||||
Variant = variant;
|
Variant = variant;
|
||||||
|
|||||||
Reference in New Issue
Block a user