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

Function generateParameters

src/OpenLoco/src/Paint/Paint.cpp:483–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481
482 template<uint8_t rotation>
483 GenerationParameters generateParameters(const Gfx::RenderTarget* rt)
484 {
485 // TODO: Work out what these constants represent
486 uint16_t numVerticalQuadrants = (rt->height + (rotation == 0 ? 1040 : 1056)) >> 5;
487
488 auto mapLoc = Ui::viewportCoordToMapCoord(
489 Numerics::floor2(rt->x, 32),
490 Numerics::floor2(rt->y - 16, 32),
491 0,
492 rotation);
493 if constexpr (rotation & 1)
494 {
495 mapLoc.y -= 16;
496 }
497 mapLoc.x = Numerics::floor2(mapLoc.x, 32);
498 mapLoc.y = Numerics::floor2(mapLoc.y, 32);
499
500 constexpr auto direction = directionFlipXAxis(rotation);
501 constexpr std::array<World::Pos2, 5> additionalQuadrants = {
502 Math::Vector::rotate(World::Pos2{ -32, 32 }, direction),
503 Math::Vector::rotate(World::Pos2{ 0, 32 }, direction),
504 Math::Vector::rotate(World::Pos2{ 32, 0 }, direction),
505 Math::Vector::rotate(World::Pos2{ 32, -32 }, direction),
506 Math::Vector::rotate(World::Pos2{ -32, 64 }, direction),
507 };
508 constexpr auto nextVerticalQuadrant = Math::Vector::rotate(World::Pos2{ 32, 32 }, direction);
509
510 return { mapLoc, numVerticalQuadrants, additionalQuadrants, nextVerticalQuadrant };
511 }
512
513 void PaintSession::generateTilesAndEntities(GenerationParameters&& p)
514 {

Callers

nothing calls this directly

Calls 4

viewportCoordToMapCoordFunction · 0.85
floor2Function · 0.85
directionFlipXAxisFunction · 0.85
rotateFunction · 0.50

Tested by

no test coverage detected