From 762b163655ec164c303f40adb1f9d02e279ac230 Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Wed, 5 Jul 2023 11:36:28 +0200 Subject: [PATCH] YES BABY! HOLESSSSSSSS~ Fixed the realised that the coordinate system for the simulation cannot be skewed. Now keeping the proper proportions in diagonal world coordinates --- src/coordinates/coordinate_transformer.cpp | 4 +++- src/game/physics/holes/layouts/hole_description.hpp | 3 +-- src/levels.hpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/coordinates/coordinate_transformer.cpp b/src/coordinates/coordinate_transformer.cpp index aac5248..1516135 100644 --- a/src/coordinates/coordinate_transformer.cpp +++ b/src/coordinates/coordinate_transformer.cpp @@ -2,6 +2,7 @@ #include "../config.h" #include "../logging/easylogging++.h" #include "../utilities/vector_utils.hpp" +#include // Initialize matrix const Eigen::Matrix CoordinateTransformer::worldToIsometricMatrix = @@ -12,9 +13,10 @@ const Eigen::Matrix CoordinateTransformer::worldToIsometricMatrix = ).finished(); // Same as above, but with SKEW = 0 and height positive +const auto rotateFactor = cos(M_PI / 4); const Eigen::Matrix CoordinateTransformer::worldToDiagonalMatrix = (Eigen::Matrix() << - WORLD_TO_ISO_SCALE, -WORLD_TO_ISO_SCALE, 0, + rotateFactor, -rotateFactor, 0, 0, 0, 1, 1, 1, 0 ).finished(); diff --git a/src/game/physics/holes/layouts/hole_description.hpp b/src/game/physics/holes/layouts/hole_description.hpp index 1a6e01e..e875050 100644 --- a/src/game/physics/holes/layouts/hole_description.hpp +++ b/src/game/physics/holes/layouts/hole_description.hpp @@ -33,11 +33,10 @@ struct HoleDescription } float chordLength = 2.f * std::sqrt(radius * radius - distance * distance); - float chordLengthInDiagonal = chordLength * WORLD_TO_ISO_SCALE; auto diagonalWorldCoords = CoordinateTransformer::worldToDiagonal(WorldCoordinates{worldPosition}); - return {playerId, diagonalWorldCoords.horizontal, chordLengthInDiagonal}; + return {playerId, diagonalWorldCoords.horizontal, chordLength}; } }; diff --git a/src/levels.hpp b/src/levels.hpp index 2465dd2..717fada 100644 --- a/src/levels.hpp +++ b/src/levels.hpp @@ -22,7 +22,7 @@ std::map const all_levels = { CollectableInLevel("box", {6, 7}), CollectableInLevel("box", {5, 5}), CollectableInLevel("box", {9, 5}), - CollectableInLevel("box", {7, 4}) + CollectableInLevel("box", {0, 1}) }, { // Blues