summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkDefender <darkdefende@gmail.com>2020-09-01 00:05:27 +0200
committerGitHub <noreply@github.com>2020-08-31 15:05:27 -0700
commit85a3cb0ed5906a338f597ef435942c1f7f09cc51 (patch)
tree6d8d0be10a8bd94a21dca02a3c2775811e9cceec
parentbb1da5b5f50fce595bc44d4054b9ad7d5fad5ff8 (diff)
downloadbullet3-85a3cb0ed5906a338f597ef435942c1f7f09cc51.tar.gz
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.
-rw-r--r--src/LinearMath/btConvexHullComputer.cpp2
-rw-r--r--src/LinearMath/btConvexHullComputer.h3
2 files changed, 5 insertions, 0 deletions
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<btVector3> vertices;
+ // The original vertex index in the input coords array
+ btAlignedObjectArray<int> original_vertex_index;
+
// Edges of the output hull
btAlignedObjectArray<Edge> edges;