diff options
author | Maarten Behn <46872913+MaartenBehn@users.noreply.github.com> | 2022-12-21 14:44:35 +0100 |
---|---|---|
committer | Maarten Behn <46872913+MaartenBehn@users.noreply.github.com> | 2022-12-21 14:44:35 +0100 |
commit | 2b4757f51298d52b04eb052f19cc0e9c5f9b2e57 (patch) | |
tree | e6388b6f308df8d9fb7b90cad935e7d7bd353e65 /examples/pybullet/pybullet.c | |
parent | 9dd446609a7a9af8b5a586a67ab57019edbc2328 (diff) | |
download | bullet3-2b4757f51298d52b04eb052f19cc0e9c5f9b2e57.tar.gz |
extend wrapper
Diffstat (limited to 'examples/pybullet/pybullet.c')
-rw-r--r-- | examples/pybullet/pybullet.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index f78f464f9..4d62b5f8e 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -9190,6 +9190,64 @@ static PyObject* pybullet_getMeshData(PyObject* self, PyObject* args, PyObject* } +static PyObject* pybullet_getTetraMeshData(PyObject* self, PyObject* args, PyObject* keywds) +{ + int bodyUniqueId = -1; + b3PhysicsClientHandle sm = 0; + b3SharedMemoryCommandHandle command; + b3SharedMemoryStatusHandle statusHandle; + struct b3MeshData meshData; + int statusType; + int flags = -1; + + int physicsClientId = 0; + static char* kwlist[] = {"bodyUniqueId", "flags", "physicsClientId", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|iiii", kwlist, &bodyUniqueId, &flags , &physicsClientId)) + { + return NULL; + } + sm = getPhysicsClient(physicsClientId); + if (sm == 0) + { + PyErr_SetString(SpamError, "Not connected to physics server."); + return NULL; + } + command = b3GetTetraMeshDataCommandInit(sm, bodyUniqueId); + if (flags >= 0) + { + b3GetMeshDataSetFlags(command, flags); + } + + statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command); + statusType = b3GetStatusType(statusHandle); + if (statusType == CMD_REQUEST_TETRA_MESH_DATA_COMPLETED) + { + int i; + PyObject* pyVertexData; + PyObject* pyListMeshData = PyTuple_New(2); + b3GetMeshData(sm, &meshData); + PyTuple_SetItem(pyListMeshData, 0, PyInt_FromLong(meshData.m_numVertices)); + pyVertexData = PyTuple_New(meshData.m_numVertices); + PyTuple_SetItem(pyListMeshData, 1, pyVertexData); + + for (i = 0; i < meshData.m_numVertices; i++) + { + PyObject* pyListVertex = PyTuple_New(3); + PyTuple_SetItem(pyListVertex, 0, PyFloat_FromDouble(meshData.m_vertices[i].x)); + PyTuple_SetItem(pyListVertex, 1, PyFloat_FromDouble(meshData.m_vertices[i].y)); + PyTuple_SetItem(pyListVertex, 2, PyFloat_FromDouble(meshData.m_vertices[i].z)); + PyTuple_SetItem(pyVertexData, i, pyListVertex); + } + + return pyListMeshData; + } + + PyErr_SetString(SpamError, "getMeshData failed"); + return NULL; +} + + + static PyObject* pybullet_resetMeshData(PyObject* self, PyObject* args, PyObject* keywds) { int bodyUniqueId = -1; |