diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 2ca8d79717..54aefffeab 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -24,6 +24,7 @@ #include "VehicleGeometry.h" using namespace OpenRCT2; +using namespace OpenRCT2::RideVehicle; Vehicle* CableLiftSegmentCreate( Ride& ride, int32_t x, int32_t y, int32_t z, int32_t direction, uint16_t var_44, int32_t remaining_distance, bool head) @@ -277,7 +278,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards() nextVehiclePosition.z += GetRideTypeDescriptor(curRide->type).Heights.VehicleZOffset; - remaining_distance -= OpenRCT2::RideVehicle::Geometry::getTranslationDistance(nextVehiclePosition - _vehicleCurPosition, false); + remaining_distance -= Geometry::getTranslationDistance(nextVehiclePosition - _vehicleCurPosition, false); _vehicleCurPosition = nextVehiclePosition; Orientation = moveInfo->direction; @@ -286,7 +287,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards() if (remaining_distance >= 13962) { - acceleration += AccelerationFromPitch[EnumValue(pitch)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(pitch)]; } } return true; @@ -346,7 +347,7 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards() if (remaining_distance < 0) { - acceleration += AccelerationFromPitch[EnumValue(pitch)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(pitch)]; } } return true; @@ -377,7 +378,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() for (Vehicle* vehicle = frontVehicle; vehicle != nullptr;) { - vehicle->acceleration = AccelerationFromPitch[EnumValue(vehicle->pitch)]; + vehicle->acceleration = Geometry::kAccelerationFromPitch[EnumValue(vehicle->pitch)]; _vehicleUnkF64E10 = 1; vehicle->remaining_distance += _vehicleVelocityF64E0C; @@ -398,7 +399,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; _vehicleVelocityF64E0C -= vehicle->remaining_distance - 13962; vehicle->remaining_distance = 13962; - vehicle->acceleration += AccelerationFromPitch[EnumValue(vehicle->pitch)]; + vehicle->acceleration += Geometry::kAccelerationFromPitch[EnumValue(vehicle->pitch)]; _vehicleUnkF64E10++; continue; } @@ -411,7 +412,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion() _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; _vehicleVelocityF64E0C -= vehicle->remaining_distance + 1; vehicle->remaining_distance = -1; - vehicle->acceleration += AccelerationFromPitch[EnumValue(vehicle->pitch)]; + vehicle->acceleration += Geometry::kAccelerationFromPitch[EnumValue(vehicle->pitch)]; _vehicleUnkF64E10++; } vehicle->MoveTo(_vehicleCurPosition); diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 366883eec5..5edcdb2e45 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -5405,7 +5405,7 @@ void Vehicle::UpdateTrackMotionUpStopCheck() const gForces.LateralG = std::abs(gForces.LateralG); if (gForces.LateralG <= 150) { - if (AccelerationFromPitch[EnumValue(pitch)] < 0) + if (Geometry::kAccelerationFromPitch[EnumValue(pitch)] < 0) { if (gForces.VerticalG > -40) { @@ -5431,7 +5431,7 @@ void Vehicle::UpdateTrackMotionUpStopCheck() const { auto gForces = GetGForces(); - if (AccelerationFromPitch[EnumValue(pitch)] < 0) + if (Geometry::kAccelerationFromPitch[EnumValue(pitch)] < 0) { if (gForces.VerticalG > -45) { @@ -7354,7 +7354,7 @@ bool Vehicle::UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& cu return true; } - acceleration += AccelerationFromPitch[moveInfovehicleAnimationGroup]; + acceleration += Geometry::kAccelerationFromPitch[moveInfovehicleAnimationGroup]; _vehicleUnkF64E10++; } } @@ -7650,7 +7650,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c { return true; } - acceleration += AccelerationFromPitch[EnumValue(moveInfoVehicleAnimationGroup)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(moveInfoVehicleAnimationGroup)]; _vehicleUnkF64E10++; } } @@ -7671,7 +7671,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7693,7 +7693,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7721,7 +7721,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7738,7 +7738,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7767,7 +7767,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7784,7 +7784,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7820,7 +7820,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return Vehicle::UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -7859,7 +7859,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; _vehicleVelocityF64E0C -= remaining_distance + 1; remaining_distance = -1; - acceleration += AccelerationFromPitch[EnumValue(pitch)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return UpdateMiniGolfSubroutineStatus::carryOn; } @@ -7876,7 +7876,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c { Loc6DCDE4(curRide); } - acceleration += AccelerationFromPitch[EnumValue(pitch)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return UpdateMiniGolfSubroutineStatus::carryOn; } @@ -8034,7 +8034,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return UpdateMiniGolfSubroutineStatus::stop; } - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; } } @@ -8052,7 +8052,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; _vehicleVelocityF64E0C -= remaining_distance + 1; remaining_distance = -1; - acceleration += AccelerationFromPitch[EnumValue(pitch)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; continue; } @@ -8065,7 +8065,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; _vehicleVelocityF64E0C -= remaining_distance - 0x368A; remaining_distance = 0x368A; - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return Vehicle::UpdateMiniGolfSubroutineStatus::restart; } @@ -8135,7 +8135,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c vEBP->velocity = vEDI->velocity >> 1; } _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; return UpdateMiniGolfSubroutineStatus::restart; } @@ -8147,7 +8147,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c Loc6DCDE4(curRide); return UpdateMiniGolfSubroutineStatus::stop; } - acceleration += AccelerationFromPitch[EnumValue(pitch)]; + acceleration += Geometry::kAccelerationFromPitch[EnumValue(pitch)]; _vehicleUnkF64E10++; } } @@ -8161,7 +8161,7 @@ bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& c void Vehicle::UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) { _vehicleUnkF64E10 = 1; - acceleration = AccelerationFromPitch[EnumValue(pitch)]; + acceleration = Geometry::kAccelerationFromPitch[EnumValue(pitch)]; if (!HasFlag(VehicleFlags::MoveSingleCar)) { remaining_distance = _vehicleVelocityF64E0C + remaining_distance; @@ -8487,7 +8487,7 @@ void Vehicle::UpdateTrackMotionPreUpdate( { car.UpdateAdditionalAnimation(); } - car.acceleration = AccelerationFromPitch[EnumValue(car.pitch)]; + car.acceleration = Geometry::kAccelerationFromPitch[EnumValue(car.pitch)]; _vehicleUnkF64E10 = 1; if (!car.HasFlag(VehicleFlags::MoveSingleCar)) @@ -8515,7 +8515,7 @@ void Vehicle::UpdateTrackMotionPreUpdate( { break; } - car.acceleration += AccelerationFromPitch[EnumValue(car.pitch)]; + car.acceleration += Geometry::kAccelerationFromPitch[EnumValue(car.pitch)]; _vehicleUnkF64E10++; continue; } @@ -8533,7 +8533,7 @@ void Vehicle::UpdateTrackMotionPreUpdate( { break; } - car.acceleration = AccelerationFromPitch[EnumValue(car.pitch)]; + car.acceleration = Geometry::kAccelerationFromPitch[EnumValue(car.pitch)]; _vehicleUnkF64E10++; continue; } diff --git a/src/openrct2/ride/VehicleData.cpp b/src/openrct2/ride/VehicleData.cpp index b4e94fa698..c794105d62 100644 --- a/src/openrct2/ride/VehicleData.cpp +++ b/src/openrct2/ride/VehicleData.cpp @@ -795,73 +795,6 @@ const uint8_t MotionSimulatorTimeToSpriteMap[] = { const int32_t MotionSimulatorTimeToSpriteMapCount = static_cast(std::size(MotionSimulatorTimeToSpriteMap)); -/** rct2: 0x009A2970 */ -const int32_t AccelerationFromPitch[] = { - 0, // Flat - // The geometric angle of slopes 12.5 and 25 are actually 11.1 and 22.2 respectively. - -124548, // 1 Slope Up 12.5 - -243318, // 2 Slope Up 25 - -416016, // 3 Slope Up 42.5 - -546342, // 4 Slope Up 60 - 124548, // 5 Slope Down 12.5 - 243318, // 6 Slope Down 25 - 416016, // 7 Slope Down 42.5 - 546342, // 8 Slope Down 60 - -617604, // 9 Slope Up 75 - -642000, // 10 Slope Up 90 - -620172, // 11 Slope Up 105 - -555972, // 12 Slope Up 120 - -453894, // 13 Slope Up 135 - -321000, // 14 Slope Up 150 - -166278, // 15 Slope Up 165 - 0, // 16 Fully Inverted - 617604, // 17 Slope Down 75 - 642000, // 18 Slope Down 90 - 620172, // 19 Slope Down 105 - 555972, // 20 Slope Down 120 - 453894, // 21 Slope Down 135 - 321000, // 22 Slope Down 150 - 166278, // 23 Slope Down 165 - -321000, // 24 Corkscrew Right Up 0 - -555972, // 25 Corkscrew Right Up 1 - -642000, // 26 Corkscrew Right Up 2 - -555972, // 27 Corkscrew Right Up 3 - -321000, // 28 Corkscrew Right Up 4 - 321000, // 29 Corkscrew Right Down 4 - 555972, // 30 Corkscrew Right Down 3 - 642000, // 31 Corkscrew Right Down 2 - 555972, // 32 Corkscrew Right Down 1 - 321000, // 33 Corkscrew Right Down 0 - -321000, // 34 Corkscrew Left Up 0 - -555972, // 35 Corkscrew Left Up 1 - -642000, // 36 Corkscrew Left Up 2 - -555972, // 37 Corkscrew Left Up 3 - -321000, // 38 Corkscrew Left Up 4 - 321000, // 39 Corkscrew Left Down 4 - 555972, // 40 Corkscrew Left Down 2 - 642000, // 41 Corkscrew Left Down 1 - 555972, // 42 Corkscrew Left Down 1 - 321000, // 43 Corkscrew Left Down 0 - -33384, // 44 Half Helix Up Large - -55854, // 45 Half Helix Up Small - 33384, // 46 Half Helix Down Large - 55854, // 47 Half Helix Down Small - -66768, // 48 Quarter Helix Up - 66768, // 49 Quarter Helix Down - // currently only diagonal elements use slopes angles 8, 16, 50. Diagonal gentle-to-steep transition uses - // diagonal sprites of slopes 25 and 42. - -90522, // 50 Slope Up 8 - -179760, // 51 Slope Down 16 - -484068, // 52 Slope Up 50 - 90522, // 53 Slope Down 8 - 179760, // 54 Slope Down 16 - 484068, // 55 Slope Down 50 - 243318, // 56 Inverting Loop Down 25 - 416016, // 57 Inverting Loop Down 42.5 - 546342, // 58 Inverting Loop Down 60 - -110424, // 59 Slope Up Spiral Lift Hill -}; - /** rct2: 0x009A3684 */ const int32_t SpriteDirectionToSoundDirection[] = { -0x4000, // 0 diff --git a/src/openrct2/ride/VehicleData.h b/src/openrct2/ride/VehicleData.h index 9ef99fc105..0618f82acd 100644 --- a/src/openrct2/ride/VehicleData.h +++ b/src/openrct2/ride/VehicleData.h @@ -26,6 +26,4 @@ extern const TopSpinTimeToSpriteMap* TopSpinTimeToSpriteMaps[]; extern const uint8_t MotionSimulatorTimeToSpriteMap[]; extern const int32_t MotionSimulatorTimeToSpriteMapCount; -extern const int32_t AccelerationFromPitch[]; - extern const int32_t SpriteDirectionToSoundDirection[]; diff --git a/src/openrct2/ride/VehicleGeometry.cpp b/src/openrct2/ride/VehicleGeometry.cpp index 70e2f56cbf..c3073c811a 100644 --- a/src/openrct2/ride/VehicleGeometry.cpp +++ b/src/openrct2/ride/VehicleGeometry.cpp @@ -39,7 +39,7 @@ namespace OpenRCT2::RideVehicle::Geometry static_assert(std::size(kSubpositionTranslationDistances) == 16); /** rct2: 0x009A36C4 */ - constexpr auto kFreeroamVehicleMovementData = std::to_array( { + constexpr auto kFreeroamVehicleMovementData = std::to_array({ { -1, 0, 8716 }, { -1, 0, 8716 }, { -1, 0, 8716 }, { -1, 1, 12327 }, { -1, 1, 12327 }, { -1, 1, 12327 }, { 0, 1, 8716 }, { -1, 1, 12327 }, { 0, 1, 8716 }, { 0, 1, 8716 }, { 0, 1, 8716 }, { 1, 1, 12327 }, { 1, 1, 12327 }, { 1, 1, 12327 }, { 1, 0, 8716 }, { 1, 1, 12327 }, { 1, 0, 8716 }, { 1, 0, 8716 }, @@ -49,4 +49,70 @@ namespace OpenRCT2::RideVehicle::Geometry }); static_assert(std::size(kFreeroamVehicleMovementData) == 32); + /** rct2: 0x009A2970 */ + constexpr auto kAccelerationFromPitch = std::to_array({ + 0, // Flat + -124548, // 1 Slope Up 12.5 + -243318, // 2 Slope Up 25 + -416016, // 3 Slope Up 42.5 + -546342, // 4 Slope Up 60 + 124548, // 5 Slope Down 12.5 + 243318, // 6 Slope Down 25 + 416016, // 7 Slope Down 42.5 + 546342, // 8 Slope Down 60 + -617604, // 9 Slope Up 75 + -642000, // 10 Slope Up 90 + -620172, // 11 Slope Up 105 + -555972, // 12 Slope Up 120 + -453894, // 13 Slope Up 135 + -321000, // 14 Slope Up 150 + -166278, // 15 Slope Up 165 + 0, // 16 Fully Inverted + 617604, // 17 Slope Down 75 + 642000, // 18 Slope Down 90 + 620172, // 19 Slope Down 105 + 555972, // 20 Slope Down 120 + 453894, // 21 Slope Down 135 + 321000, // 22 Slope Down 150 + 166278, // 23 Slope Down 165 + -321000, // 24 Corkscrew Right Up 0 + -555972, // 25 Corkscrew Right Up 1 + -642000, // 26 Corkscrew Right Up 2 + -555972, // 27 Corkscrew Right Up 3 + -321000, // 28 Corkscrew Right Up 4 + 321000, // 29 Corkscrew Right Down 4 + 555972, // 30 Corkscrew Right Down 3 + 642000, // 31 Corkscrew Right Down 2 + 555972, // 32 Corkscrew Right Down 1 + 321000, // 33 Corkscrew Right Down 0 + -321000, // 34 Corkscrew Left Up 0 + -555972, // 35 Corkscrew Left Up 1 + -642000, // 36 Corkscrew Left Up 2 + -555972, // 37 Corkscrew Left Up 3 + -321000, // 38 Corkscrew Left Up 4 + 321000, // 39 Corkscrew Left Down 4 + 555972, // 40 Corkscrew Left Down 2 + 642000, // 41 Corkscrew Left Down 1 + 555972, // 42 Corkscrew Left Down 1 + 321000, // 43 Corkscrew Left Down 0 + -33384, // 44 Half Helix Up Large + -55854, // 45 Half Helix Up Small + 33384, // 46 Half Helix Down Large + 55854, // 47 Half Helix Down Small + -66768, // 48 Quarter Helix Up + 66768, // 49 Quarter Helix Down + -90522, // 50 Slope Up 8 + -179760, // 51 Slope Down 16 + -484068, // 52 Slope Up 50 + 90522, // 53 Slope Down 8 + 179760, // 54 Slope Down 16 + 484068, // 55 Slope Down 50 + 243318, // 56 Inverting Loop Down 25 + 416016, // 57 Inverting Loop Down 42.5 + 546342, // 58 Inverting Loop Down 60 + -110424, // 59 Slope Up Spiral Lift Hill + 110424, // 60 Slope Down Spiral Lift Hill + }); + static_assert(std::size(kAccelerationFromPitch) == EnumValue(VehiclePitch::pitchCount)); + } // namespace OpenRCT2::RideVehicle::Geometry diff --git a/src/openrct2/ride/VehicleGeometry.h b/src/openrct2/ride/VehicleGeometry.h index 68aea8c92e..f7b48c1146 100644 --- a/src/openrct2/ride/VehicleGeometry.h +++ b/src/openrct2/ride/VehicleGeometry.h @@ -9,6 +9,7 @@ #pragma once +#include "../core/EnumUtils.hpp" #include "../world/Location.hpp" #include "Angles.h" @@ -17,7 +18,6 @@ namespace OpenRCT2::RideVehicle::Geometry { - struct Unk9A36C4Struct { int16_t x; @@ -27,6 +27,7 @@ namespace OpenRCT2::RideVehicle::Geometry extern const std::array kSubpositionTranslationDistances; extern const std::array kFreeroamVehicleMovementData; + extern const std::array kAccelerationFromPitch; /** The distance between subposition points in a movement vector. * Squashes vector components to 0 or !0, so vector length is ignored.