1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-26 00:04:43 +01:00

Implement track iterator

This commit is contained in:
Ted John
2022-03-13 03:02:55 +00:00
parent 76601ef6fc
commit 4eef86dc50
11 changed files with 270 additions and 5 deletions

View File

@@ -664,6 +664,25 @@ bool TrackTypeHasSpeedSetting(track_type_t trackType)
return trackType == TrackElemType::Brakes || trackType == TrackElemType::Booster;
}
std::optional<CoordsXYZD> GetTrackSegmentOrigin(const CoordsXYE& posEl)
{
auto trackEl = posEl.element->AsTrack();
if (trackEl == nullptr)
return {};
const auto& ted = GetTrackElementDescriptor(trackEl->GetTrackType());
auto direction = trackEl->GetDirection();
auto coords = CoordsXYZ(posEl.x, posEl.y, trackEl->GetBaseZ());
// Subtract the current sequence's offset
const auto* trackBlock = &ted.Block[trackEl->GetSequenceIndex()];
CoordsXY trackBlockOffset = { trackBlock->x, trackBlock->y };
coords += trackBlockOffset.Rotate(direction_reverse(direction));
coords.z -= trackBlock->z;
return CoordsXYZD(coords, direction);
}
uint8_t TrackElement::GetSeatRotation() const
{
const auto* ride = get_ride(GetRideIndex());