Small rendering optimization.

Removes WorldPosition fetch from sprite sort.
This commit is contained in:
Pieter-Jan Briers
2020-04-19 18:27:32 +02:00
parent 76005b0706
commit ae756d9ebe
2 changed files with 7 additions and 6 deletions
+4 -3
View File
@@ -21,9 +21,9 @@ namespace Robust.Client.Graphics.Clyde
{
public ClydeDebugLayers DebugLayers { get; set; }
private readonly RefList<(SpriteComponent sprite, Matrix3 worldMatrix, Angle worldRotation)> _drawingSpriteList
private readonly RefList<(SpriteComponent sprite, Matrix3 worldMatrix, Angle worldRotation, float yWorldPos)> _drawingSpriteList
=
new RefList<(SpriteComponent, Matrix3, Angle)>();
new RefList<(SpriteComponent, Matrix3, Angle, float)>();
public void Render()
{
@@ -212,7 +212,7 @@ namespace Robust.Client.Graphics.Clyde
}
private void ProcessSpriteEntities(IEntity entity, ref Matrix3 parentTransform, Angle parentRotation,
Box2 worldBounds, RefList<(SpriteComponent, Matrix3, Angle)> list)
Box2 worldBounds, RefList<(SpriteComponent, Matrix3, Angle, float yWorldPos)> list)
{
entity.TryGetComponent(out ContainerManagerComponent containerManager);
@@ -246,6 +246,7 @@ namespace Robust.Client.Graphics.Clyde
entry.Item1 = sprite;
entry.Item3 = childWorldRotation;
entry.yWorldPos = worldPosition.Y;
}
}
@@ -811,9 +811,9 @@ namespace Robust.Client.Graphics.Clyde
private sealed class SpriteDrawingOrderComparer : IComparer<int>
{
private readonly RefList<(SpriteComponent, Matrix3, Angle)> _drawList;
private readonly RefList<(SpriteComponent, Matrix3, Angle, float)> _drawList;
public SpriteDrawingOrderComparer(RefList<(SpriteComponent, Matrix3, Angle)> drawList)
public SpriteDrawingOrderComparer(RefList<(SpriteComponent, Matrix3, Angle, float)> drawList)
{
_drawList = drawList;
}
@@ -836,7 +836,7 @@ namespace Robust.Client.Graphics.Clyde
return cmp;
}
cmp = b.Owner.Transform.WorldPosition.Y.CompareTo(a.Owner.Transform.WorldPosition.Y);
cmp = _drawList[x].Item4.CompareTo(_drawList[y].Item4);
if (cmp != 0)
{