mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
use getter for subposition translation distance
This commit is contained in:
@@ -15,7 +15,7 @@ namespace OpenRCT2::RideVehicle::Geometry
|
||||
{
|
||||
|
||||
/** rct2: 0x009A2930 */
|
||||
static constexpr auto kSubpositionTranslationDistances = std::to_array({
|
||||
constexpr auto kSubpositionTranslationDistances = std::to_array({
|
||||
// For a base length of 8716 (0x220C) on the horizontal and 6554 (0x199A) on the vertical,
|
||||
// use the Pythagoras theorem and round up.
|
||||
0, // no movement
|
||||
@@ -38,11 +38,4 @@ namespace OpenRCT2::RideVehicle::Geometry
|
||||
});
|
||||
static_assert(std::size(kSubpositionTranslationDistances) == 16);
|
||||
|
||||
constexpr int32_t getTranslationDistance(CoordsXYZ distance, bool useReverserDistance)
|
||||
{
|
||||
uint8_t index = ((distance.x != 0) << 0) | ((distance.y != 0) << 1) | ((distance.z != 0) << 2)
|
||||
| ((useReverserDistance) << 3);
|
||||
return kSubpositionTranslationDistances[index];
|
||||
}
|
||||
|
||||
} // namespace OpenRCT2::RideVehicle::Geometry
|
||||
|
||||
@@ -17,9 +17,16 @@
|
||||
namespace OpenRCT2::RideVehicle::Geometry
|
||||
{
|
||||
|
||||
extern const std::array<int32_t, 16> kSubpositionTranslationDistances;
|
||||
|
||||
/** The distance between subposition points in a movement vector.
|
||||
* Squashes vector components to 0 or !0, so vector length is ignored.
|
||||
*/
|
||||
constexpr int32_t getTranslationDistance(CoordsXYZ distance, bool useReverserDistance);
|
||||
constexpr int32_t getTranslationDistance(CoordsXYZ distance, bool useReverserDistance)
|
||||
{
|
||||
uint8_t index = ((distance.x != 0) << 0) | ((distance.y != 0) << 1) | ((distance.z != 0) << 2)
|
||||
| ((useReverserDistance) << 3);
|
||||
return kSubpositionTranslationDistances[index];
|
||||
}
|
||||
|
||||
} // namespace OpenRCT2::RideVehicle::Geometry
|
||||
|
||||
Reference in New Issue
Block a user