Skip to content

Commit

Permalink
expand mini map zoom clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Aug 27, 2024
1 parent 9c42aa4 commit 98038ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions samples/golf/src/golf/GolfStateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5544,8 +5544,8 @@ void GolfState::retargetMinimap(bool reset)
auto centre = bb.getCentre();
target.end.pan = glm::vec2(centre.x, -centre.z) * m_minimapZoom.mapScale;

auto xZoom = std::clamp(static_cast<float>(MiniMapSize.x) / ((bb[1].x - bb[0].x) * 1.6f), 0.9f, 16.f);
auto zZoom = std::clamp(static_cast<float>(MiniMapSize.y) / ((bb[1].z - bb[0].z) * 1.6f), 0.9f, 16.f);
auto xZoom = std::clamp(static_cast<float>(MiniMapSize.x) / ((bb[1].x - bb[0].x) * 1.6f), 0.9f, 32.f);
auto zZoom = std::clamp(static_cast<float>(MiniMapSize.y) / ((bb[1].z - bb[0].z) * 1.6f), 0.9f, 32.f);
target.end.zoom = xZoom > zZoom ? xZoom : zZoom;
}
else
Expand Down Expand Up @@ -5596,8 +5596,8 @@ void GolfState::retargetMinimap(bool reset)
//get distance between flag and player and expand by 1.7 (about 3m around a putting hole)
float viewLength = std::max(glm::length(dir), m_inputParser.getEstimatedDistance()) * 1.5f; //remember this is world coords

//scale zoom on long edge of map by box length and clamp to 16x
target.end.zoom = std::clamp(static_cast<float>(MiniMapSize.x) / viewLength, 0.8f, 16.f);
//scale zoom on long edge of map by box length and clamp to 32x
target.end.zoom = std::clamp(static_cast<float>(MiniMapSize.x) / viewLength, 0.8f, 32.f);
}

//create a temp ent to interp between start and end values
Expand Down

0 comments on commit 98038ad

Please sign in to comment.