Cache rotation matrices used by WorldRenderer.DrawRangeCircle.
This commit is contained in:
@@ -21,6 +21,10 @@ namespace OpenRA.Graphics
|
|||||||
public static readonly Func<IRenderable, int> RenderableScreenZPositionComparisonKey =
|
public static readonly Func<IRenderable, int> RenderableScreenZPositionComparisonKey =
|
||||||
r => ZPosition(r.Pos, r.ZOffset);
|
r => ZPosition(r.Pos, r.ZOffset);
|
||||||
|
|
||||||
|
const int RangeCircleSegments = 32;
|
||||||
|
static readonly int[][] RangeCircleStartRotations = Exts.MakeArray(RangeCircleSegments, i => WRot.FromFacing(8 * i).AsMatrix());
|
||||||
|
static readonly int[][] RangeCircleEndRotations = Exts.MakeArray(RangeCircleSegments, i => WRot.FromFacing(8 * i + 6).AsMatrix());
|
||||||
|
|
||||||
public readonly World World;
|
public readonly World World;
|
||||||
public readonly Theater Theater;
|
public readonly Theater Theater;
|
||||||
public Viewport Viewport { get; private set; }
|
public Viewport Viewport { get; private set; }
|
||||||
@@ -197,10 +201,10 @@ namespace OpenRA.Graphics
|
|||||||
public void DrawRangeCircle(WPos pos, WDist range, Color c)
|
public void DrawRangeCircle(WPos pos, WDist range, Color c)
|
||||||
{
|
{
|
||||||
var offset = new WVec(range.Length, 0, 0);
|
var offset = new WVec(range.Length, 0, 0);
|
||||||
for (var i = 0; i < 32; i++)
|
for (var i = 0; i < RangeCircleSegments; i++)
|
||||||
{
|
{
|
||||||
var pa = pos + offset.Rotate(WRot.FromFacing(8 * i));
|
var pa = pos + offset.Rotate(RangeCircleStartRotations[i]);
|
||||||
var pb = pos + offset.Rotate(WRot.FromFacing(8 * i + 6));
|
var pb = pos + offset.Rotate(RangeCircleEndRotations[i]);
|
||||||
Game.Renderer.WorldLineRenderer.DrawLine(ScreenPosition(pa), ScreenPosition(pb), c);
|
Game.Renderer.WorldLineRenderer.DrawLine(ScreenPosition(pa), ScreenPosition(pb), c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,12 @@ namespace OpenRA
|
|||||||
|
|
||||||
public WVec Rotate(WRot rot)
|
public WVec Rotate(WRot rot)
|
||||||
{
|
{
|
||||||
var mtx = rot.AsMatrix();
|
return Rotate(rot.AsMatrix());
|
||||||
|
}
|
||||||
|
|
||||||
|
public WVec Rotate(int[] rotationMatrix)
|
||||||
|
{
|
||||||
|
var mtx = rotationMatrix;
|
||||||
var lx = (long)X;
|
var lx = (long)X;
|
||||||
var ly = (long)Y;
|
var ly = (long)Y;
|
||||||
var lz = (long)Z;
|
var lz = (long)Z;
|
||||||
|
|||||||
Reference in New Issue
Block a user