From 76938f165403050ce1e6db8aca1158124c2d5923 Mon Sep 17 00:00:00 2001 From: John Turner <7strbass@gmail.com> Date: Tue, 16 Jan 2024 12:48:07 -0500 Subject: [PATCH] --more cleanup. --- src/esp/bindings/SensorBindings.cpp | 1 + src/esp/core/EspEigen.h | 105 +++++++++++++--------------- src/esp/nav/PathFinder.cpp | 7 +- src/esp/nav/PathFinder.h | 2 +- 4 files changed, 55 insertions(+), 60 deletions(-) diff --git a/src/esp/bindings/SensorBindings.cpp b/src/esp/bindings/SensorBindings.cpp index f21bf121a3..d7b7d7cd2a 100644 --- a/src/esp/bindings/SensorBindings.cpp +++ b/src/esp/bindings/SensorBindings.cpp @@ -13,6 +13,7 @@ #include +#include "esp/core/EspEigen.h" #include "esp/sensor/CameraSensor.h" #include "esp/sensor/CubeMapSensorBase.h" #include "esp/sensor/EquirectangularSensor.h" diff --git a/src/esp/core/EspEigen.h b/src/esp/core/EspEigen.h index 20b017ab46..8477c48c9b 100644 --- a/src/esp/core/EspEigen.h +++ b/src/esp/core/EspEigen.h @@ -14,66 +14,59 @@ #include #include -#include -#include -#include -#include - -#include "esp/core/configure.h" - namespace Eigen { typedef Matrix RowMatrixXf; -//! Eigen JSON string format specification -static const IOFormat kJsonFormat(StreamPrecision, - DontAlignCols, - ",", // coef separator - ",", // row separator - "", // row prefix - "", // col prefix - "[", // mat prefix - "]"); // mat suffix - -template -std::ostream& operator<<(std::ostream& os, - const Matrix& matrix) { - return os << matrix.format(kJsonFormat); -} - -//! Write Eigen matrix types into ostream in JSON string format -template -typename std::enable_if::type -operator<<(Corrade::Utility::Debug& os, - const Matrix& matrix) { - return os << matrix.format(kJsonFormat); -} - -template -typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) && - (numRows != 1 && numCols != 1), - Corrade::Utility::Debug&>::type -operator<<(Corrade::Utility::Debug& os, - const Matrix& matrix) { - return os << Magnum::Math::RectangularMatrix{matrix}; -} - -template -typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) && - (numRows == 1 || numCols == 1), - Corrade::Utility::Debug&>::type -operator<<(Corrade::Utility::Debug& os, - const Matrix& matrix) { - return os << Magnum::Math::Vector<(numRows == 1 ? numCols : numRows), T>{ - matrix}; -} - -//! Write Eigen map into ostream in JSON string format -template -std::ostream& operator<<(std::ostream& os, const Map& m) { - return os << m.format(kJsonFormat); -} +// //! Eigen JSON string format specification +// static const IOFormat kJsonFormat(StreamPrecision, +// DontAlignCols, +// ",", // coef separator +// ",", // row separator +// "", // row prefix +// "", // col prefix +// "[", // mat prefix +// "]"); // mat suffix + +// template +// std::ostream& operator<<(std::ostream& os, +// const Matrix& matrix) { +// return os << matrix.format(kJsonFormat); +// } + +// //! Write Eigen matrix types into ostream in JSON string format +// template +// typename std::enable_if::type +// operator<<(Corrade::Utility::Debug& os, +// const Matrix& matrix) { +// return os << matrix.format(kJsonFormat); +// } + +// template +// typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) && +// (numRows != 1 && numCols != 1), +// Corrade::Utility::Debug&>::type +// operator<<(Corrade::Utility::Debug& os, +// const Matrix& matrix) { +// return os << Magnum::Math::RectangularMatrix{matrix}; +// } + +// template +// typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) && +// (numRows == 1 || numCols == 1), +// Corrade::Utility::Debug&>::type +// operator<<(Corrade::Utility::Debug& os, +// const Matrix& matrix) { +// return os << Magnum::Math::Vector<(numRows == 1 ? numCols : numRows), T>{ +// matrix}; +// } + +// //! Write Eigen map into ostream in JSON string format +// template +// std::ostream& operator<<(std::ostream& os, const Map& m) { +// return os << m.format(kJsonFormat); +// } } // namespace Eigen diff --git a/src/esp/nav/PathFinder.cpp b/src/esp/nav/PathFinder.cpp index 91e3f41e2f..3ccfafbdb7 100644 --- a/src/esp/nav/PathFinder.cpp +++ b/src/esp/nav/PathFinder.cpp @@ -25,6 +25,7 @@ #include "esp/assets/MeshData.h" #include "esp/core/Esp.h" +#include "esp/core/EspEigen.h" #include "DetourCommon.h" #include "DetourNavMesh.h" @@ -429,7 +430,7 @@ class IslandSystem { navMesh->getTileAndPolyByRefUnsafe(ref, &tile, &poly); for (int iVert = 0; iVert < poly->vertCount; ++iVert) { - islandVerts.emplace_back(Eigen::Map( + islandVerts.emplace_back(Mn::Vector3::from( &tile->verts[static_cast(poly->verts[iVert]) * 3])); } @@ -1749,8 +1750,8 @@ bool PathFinder::Impl::isNavigable(const Mn::Vector3& pt, return false; if (std::abs(polyPt[1] - pt[1]) > maxYDelta || - (Eigen::Vector2f(pt[0], pt[2]) - Eigen::Vector2f(polyPt[0], polyPt[2])) - .norm() > 1e-2) + (Mn::Vector2(pt[0], pt[2]) - Mn::Vector2(polyPt[0], polyPt[2])).length() > + 1e-2) return false; return true; diff --git a/src/esp/nav/PathFinder.h b/src/esp/nav/PathFinder.h index 79154f7bae..3383dbc711 100644 --- a/src/esp/nav/PathFinder.h +++ b/src/esp/nav/PathFinder.h @@ -6,11 +6,11 @@ #define ESP_NAV_PATHFINDER_H_ #include +#include #include #include #include "esp/core/Esp.h" -#include "esp/core/EspEigen.h" namespace esp { // forward declaration