1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Minor Paint refactor (#17144)

* Tidy up masked paint code

Its only used by surface elements and only then by attached ps's so no need to support it in the normal ps.

* Remove unneeded function
This commit is contained in:
Duncan
2022-05-06 06:46:50 +01:00
committed by GitHub
parent d551e590e1
commit d09140aaed
4 changed files with 10 additions and 30 deletions

View File

@@ -56,7 +56,6 @@ bool gPaintBlockedTiles;
static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t viewFlags);
static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y);
static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y);
static ImageId PaintPSColourifyImage(const paint_struct* ps, ImageId imageId, uint32_t viewFlags);
static int32_t RemapPositionToQuadrant(const paint_struct& ps, uint8_t rotation)
@@ -187,7 +186,6 @@ static paint_struct* CreateNormalPaintStruct(
ps->bounds.x = rotBoundBoxOffset.x + session.SpritePosition.x;
ps->bounds.y = rotBoundBoxOffset.y + session.SpritePosition.y;
ps->bounds.z = rotBoundBoxOffset.z;
ps->flags = 0;
ps->attached_ps = nullptr;
ps->children = nullptr;
ps->sprite_type = session.InteractionType;
@@ -512,7 +510,7 @@ static void PaintDrawStruct(paint_session& session, paint_struct* ps)
}
else
{
PaintPSImage(dpi, ps, imageId, x, y);
gfx_draw_sprite(dpi, imageId, { x, y });
}
if (ps->children != nullptr)
@@ -556,9 +554,9 @@ static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t v
auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->x, attached_ps->y + ps->y };
auto imageId = PaintPSColourifyImage(ps, attached_ps->image_id, viewFlags);
if (attached_ps->flags & PAINT_STRUCT_FLAG_IS_MASKED)
if (attached_ps->IsMasked)
{
gfx_draw_sprite_raw_masked(dpi, screenCoords, imageId, attached_ps->colour_image_id);
gfx_draw_sprite_raw_masked(dpi, screenCoords, imageId, attached_ps->ColourImageId);
}
else
{
@@ -643,7 +641,7 @@ static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct*
gfx_draw_line(dpi, { screenCoordBackTop, screenCoordLeftTop }, colour);
gfx_draw_line(dpi, { screenCoordBackTop, screenCoordRightTop }, colour);
PaintPSImage(dpi, ps, imageId, x, y);
gfx_draw_sprite(dpi, imageId, { x, y });
// vertical front
gfx_draw_line(dpi, { screenCoordFrontTop, screenCoordFrontBottom }, colour);
@@ -653,16 +651,6 @@ static void PaintPSImageWithBoundingBoxes(rct_drawpixelinfo* dpi, paint_struct*
gfx_draw_line(dpi, { screenCoordFrontTop, screenCoordRightTop }, colour);
}
static void PaintPSImage(rct_drawpixelinfo* dpi, paint_struct* ps, ImageId imageId, int32_t x, int32_t y)
{
if (ps->flags & PAINT_STRUCT_FLAG_IS_MASKED)
{
return gfx_draw_sprite_raw_masked(dpi, { x, y }, imageId, ps->colour_image_id);
}
gfx_draw_sprite(dpi, imageId, { x, y });
}
static ImageId PaintPSColourifyImage(const paint_struct* ps, ImageId imageId, uint32_t viewFlags)
{
auto visibility = GetPaintStructVisibility(ps, viewFlags);
@@ -848,7 +836,7 @@ bool PaintAttachToPreviousAttach(paint_session& session, ImageId imageId, int32_
ps->image_id = imageId;
ps->x = x;
ps->y = y;
ps->flags = 0;
ps->IsMasked = false;
ps->next = nullptr;
previousAttachedPS->next = ps;
@@ -886,7 +874,7 @@ bool PaintAttachToPreviousPS(paint_session& session, ImageId image_id, int32_t x
ps->image_id = image_id;
ps->x = x;
ps->y = y;
ps->flags = 0;
ps->IsMasked = false;
attached_paint_struct* oldFirstAttached = masterPs->attached_ps;
masterPs->attached_ps = ps;

View File

@@ -28,10 +28,10 @@ struct attached_paint_struct
{
attached_paint_struct* next;
ImageId image_id;
ImageId colour_image_id;
ImageId ColourImageId;
int32_t x;
int32_t y;
uint8_t flags;
bool IsMasked;
};
struct paint_struct_bound_box
@@ -53,13 +53,11 @@ struct paint_struct
TileElement* tileElement;
EntityBase* entity;
ImageId image_id;
ImageId colour_image_id;
int32_t x;
int32_t y;
int32_t map_x;
int32_t map_y;
uint16_t quadrant_index;
uint8_t flags;
uint8_t SortFlags;
ViewportInteractionItem sprite_type;
};
@@ -111,11 +109,6 @@ struct sprite_bb
CoordsXYZ bb_size;
};
enum PAINT_STRUCT_FLAGS
{
PAINT_STRUCT_FLAG_IS_MASKED = (1 << 0)
};
struct support_height
{
uint16_t height;

View File

@@ -545,8 +545,8 @@ static void viewport_surface_smoothen_edge(
{
attached_paint_struct* out = session.LastAttachedPS;
// set content and enable masking
out->colour_image_id = get_surface_pattern(neighbour.terrain, cl);
out->flags |= PAINT_STRUCT_FLAG_IS_MASKED;
out->ColourImageId = get_surface_pattern(neighbour.terrain, cl);
out->IsMasked = true;
}
}

View File

@@ -342,7 +342,6 @@ static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoo
{ xOffset + 1, yOffset + 16, segmentHeight });
if (ps != nullptr)
{
ps->flags &= PAINT_STRUCT_FLAG_IS_MASKED;
ps->image_id = ps->image_id.WithTertiary(COLOUR_BORDEAUX_RED);
}
}