map renderer fixes (#29523)
* map renderer fixes * remove useless casts
This commit is contained in:
@@ -86,7 +86,8 @@ public sealed class DecalPainter
|
|||||||
|
|
||||||
image.Mutate(o => o.Rotate((float) -decal.Angle.Degrees));
|
image.Mutate(o => o.Rotate((float) -decal.Angle.Degrees));
|
||||||
var coloredImage = new Image<Rgba32>(image.Width, image.Height);
|
var coloredImage = new Image<Rgba32>(image.Width, image.Height);
|
||||||
Color color = decal.Color?.ConvertImgSharp() ?? Color.White;
|
Color color = decal.Color?.WithAlpha(byte.MaxValue).ConvertImgSharp() ?? Color.White; // remove the encoded color alpha here
|
||||||
|
var alpha = decal.Color?.A ?? 1; // get the alpha separately so we can use it in DrawImage
|
||||||
coloredImage.Mutate(o => o.BackgroundColor(color));
|
coloredImage.Mutate(o => o.BackgroundColor(color));
|
||||||
|
|
||||||
image.Mutate(o => o
|
image.Mutate(o => o
|
||||||
@@ -95,6 +96,6 @@ public sealed class DecalPainter
|
|||||||
|
|
||||||
// Very unsure why the - 1 is needed in the first place but all decals are off by exactly one pixel otherwise
|
// Very unsure why the - 1 is needed in the first place but all decals are off by exactly one pixel otherwise
|
||||||
// Woohoo!
|
// Woohoo!
|
||||||
canvas.Mutate(o => o.DrawImage(image, new Point((int) data.X, (int) data.Y - 1), 1.0f));
|
canvas.Mutate(o => o.DrawImage(image, new Point((int) data.X, (int) data.Y - 1), alpha));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,19 +123,28 @@ public sealed class EntityPainter
|
|||||||
|
|
||||||
image.Mutate(o => o.Crop(rect));
|
image.Mutate(o => o.Crop(rect));
|
||||||
|
|
||||||
|
var spriteRotation = 0f;
|
||||||
|
if (!entity.Sprite.NoRotation && !entity.Sprite.SnapCardinals && entity.Sprite.GetLayerDirectionCount(layer) == 1)
|
||||||
|
{
|
||||||
|
spriteRotation = (float) worldRotation.Degrees;
|
||||||
|
}
|
||||||
|
|
||||||
var colorMix = entity.Sprite.Color * layer.Color;
|
var colorMix = entity.Sprite.Color * layer.Color;
|
||||||
var imageColor = Color.FromRgba(colorMix.RByte, colorMix.GByte, colorMix.BByte, colorMix.AByte);
|
var imageColor = Color.FromRgba(colorMix.RByte, colorMix.GByte, colorMix.BByte, colorMix.AByte);
|
||||||
var coloredImage = new Image<Rgba32>(image.Width, image.Height);
|
var coloredImage = new Image<Rgba32>(image.Width, image.Height);
|
||||||
coloredImage.Mutate(o => o.BackgroundColor(imageColor));
|
coloredImage.Mutate(o => o.BackgroundColor(imageColor));
|
||||||
|
|
||||||
var (imgX, imgY) = rsi?.Size ?? (EyeManager.PixelsPerMeter, EyeManager.PixelsPerMeter);
|
var (imgX, imgY) = rsi?.Size ?? (EyeManager.PixelsPerMeter, EyeManager.PixelsPerMeter);
|
||||||
|
var offsetX = (int) (entity.Sprite.Offset.X * EyeManager.PixelsPerMeter);
|
||||||
|
var offsetY = (int) (entity.Sprite.Offset.Y * EyeManager.PixelsPerMeter);
|
||||||
image.Mutate(o => o
|
image.Mutate(o => o
|
||||||
.DrawImage(coloredImage, PixelColorBlendingMode.Multiply, PixelAlphaCompositionMode.SrcAtop, 1)
|
.DrawImage(coloredImage, PixelColorBlendingMode.Multiply, PixelAlphaCompositionMode.SrcAtop, 1)
|
||||||
.Resize(imgX, imgY)
|
.Resize(imgX, imgY)
|
||||||
.Flip(FlipMode.Vertical));
|
.Flip(FlipMode.Vertical)
|
||||||
|
.Rotate(spriteRotation));
|
||||||
|
|
||||||
var pointX = (int) entity.X - imgX / 2 + EyeManager.PixelsPerMeter / 2;
|
var pointX = (int) entity.X + offsetX - imgX / 2;
|
||||||
var pointY = (int) entity.Y - imgY / 2 + EyeManager.PixelsPerMeter / 2;
|
var pointY = (int) entity.Y + offsetY - imgY / 2;
|
||||||
canvas.Mutate(o => o.DrawImage(image, new Point(pointX, pointY), 1));
|
canvas.Mutate(o => o.DrawImage(image, new Point(pointX, pointY), 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ namespace Content.MapRenderer.Painters
|
|||||||
var yOffset = (int) -grid.LocalAABB.Bottom;
|
var yOffset = (int) -grid.LocalAABB.Bottom;
|
||||||
var tileSize = grid.TileSize;
|
var tileSize = grid.TileSize;
|
||||||
|
|
||||||
var x = ((float) Math.Floor(position.X) + xOffset) * tileSize * TilePainter.TileImageSize;
|
var x = (position.X + xOffset) * tileSize * TilePainter.TileImageSize;
|
||||||
var y = ((float) Math.Floor(position.Y) + yOffset) * tileSize * TilePainter.TileImageSize;
|
var y = (position.Y + yOffset) * tileSize * TilePainter.TileImageSize;
|
||||||
|
|
||||||
return (x, y);
|
return (x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user