diff --git a/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp b/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp index a6e0c6737ff..42bd7a8a9ed 100644 --- a/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp +++ b/3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp @@ -35,58 +35,35 @@ inline vec3d camera_euler_angles_yxz(const Level& /*level*/, bool side = false) } inline matrix4x4 camera_matrix_from_trans( - const vec3d& pos, - const vec3d& euler, + [[maybe_unused]] const vec3d& pos, + [[maybe_unused]] const vec3d& euler, double ratio, double fov_2_y = 20 * degree, double far = 1000, double near = 0.3) { - const double cos_y = std::cos(euler[0]); - const double sin_y = std::sin(euler[0]); - const double cos_x = std::cos(euler[1]); - const double sin_x = std::sin(euler[1]); const double tan_f = std::tan(fov_2_y); - - const matrix4x4 translate = { - 1, 0, 0, -pos[0], // - 0, 1, 0, -pos[1], // - 0, 0, 1, -pos[2], // - 0, 0, 0, 1, - }; - const matrix4x4 matrixY = { - cos_y, 0, sin_y, 0, // - 0, 1, 0, 0, // - -sin_y, 0, cos_y, 0, // - 0, 0, 0, 1, - }; - const matrix4x4 matrixX = { - 1, 0, 0, 0, // - 0, cos_x, -sin_x, 0, // - 0, -sin_x, -cos_x, 0, // - 0, 0, 0, 1, - }; const double elem1 = -(far + near) / (far - near); // unable to inline, MSVC bug? const double elem2 = -(far * near * 2) / (far - near); - const matrix4x4 proj = matrix4x4 { - // clang-format off - ratio / tan_f, 0, 0, 0, - 0, 1 / tan_f, 0, 0, - 0, 0, elem1, elem2, - 0, 0, -1, 0, - // clang-format on - }; + matrix4x4 proj = {}; + proj(0, 0) = 1 / (tan_f * ratio); + proj(1, 1) = 1 / tan_f; + proj(2, 2) = elem1; + proj(2, 3) = -elem2; + /* return proj * matrixX * matrixY * translate; + */ + return proj; } inline cv::Point world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {}) { - static constexpr double width = 1280; - static constexpr double height = 720; + static constexpr int width = 1280; + static constexpr int height = 720; const vec3d pos_cam = camera_pos(level, side, width, height) + offset; const vec3d euler = camera_euler_angles_yxz(level, side); - const matrix4x4 matrix = camera_matrix_from_trans(pos_cam, euler, height / width); + const matrix4x4 matrix = camera_matrix_from_trans(pos_cam, euler, static_cast(height) / width); auto result = matrix * cv::Point3d(world_pos); result = result / result(3); result = (result + cv::Vec4d::ones()) / 2.;