MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / TrackDesignDrawPreview

Function TrackDesignDrawPreview

src/openrct2/ride/TrackDesign.cpp:2075–2165  ·  view source on GitHub ↗

* * rct2: 0x006D1EF0 */

Source from the content-addressed store, hash-verified

2073 * rct2: 0x006D1EF0
2074 */
2075void TrackDesignDrawPreview(TrackDesign& td, TrackDesignPreviewBuffer& pixels, bool placeScenery)
2076{
2077 StashMap();
2078 TrackDesignPreviewClearMap();
2079
2080 if (gLegacyScene == LegacyScene::trackDesignsManager)
2081 {
2082 TrackDesignLoadSceneryObjects(td);
2083 }
2084
2085 TrackDesignState tds{};
2086
2087 Ride* ride;
2088 TrackDesignGameStateData updatedGameStateData = td.gameStateData;
2089 if (!TrackDesignPlacePreview(tds, td, &ride, updatedGameStateData, placeScenery))
2090 {
2091 std::fill(std::begin(pixels), std::end(pixels), PaletteIndex::transparent);
2092 UnstashMap();
2093 return;
2094 }
2095 td.gameStateData = updatedGameStateData;
2096
2097 CoordsXYZ centre = { (tds.previewMin.x + tds.previewMax.x) / 2 + 16, (tds.previewMin.y + tds.previewMax.y) / 2 + 16,
2098 (tds.previewMin.z + tds.previewMax.z) / 2 };
2099
2100 int32_t size_x = tds.previewMax.x - tds.previewMin.x;
2101 int32_t size_y = tds.previewMax.y - tds.previewMin.y;
2102 int32_t size_z = tds.previewMax.z - tds.previewMin.z;
2103
2104 // Special case for flat rides - Z-axis info is irrelevant
2105 // and must be zeroed out lest the preview be off-centre
2106 if (!GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasTrack))
2107 {
2108 centre.z = 0;
2109 size_z = 0;
2110 }
2111
2112 ZoomLevel zoom_level{ 1 };
2113 if (size_x < size_y)
2114 {
2115 size_x = size_y;
2116 }
2117
2118 if (size_x > 1000 || size_z > 280)
2119 {
2120 zoom_level = ZoomLevel{ 2 };
2121 }
2122
2123 if (size_x > 1600 || size_z > 1000)
2124 {
2125 zoom_level = ZoomLevel{ 3 };
2126 }
2127
2128 size_x = zoom_level.ApplyTo(370);
2129 size_y = zoom_level.ApplyTo(217);
2130
2131 Viewport view;
2132 view.width = 370;

Callers 2

UpdatePreviewMethod · 0.85
loadDesignPreviewMethod · 0.85

Calls 15

StashMapFunction · 0.85
TrackDesignPlacePreviewFunction · 0.85
fillFunction · 0.85
UnstashMapFunction · 0.85
GetContextFunction · 0.85
Translate3DTo2DWithZFunction · 0.85
ViewportRenderFunction · 0.85
ApplyToMethod · 0.80
hasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected