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

Function ViewportMove

src/openrct2/interface/Viewport.cpp:446–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444 }
445
446 static void ViewportMove(const ScreenCoordsXY& coords, WindowBase* w, Viewport* viewport)
447 {
448 // Note: do not do the subtraction and then divide!
449 // Note: Due to arithmetic shift != /zoom a shift will have to be used
450 // hopefully when 0x006E7FF3 is finished this can be converted to /zoom.
451 auto x_diff = viewport->zoom.ApplyInversedTo(viewport->viewPos.x) - viewport->zoom.ApplyInversedTo(coords.x);
452 auto y_diff = viewport->zoom.ApplyInversedTo(viewport->viewPos.y) - viewport->zoom.ApplyInversedTo(coords.y);
453
454 viewport->viewPos = coords;
455
456 // If no change in viewing area
457 if ((!x_diff) && (!y_diff))
458 return;
459
460 const int32_t left = std::max(viewport->pos.x, 0);
461 const int32_t top = std::max(viewport->pos.y, 0);
462 const int32_t right = std::min(left + viewport->width + std::min(viewport->pos.x, 0), ContextGetWidth());
463 const int32_t bottom = std::min(top + viewport->height + std::min(viewport->pos.y, 0), ContextGetHeight());
464
465 if (left >= right || top >= bottom)
466 return;
467
468 if (DrawingEngineHasDirtyOptimisations())
469 {
470 RenderTarget& rt = DrawingEngineGetRT();
471 ViewportShiftPixels(rt, w, { left, top, right, bottom }, { x_diff, y_diff });
472 }
473 else
474 {
475 GfxInvalidateScreen();
476 }
477 }
478
479 // rct2: 0x006E7A15
480 static void ViewportSetUndergroundFlag(int32_t underground, WindowBase* window, Viewport* viewport)

Callers 2

ViewportUpdatePositionFunction · 0.85

Calls 6

ContextGetWidthFunction · 0.85
ContextGetHeightFunction · 0.85
ViewportShiftPixelsFunction · 0.85
GfxInvalidateScreenFunction · 0.85
ApplyInversedToMethod · 0.80

Tested by

no test coverage detected