1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 05:23:04 +01:00

move doppler and crash direction arrays

This commit is contained in:
Spacek531
2025-10-20 23:18:53 -07:00
committed by Gymnasiast
parent 965ce8bf69
commit af3286acef
5 changed files with 63 additions and 47 deletions

View File

@@ -2883,12 +2883,6 @@ void Vehicle::UpdateCollisionSetup()
velocity = 0;
}
/** rct2: 0x009A3AC4, 0x009A3AC6 */
static constexpr CoordsXY stru_9A3AC4[] = {
{ -256, 0 }, { -236, 98 }, { -181, 181 }, { -98, 236 }, { 0, 256 }, { 98, 236 }, { 181, 181 }, { 236, 98 },
{ 256, 0 }, { 236, -98 }, { 181, -181 }, { 98, -236 }, { 0, -256 }, { -98, -236 }, { -181, -181 }, { -236, -98 },
};
/**
*
* rct2: 0x006D9EFE
@@ -2922,8 +2916,8 @@ void Vehicle::UpdateCrashSetup()
lastVehicle = trainVehicle;
trainVehicle->sub_state = 0;
int32_t trainX = stru_9A3AC4[trainVehicle->Orientation / 2].x;
int32_t trainY = stru_9A3AC4[trainVehicle->Orientation / 2].y;
int32_t trainX = Geometry::kCrashDirectionComponents[trainVehicle->Orientation / 2].x;
int32_t trainY = Geometry::kCrashDirectionComponents[trainVehicle->Orientation / 2].y;
auto carLaunchDirection = Geometry::getPitchVector32(trainVehicle->pitch);
@@ -4922,7 +4916,7 @@ void Vehicle::UpdateSound()
sound2_volume = soundIdVolume.volume;
// Calculate Sound Vector (used for sound frequency calcs)
int32_t soundDirection = SpriteDirectionToSoundDirection[Orientation];
int32_t soundDirection = Geometry::kSpriteDirectionToSoundDirection[Orientation];
int32_t soundVector = ((velocity >> 14) * soundDirection) >> 14;
soundVector = std::clamp(soundVector, -127, 127);

View File

@@ -794,40 +794,4 @@ const uint8_t MotionSimulatorTimeToSpriteMap[] = {
};
const int32_t MotionSimulatorTimeToSpriteMapCount = static_cast<int32_t>(std::size(MotionSimulatorTimeToSpriteMap));
/** rct2: 0x009A3684 */
const int32_t SpriteDirectionToSoundDirection[] = {
-0x4000, // 0
-0x3000, // 1
-0x2000, // 2
-0x1000, // 3
0, // 4
0x1000, // 5
0x2000, // 6
0x3000, // 7
0x4000, // 8
0x4800, // 9
0x4800, // 10
0x4800, // 11
0x4800, // 12
0x4800, // 13
0x4800, // 14
0x4800, // 15
0x4000, // 16
0x3000, // 17
0x2000, // 18
0x1000, // 19
0, // 20
-0x1000, // 21
-0x2000, // 22
-0x3000, // 23
-0x4000, // 24
-0x4800, // 25
-0x4800, // 26
-0x4800, // 27
-0x4800, // 28
-0x4800, // 29
-0x4800, // 30
-0x4800, // 31
};
// clang-format on

View File

@@ -25,5 +25,3 @@ extern const TopSpinTimeToSpriteMap* TopSpinTimeToSpriteMaps[];
extern const uint8_t MotionSimulatorTimeToSpriteMap[];
extern const int32_t MotionSimulatorTimeToSpriteMapCount;
extern const int32_t SpriteDirectionToSoundDirection[];

View File

@@ -190,4 +190,62 @@ namespace OpenRCT2::RideVehicle::Geometry
-1859775391, 0, 2096579710, 1946281152, 2096579710, 1946281152,
});
static_assert(std::size(kRollHorizontalComponent) == EnumValue(VehicleRoll::rollCount));
/** rct2: 0x009A3684 */
constexpr auto kSpriteDirectionToSoundDirection = std::to_array<int32_t>({
-0x4000, // 0
-0x3000, // 1
-0x2000, // 2
-0x1000, // 3
0, // 4
0x1000, // 5
0x2000, // 6
0x3000, // 7
0x4000, // 8
0x4800, // 9
0x4800, // 10
0x4800, // 11
0x4800, // 12
0x4800, // 13
0x4800, // 14
0x4800, // 15
0x4000, // 16
0x3000, // 17
0x2000, // 18
0x1000, // 19
0, // 20
-0x1000, // 21
-0x2000, // 22
-0x3000, // 23
-0x4000, // 24
-0x4800, // 25
-0x4800, // 26
-0x4800, // 27
-0x4800, // 28
-0x4800, // 29
-0x4800, // 30
-0x4800, // 31
});
/** rct2: 0x009A3AC4, 0x009A3AC6 */
constexpr auto kCrashDirectionComponents = std::to_array<CoordsXY>({
{ -256, 0 },
{ -236, 98 },
{ -181, 181 },
{ -98, 236 },
{ 0, 256 },
{ 98, 236 },
{ 181, 181 },
{ 236, 98 },
{ 256, 0 },
{ 236, -98 },
{ 181, -181 },
{ 98, -236 },
{ 0, -256 },
{ -98, -236 },
{ -181, -181 },
{ -236, -98 },
});
static_assert(std::size(kCrashDirectionComponents) == 16);
} // namespace OpenRCT2::RideVehicle::Geometry

View File

@@ -30,6 +30,8 @@ namespace OpenRCT2::RideVehicle::Geometry
extern const std::array<int32_t, EnumValue(VehiclePitch::pitchCount)> kAccelerationFromPitch;
extern const std::array<CoordsXY, EnumValue(VehiclePitch::pitchCount)> kPitchToDirectionVectorInt32;
extern const std::array<int32_t, EnumValue(VehicleRoll::rollCount)> kRollHorizontalComponent;
extern const std::array<int32_t, 32> kSpriteDirectionToSoundDirection;
extern const std::array<CoordsXY, 16> kCrashDirectionComponents;
/** The distance between subposition points in a movement vector.
* Squashes vector components to 0 or !0, so vector length is ignored.