From b78906a8b6fdab9208d50280e43aa4ce413d0b1b Mon Sep 17 00:00:00 2001 From: mix Date: Thu, 1 May 2025 02:56:44 +0100 Subject: [PATCH] Use original intended bounding box for fallback vehicle sprites --- src/openrct2/paint/vehicle/VehiclePaint.cpp | 1697 ++++++++++--------- 1 file changed, 935 insertions(+), 762 deletions(-) diff --git a/src/openrct2/paint/vehicle/VehiclePaint.cpp b/src/openrct2/paint/vehicle/VehiclePaint.cpp index 448b2a5651..00091340ad 100644 --- a/src/openrct2/paint/vehicle/VehiclePaint.cpp +++ b/src/openrct2/paint/vehicle/VehiclePaint.cpp @@ -954,6 +954,8 @@ const uint8_t PitchInvertTable[] = { // Opposite Bank values for reversed cars const uint8_t BankInvertTable[] = { 0, 3, 4, 1, 2, 10, 11, 12, 13, 14, 5, 6, 7, 8, 9, 15, 18, 19, 16, 17 }; +constexpr uint32_t kBoundingBoxIndexUndefined = std::numeric_limits::max(); + #pragma endregion #pragma region VehiclePaintUtil @@ -1028,21 +1030,22 @@ static void vehicle_sprite_paint( // 6D520E static void VehicleSpritePaintWithSwinging( - PaintSession& session, const Vehicle* vehicle, int32_t spriteNum, int32_t boundingBoxNum, int32_t z, + PaintSession& session, const Vehicle* vehicle, int32_t spriteNum, int32_t boundingBoxIndex, int32_t z, const CarEntry* carEntry) { vehicle_sprite_paint( - session, vehicle, spriteNum + vehicle->SwingSprite, VehicleBoundboxes[carEntry->draw_order][boundingBoxNum], z, + session, vehicle, spriteNum + vehicle->SwingSprite, VehicleBoundboxes[carEntry->draw_order][boundingBoxIndex], z, carEntry); } static void VehicleSpritePaintRestraints( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { - int32_t boundingBoxNum = YawTo16(imageDirection); + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); auto restraintFrame = ((vehicle->restraints_position - 64) / 64); auto spriteNum = carEntry->SpriteOffset(SpriteGroupType::RestraintAnimation, imageDirection, restraintFrame); - vehicle_sprite_paint(session, vehicle, spriteNum, VehicleBoundboxes[carEntry->draw_order][boundingBoxNum], z, carEntry); + vehicle_sprite_paint(session, vehicle, spriteNum, VehicleBoundboxes[carEntry->draw_order][boundingBoxIndex], z, carEntry); } // Returns the opposite of the bank angle for reversed cars, normal bank angle otherwise @@ -1057,383 +1060,403 @@ static uint8_t GetPaintBankRotation(const Vehicle* vehicle) // 6D51DE static void VehiclePitchFlatUnbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // Restraint animations are only drawn for vehicles that are in a cardinal direction (north, east, south, west) if (vehicle->restraints_position >= 64 && carEntry->GroupEnabled(SpriteGroupType::RestraintAnimation) && (imageDirection & 7) == 0) { - VehicleSpritePaintRestraints(session, vehicle, imageDirection, z, carEntry); + VehicleSpritePaintRestraints(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); return; } - int32_t boundingBoxNum = YawTo16(imageDirection); + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); auto spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopeFlat, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } // 6D4EE7 static void VehiclePitchFlatBankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4F34 static void VehiclePitchFlatBankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection) + 108; if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection) + 108; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4F0C static void VehiclePitchFlatBankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4F5C static void VehiclePitchFlatBankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection) ^ 8) + 108; if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked45)) { - int32_t boundingBoxNum = (YawTo16(imageDirection) ^ 8) + 108; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4F84 static void VehiclePitchFlatBankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 124; if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked67)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 124; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked67, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4FE4 static void VehiclePitchFlatBankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 128; if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked90)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 128; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked90, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D5055 static void VehiclePitchFlatBankedLeft112( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 132; if (carEntry->GroupEnabled(SpriteGroupType::InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 132; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::InlineTwists, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D50C6 static void VehiclePitchFlatBankedLeft135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 136; if (carEntry->GroupEnabled(SpriteGroupType::InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 136; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::InlineTwists, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D5137 static void VehiclePitchFlatBankedLeft157( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 140; if (carEntry->GroupEnabled(SpriteGroupType::InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 140; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::InlineTwists, imageDirection, 4); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4FB1 static void VehiclePitchFlatBankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 124; if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked67)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 124; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked67, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D501B static void VehiclePitchFlatBankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 128; if (carEntry->GroupEnabled(SpriteGroupType::FlatBanked90)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 128; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::FlatBanked90, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D508C static void VehiclePitchFlatBankedRight112( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 132; if (carEntry->GroupEnabled(SpriteGroupType::InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 132; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::InlineTwists, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D50FD static void VehiclePitchFlatBankedRight135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 136; if (carEntry->GroupEnabled(SpriteGroupType::InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 136; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::InlineTwists, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D516E static void VehiclePitchFlatBankedRight157( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 140; if (carEntry->GroupEnabled(SpriteGroupType::InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 140; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::InlineTwists, imageDirection, 5); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4EE4 static void VehiclePitchUninvertedFlatBankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchFlatBankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } // 6D4F31 static void VehiclePitchUninvertedFlatBankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } // 6D4F09 static void VehiclePitchUninvertedFlatBankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchFlatBankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } // 6D4F59 static void VehiclePitchUninvertedFlatBankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } // 6D51D7 static void VehiclePitchFlat( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3DE4: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchFlatBankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchFlatBankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchFlatBankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 7: - VehiclePitchFlatBankedLeft112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 8: - VehiclePitchFlatBankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 9: - VehiclePitchFlatBankedLeft157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchFlatBankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 12: - VehiclePitchFlatBankedRight112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 13: - VehiclePitchFlatBankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 14: - VehiclePitchFlatBankedRight157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 15: // what is roll 15? - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 16: - VehiclePitchUninvertedFlatBankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUninvertedFlatBankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 17: - VehiclePitchUninvertedFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUninvertedFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 18: - VehiclePitchUninvertedFlatBankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUninvertedFlatBankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 19: - VehiclePitchUninvertedFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUninvertedFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -1446,120 +1469,126 @@ static void VehiclePitchFlat( // 6D4614 static void VehiclePitchUp12Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4662 static void VehiclePitchUp12BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D46DB static void VehiclePitchUp12BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp12BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D467D static void VehiclePitchUp12BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D46FD static void VehiclePitchUp12BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp12BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D460D static void VehiclePitchUp12( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3C04: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchUp12BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchUp12BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchUp12BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchUp12BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 16: - VehiclePitchUp12BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 17: - VehiclePitchUp12BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 18: - VehiclePitchUp12BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 19: - VehiclePitchUp12BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -1569,309 +1598,330 @@ static void VehiclePitchUp12( // 6D4791 static void VehiclePitchUp25Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 16; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4833 static void VehiclePitchUp25BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection) + 16; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection) + 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D48D6 static void VehiclePitchUp25BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + if (boundingBoxIndex == kBoundingBoxIndexUndefined) + { + boundingBoxIndex = YawTo16(imageDirection); + if (carEntry->draw_order < 5) + boundingBoxIndex += 108; + else + boundingBoxIndex += 16; + } if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); - if (carEntry->draw_order < 5) - boundingBoxNum += 108; - else - boundingBoxNum += 16; - int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4858 static void VehiclePitchUp25BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection) + 16; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection) + 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4910 static void VehiclePitchUp25BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + if (boundingBoxIndex == kBoundingBoxIndexUndefined) + { + boundingBoxIndex = YawTo16(imageDirection); + if (carEntry->draw_order < 5) + boundingBoxIndex = (boundingBoxIndex ^ 8) + 108; + else + boundingBoxIndex += 16; + } if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); - if (carEntry->draw_order < 5) - boundingBoxNum = (boundingBoxNum ^ 8) + 108; - else - boundingBoxNum += 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 124; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked67)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 124; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked67, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 128; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked90)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 128; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked90, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedLeft112( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 132; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 132; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedLeft135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 136; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 136; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 4); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedLeft157( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 140; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 140; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 8); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 124; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked67)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 124; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked67, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 128; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked90)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 128; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked90, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedRight112( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 132; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 132; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedRight135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 136; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 136; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 5); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp25BankedRight157( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 140; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 140; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 9); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D476C static void VehiclePitchUp25( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3CA4: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchUp25BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchUp25BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchUp25BankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchUp25BankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 7: - VehiclePitchUp25BankedLeft112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 8: - VehiclePitchUp25BankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 9: - VehiclePitchUp25BankedLeft157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchUp25BankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchUp25BankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 12: - VehiclePitchUp25BankedRight112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 13: - VehiclePitchUp25BankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 14: - VehiclePitchUp25BankedRight157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 15: - VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 16: - VehiclePitchUp25BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 17: - VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 18: - VehiclePitchUp25BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 19: - VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -1884,277 +1934,294 @@ static void VehiclePitchUp25( // 6D49DC static void VehiclePitchUp42Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked22)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked45)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked22)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked45)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked67)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked67, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked90)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked90, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked67)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked67, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked90)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked90, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedLeft135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + const int32_t modifiedImageDirection = (imageDirection + 8) % 32; + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex + : YawTo4(modifiedImageDirection) + 13 * 4 + 144; if (carEntry->GroupEnabled(SpriteGroupType::Corkscrews)) { - imageDirection = (imageDirection + 8) % 32; - int32_t boundingBoxNum = YawTo4(imageDirection) + 13 * 4 + 144; - int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, imageDirection, 13); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, modifiedImageDirection, 13); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp42BankedRight135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 3 * 4 + 144; if (carEntry->GroupEnabled(SpriteGroupType::Corkscrews)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 3 * 4 + 144; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D49DC static void VehiclePitchUp42( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchUp42BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchUp42BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchUp42BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchUp42BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchUp42BankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchUp42BankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 8: - VehiclePitchUp42BankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchUp42BankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchUp42BankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 13: - VehiclePitchUp42BankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42BankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4A31 static void VehiclePitchUp60Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes60)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes60, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp60BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes60Banked22)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes60Banked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp60BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes60Banked22)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes60Banked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp60( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchUp60BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchUp60BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -2166,150 +2233,156 @@ static void VehiclePitchUp60( // 6D463D static void VehiclePitchDown12Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D469B static void VehiclePitchDown12BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked22, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4722 static void VehiclePitchDown12BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked45, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown12BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D46B9 static void VehiclePitchDown12BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked22, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4747 static void VehiclePitchDown12BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes12Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes12Banked45, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown12BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4636 static void VehiclePitchDown12( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3C54: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchDown12BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchDown12BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchDown12BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchDown12BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 7: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 8: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 9: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 12: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 13: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 14: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 15: - VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 16: - VehiclePitchDown12BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 17: - VehiclePitchDown12BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 18: - VehiclePitchDown12BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 19: - VehiclePitchDown12BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown12BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -2323,310 +2396,330 @@ static void VehiclePitchDown12( // 6D47E4 static void VehiclePitchDown25Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo16(imageDirection)) ^ 8) + 16; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25)) { - int32_t boundingBoxNum = ((YawTo16(imageDirection)) ^ 8) + 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4880 static void VehiclePitchDown25BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo16(imageDirection)) ^ 8) + 16; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked22)) { - int32_t boundingBoxNum = ((YawTo16(imageDirection)) ^ 8) + 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked22, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4953 static void VehiclePitchDown25BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + if (boundingBoxIndex == kBoundingBoxIndexUndefined) + { + boundingBoxIndex = YawTo16(imageDirection); + if (carEntry->draw_order < 5) + boundingBoxIndex += 108; + else + boundingBoxIndex = (boundingBoxIndex ^ 8) + 16; + } if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); - if (carEntry->draw_order < 5) - boundingBoxNum += 108; - else - boundingBoxNum = (boundingBoxNum ^ 8) + 16; - int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked45, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D48AB static void VehiclePitchDown25BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo16(imageDirection)) ^ 8) + 16; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked22)) { - int32_t boundingBoxNum = ((YawTo16(imageDirection)) ^ 8) + 16; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked22, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4996 static void VehiclePitchDown25BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + if (boundingBoxIndex == kBoundingBoxIndexUndefined) + { + boundingBoxIndex = YawTo16(imageDirection); + if (carEntry->draw_order < 5) + boundingBoxIndex = (boundingBoxIndex ^ 8) + 108; + else + boundingBoxIndex = (boundingBoxIndex ^ 8) + 16; + } if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); - if (carEntry->draw_order < 5) - boundingBoxNum = (boundingBoxNum ^ 8) + 108; - else - boundingBoxNum = (boundingBoxNum ^ 8) + 16; - int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked45, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 124; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked67)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 124; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked67, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 128; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked90)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 128; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked90, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedLeft112( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 132; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 132; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedLeft135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 136; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 136; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 6); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedLeft157( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 140; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 140; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 10); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 124; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked67)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 124; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked67, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 128; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25Banked90)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 128; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25Banked90, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedRight112( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 132; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 132; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedRight135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 136; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 136; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 7); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown25BankedRight157( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection) ^ 2) + 140; if (carEntry->GroupEnabled(SpriteGroupType::Slopes25InlineTwists)) { - int32_t boundingBoxNum = (YawTo4(imageDirection) ^ 2) + 140; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes25InlineTwists, imageDirection, 11); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D47DD static void VehiclePitchDown25( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3CF4: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchDown25BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchDown25BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchDown25BankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchDown25BankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 7: - VehiclePitchDown25BankedLeft112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 8: - VehiclePitchDown25BankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 9: - VehiclePitchDown25BankedLeft157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchDown25BankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchDown25BankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 12: - VehiclePitchDown25BankedRight112(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight112(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 13: - VehiclePitchDown25BankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 14: - VehiclePitchDown25BankedRight157(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight157(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 15: - VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 16: - VehiclePitchDown25BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 17: - VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 18: - VehiclePitchDown25BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 19: - VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -2639,276 +2732,293 @@ static void VehiclePitchDown25( // 6D4A05 static void VehiclePitchDown42Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo8(imageDirection)) ^ 4) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42)) { - int32_t boundingBoxNum = ((YawTo8(imageDirection)) ^ 4) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked22)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked22, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked45)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked45, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked22)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked22, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked45)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked45, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked67)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked67, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked90)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked90, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked67)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked67, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo8(imageDirection)) + 32; if (carEntry->GroupEnabled(SpriteGroupType::Slopes42Banked90)) { - int32_t boundingBoxNum = (YawTo8(imageDirection)) + 32; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes42Banked90, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedLeft135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo4(imageDirection) + 8 * 4 + 144; if (carEntry->GroupEnabled(SpriteGroupType::Corkscrews)) { - int32_t boundingBoxNum = YawTo4(imageDirection) + 8 * 4 + 144; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, imageDirection, 8); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42BankedRight135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + const int32_t modifiedImageDirection = (imageDirection + 8) % 32; + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex + : YawTo4(modifiedImageDirection) + 18 * 4 + 144; if (carEntry->GroupEnabled(SpriteGroupType::Corkscrews)) { - imageDirection = (imageDirection + 8) % 32; - int32_t boundingBoxNum = YawTo4(imageDirection) + 18 * 4 + 144; - int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, imageDirection, 18); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, modifiedImageDirection, 18); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown42( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchDown42BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchDown42BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchDown42BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchDown42BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchDown42BankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchDown42BankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 8: - VehiclePitchDown42BankedLeft135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedLeft135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchDown42BankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchDown42BankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 13: - VehiclePitchDown42BankedRight135(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42BankedRight135(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4A59 static void VehiclePitchDown60Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo16(imageDirection)) ^ 8) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes60)) { - int32_t boundingBoxNum = ((YawTo16(imageDirection)) ^ 8) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes60, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown60BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes60Banked22)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes60Banked22, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown60BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes60Banked22)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes60Banked22, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown60( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchDown60BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchDown60BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -2918,33 +3028,35 @@ static void VehiclePitchDown60( // 6D4A81 static void VehiclePitchUp75( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 56; if (carEntry->GroupEnabled(SpriteGroupType::Slopes75)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 56; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes75, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4AE8 static void VehiclePitchUp90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 60; if (carEntry->GroupEnabled(SpriteGroupType::Slopes90)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 60; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes90, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -2954,81 +3066,86 @@ static void VehiclePitchUp90( // 6D4B57 static void VehiclePitchUp105( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 76; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 76; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4BB7 static void VehiclePitchUp120( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 80; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 80; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4C17 static void VehiclePitchUp135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 84; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 84; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 4); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4C77 static void VehiclePitchUp150( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 88; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 88; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 6); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4CD7 static void VehiclePitchUp165( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 92; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 92; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 8); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3038,17 +3155,18 @@ static void VehiclePitchUp165( // 6D4D37 static void VehiclePitchInverted( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo4(imageDirection)) + 96; if (carEntry->GroupEnabled(SpriteGroupType::SlopeInverted)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + 96; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopeInverted, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3058,7 +3176,8 @@ static void VehiclePitchInverted( // 6D4AA3 static void VehiclePitchDown75( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { @@ -3068,21 +3187,22 @@ static void VehiclePitchDown75( carEntry--; } } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo4(imageDirection)) ^ 2) + 56; if (carEntry->GroupEnabled(SpriteGroupType::Slopes75)) { - int32_t boundingBoxNum = ((YawTo4(imageDirection)) ^ 2) + 56; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes75, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4B0D static void VehiclePitchDown90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { @@ -3092,15 +3212,15 @@ static void VehiclePitchDown90( carEntry--; } } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo16(imageDirection)) ^ 8) + 60; if (carEntry->GroupEnabled(SpriteGroupType::Slopes90)) { - int32_t boundingBoxNum = ((YawTo16(imageDirection)) ^ 8) + 60; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes90, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3110,101 +3230,106 @@ static void VehiclePitchDown90( // 6D4B80 static void VehiclePitchDown105( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo4(imageDirection)) ^ 2) + 76; if (carEntry->GroupEnabled(SpriteGroupType::Slopes90)) { - int32_t boundingBoxNum = ((YawTo4(imageDirection)) ^ 2) + 76; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4BE0 static void VehiclePitchDown120( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo4(imageDirection)) ^ 2) + 80; if (carEntry->GroupEnabled(SpriteGroupType::Slopes90)) { - int32_t boundingBoxNum = ((YawTo4(imageDirection)) ^ 2) + 80; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4C40 static void VehiclePitchDown135( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo4(imageDirection)) ^ 2) + 84; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = ((YawTo4(imageDirection)) ^ 2) + 84; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 5); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4CA0 static void VehiclePitchDown150( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo4(imageDirection)) ^ 2) + 88; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = ((YawTo4(imageDirection)) ^ 2) + 88; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 7); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4D00 static void VehiclePitchDown165( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : ((YawTo4(imageDirection)) ^ 2) + 92; if (carEntry->GroupEnabled(SpriteGroupType::SlopesLoop)) { - int32_t boundingBoxNum = ((YawTo4(imageDirection)) ^ 2) + 92; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::SlopesLoop, imageDirection, 9); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3215,21 +3340,23 @@ static void VehiclePitchDown165( // 6D51A5 template void VehiclePitchCorkscrew( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) { carEntry--; } + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex + : (YawTo4(imageDirection)) + corkscrewFrame * 4 + 144; if (carEntry->GroupEnabled(SpriteGroupType::Corkscrews)) { - int32_t boundingBoxNum = (YawTo4(imageDirection)) + corkscrewFrame * 4 + 144; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Corkscrews, imageDirection, corkscrewFrame); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatUnbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3241,108 +3368,114 @@ void VehiclePitchCorkscrew( // 6D4D67 static void VehiclePitchUp8Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4DB5 static void VehiclePitchUp8BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4DD3 static void VehiclePitchUp8BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp8BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp8BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4D60 static void VehiclePitchUp8( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3D44: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: case 16: - VehiclePitchUp8BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: case 18: - VehiclePitchUp8BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchUp8BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchUp8BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp8Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -3353,102 +3486,108 @@ static void VehiclePitchUp8( // 6D4E3A static void VehiclePitchUp16Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp16BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked22, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp16BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked22, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp16BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp16BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp16BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp16BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp16( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp16Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchUp16BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchUp16BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchUp16BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchUp16BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchUp16Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp16Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -3459,138 +3598,146 @@ static void VehiclePitchUp16( // 6D4E8F static void VehiclePitchUp50Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes50)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked45)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked45, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked45)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked45, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50BankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked67)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked67, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedLeft45(session, vehicle, (imageDirection + 2) % 32, z, carEntry); + VehiclePitchUp25BankedLeft45(session, vehicle, (imageDirection + 2) % 32, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50BankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked67)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked67, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchUp25BankedRight45(session, vehicle, (imageDirection - 2) % 32, z, carEntry); + VehiclePitchUp25BankedRight45(session, vehicle, (imageDirection - 2) % 32, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50BankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked90)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked90, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchCorkscrew<12>(session, vehicle, (imageDirection + 8) % 32, z, carEntry); + VehiclePitchCorkscrew<12>(session, vehicle, (imageDirection + 8) % 32, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50BankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked90)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked90, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchCorkscrew<2>(session, vehicle, imageDirection, z, carEntry); + VehiclePitchCorkscrew<2>(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchUp50( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchUp50BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchUp50BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchUp50BankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50BankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchUp50BankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50BankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchUp50BankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50BankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchUp50BankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50BankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchUp50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3604,108 +3751,114 @@ static void VehiclePitchUp50( // 6D4D90 static void VehiclePitchDown8Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4DF4 static void VehiclePitchDown8BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked22, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4E15 static void VehiclePitchDown8BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked22, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown8BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked45, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown8BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes8Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes8Banked45, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlatBankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } // 6D4D89 static void VehiclePitchDown8( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { // 0x009A3D94: switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown8Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown8Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: case 16: - VehiclePitchDown8BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown8BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: case 18: - VehiclePitchDown8BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown8BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchDown8BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown8BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchDown8BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown8BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchDown8Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown8Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -3716,102 +3869,108 @@ static void VehiclePitchDown8( // 6D4E63 static void VehiclePitchDown16Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown16BankedLeft22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked22, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown16BankedRight22( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked22)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked22, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown16BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked45, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown16BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown16BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes16Banked45)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes16Banked45, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown16BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown16( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown16Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 1: - VehiclePitchDown16BankedLeft22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16BankedLeft22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 3: - VehiclePitchDown16BankedRight22(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16BankedRight22(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchDown16BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchDown16BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchDown16Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown16Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; } } @@ -3822,138 +3981,146 @@ static void VehiclePitchDown16( // 6D4EB8 static void VehiclePitchDown50Unbanked( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::Slopes50)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50, imageDirection, 1); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50BankedLeft45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked45)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked45, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50BankedRight45( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked45)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked45, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50BankedLeft67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked67)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked67, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedLeft45(session, vehicle, (imageDirection - 2) % 32, z, carEntry); + VehiclePitchDown25BankedLeft45(session, vehicle, (imageDirection - 2) % 32, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50BankedRight67( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked67)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked67, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchDown25BankedRight45(session, vehicle, (imageDirection + 2) % 32, z, carEntry); + VehiclePitchDown25BankedRight45(session, vehicle, (imageDirection + 2) % 32, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50BankedLeft90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked90)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked90, imageDirection, 2); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchCorkscrew<7>(session, vehicle, imageDirection, z, carEntry); + VehiclePitchCorkscrew<7>(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50BankedRight90( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : (YawTo16(imageDirection)) + 40; if (carEntry->GroupEnabled(SpriteGroupType::Slopes50Banked90)) { - int32_t boundingBoxNum = (YawTo16(imageDirection)) + 40; int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::Slopes50Banked90, imageDirection, 3); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchCorkscrew<17>(session, vehicle, (imageDirection + 8) % 32, z, carEntry); + VehiclePitchCorkscrew<17>(session, vehicle, (imageDirection + 8) % 32, z, carEntry, boundingBoxIndex); } } static void VehiclePitchDown50( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { switch (GetPaintBankRotation(vehicle)) { case 0: - VehiclePitchDown50Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 2: - VehiclePitchDown50BankedLeft45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50BankedLeft45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 4: - VehiclePitchDown50BankedRight45(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50BankedRight45(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 5: - VehiclePitchDown50BankedLeft67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50BankedLeft67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 6: - VehiclePitchDown50BankedLeft90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50BankedLeft90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 10: - VehiclePitchDown50BankedRight67(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50BankedRight67(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; case 11: - VehiclePitchDown50BankedRight90(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown50BankedRight90(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); break; default: - VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60Unbanked(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -3965,26 +4132,29 @@ static void VehiclePitchDown50( // 6D47DA static void VehiclePitchInvertingDown25( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchDown25(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown25(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } // 6D4A02 static void VehiclePitchInvertingDown42( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchDown42(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown42(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } // 6D4A56 static void VehiclePitchInvertingDown60( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { carEntry--; - VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry); + VehiclePitchDown60(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } #pragma endregion @@ -3993,32 +4163,34 @@ static void VehiclePitchInvertingDown60( // 6D4773 static void VehiclePitchSpiralLiftUp( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::CurvedLiftHillUp)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::CurvedLiftHillUp, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } static void VehiclePitchSpiralLiftDown( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry) + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex) { + boundingBoxIndex = boundingBoxIndex != kBoundingBoxIndexUndefined ? boundingBoxIndex : YawTo16(imageDirection); if (carEntry->GroupEnabled(SpriteGroupType::CurvedLiftHillDown)) { - int32_t boundingBoxNum = YawTo16(imageDirection); int32_t spriteNum = carEntry->SpriteOffset(SpriteGroupType::CurvedLiftHillDown, imageDirection, 0); - VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxNum, z, carEntry); + VehicleSpritePaintWithSwinging(session, vehicle, spriteNum, boundingBoxIndex, z, carEntry); } else { - VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry); + VehiclePitchFlat(session, vehicle, imageDirection, z, carEntry, boundingBoxIndex); } } @@ -4026,7 +4198,8 @@ static void VehiclePitchSpiralLiftDown( // 0x009A3B14: using vehicle_sprite_func = void (*)( - PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry); + PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, int32_t z, const CarEntry* carEntry, + uint32_t boundingBoxIndex); // clang-format off static constexpr vehicle_sprite_func PaintFunctionsByPitch[] = { @@ -4267,11 +4440,11 @@ void VehicleVisualDefault( auto imagePitch = PitchInvertTable[vehicle->Pitch]; auto imageYaw = (imageDirection + (OpenRCT2::Entity::Yaw::kBaseRotation / 2)) & (OpenRCT2::Entity::Yaw::kBaseRotation - 1); - PaintFunctionsByPitch[imagePitch](session, vehicle, imageYaw, z, carEntry); + PaintFunctionsByPitch[imagePitch](session, vehicle, imageYaw, z, carEntry, kBoundingBoxIndexUndefined); } else { - PaintFunctionsByPitch[vehicle->Pitch](session, vehicle, imageDirection, z, carEntry); + PaintFunctionsByPitch[vehicle->Pitch](session, vehicle, imageDirection, z, carEntry, kBoundingBoxIndexUndefined); } } }