MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / addToPlotList4FD200

Method addToPlotList4FD200

src/OpenLoco/src/Paint/Paint.cpp:263–333  ·  view source on GitHub ↗

0x004FD200

Source from the content-addressed store, hash-verified

261
262 // 0x004FD200
263 PaintStruct* PaintSession::addToPlotList4FD200(ImageId imageId, const World::Pos3& offset, const World::Pos3& boundBoxOffset, const World::Pos3& boundBoxSize)
264 {
265 _lastPS = nullptr;
266
267 auto* ps = createNormalPaintStruct(imageId, offset, boundBoxOffset, boundBoxSize);
268 if (ps == nullptr)
269 {
270 return nullptr;
271 }
272
273 const auto rtLeft = getRenderTarget()->x;
274 const auto rtRight = getRenderTarget()->x + getRenderTarget()->width;
275
276 auto newMins = ps->bounds.mins;
277 // The following uses the fact that gameToScreen calculates the
278 // screen x to be y - x of the map coordinate. It is then back
279 // calculating the x and y so that they would within the render
280 // target size when converted.
281 switch (getRotation())
282 {
283 case 0:
284 if (newMins.y - newMins.x < rtLeft)
285 {
286 newMins.y = newMins.x + rtLeft;
287 }
288
289 if (newMins.y - newMins.x > rtRight)
290 {
291 newMins.x = newMins.y - rtRight;
292 }
293 break;
294 case 1:
295 if (-newMins.y - newMins.x < rtLeft)
296 {
297 newMins.x = -newMins.y - rtLeft;
298 }
299
300 if (-newMins.y - newMins.x > rtRight)
301 {
302 newMins.y = -newMins.x - rtRight;
303 }
304 break;
305 case 2:
306 if (-newMins.y + newMins.x < rtLeft)
307 {
308 newMins.y = newMins.x - rtLeft;
309 }
310
311 if (-newMins.y + newMins.x > rtRight)
312 {
313 newMins.x = newMins.y + rtRight;
314 }
315 break;
316 case 3:
317 if (newMins.y + newMins.x < rtLeft)
318 {
319 newMins.x = -newMins.y + rtLeft;
320 }

Callers 2

paintBogieFunction · 0.80
paintBodyFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected