Skip to content

Commit

Permalink
Avoid full-rendering sprites a second time in the mouse map (#2189)
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit authored Jan 28, 2025
1 parent 863f60d commit 8434b8e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions OpenDreamClient/Rendering/DreamPlane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ public void Draw(DreamViewOverlay overlay, DrawingHandleWorld handle, Box2 world
public void DrawMouseMap(DrawingHandleWorld handle, DreamViewOverlay overlay, Vector2i renderTargetSize, Box2 worldAABB) {
if (Master?.MouseOpacity == MouseOpacity.Transparent)
return;

handle.UseShader(overlay.BlockColorInstance);
foreach (var sprite in Sprites) {
if (sprite.MouseOpacity == MouseOpacity.Transparent || sprite.ShouldPassMouse)
continue;

var texture = sprite.GetTexture(overlay, handle);
var texture = sprite.MainIcon?.LastRenderedTexture;
if (texture == null)
continue;

Expand All @@ -90,7 +92,6 @@ public void DrawMouseMap(DrawingHandleWorld handle, DreamViewOverlay overlay, Ve
var colorB = (byte)((hash >> 16) & 0xFF);
Color targetColor = new Color(colorR, colorG, colorB); //TODO - this could result in mis-clicks due to hash-collision since we ditch a whole byte.
overlay.MouseMapLookup[targetColor] = sprite;
handle.UseShader(overlay.BlockColorInstance); //it seems like you could put this outside the loop, but you can't without breakng the mousemap
handle.SetTransform(DreamViewOverlay.CalculateDrawingMatrix(sprite.TransformToApply, pos, texture.Size, renderTargetSize));
handle.DrawTextureRect(texture, new Box2(Vector2.Zero, texture.Size), targetColor);
}
Expand Down

0 comments on commit 8434b8e

Please sign in to comment.