Skip to content

Commit

Permalink
Part of #16152: Use BoundBoxXYZ for PaintAddImageAsChild
Browse files Browse the repository at this point in the history
  • Loading branch information
frutiemax92 committed Nov 27, 2022
1 parent 540e5d2 commit 76faa77
Show file tree
Hide file tree
Showing 31 changed files with 157 additions and 160 deletions.
11 changes: 7 additions & 4 deletions src/openrct2/entity/Peep.cpp
Expand Up @@ -2821,29 +2821,32 @@ void Peep::Paint(PaintSession& session, int32_t imageDirection) const
// bound_box_offset_z to make sure peeps are drawn on top of railways
uint32_t baseImageId = (imageDirection >> 3) + GetPeepAnimation(SpriteType, actionSpriteType).base_image + imageOffset * 4;
auto imageId = ImageId(baseImageId, TshirtColour, TrousersColour);
PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 1, 1, 11 }, { 0, 0, z + 5 });

auto bb = BoundBoxXYZ{ { 0, 0, z + 5 }, { 1, 1, 11 } };
auto offset = CoordsXYZ{ 0, 0, z };
PaintAddImageAsParent(session, imageId, { 0, 0, z }, bb);

auto* guest = As<Guest>();
if (guest != nullptr)
{
if (baseImageId >= 10717 && baseImageId < 10749)
{
imageId = ImageId(baseImageId + 32, guest->HatColour);
PaintAddImageAsChild(session, imageId, { 0, 0, z }, { 1, 1, 11 }, { 0, 0, z + 5 });
PaintAddImageAsChild(session, imageId, offset, bb);
return;
}

if (baseImageId >= 10781 && baseImageId < 10813)
{
imageId = ImageId(baseImageId + 32, guest->BalloonColour);
PaintAddImageAsChild(session, imageId, { 0, 0, z }, { 1, 1, 11 }, { 0, 0, z + 5 });
PaintAddImageAsChild(session, imageId, offset, bb);
return;
}

if (baseImageId >= 11197 && baseImageId < 11229)
{
imageId = ImageId(baseImageId + 32, guest->UmbrellaColour);
PaintAddImageAsChild(session, imageId, { 0, 0, z }, { 1, 1, 11 }, { 0, 0, z + 5 });
PaintAddImageAsChild(session, imageId, offset, bb);
return;
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/openrct2/paint/Paint.cpp
Expand Up @@ -757,13 +757,6 @@ PaintStruct* PaintAddImageAsParent(
return CreateNormalPaintStruct(session, imageId, offset, boundBox);
}

PaintStruct* PaintAddImageAsChild(
PaintSession& session, const ImageId imageId, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength,
const CoordsXYZ& boundBoxOffset)
{
return PaintAddImageAsChild(session, imageId, offset, { boundBoxOffset, boundBoxLength });
}

/**
*
* rct2: 0x006874B0, 0x00687618, 0x0068778C, 0x00687902, 0x0098199C
Expand Down
3 changes: 0 additions & 3 deletions src/openrct2/paint/Paint.h
Expand Up @@ -303,9 +303,6 @@ PaintStruct* PaintAddImageAsParent(
PaintSession& session, const ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox);
[[nodiscard]] PaintStruct* PaintAddImageAsOrphan(
PaintSession& session, const ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox);
PaintStruct* PaintAddImageAsChild(
PaintSession& session, const ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength,
const CoordsXYZ& boundBoxOffset);
PaintStruct* PaintAddImageAsChild(
PaintSession& session, const ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox);

Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/paint/PaintHelpers.cpp
Expand Up @@ -45,11 +45,11 @@ PaintStruct* PaintAddImageAsChildRotated(
if (direction & 1)
{
return PaintAddImageAsChild(
session, image_id, { offset.y, offset.x, offset.z }, { boundBoxSize.y, boundBoxSize.x, boundBoxSize.z },
{ boundBoxOffset.y, boundBoxOffset.x, boundBoxOffset.z });
session, image_id, { offset.y, offset.x, offset.z },
{ { boundBoxOffset.y, boundBoxOffset.x, boundBoxOffset.z }, { boundBoxSize.y, boundBoxSize.x, boundBoxSize.z } });
}

return PaintAddImageAsChild(session, image_id, offset, boundBoxSize, boundBoxOffset);
return PaintAddImageAsChild(session, image_id, offset, { boundBoxOffset, boundBoxSize });
}

void PaintUtilPushTunnelRotated(PaintSession& session, uint8_t direction, uint16_t height, uint8_t type)
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/paint/tile_element/Paint.Banner.cpp
Expand Up @@ -64,7 +64,7 @@ static void PaintBannerScrollingText(
auto stringWidth = gfx_get_string_width(text, FontStyle::Tiny);
auto scroll = (gCurrentTicks / 2) % stringWidth;
auto imageId = scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, COLOUR_BLACK);
PaintAddImageAsChild(session, imageId, { 0, 0, height + 22 }, { 1, 1, 21 }, bbOffset);
PaintAddImageAsChild(session, imageId, { 0, 0, height + 22 }, { bbOffset, { 1, 1, 21 } });
}

void PaintBanner(PaintSession& session, uint8_t direction, int32_t height, const BannerElement& bannerElement)
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/paint/tile_element/Paint.Entrance.cpp
Expand Up @@ -74,7 +74,7 @@ static void PaintRideEntranceExitScrollingText(

PaintAddImageAsChild(
session, scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, stationObj.ScrollingMode, COLOUR_BLACK),
{ 0, 0, height + stationObj.Height }, { 28, 28, 51 }, { 2, 2, height + stationObj.Height });
{ 0, 0, height + stationObj.Height }, { { 2, 2, height + stationObj.Height }, { 28, 28, 51 } });
}

static void PaintRideEntranceExitLightEffects(PaintSession& session, int32_t height, const EntranceElement& entranceEl)
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/paint/tile_element/Paint.LargeScenery.cpp
Expand Up @@ -324,7 +324,7 @@ static void PaintLargeSceneryScrollingText(
auto stringWidth = gfx_get_string_width(text, FontStyle::Tiny);
auto scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
auto imageId = scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollMode, textPaletteIndex);
PaintAddImageAsChild(session, imageId, { 0, 0, height + 25 }, { 1, 1, 21 }, bbOffset);
PaintAddImageAsChild(session, imageId, { 0, 0, height + 25 }, { bbOffset, { 1, 1, 21 } });
}

void PaintLargeScenery(PaintSession& session, uint8_t direction, uint16_t height, const LargeSceneryElement& tileElement)
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/paint/tile_element/Paint.Path.cpp
Expand Up @@ -471,7 +471,7 @@ static void PathPaintFencesAndQueueBanners(

PaintAddImageAsChild(
session, scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, COLOUR_BLACK),
{ 0, 0, height + 7 }, { 1, 1, 21 }, boundBoxOffsets);
{ 0, 0, height + 7 }, { boundBoxOffsets, { 1, 1, 21 } });
}

session.InteractionType = ViewportInteractionItem::Footpath;
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/paint/tile_element/Paint.Wall.cpp
Expand Up @@ -184,7 +184,7 @@ static void PaintWallScrollingText(
auto stringWidth = gfx_get_string_width(signString, FontStyle::Tiny);
auto scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
auto imageId = scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollingMode, textPaletteIndex);
PaintAddImageAsChild(session, imageId, { 0, 0, height + 8 }, { 1, 1, 13 }, boundsOffset);
PaintAddImageAsChild(session, imageId, { 0, 0, height + 8 }, { boundsOffset, { 1, 1, 13 } });
}

static void PaintWallWall(
Expand Down
10 changes: 5 additions & 5 deletions src/openrct2/ride/TrackPaint.cpp
Expand Up @@ -298,17 +298,17 @@ void track_paint_util_paint_fences(
if (edges & EDGE_NW && track_paint_util_has_fence(EDGE_NW, position, trackElement, ride, rotation))
{
PaintAddImageAsChild(
session, colourFlags.WithIndex(fenceSprites[3]), { 0, 0, height }, { 32, 1, 7 }, { 0, 2, height + 2 });
session, colourFlags.WithIndex(fenceSprites[3]), { 0, 0, height }, { { 0, 2, height + 2 }, { 32, 1, 7 } });
}
if (edges & EDGE_NE && track_paint_util_has_fence(EDGE_NE, position, trackElement, ride, rotation))
{
PaintAddImageAsChild(
session, colourFlags.WithIndex(fenceSprites[0]), { 0, 0, height }, { 1, 32, 7 }, { 2, 0, height + 2 });
session, colourFlags.WithIndex(fenceSprites[0]), { 0, 0, height }, { { 2, 0, height + 2 }, { 1, 32, 7 } });
}
if (edges & EDGE_SE && track_paint_util_has_fence(EDGE_SE, position, trackElement, ride, rotation))
{
PaintAddImageAsParent(
session, colourFlags.WithIndex(fenceSprites[1]), { 0, 0, height }, { 32, 1, 7 }, { 0, 30, height + 2 });
session, colourFlags.WithIndex(fenceSprites[1]), { 0, 0, height }, { { 0, 30, height + 2 }, { 32, 1, 7 } });
}
if (edges & EDGE_SW && track_paint_util_has_fence(EDGE_SW, position, trackElement, ride, rotation))
{
Expand Down Expand Up @@ -2031,11 +2031,11 @@ void track_paint_util_spinning_tunnel_paint(PaintSession& session, int8_t thickn
auto imageId = colourFlags.WithIndex(trackSpritesGhostTrainSpinningTunnel[direction & 1][0][frame]);
if (direction == 0 || direction == 2)
{
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 28, 20, thickness }, { 2, 6, height });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 2, 6, height }, { 28, 20, thickness } });
}
else
{
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 20, 28, thickness }, { 6, 2, height });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 6, 2, height }, { 20, 28, thickness } });
}

imageId = colourFlags.WithIndex(trackSpritesGhostTrainSpinningTunnel[direction & 1][1][frame]);
Expand Down
10 changes: 5 additions & 5 deletions src/openrct2/ride/VehiclePaint.cpp
Expand Up @@ -3520,7 +3520,7 @@ static void vehicle_visual_splash1_effect(PaintSession& session, int32_t z, cons
}
int32_t image_id = SPR_SPLASH_EFFECT_1_NE_0 + ((((vehicle->sprite_direction / 8) + session.CurrentRotation) & 3) * 8)
+ ((gCurrentTicks / 2) & 7);
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { 0, 0, 0 }, { 0, 0, z });
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { { 0, 0, z }, { 0, 0, 0 } });
}

/**
Expand All @@ -3543,7 +3543,7 @@ static void vehicle_visual_splash2_effect(PaintSession& session, int32_t z, cons
}
int32_t image_id = SPR_SPLASH_EFFECT_3_NE_0 + ((((vehicle->sprite_direction / 8) + session.CurrentRotation) & 3) * 8)
+ ((gCurrentTicks / 2) & 7);
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { 0, 0, 0 }, { 0, 0, z });
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { { 0, 0, z }, { 0, 0, 0 } });
}

/**
Expand All @@ -3566,7 +3566,7 @@ static void vehicle_visual_splash3_effect(PaintSession& session, int32_t z, cons
}
int32_t image_id = SPR_SPLASH_EFFECT_1_NE_0 + ((((vehicle->sprite_direction / 8) + session.CurrentRotation) & 3) * 8)
+ ((gCurrentTicks / 2) & 7);
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { 0, 0, 0 }, { 0, 0, z });
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { { 0, 0, z }, { 0, 0, 0 } });
}

/**
Expand Down Expand Up @@ -3594,7 +3594,7 @@ static void vehicle_visual_splash4_effect(PaintSession& session, int32_t z, cons
}
int32_t image_id = SPR_SPLASH_EFFECT_5_NE_0 + ((((vehicle->sprite_direction / 8) + session.CurrentRotation) & 3) * 8)
+ ((gCurrentTicks / 2) & 7);
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { 1, 1, 0 }, { 0, 0, z });
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { { 0, 0, z }, { 1, 1, 0 } });
}

/**
Expand Down Expand Up @@ -3626,7 +3626,7 @@ static void vehicle_visual_splash5_effect(PaintSession& session, int32_t z, cons
}
int32_t image_id = SPR_SPLASH_EFFECT_5_NE_0 + ((((vehicle->sprite_direction / 8) + session.CurrentRotation) & 3) * 8)
+ ((gCurrentTicks / 2) & 7);
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { 1, 1, 0 }, { 0, 0, z });
PaintAddImageAsChild(session, ImageId(image_id), { 0, 0, z }, { { 0, 0, z }, { 1, 1, 0 } });
}

void vehicle_visual_splash_effect(PaintSession& session, int32_t z, const Vehicle* vehicle, const CarEntry* carEntry)
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/ride/coaster/JuniorRollerCoaster.cpp
Expand Up @@ -1855,7 +1855,7 @@ void junior_rc_paint_station(
{
imageId = session.TrackColours[SCHEME_TRACK].WithIndex(junior_rc_track_pieces_station[false][direction]);
}
PaintAddImageAsChild(session, imageId, { 0, 6, height }, { 32, 20, 1 }, { 0, 0, height });
PaintAddImageAsChild(session, imageId, { 0, 6, height }, { { 0, 0, height }, { 32, 20, 1 } });

MetalASupportsPaintSetup(session, METAL_SUPPORTS_BOXED, 5, 0, height, session.TrackColours[SCHEME_SUPPORTS]);
MetalASupportsPaintSetup(session, METAL_SUPPORTS_BOXED, 8, 0, height, session.TrackColours[SCHEME_SUPPORTS]);
Expand All @@ -1877,7 +1877,7 @@ void junior_rc_paint_station(
{
imageId = session.TrackColours[SCHEME_TRACK].WithIndex(junior_rc_track_pieces_station[false][direction]);
}
PaintAddImageAsChild(session, imageId, { 6, 0, height }, { 20, 32, 1 }, { 0, 0, height });
PaintAddImageAsChild(session, imageId, { 6, 0, height }, { { 0, 0, height }, { 20, 32, 1 } });

MetalASupportsPaintSetup(session, METAL_SUPPORTS_BOXED, 6, 0, height, session.TrackColours[SCHEME_SUPPORTS]);
MetalASupportsPaintSetup(session, METAL_SUPPORTS_BOXED, 7, 0, height, session.TrackColours[SCHEME_SUPPORTS]);
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/ride/coaster/ReverseFreefallCoaster.cpp
Expand Up @@ -231,7 +231,7 @@ static void paint_reverse_freefall_rc_station(
// height += 2 (height)

imageId = session.TrackColours[SCHEME_TRACK].WithIndex(reverse_freefall_rc_track_pieces_station[direction]);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 0, 6, height }, { 32, 20, 1 } });

WoodenASupportsPaintSetup(session, (direction & 1) ? 1 : 0, 0, height, session.TrackColours[SCHEME_SUPPORTS]);
PaintUtilPushTunnelLeft(session, height, TUNNEL_SQUARE_FLAT);
Expand All @@ -244,7 +244,7 @@ static void paint_reverse_freefall_rc_station(
// height += 2 (height)

imageId = session.TrackColours[SCHEME_TRACK].WithIndex(reverse_freefall_rc_track_pieces_station[direction]);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 6, 0, height }, { 20, 32, 1 } });

WoodenASupportsPaintSetup(session, (direction & 1) ? 1 : 0, 0, height, session.TrackColours[SCHEME_SUPPORTS]);
PaintUtilPushTunnelRight(session, height, TUNNEL_SQUARE_FLAT);
Expand Down
16 changes: 7 additions & 9 deletions src/openrct2/ride/coaster/VirginiaReel.cpp
Expand Up @@ -186,17 +186,17 @@ void vehicle_visual_virginia_reel(
}
}();
baseImage_id += ecx & 7;
const vehicle_boundbox* bb = &_virginiaReelBoundbox[baseImage_id >> 3];
const auto& vehicleBb = _virginiaReelBoundbox[baseImage_id >> 3];
auto bb = BoundBoxXYZ{ { vehicleBb.offset_x, vehicleBb.offset_y, vehicleBb.offset_z + z },
{ vehicleBb.length_x, vehicleBb.length_y, vehicleBb.length_z } };

baseImage_id += carEntry->base_image_id;
auto image_id = ImageId(baseImage_id, vehicle->colours.Body, vehicle->colours.Trim);
if (vehicle->IsGhost())
{
image_id = ConstructionMarker.WithIndex(image_id.GetIndex());
}
PaintAddImageAsParent(
session, image_id, { 0, 0, z }, { bb->length_x, bb->length_y, bb->length_z },
{ bb->offset_x, bb->offset_y, bb->offset_z + z });
PaintAddImageAsParent(session, image_id, { 0, 0, z }, bb);

if (session.DPI.zoom_level < ZoomLevel{ 2 } && vehicle->num_peeps > 0 && !vehicle->IsGhost())
{
Expand All @@ -211,9 +211,7 @@ void vehicle_visual_virginia_reel(
if (riding_peep_sprites[i] != 0xFF)
{
image_id = ImageId(baseImage_id + ((i + 1) * 72), riding_peep_sprites[i]);
PaintAddImageAsChild(
session, image_id, { 0, 0, z }, { bb->length_x, bb->length_y, bb->length_z },
{ bb->offset_x, bb->offset_y, bb->offset_z + z });
PaintAddImageAsChild(session, image_id, { 0, 0, z }, bb);
}
}
}
Expand Down Expand Up @@ -438,7 +436,7 @@ static void paint_virginia_reel_station(
PaintAddImageAsParent(session, imageId, { 0, 0, height - 2 }, { 32, 28, 2 }, { 0, 2, height });

imageId = session.TrackColours[SCHEME_TRACK].WithIndex(SPR_VIRGINIA_REEL_FLAT_SW_NE);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 32, 20, 2 }, { 0, 0, height });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 0, 0, height }, { 32, 20, 2 } });

PaintUtilPushTunnelLeft(session, height, TUNNEL_SQUARE_FLAT);
}
Expand All @@ -448,7 +446,7 @@ static void paint_virginia_reel_station(
PaintAddImageAsParent(session, imageId, { 0, 0, height - 2 }, { 28, 32, 2 }, { 2, 0, height });

imageId = session.TrackColours[SCHEME_TRACK].WithIndex(SPR_VIRGINIA_REEL_FLAT_NW_SE);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 20, 32, 2 }, { 0, 0, height });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 0, 0, height }, { 20, 32, 2 } });

PaintUtilPushTunnelRight(session, height, TUNNEL_SQUARE_FLAT);
}
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/ride/coaster/WoodenRollerCoaster.h
Expand Up @@ -68,8 +68,8 @@ template<bool isClassic> void wooden_rc_track_paint_bb(PaintSession& session, co
{
ImageId railsImageId = wooden_rc_get_rails_colour(session).WithIndex(bb->sprite_id_b);
PaintAddImageAsChild(
session, railsImageId, { bb->offset.x, bb->offset.y, height + bb->offset.z }, bb->bb_size,
{ bb->bb_offset.x, bb->bb_offset.y, height + bb->bb_offset.z });
session, railsImageId, { bb->offset.x, bb->offset.y, height + bb->offset.z },
{ { bb->bb_offset, height + bb->bb_offset.z }, bb->bb_size });
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/ride/gentle/CarRide.cpp
Expand Up @@ -345,11 +345,11 @@ static void PaintCarRideStation(
imageId = session.TrackColours[SCHEME_TRACK].WithIndex(CarRideTrackPiecesFlat[direction]);
if (direction == 0 || direction == 2)
{
PaintAddImageAsChild(session, imageId, { 0, 6, height }, { 32, 20, 1 }, { 0, 0, height });
PaintAddImageAsChild(session, imageId, { 0, 6, height }, { { 0, 0, height }, { 32, 20, 1 } });
}
else
{
PaintAddImageAsChild(session, imageId, { 6, 0, height }, { 20, 32, 1 }, { 0, 0, height });
PaintAddImageAsChild(session, imageId, { 6, 0, height }, { { 0, 0, height }, { 20, 32, 1 } });
}

if (direction == 0 || direction == 2)
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/ride/gentle/FerrisWheel.cpp
Expand Up @@ -130,12 +130,12 @@ static void PaintFerrisWheel(
if (edges & EDGE_NW && track_paint_util_has_fence(EDGE_NW, session.MapPosition, trackElement, ride, rotation))
{
imageId = colourFlags.WithIndex(SPR_FENCE_ROPE_NW);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 32, 1, 7 }, { 0, 2, height + 2 });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 0, 2, height + 2 }, { 32, 1, 7 } });
}
if (edges & EDGE_NE && track_paint_util_has_fence(EDGE_NE, session.MapPosition, trackElement, ride, rotation))
{
imageId = colourFlags.WithIndex(SPR_FENCE_ROPE_NE);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 1, 32, 7 }, { 2, 0, height + 2 });
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 2, 0, height + 2 }, { 1, 32, 7 } });
}
if (edges & EDGE_SE && track_paint_util_has_fence(EDGE_SE, session.MapPosition, trackElement, ride, rotation))
{
Expand Down

0 comments on commit 76faa77

Please sign in to comment.