Skip to content

Commit

Permalink
--more cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner65 committed Jan 16, 2024
1 parent 4beb83f commit 76938f1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/esp/bindings/SensorBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <utility>

#include "esp/core/EspEigen.h"
#include "esp/sensor/CameraSensor.h"
#include "esp/sensor/CubeMapSensorBase.h"
#include "esp/sensor/EquirectangularSensor.h"
Expand Down
105 changes: 49 additions & 56 deletions src/esp/core/EspEigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,59 @@
#include <Eigen/Core>
#include <Eigen/Geometry>

#include <Magnum/EigenIntegration/GeometryIntegration.h>
#include <Magnum/EigenIntegration/Integration.h>
#include <Magnum/Math/Range.h>
#include <Magnum/Math/RectangularMatrix.h>

#include "esp/core/configure.h"

namespace Eigen {

typedef Matrix<float, Dynamic, Dynamic, RowMajor> 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 <typename T, int numRows, int numCols>
std::ostream& operator<<(std::ostream& os,
const Matrix<T, numRows, numCols>& matrix) {
return os << matrix.format(kJsonFormat);
}

//! Write Eigen matrix types into ostream in JSON string format
template <typename T, int numRows, int numCols>
typename std::enable_if<numRows == Dynamic || numCols == Dynamic,
Corrade::Utility::Debug&>::type
operator<<(Corrade::Utility::Debug& os,
const Matrix<T, numRows, numCols>& matrix) {
return os << matrix.format(kJsonFormat);
}

template <typename T, int numRows, int numCols>
typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) &&
(numRows != 1 && numCols != 1),
Corrade::Utility::Debug&>::type
operator<<(Corrade::Utility::Debug& os,
const Matrix<T, numRows, numCols>& matrix) {
return os << Magnum::Math::RectangularMatrix<numRows, numCols, T>{matrix};
}

template <typename T, int numRows, int numCols>
typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) &&
(numRows == 1 || numCols == 1),
Corrade::Utility::Debug&>::type
operator<<(Corrade::Utility::Debug& os,
const Matrix<T, numRows, numCols>& matrix) {
return os << Magnum::Math::Vector<(numRows == 1 ? numCols : numRows), T>{
matrix};
}

//! Write Eigen map into ostream in JSON string format
template <typename T>
std::ostream& operator<<(std::ostream& os, const Map<T>& 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 <typename T, int numRows, int numCols>
// std::ostream& operator<<(std::ostream& os,
// const Matrix<T, numRows, numCols>& matrix) {
// return os << matrix.format(kJsonFormat);
// }

// //! Write Eigen matrix types into ostream in JSON string format
// template <typename T, int numRows, int numCols>
// typename std::enable_if<numRows == Dynamic || numCols == Dynamic,
// Corrade::Utility::Debug&>::type
// operator<<(Corrade::Utility::Debug& os,
// const Matrix<T, numRows, numCols>& matrix) {
// return os << matrix.format(kJsonFormat);
// }

// template <typename T, int numRows, int numCols>
// typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) &&
// (numRows != 1 && numCols != 1),
// Corrade::Utility::Debug&>::type
// operator<<(Corrade::Utility::Debug& os,
// const Matrix<T, numRows, numCols>& matrix) {
// return os << Magnum::Math::RectangularMatrix<numRows, numCols, T>{matrix};
// }

// template <typename T, int numRows, int numCols>
// typename std::enable_if<(numRows != Dynamic && numCols != Dynamic) &&
// (numRows == 1 || numCols == 1),
// Corrade::Utility::Debug&>::type
// operator<<(Corrade::Utility::Debug& os,
// const Matrix<T, numRows, numCols>& matrix) {
// return os << Magnum::Math::Vector<(numRows == 1 ? numCols : numRows), T>{
// matrix};
// }

// //! Write Eigen map into ostream in JSON string format
// template <typename T>
// std::ostream& operator<<(std::ostream& os, const Map<T>& m) {
// return os << m.format(kJsonFormat);
// }

} // namespace Eigen

Expand Down
7 changes: 4 additions & 3 deletions src/esp/nav/PathFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -429,7 +430,7 @@ class IslandSystem {
navMesh->getTileAndPolyByRefUnsafe(ref, &tile, &poly);

for (int iVert = 0; iVert < poly->vertCount; ++iVert) {
islandVerts.emplace_back(Eigen::Map<Mn::Vector3>(
islandVerts.emplace_back(Mn::Vector3::from(
&tile->verts[static_cast<size_t>(poly->verts[iVert]) * 3]));
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/esp/nav/PathFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#define ESP_NAV_PATHFINDER_H_

#include <Corrade/Containers/Optional.h>
#include <Magnum/Math/Vector3.h>
#include <string>
#include <vector>

#include "esp/core/Esp.h"
#include "esp/core/EspEigen.h"

namespace esp {
// forward declaration
Expand Down

0 comments on commit 76938f1

Please sign in to comment.