Fix lasers changing DrawingHandleWorld transform (#1103)

This commit is contained in:
ComicIronic
2020-06-06 14:26:33 +02:00
committed by GitHub
parent 89ef65b335
commit dec76c9ad9
5 changed files with 39 additions and 44 deletions
+3 -2
View File
@@ -203,8 +203,9 @@ namespace Robust.Client.Graphics.Clyde
var box = Box2i.FromDimensions(rounded, EntityPostRenderTarget.Size);
_renderHandle.DrawTexture(EntityPostRenderTarget.Texture, box.BottomLeft,
box.TopRight, Color.White, null, 0);
_renderHandle.DrawTexture(EntityPostRenderTarget.Texture,
box.BottomLeft, box.BottomRight, box.TopLeft, box.TopRight,
Color.White, null);
_renderHandle.SetSpace(CurrentSpace.WorldSpace);
_renderHandle.UseShader(null);
@@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.InteropServices;
using Robust.Client.GameObjects;
using Robust.Client.Graphics.ClientEye;
@@ -42,8 +42,7 @@ namespace Robust.Client.Graphics.Clyde
_clyde.DrawResetViewTransform();
}
public void DrawTexture(Texture texture, Vector2 a, Vector2 b, Color modulate, UIBox2? subRegion,
Angle angle)
public void DrawTexture(Texture texture, Vector2 bl, Vector2 br, Vector2 tl, Vector2 tr, Color modulate, UIBox2? subRegion)
{
if (texture is AtlasTexture atlas)
{
@@ -63,7 +62,7 @@ namespace Robust.Client.Graphics.Clyde
var clydeTexture = (ClydeTexture) texture;
_clyde.DrawTexture(clydeTexture.TextureId, a, b, modulate, subRegion, angle);
_clyde.DrawTexture(clydeTexture.TextureId, bl, br, tl, tr, modulate, subRegion);
}
public void SetScissor(UIBox2i? scissorBox)
@@ -275,8 +274,8 @@ namespace Robust.Client.Graphics.Clyde
Color? modulate = null)
{
var color = (modulate ?? Color.White) * Modulate;
_renderHandle.DrawTexture(texture, rect.TopLeft, rect.BottomRight, color,
subRegion, 0);
_renderHandle.DrawTexture(texture, rect.TopLeft, rect.TopRight,
rect.BottomLeft, rect.BottomRight, color, subRegion);
}
}
@@ -344,7 +343,8 @@ namespace Robust.Client.Graphics.Clyde
{
var color = (modulate ?? Color.White) * Modulate;
_renderHandle.DrawTexture(texture, rect.BottomLeft, rect.TopRight, color, subRegion, 0);
_renderHandle.DrawTexture(texture, rect.BottomLeft, rect.BottomRight,
rect.TopLeft, rect.TopRight, color, subRegion);
}
public override void DrawTextureRectRegion(Texture texture, in Box2Rotated rect,
@@ -352,8 +352,8 @@ namespace Robust.Client.Graphics.Clyde
{
var color = (modulate ?? Color.White) * Modulate;
_renderHandle.DrawTexture(texture, rect.Box.BottomLeft, rect.Box.TopRight, color, subRegion,
(float) rect.Rotation);
_renderHandle.DrawTexture(texture, rect.BottomLeft, rect.BottomRight,
rect.TopLeft, rect.TopRight, color, subRegion);
}
public override void DrawPrimitives(DrawPrimitiveTopology primitiveTopology, ReadOnlySpan<Vector2> vertices,
@@ -458,8 +458,7 @@ namespace Robust.Client.Graphics.Clyde
AllocRenderCommand(RenderCommandType.ResetViewMatrix);
}
private void DrawTexture(ClydeHandle texture, Vector2 a, Vector2 b, Color modulate, UIBox2? subRegion,
Angle angle)
private void DrawTexture(ClydeHandle texture, Vector2 bl, Vector2 br, Vector2 tl, Vector2 tr, Color modulate, UIBox2? subRegion)
{
EnsureBatchState(texture, modulate, true, BatchPrimitiveType.TriangleFan, _queuedShader);
@@ -489,24 +488,10 @@ namespace Robust.Client.Graphics.Clyde
}
}
Vector2 bl;
Vector2 br;
Vector2 tr;
Vector2 tl;
if (angle == Angle.Zero)
{
bl = _currentModelMatrix.Transform(a);
br = _currentModelMatrix.Transform(new Vector2(b.X, a.Y));
tr = _currentModelMatrix.Transform(b);
tl = _currentModelMatrix.Transform(new Vector2(a.X, b.Y));
}
else
{
bl = _currentModelMatrix.Transform(angle.RotateVec(a));
br = _currentModelMatrix.Transform(angle.RotateVec(new Vector2(b.X, a.Y)));
tr = _currentModelMatrix.Transform(angle.RotateVec(b));
tl = _currentModelMatrix.Transform(angle.RotateVec(new Vector2(a.X, b.Y)));
}
bl = _currentModelMatrix.Transform(bl);
br = _currentModelMatrix.Transform(br);
tr = _currentModelMatrix.Transform(tr);
tl = _currentModelMatrix.Transform(tl);
// TODO: split batch if necessary.
var vIdx = BatchVertexIndex;