Skip to content

Commit

Permalink
Adds helper function to create convex hull shape (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpumacay committed Sep 28, 2023
1 parent 5837640 commit 68b2adf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pyrep/backend/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,30 @@ def simImportMesh(fileformat, pathAndFilename, options,
return retVerticies, retIndices, retNames


def simGetConvexHullShape(pathAndFilename):
vertices, indices, _ = simImportMesh(0, pathAndFilename, 0, False, 1.0)

outVertices = ffi.new("float **")
outVerticesCount = ffi.new("int *")
outIndices = ffi.new("int **")
outIndicesCount = ffi.new("int *")
ret = lib.simGetQHull(vertices[0], len(vertices[0]),
outVertices, outVerticesCount,
outIndices, outIndicesCount, 0, ffi.NULL)
_check_return(ret)

mesh_options = 3
mesh_shading_angle = 20.0 * 3.1415 / 180.0
handle = lib.simCreateMeshShape(mesh_options, mesh_shading_angle,
outVertices[0], outVerticesCount[0],
outIndices[0], outIndicesCount[0],
ffi.NULL)

simReleaseBuffer(ffi.cast("char *", outVertices[0]))
simReleaseBuffer(ffi.cast("char *", outIndices[0]))
return handle


def simImportShape(fileformat, pathAndFilename, options,
identicalVerticeTolerance, scalingFactor):
handle = lib.simImportShape(
Expand Down

0 comments on commit 68b2adf

Please sign in to comment.