-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,10 @@ void filterIntersections(std::vector<detail::intersc>& ipts, EigenSTL::vector_Ve | |
intersections->push_back(p.pt); | ||
} | ||
} | ||
|
||
// HACK: The global map g_triangle_for_plane_ is needed for ABI compatibility with the melodic version of | ||
// geometric_shapes; in newer releases, it should instead be added as a member to ConvexMesh::MeshData. | ||
std::unordered_map<const ConvexMesh*, std::map<unsigned int, unsigned int>> g_triangle_for_plane_; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
peci1
Author
Contributor
|
||
} // namespace detail | ||
|
||
inline Eigen::Vector3d normalize(const Eigen::Vector3d& dir) | ||
|
@@ -555,7 +559,7 @@ bool bodies::Box::samplePointInside(random_numbers::RandomNumberGenerator& rng, | |
|
||
bool bodies::Box::containsPoint(const Eigen::Vector3d& p, bool /* verbose */) const | ||
{ | ||
const Eigen::Vector3d aligned = (invRot_ * (p - center_)).cwiseAbs(); | ||
const Eigen::Vector3d aligned = (pose_.linear().transpose() * (p - center_)).cwiseAbs(); | ||
return aligned[0] <= length2_ && aligned[1] <= width2_ && aligned[2] <= height2_; | ||
} | ||
|
||
|
@@ -596,7 +600,10 @@ void bodies::Box::updateInternalData() | |
radiusB_ = sqrt(radius2_); | ||
|
||
ASSERT_ISOMETRY(pose_); | ||
invRot_ = pose_.linear().transpose(); | ||
Eigen::Matrix3d basis = pose_.linear(); | ||
normalL_ = basis.col(0); | ||
normalW_ = basis.col(1); | ||
normalH_ = basis.col(2); | ||
|
||
// rotation is intentionally not applied, the corners are used in intersectsRay() | ||
const Eigen::Vector3d tmp(length2_, width2_, height2_); | ||
|
@@ -676,8 +683,9 @@ bool bodies::Box::intersectsRay(const Eigen::Vector3d& origin, const Eigen::Vect | |
|
||
// The implemented method only works for axis-aligned boxes. So we treat ours as such, cancel its rotation, and | ||
// rotate the origin and dir instead. corner1_ and corner2_ are corners with canceled rotation. | ||
const Eigen::Vector3d o(invRot_ * (origin - center_) + center_); | ||
const Eigen::Vector3d d(invRot_ * dirNorm); | ||
const Eigen::Matrix3d invRot = pose_.linear().transpose(); | ||
const Eigen::Vector3d o(invRot * (origin - center_) + center_); | ||
const Eigen::Vector3d d(invRot * dirNorm); | ||
|
||
Eigen::Vector3d tmpTmin, tmpTmax; | ||
tmpTmin = (corner1_ - o).cwiseQuotient(d); | ||
|
@@ -921,6 +929,12 @@ void bodies::ConvexMesh::useDimensions(const shapes::Shape* shape) | |
mesh_data_->mesh_radiusB_ = sqrt(mesh_data_->mesh_radiusB_); | ||
mesh_data_->triangles_.reserve(num_facets); | ||
|
||
// HACK: only needed for ABI compatibility with melodic | ||
if (detail::g_triangle_for_plane_.find(this) == detail::g_triangle_for_plane_.end()) | ||
detail::g_triangle_for_plane_.emplace(this, std::map<unsigned int, unsigned int>()); | ||
else | ||
detail::g_triangle_for_plane_[this].clear(); | ||
|
||
// neccessary for qhull macro | ||
facetT* facet; | ||
FORALLfacets | ||
|
@@ -945,7 +959,7 @@ void bodies::ConvexMesh::useDimensions(const shapes::Shape* shape) | |
} | ||
|
||
mesh_data_->plane_for_triangle_[(mesh_data_->triangles_.size() - 1) / 3] = mesh_data_->planes_.size() - 1; | ||
mesh_data_->triangle_for_plane_[mesh_data_->planes_.size() - 1] = (mesh_data_->triangles_.size() - 1) / 3; | ||
detail::g_triangle_for_plane_[this][mesh_data_->planes_.size() - 1] = (mesh_data_->triangles_.size() - 1) / 3; | ||
} | ||
qh_freeqhull(!qh_ALL); | ||
int curlong, totlong; | ||
|
@@ -1130,7 +1144,7 @@ bool bodies::ConvexMesh::isPointInsidePlanes(const Eigen::Vector3d& point) const | |
// we also cannot simply subtract padding_ from it, because padding of the points on the plane causes a different | ||
// effect than adding padding along this plane's normal (padding effect is direction-dependent) | ||
const auto scaled_point_on_plane = | ||
scaled_vertices_->at(mesh_data_->triangles_[3 * mesh_data_->triangle_for_plane_[i]]); | ||
scaled_vertices_->at(mesh_data_->triangles_[3 * detail::g_triangle_for_plane_[this][i]]); | ||
const double w_scaled_padded = -plane_vec.dot(scaled_point_on_plane); | ||
const double dist = plane_vec.dot(point) + w_scaled_padded - detail::ZERO; | ||
if (dist > 0.0) | ||
|
@@ -1264,6 +1278,13 @@ bool bodies::ConvexMesh::intersectsRay(const Eigen::Vector3d& origin, const Eige | |
return result; | ||
} | ||
|
||
bodies::ConvexMesh::~ConvexMesh() | ||
{ | ||
// HACK: only needed for ABI compatibility with melodic | ||
if (detail::g_triangle_for_plane_.find(this) != detail::g_triangle_for_plane_.end()) | ||
detail::g_triangle_for_plane_.erase(this); | ||
} | ||
|
||
bodies::BodyVector::BodyVector() | ||
{ | ||
} | ||
|
@peci1 @rhaschke
I'm no fan of global storages, but if it's required... (why didn't we ever set sonames for this package too grml)
Anyway, this is a global standard container, so you need mutex locking for access!