use of spacegraph.space3d.phys.math.convexhull.HullResult in project narchy by automenta.
the class ShapeHull method buildHull.
public boolean buildHull(float margin) {
v3 norm = new v3();
int numSampleDirections = NUM_UNITSPHERE_POINTS;
int numPDA = shape.getNumPreferredPenetrationDirections();
if (numPDA != 0) {
for (int i = 0; i < numPDA; i++) {
shape.getPreferredPenetrationDirection(i, norm);
// return array[index];
unitSpherePoints.get(numSampleDirections).set(norm);
numSampleDirections++;
}
}
FasterList<v3> supportPoints = new FasterList<>();
MiscUtil.resize(supportPoints, NUM_UNITSPHERE_POINTS + ConvexShape.MAX_PREFERRED_PENETRATION_DIRECTIONS * 2, v3.class);
for (int i = 0; i < numSampleDirections; i++) {
// return array[index];
// return array[index];
shape.localGetSupportingVertex(unitSpherePoints.get(i), supportPoints.get(i));
}
HullDesc hd = new HullDesc();
hd.flags = HullFlags.TRIANGLES;
hd.vcount = numSampleDirections;
// #ifdef BT_USE_DOUBLE_PRECISION
// hd.mVertices = &supportPoints[0];
// hd.mVertexStride = sizeof(btVector3);
// #else
hd.vertices = supportPoints;
// hd.vertexStride = 3 * 4;
// #endif
HullLibrary hl = new HullLibrary();
HullResult hr = new HullResult();
if (!hl.createConvexHull(hd, hr)) {
return false;
}
MiscUtil.resize(vertices, hr.numOutputVertices, v3.class);
for (int i = 0; i < hr.numOutputVertices; i++) {
// return array[index];
// return array[index];
vertices.get(i).set(hr.outputVertices.get(i));
}
numIndices = hr.numIndices;
MiscUtil.resize(indices, numIndices, 0);
for (int i = 0; i < numIndices; i++) {
indices.set(i, hr.indices.get(i));
}
// free temporary hull result that we just copied
HullLibrary.releaseResult(hr);
return true;
}
Aggregations