From 7bb7d97bdc499775b3b128c5e19d1ebc837ddd2e Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Tue, 27 Sep 2022 21:20:49 +0200 Subject: [PATCH] More bound box refactors --- src/openrct2/paint/Paint.cpp | 40 ++++---- src/openrct2/paint/Paint.h | 9 +- src/openrct2/paint/Supports.cpp | 52 +++++------ .../paint/tile_element/Paint.Entrance.cpp | 32 +++---- .../paint/tile_element/Paint.LargeScenery.cpp | 13 +-- .../paint/tile_element/Paint.Path.cpp | 48 +++++----- .../paint/tile_element/Paint.SmallScenery.cpp | 60 ++++++------ .../paint/tile_element/Paint.Surface.cpp | 20 ++-- .../paint/tile_element/Paint.Wall.cpp | 92 +++++++------------ src/openrct2/ride/TrackPaint.cpp | 18 ++-- src/openrct2/ride/VehiclePaint.cpp | 4 +- src/openrct2/ride/gentle/FerrisWheel.cpp | 17 ++-- src/openrct2/ride/gentle/HauntedHouse.cpp | 2 +- src/openrct2/ride/gentle/MerryGoRound.cpp | 11 +-- src/openrct2/ride/shops/Facility.cpp | 10 +- src/openrct2/ride/shops/Shop.cpp | 10 +- src/openrct2/ride/thrill/Enterprise.cpp | 12 +-- src/openrct2/ride/thrill/MagicCarpet.cpp | 50 +++++----- src/openrct2/ride/thrill/MotionSimulator.cpp | 13 +-- .../ride/thrill/SwingingInverterShip.cpp | 11 +-- src/openrct2/ride/thrill/SwingingShip.cpp | 15 ++- src/openrct2/ride/thrill/TopSpin.cpp | 24 ++--- src/openrct2/ride/thrill/Twist.cpp | 11 ++- 23 files changed, 261 insertions(+), 313 deletions(-) diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 13fe176342..b4fb0045b9 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -20,6 +20,7 @@ #include "../profiling/Profiling.h" #include "../util/Math.hpp" #include "../world/SmallScenery.h" +#include "Boundbox.h" #include "Paint.Entity.h" #include "tile_element/Paint.TileElement.h" @@ -148,8 +149,7 @@ static constexpr CoordsXYZ RotateBoundBoxSize(const CoordsXYZ& bbSize, const uin * Extracted from 0x0098196c, 0x0098197c, 0x0098198c, 0x0098199c */ static paint_struct* CreateNormalPaintStruct( - paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, - const CoordsXYZ& boundBoxOffset) + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox) { auto* const g1 = gfx_get_g1_element(image_id); if (g1 == nullptr) @@ -168,8 +168,8 @@ static paint_struct* CreateNormalPaintStruct( return nullptr; } - const auto rotBoundBoxOffset = CoordsXYZ{ boundBoxOffset.Rotate(swappedRotation), boundBoxOffset.z }; - const auto rotBoundBoxSize = RotateBoundBoxSize(boundBoxSize, session.CurrentRotation); + const auto rotBoundBoxOffset = CoordsXYZ{ boundBox.offset.Rotate(swappedRotation), boundBox.offset.z }; + const auto rotBoundBoxSize = RotateBoundBoxSize(boundBox.length, session.CurrentRotation); auto* ps = session.AllocateNormalPaintEntry(); if (ps == nullptr) @@ -690,20 +690,20 @@ void PaintSessionFree([[maybe_unused]] paint_session* session) paint_struct* PaintAddImageAsParent( paint_session& session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize) { - return PaintAddImageAsParent(session, ImageId::FromUInt32(image_id), offset, boundBoxSize, offset); + return PaintAddImageAsParent(session, ImageId::FromUInt32(image_id), offset, { offset, boundBoxSize }); } paint_struct* PaintAddImageAsParent( paint_session& session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, const CoordsXYZ& boundBoxOffset) { - return PaintAddImageAsParent(session, ImageId::FromUInt32(image_id), offset, boundBoxSize, boundBoxOffset); + return PaintAddImageAsParent(session, ImageId::FromUInt32(image_id), offset, { boundBoxOffset, boundBoxSize }); } paint_struct* PaintAddImageAsParent( paint_session& session, ImageId imageId, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize) { - return PaintAddImageAsParent(session, imageId, offset, boundBoxSize, offset); + return PaintAddImageAsParent(session, imageId, offset, { offset, boundBoxSize }); } /** @@ -723,13 +723,12 @@ paint_struct* PaintAddImageAsParent( */ // Track Pieces, Shops. paint_struct* PaintAddImageAsParent( - paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, - const CoordsXYZ& boundBoxOffset) + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox) { session.LastPS = nullptr; session.LastAttachedPS = nullptr; - auto* ps = CreateNormalPaintStruct(session, image_id, offset, boundBoxSize, boundBoxOffset); + auto* ps = CreateNormalPaintStruct(session, image_id, offset, boundBox); if (ps == nullptr) { return nullptr; @@ -740,6 +739,13 @@ paint_struct* PaintAddImageAsParent( return ps; } +paint_struct* PaintAddImageAsParent( + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, + const CoordsXYZ& boundBoxOffset) +{ + return PaintAddImageAsParent(session, image_id, offset, { boundBoxOffset, boundBoxSize }); +} + /** * * rct2: 0x00686EF0, 0x00687056, 0x006871C8, 0x0068733C, 0x0098198C @@ -758,19 +764,18 @@ paint_struct* PaintAddImageAsParent( * Creates a paint struct but does not allocate to a paint quadrant. Result cannot be ignored! */ [[nodiscard]] paint_struct* PaintAddImageAsOrphan( - paint_session& session, ImageId imageId, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, - const CoordsXYZ& boundBoxOffset) + paint_session& session, ImageId imageId, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox) { session.LastPS = nullptr; session.LastAttachedPS = nullptr; - return CreateNormalPaintStruct(session, imageId, offset, boundBoxSize, boundBoxOffset); + return CreateNormalPaintStruct(session, imageId, offset, boundBox); } paint_struct* PaintAddImageAsChild( paint_session& session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength, const CoordsXYZ& boundBoxOffset) { - return PaintAddImageAsChild(session, ImageId::FromUInt32(image_id), offset, boundBoxLength, boundBoxOffset); + return PaintAddImageAsChild(session, ImageId::FromUInt32(image_id), offset, { boundBoxOffset, boundBoxLength }); } /** @@ -791,16 +796,15 @@ paint_struct* PaintAddImageAsChild( * If there is no parent paint struct then image is added as a parent */ paint_struct* PaintAddImageAsChild( - paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength, - const CoordsXYZ& boundBoxOffset) + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox) { paint_struct* parentPS = session.LastPS; if (parentPS == nullptr) { - return PaintAddImageAsParent(session, image_id, offset, boundBoxLength, boundBoxOffset); + return PaintAddImageAsParent(session, image_id, offset, boundBox); } - auto* ps = CreateNormalPaintStruct(session, image_id, offset, boundBoxLength, boundBoxOffset); + auto* ps = CreateNormalPaintStruct(session, image_id, offset, boundBox); if (ps == nullptr) { return nullptr; diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 93c130c825..c23ae61cc5 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -15,6 +15,7 @@ #include "../interface/Colour.h" #include "../world/Location.hpp" #include "../world/Map.h" +#include "Boundbox.h" #include #include @@ -298,18 +299,18 @@ paint_struct* PaintAddImageAsParent( const CoordsXYZ& boundBoxOffset); paint_struct* PaintAddImageAsParent( paint_session& session, ImageId imageId, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize); +paint_struct* PaintAddImageAsParent( + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox); paint_struct* PaintAddImageAsParent( paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, const CoordsXYZ& boundBoxOffset); [[nodiscard]] paint_struct* PaintAddImageAsOrphan( - paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, - const CoordsXYZ& boundBoxOffset); + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox); paint_struct* PaintAddImageAsChild( paint_session& session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength, const CoordsXYZ& boundBoxOffset); paint_struct* PaintAddImageAsChild( - paint_session& session, ImageId image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength, - const CoordsXYZ& boundBoxOffset); + paint_session& session, ImageId image_id, const CoordsXYZ& offset, const BoundBoxXYZ& boundBox); paint_struct* PaintAddImageAsChildRotated( paint_session& session, const uint8_t direction, const uint32_t image_id, const CoordsXYZ& offset, diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 89b0dfb0c8..8cec0d31af 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -519,8 +519,9 @@ bool wooden_a_supports_paint_setup( else { auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); - PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, 11 }, { 0, 0, z + 2 }); - PaintAddImageAsParent(session, imageId.WithIndexOffset(4), { 0, 0, z + 16 }, { 32, 32, 11 }, { 0, 0, z + 16 + 2 }); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, { { 0, 0, z + 2 }, { 32, 32, 11 } }); + PaintAddImageAsParent( + session, imageId.WithIndexOffset(4), { 0, 0, z + 16 }, { { 0, 0, z + 16 + 2 }, { 32, 32, 11 } }); hasSupports = true; } @@ -543,7 +544,7 @@ bool wooden_a_supports_paint_setup( else { auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); - PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, 11 }, { 0, 0, z + 2 }); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, { { 0, 0, z + 2 }, { 32, 32, 11 } }); hasSupports = true; } z += 16; @@ -592,19 +593,18 @@ bool wooden_a_supports_paint_setup( { auto imageId = imageTemplate.WithIndex(WoodenCurveSupportImageIds[supportType][special]); - const BoundBoxXYZ& bBox = byte_97B23C[special].bounding_box; + auto bBox = byte_97B23C[special].bounding_box; + bBox.offset.z += z; if (byte_97B23C[special].var_6 == 0 || session.WoodenSupportsPrependTo == nullptr) { - PaintAddImageAsParent( - session, imageId, { 0, 0, z }, bBox.length, { bBox.offset.x, bBox.offset.y, bBox.offset.z + z }); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, bBox); hasSupports = true; } else { hasSupports = true; - auto* ps = PaintAddImageAsOrphan( - session, imageId, { 0, 0, z }, bBox.length, { bBox.offset.x, bBox.offset.y, bBox.offset.z + z }); + auto* ps = PaintAddImageAsOrphan(session, imageId, { 0, 0, z }, bBox); if (ps != nullptr) { session.WoodenSupportsPrependTo->children = ps; @@ -680,11 +680,11 @@ bool wooden_b_supports_paint_setup( auto imageid = imageTemplate.WithIndex( imageIndex + word_97B3C4[session.Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); - PaintAddImageAsParent(session, imageid, { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); + PaintAddImageAsParent(session, imageid, { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } }); baseHeight += 16; PaintAddImageAsParent( - session, imageid.WithIndexOffset(4), { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); + session, imageid.WithIndexOffset(4), { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 3 } }); baseHeight += 16; _9E32B1 = true; @@ -709,7 +709,7 @@ bool wooden_b_supports_paint_setup( auto imageId = imageTemplate.WithIndex( imageIndex + word_97B3C4[session.Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); - PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); + PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 3 } }); baseHeight += 16; _9E32B1 = true; @@ -765,20 +765,17 @@ bool wooden_b_supports_paint_setup( { // byte_97B23C[special].var_7 is never 0 auto imageId = imageTemplate.WithIndex(WoodenCurveSupportImageIds[supportType][specialIndex]); - const BoundBoxXYZ& boundBox = supportsDesc.bounding_box; + auto boundBox = supportsDesc.bounding_box; + boundBox.offset.z += baseHeight; if (supportsDesc.var_6 == 0 || session.WoodenSupportsPrependTo == nullptr) { - PaintAddImageAsParent( - session, imageId, { 0, 0, baseHeight }, boundBox.length, - { boundBox.offset.x, boundBox.offset.y, boundBox.offset.z + baseHeight }); + PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, boundBox); _9E32B1 = true; } else { - auto* paintStruct = PaintAddImageAsOrphan( - session, imageId, { 0, 0, baseHeight }, boundBox.length, - { boundBox.offset.x, boundBox.offset.y, boundBox.offset.z + baseHeight }); + auto* paintStruct = PaintAddImageAsOrphan(session, imageId, { 0, 0, baseHeight }, boundBox); _9E32B1 = true; if (paintStruct != nullptr) { @@ -1240,11 +1237,11 @@ bool path_a_supports_paint_setup( + pathPaintInfo.BridgeImageId; PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageId), { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); + session, imageTemplate.WithIndex(imageId), { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } }); baseHeight += 16; PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageId + 4), { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); + session, imageTemplate.WithIndex(imageId + 4), { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } }); baseHeight += 16; hasSupports = true; @@ -1263,7 +1260,7 @@ bool path_a_supports_paint_setup( + pathPaintInfo.BridgeImageId; PaintAddImageAsParent( - session, imageTemplate.WithIndex(ebx), { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); + session, imageTemplate.WithIndex(ebx), { 0, 0, baseHeight }, { { 0, 0, baseHeight + 2 }, { 32, 32, 11 } }); hasSupports = true; baseHeight += 16; @@ -1300,20 +1297,18 @@ bool path_a_supports_paint_setup( ImageIndex imageIndex = pathPaintInfo.BridgeImageId + 55 + specialIndex; const unk_supports_desc& supportsDesc = byte_98D8D4[specialIndex]; - const BoundBoxXYZ& boundBox = supportsDesc.bounding_box; + auto boundBox = supportsDesc.bounding_box; + boundBox.offset.z += baseHeight; if (supportsDesc.var_6 == 0 || session.WoodenSupportsPrependTo == nullptr) { - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, baseHeight }, boundBox.length, - { boundBox.offset.x, boundBox.offset.y, baseHeight + boundBox.offset.z }); + PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), { 0, 0, baseHeight }, boundBox); hasSupports = true; } else { paint_struct* paintStruct = PaintAddImageAsOrphan( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, baseHeight }, boundBox.length, - { boundBox.offset.x, boundBox.offset.y, baseHeight + boundBox.offset.z }); + session, imageTemplate.WithIndex(imageIndex), { 0, 0, baseHeight }, boundBox); hasSupports = true; if (paintStruct != nullptr) { @@ -1477,8 +1472,7 @@ bool path_b_supports_paint_setup( ImageIndex imageIndex = pathPaintInfo.BridgeImageId + 20 + (z - 1); PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { SupportBoundBoxes[segment], baseHeight }, { 0, 0, 0 }, - { SupportBoundBoxes[segment], baseHeight }); + session, imageTemplate.WithIndex(imageIndex), { SupportBoundBoxes[segment], baseHeight }, { 0, 0, 0 }); baseHeight += z; } diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.cpp b/src/openrct2/paint/tile_element/Paint.Entrance.cpp index fe8c5c212e..dd8f887a4d 100644 --- a/src/openrct2/paint/tile_element/Paint.Entrance.cpp +++ b/src/openrct2/paint/tile_element/Paint.Entrance.cpp @@ -159,33 +159,33 @@ static void PaintRideEntranceExit(paint_session& session, uint8_t direction, int // Certain entrance styles have another 2 images to draw for coloured windows auto isExit = entranceEl.GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT; - auto lengthY = (direction & 1) ? 28 : 2; - auto lengthX = (direction & 1) ? 2 : 28; - auto lengthZ = isExit ? 35 : 51; + CoordsXYZ boundBoxLength = { + (direction & 1) ? 2 : 28, + (direction & 1) ? 28 : 2, + isExit ? 35 : 51, + }; // Back ImageIndex imageIndex = isExit ? stationObj->BaseImageId + direction + 8 : stationObj->BaseImageId + direction; ImageIndex glassImageIndex = isExit ? stationObj->BaseImageId + direction + 24 : stationObj->BaseImageId + direction + 16; - PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { lengthX, lengthY, lengthZ }, { 2, 2, height }); + PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { { 2, 2, height }, boundBoxLength }); if (hasGlass) { PaintAddImageAsChild( - session, glassImageTemplate.WithIndex(glassImageIndex), { 0, 0, height }, { lengthX, lengthY, lengthZ }, - { 2, 2, height }); + session, glassImageTemplate.WithIndex(glassImageIndex), { 0, 0, height }, { { 2, 2, height }, boundBoxLength }); } // Front imageIndex += 4; PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { lengthX, lengthY, lengthZ }, - { (direction & 1) ? 28 : 2, (direction & 1) ? 2 : 28, height }); + session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, + { { (direction & 1) ? 28 : 2, (direction & 1) ? 2 : 28, height }, boundBoxLength }); if (hasGlass) { glassImageIndex += 4; PaintAddImageAsChild( - session, glassImageTemplate.WithIndex(glassImageIndex), { 0, 0, height }, { lengthX, lengthY, lengthZ }, - { (direction & 1) ? 28 : 2, (direction & 1) ? 2 : 28, height }); + session, glassImageTemplate.WithIndex(glassImageIndex), { 0, 0, height }, + { { (direction & 1) ? 28 : 2, (direction & 1) ? 2 : 28, height }, boundBoxLength }); } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT); @@ -246,7 +246,7 @@ static void PaintParkEntranceScrollingText( auto imageIndex = scrolling_text_setup( session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode + direction / 2, COLOUR_BLACK); auto textHeight = height + entrance.GetTextHeight(); - PaintAddImageAsChild(session, ImageId(imageIndex), { 0, 0, textHeight }, { 28, 28, 47 }, { 2, 2, textHeight }); + PaintAddImageAsChild(session, ImageId(imageIndex), { 0, 0, textHeight }, { { 2, 2, textHeight }, { 28, 28, 47 } }); } static void PaintParkEntranceLightEffects(paint_session& session) @@ -294,7 +294,7 @@ static void PaintParkEntrance(paint_session& session, uint8_t direction, int32_t { auto imageIndex = (surfaceDescriptor->Image + 5 * (1 + (direction & 1))); PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { 32, 28, 0 }, { 0, 2, height }); + session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { { 0, 2, height }, { 32, 28, 0 } }); } // Entrance @@ -302,7 +302,7 @@ static void PaintParkEntrance(paint_session& session, uint8_t direction, int32_t { auto imageIndex = entrance->GetImage(sequence, direction); PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { 28, 28, 47 }, { 2, 2, height + 32 }); + session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { { 2, 2, height + 32 }, { 28, 28, 47 } }); if (!entranceEl.IsGhost()) PaintParkEntranceScrollingText(session, *entrance, direction, height); @@ -316,7 +316,7 @@ static void PaintParkEntrance(paint_session& session, uint8_t direction, int32_t auto imageIndex = entrance->GetImage(sequence, direction); auto y = ((direction / 2 + sequence / 2) & 1) ? 26 : 32; PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { 26, y, 79 }, { 3, 3, height }); + session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { { 3, 3, height }, { 26, y, 79 } }); } break; } @@ -346,7 +346,7 @@ static void PaintHeightMarkers(paint_session& session, const EntranceElement& en baseImageIndex += get_height_marker_offset(); baseImageIndex -= gMapBaseZ; auto imageId = ImageId(baseImageIndex, COLOUR_GREY); - PaintAddImageAsParent(session, imageId, { 16, 16, height }, { 1, 1, 0 }, { 31, 31, heightMarkerBaseZ + 64 }); + PaintAddImageAsParent(session, imageId, { 16, 16, height }, { { 31, 31, heightMarkerBaseZ + 64 }, { 1, 1, 0 } }); } } } diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index 83e881d48d..e88af96fe3 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -26,17 +26,12 @@ #include "../../world/Map.h" #include "../../world/Scenery.h" #include "../../world/TileInspector.h" +#include "../Boundbox.h" #include "../Supports.h" #include "Paint.TileElement.h" -struct boundbox -{ - CoordsXY offset; - CoordsXY length; -}; - // clang-format off -static constexpr const boundbox LargeSceneryBoundBoxes[] = { +static constexpr const BoundBoxXY LargeSceneryBoundBoxes[] = { { { 3, 3 }, { 26, 26 } }, { { 17, 17 }, { 12, 12 } }, { { 17, 3 }, { 12, 12 } }, @@ -397,8 +392,8 @@ void PaintLargeScenery(paint_session& session, uint8_t direction, uint16_t heigh flags = Numerics::rol16(flags, direction); bbIndex = (flags & 0xF) | (flags >> 12); } - const CoordsXYZ bbOffset = { LargeSceneryBoundBoxes[bbIndex].offset, height }; - const CoordsXYZ bbLength = { LargeSceneryBoundBoxes[bbIndex].length, boxlengthZ }; + const CoordsXYZ& bbOffset = { LargeSceneryBoundBoxes[bbIndex].offset, height }; + const CoordsXYZ& bbLength = { LargeSceneryBoundBoxes[bbIndex].length, boxlengthZ }; auto imageIndex = sceneryEntry->image + 4 + (sequenceNum << 2) + direction; PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, bbLength, bbOffset); diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 4911f7c48b..3bd8ea5b61 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -36,6 +36,7 @@ #include "../../world/Scenery.h" #include "../../world/Surface.h" #include "../../world/TileInspector.h" +#include "../Boundbox.h" #include "../Supports.h" #include "Paint.Surface.h" #include "Paint.TileElement.h" @@ -63,23 +64,23 @@ static constexpr const uint8_t byte_98D6E0[] = { }; // clang-format off -static constexpr const int16_t stru_98D804[][4] = { - { 3, 3, 26, 26 }, - { 0, 3, 29, 26 }, - { 3, 3, 26, 29 }, - { 0, 3, 29, 29 }, - { 3, 3, 29, 26 }, - { 0, 3, 32, 26 }, - { 3, 3, 29, 29 }, - { 0, 3, 32, 29 }, - { 3, 0, 26, 29 }, - { 0, 0, 29, 29 }, - { 3, 0, 26, 32 }, - { 0, 0, 29, 32 }, - { 3, 0, 29, 29 }, - { 0, 0, 32, 29 }, - { 3, 0, 29, 32 }, - { 0, 0, 32, 32 }, +static constexpr const BoundBoxXY stru_98D804[] = { + { { 3, 3 }, { 26, 26 } }, + { { 0, 3 }, { 29, 26 } }, + { { 3, 3 }, { 26, 29 } }, + { { 0, 3 }, { 29, 29 } }, + { { 3, 3 }, { 29, 26 } }, + { { 0, 3 }, { 32, 26 } }, + { { 3, 3 }, { 29, 29 } }, + { { 0, 3 }, { 32, 29 } }, + { { 3, 0 }, { 26, 29 } }, + { { 0, 0 }, { 29, 29 } }, + { { 3, 0 }, { 26, 32 } }, + { { 0, 0 }, { 29, 32 } }, + { { 3, 0 }, { 29, 29 } }, + { { 0, 0 }, { 32, 29 } }, + { { 3, 0 }, { 29, 32 } }, + { { 0, 0 }, { 32, 32 } }, }; static constexpr const uint8_t byte_98D8A4[] = { @@ -1053,8 +1054,8 @@ void path_paint_box_support( uint8_t corners = (((pathElement.GetCorners()) << session.CurrentRotation) & 0xF) | (((pathElement.GetCorners()) << session.CurrentRotation) >> 4); - CoordsXY boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; - CoordsXY boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; + CoordsXY boundBoxOffset = stru_98D804[edges].offset; + CoordsXY boundBoxSize = stru_98D804[edges].length; uint16_t edi = edges | (corners << 4); @@ -1120,7 +1121,7 @@ void path_paint_box_support( { PaintAddImageAsChild( session, imageTemplate.WithIndex(surfaceBaseImageIndex), { 0, 0, height }, - { boundBoxSize.x, boundBoxSize.y, 0 }, { boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset }); + { { boundBoxOffset, height + boundingBoxZOffset }, { boundBoxSize, 0 } }); } } @@ -1188,9 +1189,8 @@ void path_paint_pole_support( uint8_t edges = ((pathElement.GetEdges() << session.CurrentRotation) & 0xF) | (((pathElement.GetEdges()) << session.CurrentRotation) >> 4); - CoordsXY boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; - - CoordsXY boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; + CoordsXY boundBoxOffset = stru_98D804[edges].offset; + CoordsXY boundBoxSize = stru_98D804[edges].length; uint8_t corners = (((pathElement.GetCorners()) << session.CurrentRotation) & 0xF) | (((pathElement.GetCorners()) << session.CurrentRotation) >> 4); @@ -1260,7 +1260,7 @@ void path_paint_pole_support( { PaintAddImageAsChild( session, imageTemplate.WithIndex(surfaceBaseImageIndex), { 0, 0, height }, - { boundBoxSize.x, boundBoxSize.y, 0 }, { boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset }); + { { boundBoxOffset, height + boundingBoxZOffset }, { boundBoxSize, 0 } }); } } diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index f790e776a8..6fefb58493 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -109,11 +109,7 @@ static void PaintSmallSceneryBody( { PROFILED_FUNCTION(); - CoordsXYZ boxLength; - CoordsXYZ boxOffset{ 0, 0, height }; - - boxLength.x = 2; - boxLength.y = 2; + BoundBoxXYZ boundBox = { { 0, 0, height }, { 2, 2, 0 } }; CoordsXYZ offset = { 0, 0, height }; if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE)) @@ -126,10 +122,10 @@ static void PaintSmallSceneryBody( { 17, 3 }, { 3, 3 }, }; - boxOffset.x = sceneryHalfTileOffsets[direction].x; - boxOffset.y = sceneryHalfTileOffsets[direction].y; - boxLength.x = lengths[direction].x; - boxLength.y = lengths[direction].y; + boundBox.offset.x = sceneryHalfTileOffsets[direction].x; + boundBox.offset.y = sceneryHalfTileOffsets[direction].y; + boundBox.length.x = lengths[direction].x; + boundBox.length.y = lengths[direction].y; offset.x = 3; offset.y = 3; } @@ -141,18 +137,18 @@ static void PaintSmallSceneryBody( { offset.x = 3; offset.y = 3; - boxLength.x = 26; - boxLength.y = 26; + boundBox.length.x = 26; + boundBox.length.y = 26; if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_NO_WALLS)) { offset.x = 1; offset.y = 1; - boxLength.x = 30; - boxLength.y = 30; + boundBox.length.x = 30; + boundBox.length.y = 30; } } - boxOffset.x = offset.x; - boxOffset.y = offset.y; + boundBox.offset.x = offset.x; + boundBox.offset.y = offset.y; } } else @@ -161,15 +157,15 @@ static void PaintSmallSceneryBody( // -1 to maintain compatibility with existing CSOs in context of issue #17616 offset.x = SceneryQuadrantOffsets[quadrant].x - 1; offset.y = SceneryQuadrantOffsets[quadrant].y - 1; - boxOffset.x = offset.x; - boxOffset.y = offset.y; + boundBox.offset.x = offset.x; + boundBox.offset.y = offset.y; } - boxLength.z = sceneryEntry->height - 4; - if (boxLength.z > 128 || boxLength.z < 0) + boundBox.length.z = sceneryEntry->height - 4; + if (boundBox.length.z > 128 || boundBox.length.z < 0) { - boxLength.z = 128; + boundBox.length.z = 128; } - boxLength.z--; + boundBox.length.z--; ImageIndex baseImageIndex = sceneryEntry->image + direction; if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_CAN_WITHER)) @@ -201,13 +197,13 @@ static void PaintSmallSceneryBody( imageId = imageId.WithTertiary(sceneryElement.GetTertiaryColour()); } } - PaintAddImageAsParent(session, imageId, offset, boxLength, boxOffset); + PaintAddImageAsParent(session, imageId, offset, boundBox); } if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_HAS_GLASS) && !imageTemplate.IsRemap()) { auto imageId = ImageId(baseImageIndex + 4).WithTransparancy(sceneryElement.GetPrimaryColour()); - PaintAddImageAsChild(session, imageId, offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageId, offset, boundBox); } if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ANIMATED)) @@ -218,18 +214,18 @@ static void PaintSmallSceneryBody( { auto imageIndex = sceneryEntry->image + 4 + ((gCurrentTicks / 2) & 0xF); auto imageId = imageTemplate.WithIndex(imageIndex); - PaintAddImageAsChild(session, imageId, offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageId, offset, boundBox); } else if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4)) { auto imageIndex = sceneryEntry->image + 8 + ((gCurrentTicks / 2) & 0xF); - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); imageIndex = direction + sceneryEntry->image + 4; - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); imageIndex = sceneryEntry->image + 24 + ((gCurrentTicks / 2) & 0xF); - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); } else if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_CLOCK)) { @@ -251,7 +247,7 @@ static void PaintSmallSceneryBody( } imageIndex = sceneryEntry->image + 68 + imageIndex; - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); imageIndex = gRealTimeOfDay.minute + (direction * 15); if (imageIndex >= 60) @@ -259,7 +255,7 @@ static void PaintSmallSceneryBody( imageIndex -= 60; } imageIndex = sceneryEntry->image + 8 + imageIndex; - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); } else if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_SWAMP_GOO)) { @@ -267,7 +263,7 @@ static void PaintSmallSceneryBody( imageIndex += session.SpritePosition.x / 4; imageIndex += session.SpritePosition.y / 4; imageIndex = sceneryEntry->image + ((imageIndex / 4) % 16); - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); } else if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS)) { @@ -310,11 +306,11 @@ static void PaintSmallSceneryBody( if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_VISIBLE_WHEN_ZOOMED)) { - PaintAddImageAsParent(session, imageId, offset, boxLength, boxOffset); + PaintAddImageAsParent(session, imageId, offset, boundBox); } else { - PaintAddImageAsChild(session, imageId, offset, boxLength, boxOffset); + PaintAddImageAsChild(session, imageId, offset, boundBox); } } } diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index 56cfe4caf3..66824fe54d 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -31,6 +31,7 @@ #include "../../sprites.h" #include "../../world/Surface.h" #include "../../world/TileInspector.h" +#include "../Boundbox.h" #include "Paint.TileElement.h" #include @@ -228,8 +229,7 @@ struct tile_surface_boundary_data int32_t bit_2; uint32_t image[5]; CoordsXY offset; - CoordsXY box_offset; - CoordsXY box_size; + BoundBoxXY Boundbox; }; static constexpr const tile_surface_boundary_data _tileSurfaceBoundaries[4] = { @@ -247,8 +247,7 @@ static constexpr const tile_surface_boundary_data _tileSurfaceBoundaries[4] = { SPR_TERRAIN_BOUNDARY_FENCES_5, }, { 1, 31 }, - { 1, 31 }, - { 30, 1 }, + { { 1, 31 }, { 30, 1 } }, }, { // Bottom left @@ -264,8 +263,7 @@ static constexpr const tile_surface_boundary_data _tileSurfaceBoundaries[4] = { SPR_TERRAIN_BOUNDARY_FENCES_6, }, { 31, 0 }, - { 31, 1 }, - { 1, 30 }, + { { 31, 1 }, { 1, 30 } }, }, { // Top left @@ -281,8 +279,7 @@ static constexpr const tile_surface_boundary_data _tileSurfaceBoundaries[4] = { SPR_TERRAIN_BOUNDARY_FENCES_5, }, { 1, 0 }, - { 1, 1 }, - { 30, 1 }, + { { 1, 1 }, { 30, 1 } }, }, { // Top right @@ -298,8 +295,7 @@ static constexpr const tile_surface_boundary_data _tileSurfaceBoundaries[4] = { SPR_TERRAIN_BOUNDARY_FENCES_6, }, { 1, 1 }, - { 1, 1 }, - { 1, 30 }, + { { 1, 1 }, { 1, 30 } }, }, }; @@ -1412,8 +1408,8 @@ void PaintSurface(paint_session& session, uint8_t direction, uint16_t height, co } PaintAddImageAsParent( - session, image_id, { fenceData.offset, local_height }, { fenceData.box_size, 9 }, - { fenceData.box_offset, local_height + 1 }); + session, image_id, { fenceData.offset, local_height }, { fenceData.Boundbox.length, 9 }, + { fenceData.Boundbox.offset, local_height + 1 }); } } diff --git a/src/openrct2/paint/tile_element/Paint.Wall.cpp b/src/openrct2/paint/tile_element/Paint.Wall.cpp index 6abb7ccbb6..cb1ad07e34 100644 --- a/src/openrct2/paint/tile_element/Paint.Wall.cpp +++ b/src/openrct2/paint/tile_element/Paint.Wall.cpp @@ -46,8 +46,8 @@ static constexpr const uint8_t* DirectionToDoorImageOffset[] = { DirectionToDoor DirectionToDoorImageOffset2, DirectionToDoorImageOffset3 }; static void PaintWallDoor( - paint_session& session, const WallSceneryEntry& wallEntry, ImageId imageId, CoordsXYZ offset, CoordsXYZ bbLengthR1, - CoordsXYZ bbOffsetR1, CoordsXYZ bbLengthR2, CoordsXYZ bbOffsetR2, CoordsXYZ bbLengthL, CoordsXYZ bbOffsetL) + paint_session& session, const WallSceneryEntry& wallEntry, ImageId imageId, CoordsXYZ offset, BoundBoxXYZ bbR1, + BoundBoxXYZ bbR2, BoundBoxXYZ bbL) { PROFILED_FUNCTION(); @@ -55,13 +55,13 @@ static void PaintWallDoor( auto newImageId1 = imageId.WithIndexOffset(1); if (wallEntry.flags & WALL_SCENERY_IS_DOUBLE_SIDED) { - PaintAddImageAsParent(session, newImageId0, offset, bbLengthR1, bbOffsetR1); - PaintAddImageAsParent(session, newImageId1, offset, bbLengthR2, bbOffsetR2); + PaintAddImageAsParent(session, newImageId0, offset, bbR1); + PaintAddImageAsParent(session, newImageId1, offset, bbR2); } else { - PaintAddImageAsParent(session, newImageId0, offset, bbLengthL, bbOffsetL); - PaintAddImageAsChild(session, newImageId1, offset, bbLengthL, bbOffsetL); + PaintAddImageAsParent(session, newImageId0, offset, bbL); + PaintAddImageAsChild(session, newImageId1, offset, bbL); } } @@ -83,70 +83,47 @@ static void PaintWallDoor( { case 0: { - CoordsXYZ bbLengthR1 = { 1, 3, bbHeight - 5 }; - CoordsXYZ bbOffsetR1 = { 1, 1, height + 1 }; - CoordsXYZ bbLengthR2 = { 1, 28, 3 }; - CoordsXYZ bbOffsetR2 = { 1, 1, height + bbHeight - 9 }; + BoundBoxXYZ bbR1 = { { 1, 1, height + 1 }, { 1, 3, bbHeight - 5 } }; + BoundBoxXYZ bbR2 = { { 1, 1, height + bbHeight - 9 }, { 1, 28, 3 } }; - CoordsXYZ bbLengthL = { 1, 28, bbHeight }; - CoordsXYZ bbOffsetL = { 1, 1, height + 1 }; + BoundBoxXYZ bbL = { { 1, 1, height + 1 }, { 1, 28, bbHeight } }; CoordsXYZ offset = { 0, 0, height }; - PaintWallDoor( - session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbLengthR1, bbOffsetR1, bbLengthR2, bbOffsetR2, - bbLengthL, bbOffsetL); + PaintWallDoor(session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbR1, bbR2, bbL); break; } case 1: { - CoordsXYZ bbLengthR1 = { 3, 3, bbHeight - 5 }; - CoordsXYZ bbOffsetR1 = { 1, 30, height + 1 }; - CoordsXYZ bbLengthR2 = { 29, 3, 2 }; - CoordsXYZ bbOffsetR2 = { 1, 30, height + bbHeight - 8 }; - - CoordsXYZ bbLengthL = { 29, 1, bbHeight }; - CoordsXYZ bbOffsetL = { 2, 30, height + 1 }; + BoundBoxXYZ bbR1 = { { 1, 30, height + 1 }, { 3, 3, bbHeight - 5 } }; + BoundBoxXYZ bbR2 = { { 1, 30, height + bbHeight - 8 }, { 29, 3, 2 } }; + BoundBoxXYZ bbL = { { 2, 30, height + 1 }, { 29, 1, bbHeight } }; CoordsXYZ offset = { 1, 31, height }; - PaintWallDoor( - session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbLengthR1, bbOffsetR1, bbLengthR2, bbOffsetR2, - bbLengthL, bbOffsetL); + PaintWallDoor(session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbR1, bbR2, bbL); break; } case 2: { - CoordsXYZ bbLengthR1 = { 3, 3, bbHeight - 5 }; - CoordsXYZ bbOffsetR1 = { 30, 1, height + 1 }; - CoordsXYZ bbLengthR2 = { 3, 29, 2 }; - CoordsXYZ bbOffsetR2 = { 30, 1, height + bbHeight - 8 }; - - CoordsXYZ bbLengthL = { 1, 29, bbHeight }; - CoordsXYZ bbOffsetL = { 30, 2, height + 1 }; + BoundBoxXYZ bbR1 = { { 30, 1, height + 1 }, { 3, 3, bbHeight - 5 } }; + BoundBoxXYZ bbR2 = { { 30, 1, height + bbHeight - 8 }, { 3, 29, 2 } }; + BoundBoxXYZ bbL = { { 30, 2, height + 1 }, { 1, 29, bbHeight } }; CoordsXYZ offset = { 31, 0, height }; - PaintWallDoor( - session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbLengthR1, bbOffsetR1, bbLengthR2, bbOffsetR2, - bbLengthL, bbOffsetL); + PaintWallDoor(session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbR1, bbR2, bbL); break; } case 3: { - CoordsXYZ bbLengthR1 = { 3, 1, bbHeight - 5 }; - CoordsXYZ bbOffsetR1 = { 1, 1, height + 1 }; - CoordsXYZ bbLengthR2 = { 28, 1, 3 }; - CoordsXYZ bbOffsetR2 = { 1, 1, height + bbHeight - 9 }; - - CoordsXYZ bbLengthL = { 28, 1, bbHeight }; - CoordsXYZ bbOffsetL = { 1, 1, height + 1 }; + BoundBoxXYZ bbR1 = { { 1, 1, height + 1 }, { 3, 1, bbHeight - 5 } }; + BoundBoxXYZ bbR2 = { { 1, 1, height + bbHeight - 9 }, { 28, 1, 3 } }; + BoundBoxXYZ bbL = { { 1, 1, height + 1 }, { 28, 1, bbHeight } }; CoordsXYZ offset = { 2, 1, height }; - PaintWallDoor( - session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbLengthR1, bbOffsetR1, bbLengthR2, bbOffsetR2, - bbLengthL, bbOffsetL); + PaintWallDoor(session, wallEntry, imageTemplate.WithIndex(imageId), offset, bbR1, bbR2, bbL); break; } } @@ -154,17 +131,17 @@ static void PaintWallDoor( static void PaintWallWall( paint_session& session, const WallSceneryEntry& wallEntry, ImageId imageTemplate, uint32_t imageOffset, CoordsXYZ offset, - CoordsXYZ bounds, CoordsXYZ boundsOffset, bool isGhost) + BoundBoxXYZ boundBox, bool isGhost) { PROFILED_FUNCTION(); auto frameNum = (wallEntry.flags2 & WALL_SCENERY_2_ANIMATED) ? (gCurrentTicks & 7) * 2 : 0; auto imageIndex = wallEntry.image + imageOffset + frameNum; - PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), offset, bounds, boundsOffset); + PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), offset, boundBox); if ((wallEntry.flags & WALL_SCENERY_HAS_GLASS) && !isGhost) { auto glassImageId = ImageId(imageIndex + 6).WithTransparancy(imageTemplate.GetPrimary()); - PaintAddImageAsChild(session, glassImageId, offset, bounds, boundsOffset); + PaintAddImageAsChild(session, glassImageId, offset, boundBox); } } @@ -218,7 +195,8 @@ static void PaintWallWall( uint8_t bbHeight = wallEntry.height * 8 - 2; ImageIndex imageOffset = 0; - CoordsXYZ offset, bounds, boundsOffset; + CoordsXYZ offset; + BoundBoxXYZ boundBox; switch (direction) { case 0: @@ -236,8 +214,7 @@ static void PaintWallWall( } offset = { 0, 0, height }; - bounds = { 1, 28, bbHeight }; - boundsOffset = { 1, 1, height + 1 }; + boundBox = { { 1, 1, height + 1 }, { 1, 28, bbHeight } }; break; case 1: @@ -270,8 +247,7 @@ static void PaintWallWall( } offset = { 1, 31, height }; - bounds = { 29, 1, bbHeight }; - boundsOffset = { 2, 30, height + 1 }; + boundBox = { { 2, 30, height + 1 }, { 29, 1, bbHeight } }; break; case 2: @@ -294,8 +270,7 @@ static void PaintWallWall( } offset = { 31, 0, height }; - bounds = { 1, 29, bbHeight }; - boundsOffset = { 30, 2, height + 1 }; + boundBox = { { 30, 2, height + 1 }, { 1, 29, bbHeight } }; break; case 3: @@ -313,13 +288,12 @@ static void PaintWallWall( } offset = { 2, 1, height }; - bounds = { 28, 1, bbHeight }; - boundsOffset = { 1, 1, height + 1 }; + boundBox = { { 1, 1, height + 1 }, { 28, 1, bbHeight } }; break; } - PaintWallWall(session, wallEntry, imageTemplate, imageOffset, offset, bounds, boundsOffset, isGhost); - PaintWallScrollingText(session, wallEntry, wallElement, direction, height, boundsOffset, isGhost); + PaintWallWall(session, wallEntry, imageTemplate, imageOffset, offset, boundBox, isGhost); + PaintWallScrollingText(session, wallEntry, wallElement, direction, height, boundBox.offset, isGhost); } void PaintWall(paint_session& session, uint8_t direction, int32_t height, const WallElement& wallElement) diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index fc3be61c85..5e46cb1b69 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -799,28 +799,24 @@ bool track_paint_util_draw_station_covers_2( }; int32_t imageOffset = 0; - CoordsXYZ bounds, boundsOffset; + BoundBoxXYZ boundBox; CoordsXYZ offset = CoordsXYZ(0, 0, height); switch (edge) { case EDGE_NE: - bounds = CoordsXYZ(1, 30, heights[stationVariant][0]); - boundsOffset = CoordsXYZ(0, 1, height + 1); + boundBox = { { 0, 1, height + 1 }, { 1, 30, heights[stationVariant][0] } }; imageOffset = hasFence ? SPR_STATION_COVER_OFFSET_SE_NW_BACK_1 : SPR_STATION_COVER_OFFSET_SE_NW_BACK_0; break; case EDGE_SE: - bounds = CoordsXYZ(32, 32, 0); - boundsOffset = CoordsXYZ(0, 0, height + 1 + heights[stationVariant][0]); + boundBox = { { 0, 0, height + 1 + heights[stationVariant][0] }, { 32, 32, 0 } }; imageOffset = SPR_STATION_COVER_OFFSET_NE_SW_FRONT; break; case EDGE_SW: - bounds = CoordsXYZ(32, 32, 0); - boundsOffset = CoordsXYZ(0, 0, height + 1 + heights[stationVariant][0]); + boundBox = { { 0, 0, height + 1 + heights[stationVariant][0] }, { 32, 32, 0 } }; imageOffset = SPR_STATION_COVER_OFFSET_SE_NW_FRONT; break; case EDGE_NW: - bounds = CoordsXYZ(30, 1, heights[stationVariant][0]); - boundsOffset = CoordsXYZ(1, 0, height + 1); + boundBox = { { 1, 0, height + 1 }, { 30, 1, heights[stationVariant][0] } }; imageOffset = hasFence ? SPR_STATION_COVER_OFFSET_NE_SW_BACK_1 : SPR_STATION_COVER_OFFSET_NE_SW_BACK_0; break; } @@ -832,13 +828,13 @@ bool track_paint_util_draw_station_covers_2( auto imageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_TRACK]); auto imageId = imageTemplate.WithIndex(baseImageIndex + imageOffset); - PaintAddImageAsParent(session, imageId, offset, bounds, boundsOffset); + PaintAddImageAsParent(session, imageId, offset, boundBox); // Glass if (session.TrackColours[SCHEME_MISC] == IMAGE_TYPE_REMAP && (stationObject->Flags & STATION_OBJECT_FLAGS::IS_TRANSPARENT)) { imageId = ImageId(baseImageIndex + imageOffset + 12).WithTransparancy(imageTemplate.GetPrimary()); - PaintAddImageAsChild(session, imageId, offset, bounds, boundsOffset); + PaintAddImageAsChild(session, imageId, offset, boundBox); } return true; } diff --git a/src/openrct2/ride/VehiclePaint.cpp b/src/openrct2/ride/VehiclePaint.cpp index bfcf00c24a..1b9c37cbef 100644 --- a/src/openrct2/ride/VehiclePaint.cpp +++ b/src/openrct2/ride/VehiclePaint.cpp @@ -962,8 +962,8 @@ static void PaintVehicleRiders( } PaintAddImageAsChild( - session, imageId, { 0, 0, z }, { bb.length_x, bb.length_y, bb.length_z }, - { bb.offset_x, bb.offset_y, bb.offset_z + z }); + session, imageId, { 0, 0, z }, + { { bb.offset_x, bb.offset_y, bb.offset_z + z }, { bb.length_x, bb.length_y, bb.length_z } }); baseImageId += carEntry->NumCarImages; } } diff --git a/src/openrct2/ride/gentle/FerrisWheel.cpp b/src/openrct2/ride/gentle/FerrisWheel.cpp index e24523f080..e05d121c6e 100644 --- a/src/openrct2/ride/gentle/FerrisWheel.cpp +++ b/src/openrct2/ride/gentle/FerrisWheel.cpp @@ -43,7 +43,7 @@ static constexpr BoundBoxXY FerrisWheelData[] = { static void PaintFerrisWheelRiders( paint_session& session, const rct_ride_entry& rideEntry, const Vehicle& vehicle, uint8_t direction, const CoordsXYZ offset, - const CoordsXYZ bbLength, const CoordsXYZ bbOffset) + const BoundBoxXYZ& bb) { for (int32_t i = 0; i < 32; i += 2) { @@ -54,7 +54,7 @@ static void PaintFerrisWheelRiders( auto frameNum = (vehicle.Pitch + i * 4) % 128; auto imageIndex = rideEntry.Cars[0].base_image_id + 32 + direction * 128 + frameNum; auto imageId = ImageId(imageIndex, vehicle.peep_tshirt_colours[i], vehicle.peep_tshirt_colours[i + 1]); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); } } @@ -72,10 +72,9 @@ static void PaintFerrisWheelStructure( session.CurrentlyDrawnEntity = vehicle; } - const auto& boundBox = FerrisWheelData[direction]; + auto boundBox = FerrisWheelData[direction]; CoordsXYZ offset((direction & 1) ? 0 : axisOffset, (direction & 1) ? axisOffset : 0, height + 7); - CoordsXYZ bbLength(boundBox.length.x, boundBox.length.y, 127); - CoordsXYZ bbOffset(boundBox.offset.x, boundBox.offset.y, height + 7); + BoundBoxXYZ bb = { { boundBox.offset, height + 7 }, { boundBox.length, 127 } }; auto supportsImageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_TRACK]); auto wheelImageTemplate = ImageId(0, ride.vehicle_colours[0].Body, ride.vehicle_colours[0].Trim); @@ -90,13 +89,13 @@ static void PaintFerrisWheelStructure( auto wheelImageId = wheelImageTemplate.WithIndex(rideEntry->Cars[0].base_image_id + direction * 8 + imageOffset); auto rightSupportImageId = leftSupportImageId.WithIndexOffset(1); - PaintAddImageAsParent(session, leftSupportImageId, offset, bbLength, bbOffset); - PaintAddImageAsChild(session, wheelImageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, leftSupportImageId, offset, bb); + PaintAddImageAsChild(session, wheelImageId, offset, bb); if (vehicle != nullptr) { - PaintFerrisWheelRiders(session, *rideEntry, *vehicle, direction, offset, bbLength, bbOffset); + PaintFerrisWheelRiders(session, *rideEntry, *vehicle, direction, offset, bb); } - PaintAddImageAsChild(session, rightSupportImageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, rightSupportImageId, offset, bb); session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; diff --git a/src/openrct2/ride/gentle/HauntedHouse.cpp b/src/openrct2/ride/gentle/HauntedHouse.cpp index d7e9cbf55e..71d12f7a98 100644 --- a/src/openrct2/ride/gentle/HauntedHouse.cpp +++ b/src/openrct2/ride/gentle/HauntedHouse.cpp @@ -53,7 +53,7 @@ static void PaintHauntedHouseStructure( imageIndex = baseImageIndex + 3 + ((direction & 3) * 18) + frameNum; PaintAddImageAsChild( session, imageTemplate.WithIndex(imageIndex), { xOffset, yOffset, height }, - { boundBox.length.x, boundBox.length.y, 127 }, { boundBox.offset.x, boundBox.offset.y, height }); + { { boundBox.offset, height }, { boundBox.length, 127 } }); } session.CurrentlyDrawnEntity = nullptr; diff --git a/src/openrct2/ride/gentle/MerryGoRound.cpp b/src/openrct2/ride/gentle/MerryGoRound.cpp index b8b5851677..2e2f617cb1 100644 --- a/src/openrct2/ride/gentle/MerryGoRound.cpp +++ b/src/openrct2/ride/gentle/MerryGoRound.cpp @@ -27,7 +27,7 @@ static constexpr const uint16_t MerryGoRoundBreakdownVibration[] = { static void PaintRiders( paint_session& session, const Ride& ride, const rct_ride_entry& rideEntry, const Vehicle& vehicle, int32_t rotationOffset, - const CoordsXYZ& offset, const CoordsXYZ& bbLength, const CoordsXYZ& bbOffset) + const CoordsXYZ& offset, const BoundBoxXYZ& bb) { if (session.DPI.zoom_level > ZoomLevel{ 0 }) return; @@ -46,7 +46,7 @@ static void PaintRiders( auto imageIndex = rideEntry.Cars[0].base_image_id + 32 + imageOffset; auto imageId = ImageId(imageIndex, vehicle.peep_tshirt_colours[peep], vehicle.peep_tshirt_colours[peep + 1]); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); } } @@ -80,8 +80,7 @@ static void PaintCarousel( } CoordsXYZ offset(xOffset, yOffset, height); - CoordsXYZ bbLength(24, 24, 48); - CoordsXYZ bbOffset(xOffset + 16, yOffset + 16, height); + BoundBoxXYZ bb = { { xOffset + 16, yOffset + 16, height }, { 24, 24, 48 } }; auto imageTemplate = ImageId(0, ride.vehicle_colours[0].Body, ride.vehicle_colours[0].Trim); auto imageFlags = session.TrackColours[SCHEME_MISC]; @@ -91,9 +90,9 @@ static void PaintCarousel( } auto imageOffset = rotationOffset & 0x1F; auto imageId = imageTemplate.WithIndex(rideEntry->Cars[0].base_image_id + imageOffset); - PaintAddImageAsParent(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, imageId, offset, bb); - PaintRiders(session, ride, *rideEntry, *vehicle, rotationOffset, offset, bbLength, bbOffset); + PaintRiders(session, ride, *rideEntry, *vehicle, rotationOffset, offset, bb); session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; diff --git a/src/openrct2/ride/shops/Facility.cpp b/src/openrct2/ride/shops/Facility.cpp index 20fce8b2be..5904ace281 100644 --- a/src/openrct2/ride/shops/Facility.cpp +++ b/src/openrct2/ride/shops/Facility.cpp @@ -8,6 +8,7 @@ *****************************************************************************/ #include "../../interface/Viewport.h" +#include "../../paint/Boundbox.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../../sprites.h" @@ -34,8 +35,7 @@ static void PaintFacility( auto lengthX = (direction & 1) == 0 ? 28 : 2; auto lengthY = (direction & 1) == 0 ? 2 : 28; CoordsXYZ offset(0, 0, height); - CoordsXYZ bbLength(lengthX, lengthY, 29); - CoordsXYZ bbOffset(direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height); + BoundBoxXYZ bb = { { direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height }, { lengthX, lengthY, 29 } }; auto imageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_TRACK]); auto imageIndex = firstCarEntry->base_image_id + ((direction + 2) & 3); @@ -45,12 +45,12 @@ static void PaintFacility( auto foundationImageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_3]); auto foundationImageIndex = (direction & 1) ? SPR_FLOOR_PLANKS_90_DEG : SPR_FLOOR_PLANKS; auto foundationImageId = foundationImageTemplate.WithIndex(foundationImageIndex); - PaintAddImageAsParent(session, foundationImageId, offset, bbLength, bbOffset); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, foundationImageId, offset, bb); + PaintAddImageAsChild(session, imageId, offset, bb); } else { - PaintAddImageAsParent(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, imageId, offset, bb); } // Base image if door was drawn diff --git a/src/openrct2/ride/shops/Shop.cpp b/src/openrct2/ride/shops/Shop.cpp index f89875f08f..f14309a139 100644 --- a/src/openrct2/ride/shops/Shop.cpp +++ b/src/openrct2/ride/shops/Shop.cpp @@ -8,6 +8,7 @@ *****************************************************************************/ #include "../../interface/Viewport.h" +#include "../../paint/Boundbox.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../../sprites.h" @@ -32,8 +33,7 @@ static void PaintShop( return; CoordsXYZ offset(0, 0, height); - CoordsXYZ bbLength(28, 28, 45); - CoordsXYZ bbOffset(2, 2, height); + BoundBoxXYZ bb = { { 2, 2, height }, { 28, 28, 45 } }; auto imageFlags = session.TrackColours[SCHEME_TRACK]; if (imageFlags & IMAGE_TYPE_REMAP_2_PLUS) @@ -48,12 +48,12 @@ static void PaintShop( auto foundationImageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_3]); auto foundationImageIndex = (direction & 1) ? SPR_FLOOR_PLANKS_90_DEG : SPR_FLOOR_PLANKS; auto foundationImageId = foundationImageTemplate.WithIndex(foundationImageIndex); - PaintAddImageAsParent(session, foundationImageId, offset, bbLength, bbOffset); - PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); + PaintAddImageAsParent(session, foundationImageId, offset, bb); + PaintAddImageAsChild(session, imageTemplate.WithIndex(imageIndex), offset, bb); } else { - PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); + PaintAddImageAsParent(session, imageTemplate.WithIndex(imageIndex), offset, bb); } paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); diff --git a/src/openrct2/ride/thrill/Enterprise.cpp b/src/openrct2/ride/thrill/Enterprise.cpp index ac476f8874..abb22c4b6c 100644 --- a/src/openrct2/ride/thrill/Enterprise.cpp +++ b/src/openrct2/ride/thrill/Enterprise.cpp @@ -10,6 +10,7 @@ #include "../../common.h" #include "../../entity/EntityRegistry.h" #include "../../interface/Viewport.h" +#include "../../paint/Boundbox.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../Ride.h" @@ -20,7 +21,7 @@ static void PaintEnterpriseRiders( paint_session& session, const rct_ride_entry& rideEntry, Vehicle& vehicle, uint32_t imageOffset, const CoordsXYZ& offset, - const CoordsXYZ& bbLength, const CoordsXYZ& bbOffset) + const BoundBoxXYZ& bb) { if (session.DPI.zoom_level > ZoomLevel{ 0 }) return; @@ -37,7 +38,7 @@ static void PaintEnterpriseRiders( auto frameOffset2 = floor2(imageOffset, 4) * 4; auto imageTemplate = ImageId(0, vehicle.peep_tshirt_colours[i]); auto imageId = imageTemplate.WithIndex(baseImageIndex + 196 + frameOffset1 + frameOffset2); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); } } @@ -60,8 +61,7 @@ static void PaintEnterpriseStructure( } CoordsXYZ offset(xOffset, yOffset, height + 7); - CoordsXYZ bbLength(24, 24, 48); - CoordsXYZ bbOffset(0, 0, height + 7); + BoundBoxXYZ bb = { { 0, 0, height + 7 }, { 24, 24, 48 } }; uint32_t imageOffset = trackElement.GetDirectionWithOffset(session.CurrentRotation); if (vehicle != nullptr) @@ -76,11 +76,11 @@ static void PaintEnterpriseStructure( imageTemplate = ImageId::FromUInt32(imageFlags); } auto imageId = imageTemplate.WithIndex(rideEntry->Cars[0].base_image_id + imageOffset); - PaintAddImageAsParent(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, imageId, offset, bb); if (vehicle != nullptr) { - PaintEnterpriseRiders(session, *rideEntry, *vehicle, imageOffset, offset, bbLength, bbOffset); + PaintEnterpriseRiders(session, *rideEntry, *vehicle, imageOffset, offset, bb); } session.CurrentlyDrawnEntity = nullptr; diff --git a/src/openrct2/ride/thrill/MagicCarpet.cpp b/src/openrct2/ride/thrill/MagicCarpet.cpp index 20b1a412ef..465e70f694 100644 --- a/src/openrct2/ride/thrill/MagicCarpet.cpp +++ b/src/openrct2/ride/thrill/MagicCarpet.cpp @@ -98,7 +98,7 @@ static Vehicle* GetFirstVehicle(const Ride& ride) static void PaintMagicCarpetRiders( paint_session& session, const rct_ride_entry& rideEntry, const Vehicle& vehicle, Direction direction, - const CoordsXYZ& offset, const CoordsXYZ& bbOffset, const CoordsXYZ& bbSize) + const CoordsXYZ& offset, const BoundBoxXYZ& bb) { if (session.DPI.zoom_level > ZoomLevel{ 1 }) return; @@ -109,40 +109,37 @@ static void PaintMagicCarpetRiders( auto imageIndex = baseImageIndex + (peepIndex * 2); auto imageId = ImageId( imageIndex, vehicle.peep_tshirt_colours[peepIndex + 0], vehicle.peep_tshirt_colours[peepIndex + 1]); - PaintAddImageAsChild(session, imageId, offset, bbSize, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); } } static void PaintMagicCarpetFrame( - paint_session& session, Plane plane, Direction direction, const CoordsXYZ& offset, const CoordsXYZ& bbOffset, - const CoordsXYZ& bbSize) + paint_session& session, Plane plane, Direction direction, const CoordsXYZ& offset, const BoundBoxXYZ& bb) { auto imageIndex = GetMagicCarpetFrameImage(plane, direction); auto imageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_TRACK]); auto imageId = imageTemplate.WithIndex(imageIndex); if (plane == Plane::Back) { - PaintAddImageAsParent(session, imageId, offset, bbSize, bbOffset); + PaintAddImageAsParent(session, imageId, offset, bb); } else { - PaintAddImageAsChild(session, imageId, offset, bbSize, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); } } static void PaintMagicCarpetPendulum( - paint_session& session, Plane plane, int32_t swing, Direction direction, const CoordsXYZ& offset, const CoordsXYZ& bbOffset, - const CoordsXYZ& bbSize) + paint_session& session, Plane plane, int32_t swing, Direction direction, const CoordsXYZ& offset, const BoundBoxXYZ& bb) { auto imageIndex = GetMagicCarpetPendulumImage(plane, direction, swing); auto imageTemplate = ImageId::FromUInt32(session.TrackColours[SCHEME_TRACK]); auto imageId = imageTemplate.WithIndex(imageIndex); - PaintAddImageAsChild(session, imageId, offset, bbSize, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); } static void PaintMagicCarpetVehicle( - paint_session& session, const Ride& ride, uint8_t direction, int32_t swing, CoordsXYZ offset, const CoordsXYZ& bbOffset, - const CoordsXYZ& bbSize) + paint_session& session, const Ride& ride, uint8_t direction, int32_t swing, CoordsXYZ offset, const BoundBoxXYZ& bb) { const auto* rideEntry = ride.GetRideEntry(); if (rideEntry == nullptr) @@ -174,12 +171,12 @@ static void PaintMagicCarpetVehicle( imageTemplate = ImageId::FromUInt32(imageFlags); } auto vehicleImageIndex = rideEntry->Cars[0].base_image_id + direction; - PaintAddImageAsChild(session, imageTemplate.WithIndex(vehicleImageIndex), offset, bbSize, bbOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(vehicleImageIndex), offset, bb); auto* vehicle = GetFirstVehicle(ride); if (vehicle != nullptr) { - PaintMagicCarpetRiders(session, *rideEntry, *vehicle, direction, offset, bbOffset, bbSize); + PaintMagicCarpetRiders(session, *rideEntry, *vehicle, direction, offset, bb); } } @@ -195,23 +192,18 @@ static void PaintMagicCarpetStructure( session.CurrentlyDrawnEntity = vehicle; } - BoundBoxXY bb = MagicCarpetBounds[direction]; - CoordsXYZ offset, bbOffset, bbSize; - offset.x = (direction & 1) ? 0 : axisOffset; - offset.y = (direction & 1) ? axisOffset : 0; - offset.z = height + 7; - bbOffset.x = bb.offset.x; - bbOffset.y = bb.offset.y; - bbOffset.z = height + 7; - bbSize.x = bb.length.x; - bbSize.y = bb.length.y; - bbSize.z = 127; + CoordsXYZ offset = { + (direction & 1) ? 0 : axisOffset, + (direction & 1) ? axisOffset : 0, + height + 7, + }; + BoundBoxXYZ bb = { { MagicCarpetBounds[direction].offset, height + 7 }, { MagicCarpetBounds[direction].length, 127 } }; - PaintMagicCarpetFrame(session, Plane::Back, direction, offset, bbOffset, bbSize); - PaintMagicCarpetPendulum(session, Plane::Back, swing, direction, offset, bbOffset, bbSize); - PaintMagicCarpetVehicle(session, ride, direction, swing, offset, bbOffset, bbSize); - PaintMagicCarpetPendulum(session, Plane::Front, swing, direction, offset, bbOffset, bbSize); - PaintMagicCarpetFrame(session, Plane::Front, direction, offset, bbOffset, bbSize); + PaintMagicCarpetFrame(session, Plane::Back, direction, offset, bb); + PaintMagicCarpetPendulum(session, Plane::Back, swing, direction, offset, bb); + PaintMagicCarpetVehicle(session, ride, direction, swing, offset, bb); + PaintMagicCarpetPendulum(session, Plane::Front, swing, direction, offset, bb); + PaintMagicCarpetFrame(session, Plane::Front, direction, offset, bb); session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; diff --git a/src/openrct2/ride/thrill/MotionSimulator.cpp b/src/openrct2/ride/thrill/MotionSimulator.cpp index a785ff257b..39609ad498 100644 --- a/src/openrct2/ride/thrill/MotionSimulator.cpp +++ b/src/openrct2/ride/thrill/MotionSimulator.cpp @@ -9,6 +9,7 @@ #include "../../entity/EntityRegistry.h" #include "../../interface/Viewport.h" +#include "../../paint/Boundbox.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../Ride.h" @@ -75,24 +76,24 @@ static void PaintMotionSimulatorVehicle( switch (direction) { case 0: - PaintAddImageAsParent(session, simulatorImageId, offset, { 20, 20, 44 }, offset); - PaintAddImageAsChild(session, stairsImageId, offset, { 20, 20, 44 }, offset); + PaintAddImageAsParent(session, simulatorImageId, offset, { offset, { 20, 20, 44 } }); + PaintAddImageAsChild(session, stairsImageId, offset, { offset, { 20, 20, 44 } }); PaintAddImageAsParent(session, stairsRailImageId, offset, { 20, 2, 44 }, { offset.x, offset.y + 32, offset.z }); break; case 1: - PaintAddImageAsParent(session, simulatorImageId, offset, { 20, 20, 44 }, offset); - PaintAddImageAsChild(session, stairsImageId, offset, { 20, 20, 44 }, offset); + PaintAddImageAsParent(session, simulatorImageId, offset, { offset, { 20, 20, 44 } }); + PaintAddImageAsChild(session, stairsImageId, offset, { offset, { 20, 20, 44 } }); PaintAddImageAsParent(session, stairsRailImageId, offset, { 2, 20, 44 }, { offset.x + 34, offset.y, offset.z }); break; case 2: PaintAddImageAsParent(session, stairsRailImageId, offset, { 20, 2, 44 }, { offset.x, offset.y - 10, offset.z }); PaintAddImageAsParent(session, stairsImageId, offset, { 20, 20, 44 }, { offset.x, offset.y + 5, offset.z }); - PaintAddImageAsChild(session, simulatorImageId, offset, { 20, 20, 44 }, { offset.x, offset.y + 5, offset.z }); + PaintAddImageAsChild(session, simulatorImageId, offset, { { offset.x, offset.y + 5, offset.z }, { 20, 20, 44 } }); break; case 3: PaintAddImageAsParent(session, stairsRailImageId, offset, { 2, 20, 44 }, { offset.x - 10, offset.y, offset.z }); PaintAddImageAsParent(session, stairsImageId, offset, { 20, 20, 44 }, { offset.x + 5, offset.y, offset.z }); - PaintAddImageAsChild(session, simulatorImageId, offset, { 20, 20, 44 }, { offset.x + 5, offset.y, offset.z }); + PaintAddImageAsChild(session, simulatorImageId, offset, { { offset.x + 5, offset.y, offset.z }, { 20, 20, 44 } }); break; } diff --git a/src/openrct2/ride/thrill/SwingingInverterShip.cpp b/src/openrct2/ride/thrill/SwingingInverterShip.cpp index cf7d323726..cefc5576fa 100644 --- a/src/openrct2/ride/thrill/SwingingInverterShip.cpp +++ b/src/openrct2/ride/thrill/SwingingInverterShip.cpp @@ -67,8 +67,7 @@ static void PaintSwingingInverterShipStructure( const auto& boundBox = SwingingInverterShipBounds[direction]; CoordsXYZ offset((direction & 1) ? 0 : axisOffset, (direction & 1) ? axisOffset : 0, height); - CoordsXYZ bbLength(boundBox.length.x, boundBox.length.y, 127); - CoordsXYZ bbOffset(boundBox.offset.x, boundBox.offset.y, height); + BoundBoxXYZ bb = { { boundBox.offset, height }, { boundBox.length, 127 } }; Vehicle* vehicle = nullptr; if (ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) @@ -112,13 +111,13 @@ static void PaintSwingingInverterShipStructure( if (direction & 2) { - PaintAddImageAsParent(session, vehicleImageId, offset, bbLength, bbOffset); - PaintAddImageAsChild(session, frameImageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, vehicleImageId, offset, bb); + PaintAddImageAsChild(session, frameImageId, offset, bb); } else { - PaintAddImageAsParent(session, frameImageId, offset, bbLength, bbOffset); - PaintAddImageAsChild(session, vehicleImageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, frameImageId, offset, bb); + PaintAddImageAsChild(session, vehicleImageId, offset, bb); } session.CurrentlyDrawnEntity = nullptr; diff --git a/src/openrct2/ride/thrill/SwingingShip.cpp b/src/openrct2/ride/thrill/SwingingShip.cpp index 58c9fc1479..e3399e0b5b 100644 --- a/src/openrct2/ride/thrill/SwingingShip.cpp +++ b/src/openrct2/ride/thrill/SwingingShip.cpp @@ -57,7 +57,7 @@ static constexpr const uint32_t SwingingShipFrameSprites[][2] = { static void PaintSwingingShipRiders( paint_session& session, const Ride& ride, const Vehicle& vehicle, ImageIndex baseImageIndex, Direction direction, - const CoordsXYZ& offset, const CoordsXYZ& bbLength, const CoordsXYZ& bbOffset) + const CoordsXYZ& offset, const BoundBoxXYZ& bb) { if (session.DPI.zoom_level > ZoomLevel{ 1 }) return; @@ -76,7 +76,7 @@ static void PaintSwingingShipRiders( auto frameNum = 1 + (row * 2) + ((direction >> 1) ^ col); auto imageIndex = baseImageIndex + frameNum; auto imageId = ImageId(imageIndex, vehicle.peep_tshirt_colours[peep], vehicle.peep_tshirt_colours[peep + 1]); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); peep += 2; } @@ -100,8 +100,7 @@ static void PaintSwingingShipStructure( const auto& bounds = SwingingShipData[direction]; CoordsXYZ offset((direction & 1) ? 0 : axisOffset, (direction & 1) ? axisOffset : 0, height + 7); - CoordsXYZ bbLength(bounds.length.x, bounds.length.y, 80); - CoordsXYZ bbOffset(bounds.offset.x, bounds.offset.y, height + 7); + BoundBoxXYZ bb = { { bounds.offset, height + 7 }, { bounds.length, 80 } }; auto baseImageId = rideEntry->Cars[0].base_image_id + SwingingShipBaseSpriteOffset[direction]; if (vehicle != nullptr) @@ -132,20 +131,20 @@ static void PaintSwingingShipStructure( // Supports (back) auto imageId = supportsImageTemplate.WithIndex(SwingingShipFrameSprites[(direction & 1)][0]); - PaintAddImageAsParent(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsParent(session, imageId, offset, bb); // Ship imageId = vehicleImageTemplate.WithIndex(baseImageId); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); if (vehicle != nullptr) { - PaintSwingingShipRiders(session, ride, *vehicle, baseImageId, direction, offset, bbLength, bbOffset); + PaintSwingingShipRiders(session, ride, *vehicle, baseImageId, direction, offset, bb); } // Supports (front) imageId = supportsImageTemplate.WithIndex(SwingingShipFrameSprites[(direction & 1)][1]); - PaintAddImageAsChild(session, imageId, offset, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, offset, bb); session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; diff --git a/src/openrct2/ride/thrill/TopSpin.cpp b/src/openrct2/ride/thrill/TopSpin.cpp index 7a31c87a68..bb2ba1c5a1 100644 --- a/src/openrct2/ride/thrill/TopSpin.cpp +++ b/src/openrct2/ride/thrill/TopSpin.cpp @@ -10,6 +10,7 @@ #include "../../entity/EntityRegistry.h" #include "../../interface/Viewport.h" #include "../../localisation/Localisation.h" +#include "../../paint/Boundbox.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../../sprites.h" @@ -35,7 +36,7 @@ static int8_t TopSpinSeatPositionOffset[] = { static void PaintTopSpinRiders( paint_session& session, const Vehicle& vehicle, ImageIndex seatImageIndex, const CoordsXYZ& seatCoords, - const CoordsXYZ& bbLength, const CoordsXYZ& bbOffset) + const BoundBoxXYZ& bb) { if (session.DPI.zoom_level >= ZoomLevel{ 2 }) return; @@ -48,7 +49,7 @@ static void PaintTopSpinRiders( auto imageIndex = seatImageIndex + ((i + 1) * 76); auto imageId = ImageId( imageIndex, vehicle.peep_tshirt_colours[peepIndex], vehicle.peep_tshirt_colours[peepIndex + 1]); - PaintAddImageAsChild(session, imageId, seatCoords, bbLength, bbOffset); + PaintAddImageAsChild(session, imageId, seatCoords, bb); } else { @@ -59,7 +60,7 @@ static void PaintTopSpinRiders( static void PaintTopSpinSeat( paint_session& session, const Ride& ride, const rct_ride_entry& rideEntry, const Vehicle* vehicle, Direction direction, - uint32_t armRotation, uint32_t seatRotation, const CoordsXYZ& offset, const CoordsXYZ& bbLength, const CoordsXYZ& bbOffset) + uint32_t armRotation, uint32_t seatRotation, const CoordsXYZ& offset, const BoundBoxXYZ& bb) { if (armRotation >= std::size(TopSpinSeatHeightOffset)) return; @@ -107,10 +108,10 @@ static void PaintTopSpinSeat( imageTemplate = ImageId::FromUInt32(imageFlags); } - PaintAddImageAsChild(session, imageTemplate.WithIndex(seatImageIndex), seatCoords, bbLength, bbOffset); + PaintAddImageAsChild(session, imageTemplate.WithIndex(seatImageIndex), seatCoords, bb); if (vehicle != nullptr) { - PaintTopSpinRiders(session, *vehicle, seatImageIndex, seatCoords, bbLength, bbOffset); + PaintTopSpinRiders(session, *vehicle, seatImageIndex, seatCoords, bb); } } @@ -146,8 +147,7 @@ static void PaintTopSpinVehicle( } CoordsXYZ offset = { al, cl, height }; - CoordsXYZ bbLength = { 24, 24, 90 }; - CoordsXYZ bbOffset = { al + 16, cl + 16, height }; + BoundBoxXYZ bb = { { al + 16, cl + 16, height }, { 24, 24, 90 } }; auto imageFlags = session.TrackColours[SCHEME_MISC]; auto supportImageTemplate = ImageId(0, ride.track_colour[0].main, ride.track_colour[0].supports); @@ -160,22 +160,22 @@ static void PaintTopSpinVehicle( // Left back bottom support auto imageIndex = carEntry.base_image_id + 572 + ((direction & 1) << 1); - PaintAddImageAsParent(session, supportImageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); + PaintAddImageAsParent(session, supportImageTemplate.WithIndex(imageIndex), offset, bb); // Left hand arm imageIndex = carEntry.base_image_id + 380 + armImageOffset + ((direction & 1) * 48); - PaintAddImageAsChild(session, armImageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); + PaintAddImageAsChild(session, armImageTemplate.WithIndex(imageIndex), offset, bb); // Seat - PaintTopSpinSeat(session, ride, *rideEntry, vehicle, direction, armRotation, seatRotation, offset, bbLength, bbOffset); + PaintTopSpinSeat(session, ride, *rideEntry, vehicle, direction, armRotation, seatRotation, offset, bb); // Right hand arm imageIndex = carEntry.base_image_id + 476 + armImageOffset + ((direction & 1) * 48); - PaintAddImageAsChild(session, armImageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); + PaintAddImageAsChild(session, armImageTemplate.WithIndex(imageIndex), offset, bb); // Right back bottom support imageIndex = carEntry.base_image_id + 573 + ((direction & 1) << 1); - PaintAddImageAsChild(session, supportImageTemplate.WithIndex(imageIndex), offset, bbLength, bbOffset); + PaintAddImageAsChild(session, supportImageTemplate.WithIndex(imageIndex), offset, bb); session.CurrentlyDrawnEntity = nullptr; session.InteractionType = ViewportInteractionItem::Ride; diff --git a/src/openrct2/ride/thrill/Twist.cpp b/src/openrct2/ride/thrill/Twist.cpp index 4ae20d191f..9710a15b8f 100644 --- a/src/openrct2/ride/thrill/Twist.cpp +++ b/src/openrct2/ride/thrill/Twist.cpp @@ -10,6 +10,7 @@ #include "../../common.h" #include "../../entity/EntityRegistry.h" #include "../../interface/Viewport.h" +#include "../../paint/Boundbox.h" #include "../../paint/Paint.h" #include "../../paint/Supports.h" #include "../Ride.h" @@ -58,8 +59,11 @@ static void paint_twist_structure( auto baseImageId = rideEntry->Cars[0].base_image_id; auto structureFrameNum = frameNum % 24; auto imageId = imageTemplate.WithIndex(baseImageId + structureFrameNum); - PaintAddImageAsParent( - session, imageId, { xOffset, yOffset, height }, { 24, 24, 48 }, { xOffset + 16, yOffset + 16, height }); + const BoundBoxXYZ bb = { + { xOffset + 16, yOffset + 16, height }, + { 24, 24, 48 }, + }; + PaintAddImageAsParent(session, imageId, { xOffset, yOffset, height }, bb); if (session.DPI.zoom_level < ZoomLevel{ 1 } && ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) { @@ -68,8 +72,7 @@ static void paint_twist_structure( imageTemplate = ImageId(0, vehicle->peep_tshirt_colours[i], vehicle->peep_tshirt_colours[i + 1]); auto peepFrameNum = (frameNum + i * 12) % 216; imageId = imageTemplate.WithIndex(baseImageId + 24 + peepFrameNum); - PaintAddImageAsChild( - session, imageId, { xOffset, yOffset, height }, { 24, 24, 48 }, { xOffset + 16, yOffset + 16, height }); + PaintAddImageAsChild(session, imageId, { xOffset, yOffset, height }, bb); } }