Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp')
-rw-r--r--extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp
index bd8e2748383..cf735569a9d 100644
--- a/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/Bullet-C-API.cpp
@@ -23,7 +23,7 @@ subject to the following restrictions:
#include "Bullet-C-Api.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btAlignedAllocator.h"
-
+#include "LinearMath/btConvexHullComputer.h"
#include "LinearMath/btVector3.h"
@@ -403,3 +403,60 @@ double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float
return -1.0f;
}
+// Convex hull
+plConvexHull plConvexHullCompute(float (*coords)[3], int count)
+{
+ btConvexHullComputer *computer = new btConvexHullComputer;
+ computer->compute(reinterpret_cast< float* >(coords),
+ sizeof(*coords), count, 0, 0);
+ return reinterpret_cast<plConvexHull>(computer);
+}
+
+int plConvexHullNumVertices(plConvexHull hull)
+{
+ btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
+ return computer->vertices.size();
+}
+
+int plConvexHullNumFaces(plConvexHull hull)
+{
+ btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
+ return computer->faces.size();
+}
+
+void plConvexHullGetVertex(plConvexHull hull, int n, float coords[3],
+ int *original_index)
+{
+ btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
+ const btVector3 &v(computer->vertices[n]);
+ coords[0] = v[0];
+ coords[1] = v[1];
+ coords[2] = v[2];
+ (*original_index) = computer->original_vertex_index[n];
+}
+
+int plConvexHullGetFaceSize(plConvexHull hull, int n)
+{
+ btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
+ const btConvexHullComputer::Edge *e_orig, *e;
+ int count;
+
+ for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0;
+ count == 0 || e != e_orig;
+ e = e->getNextEdgeOfFace(), count++);
+ return count;
+}
+
+void plConvexHullGetFaceVertices(plConvexHull hull, int n, int *vertices)
+{
+ btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
+ const btConvexHullComputer::Edge *e_orig, *e;
+ int count;
+
+ for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0;
+ count == 0 || e != e_orig;
+ e = e->getNextEdgeOfFace(), count++)
+ {
+ vertices[count] = e->getTargetVertex();
+ }
+}