From 85a3cb0ed5906a338f597ef435942c1f7f09cc51 Mon Sep 17 00:00:00 2001 From: DarkDefender Date: Tue, 1 Sep 2020 00:05:27 +0200 Subject: Add ability to get the original vertex index from the convex hull (#3018) This makes it possible to know which input verticies were picked to to define the hull. With this information it is much easier to map certain features from the input mesh/point cloud to the output convex hull. --- src/LinearMath/btConvexHullComputer.cpp | 2 ++ src/LinearMath/btConvexHullComputer.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/LinearMath/btConvexHullComputer.cpp b/src/LinearMath/btConvexHullComputer.cpp index 8bbfdc5f2..fe1981a9a 100644 --- a/src/LinearMath/btConvexHullComputer.cpp +++ b/src/LinearMath/btConvexHullComputer.cpp @@ -2673,6 +2673,7 @@ btScalar btConvexHullComputer::compute(const void* coords, bool doubleCoords, in } vertices.resize(0); + original_vertex_index.resize(0); edges.resize(0); faces.resize(0); @@ -2683,6 +2684,7 @@ btScalar btConvexHullComputer::compute(const void* coords, bool doubleCoords, in { btConvexHullInternal::Vertex* v = oldVertices[copied]; vertices.push_back(hull.getCoordinates(v)); + original_vertex_index.push_back(v->point.index); btConvexHullInternal::Edge* firstEdge = v->edges; if (firstEdge) { diff --git a/src/LinearMath/btConvexHullComputer.h b/src/LinearMath/btConvexHullComputer.h index cba684f2d..18b26eea9 100644 --- a/src/LinearMath/btConvexHullComputer.h +++ b/src/LinearMath/btConvexHullComputer.h @@ -66,6 +66,9 @@ public: // Vertices of the output hull btAlignedObjectArray vertices; + // The original vertex index in the input coords array + btAlignedObjectArray original_vertex_index; + // Edges of the output hull btAlignedObjectArray edges; -- cgit v1.2.1