Skip to content

Commit 68b2adf

Browse files
authored
Adds helper function to create convex hull shape (#352)
1 parent 5837640 commit 68b2adf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pyrep/backend/sim.py

+24
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,30 @@ def simImportMesh(fileformat, pathAndFilename, options,
959959
return retVerticies, retIndices, retNames
960960

961961

962+
def simGetConvexHullShape(pathAndFilename):
963+
vertices, indices, _ = simImportMesh(0, pathAndFilename, 0, False, 1.0)
964+
965+
outVertices = ffi.new("float **")
966+
outVerticesCount = ffi.new("int *")
967+
outIndices = ffi.new("int **")
968+
outIndicesCount = ffi.new("int *")
969+
ret = lib.simGetQHull(vertices[0], len(vertices[0]),
970+
outVertices, outVerticesCount,
971+
outIndices, outIndicesCount, 0, ffi.NULL)
972+
_check_return(ret)
973+
974+
mesh_options = 3
975+
mesh_shading_angle = 20.0 * 3.1415 / 180.0
976+
handle = lib.simCreateMeshShape(mesh_options, mesh_shading_angle,
977+
outVertices[0], outVerticesCount[0],
978+
outIndices[0], outIndicesCount[0],
979+
ffi.NULL)
980+
981+
simReleaseBuffer(ffi.cast("char *", outVertices[0]))
982+
simReleaseBuffer(ffi.cast("char *", outIndices[0]))
983+
return handle
984+
985+
962986
def simImportShape(fileformat, pathAndFilename, options,
963987
identicalVerticeTolerance, scalingFactor):
964988
handle = lib.simImportShape(

0 commit comments

Comments
 (0)