fix: add cursor pos easing

This commit is contained in:
2021-09-17 19:10:20 +02:00
parent e0c7001112
commit 519c6e33e7

View File

@@ -132,14 +132,16 @@ void setIsometricView(bool isometric){
}
glm::vec2 getCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight){
float isometricEased = utils::easeInOutExpo(isometricShade);
float relativeX = (cursorPos.x / windowWidth * 2) - 1;
float relativeY = (cursorPos.y / windowHeight * 2) - 1;
float deltaX = relativeX * aspectRatio / zoom;
float deltaY = relativeY / zoom;
float worldX = camPos.x + deltaX * (1 - isometricView) + (0.5 * deltaX + deltaY) * isometricView;
float worldY = camPos.y + deltaY * (1 - isometricView) + (-0.5 * deltaX + deltaY) * isometricView;
float worldX = camPos.x + deltaX * (1 - isometricEased) + (0.5 * deltaX + deltaY) * isometricEased;
float worldY = camPos.y + deltaY * (1 - isometricEased) + (-0.5 * deltaX + deltaY) * isometricEased;
return {worldX, worldY};
}