From 5c8dfe4b21e3427730a34697b1da11779a15a2d8 Mon Sep 17 00:00:00 2001 From: Maarten Behn Date: Tue, 27 Dec 2022 19:46:22 +0100 Subject: got the data tunnelt with getMeshData --- .../SharedMemory/PhysicsServerCommandProcessor.cpp | 28 ++++++++++++++++++---- examples/pybullet/pybullet.c | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 202ed6c9b..636203f60 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -5678,6 +5678,22 @@ bool PhysicsServerCommandProcessor::processRequestMeshDataCommand(const struct S } bool requestVelocity = clientCmd.m_updateFlags & B3_MESH_DATA_SIMULATION_MESH_VELOCITY; + + + int numTetra = psb->m_tetras.size(); + int maxNumnumVertecies = bufferSizeInBytes / totalBytesPerVertex - 1; + int numVerticesRemaining = numTetra * 4; + int verticesCopied = btMin(maxNumnumVertecies, numVerticesRemaining); + for (int i = 0; i < verticesCopied; i += 4) + { + const btSoftBody::Tetra& n = psb->m_tetras[i/4]; + verticesOut[i].setValue(n.m_n[0]->m_x.x(), n.m_n[0]->m_x.y(), n.m_n[0]->m_x.z()); + verticesOut[i+1].setValue(n.m_n[1]->m_x.x(), n.m_n[1]->m_x.y(), n.m_n[1]->m_x.z()); + verticesOut[i+2].setValue(n.m_n[2]->m_x.x(), n.m_n[2]->m_x.y(), n.m_n[2]->m_x.z()); + verticesOut[i+3].setValue(n.m_n[3]->m_x.x(), n.m_n[3]->m_x.y(), n.m_n[3]->m_x.z()); + } + + /* int numVertices = separateRenderMesh ? psb->m_renderNodes.size() : psb->m_nodes.size(); int maxNumVertices = bufferSizeInBytes / totalBytesPerVertex - 1; int numVerticesRemaining = numVertices - clientCmd.m_requestMeshDataArgs.m_startingVertex; @@ -5704,6 +5720,8 @@ bool PhysicsServerCommandProcessor::processRequestMeshDataCommand(const struct S } } } + */ + sizeInBytes = verticesCopied * sizeof(btVector3); serverStatusOut.m_type = CMD_REQUEST_MESH_DATA_COMPLETED; serverStatusOut.m_sendMeshDataArgs.m_numVerticesCopied = verticesCopied; @@ -5729,7 +5747,7 @@ bool PhysicsServerCommandProcessor::processRequestTetraMeshDataCommand(const str InternalBodyHandle* bodyHandle = m_data->m_bodyHandles.getHandle(clientCmd.m_resetTetraMeshDataArgs.m_bodyUniqueId); if (bodyHandle) { - int totalBytesPerTetra = sizeof(btVector3) * 4; + int totalBytesPerVertex = sizeof(btVector3); btVector3* verticesOut = (btVector3*)bufferServerToClient; const btCollisionShape* colShape = 0; @@ -5738,18 +5756,18 @@ bool PhysicsServerCommandProcessor::processRequestTetraMeshDataCommand(const str btSoftBody* psb = bodyHandle->m_softBody; int numTetra = psb->m_tetras.size(); - int maxNumnumVertecies = bufferSizeInBytes / totalBytesPerTetra - 1; - int numVerticesRemaining = numTetra * 4 - clientCmd.m_resetTetraMeshDataArgs.m_startingVertex; + int maxNumnumVertecies = bufferSizeInBytes / totalBytesPerVertex - 1; + int numVerticesRemaining = numTetra * 4; int verticesCopied = btMin(maxNumnumVertecies, numVerticesRemaining); for (int i = 0; i < verticesCopied; i += 4) { - const btSoftBody::Tetra& n = psb->m_tetras[i / 4]; - + const btSoftBody::Tetra& n = psb->m_tetras[i/4]; verticesOut[i].setValue(n.m_n[0]->m_x.x(), n.m_n[0]->m_x.y(), n.m_n[0]->m_x.z()); verticesOut[i+1].setValue(n.m_n[1]->m_x.x(), n.m_n[1]->m_x.y(), n.m_n[1]->m_x.z()); verticesOut[i+2].setValue(n.m_n[2]->m_x.x(), n.m_n[2]->m_x.y(), n.m_n[2]->m_x.z()); verticesOut[i+3].setValue(n.m_n[3]->m_x.x(), n.m_n[3]->m_x.y(), n.m_n[3]->m_x.z()); } + sizeInBytes = verticesCopied * sizeof(btVector3); serverStatusOut.m_type = CMD_REQUEST_TETRA_MESH_DATA_COMPLETED; serverStatusOut.m_sendMeshDataArgs.m_numVerticesCopied = verticesCopied; diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 242ed98dd..5a8c2eb03 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -9202,7 +9202,7 @@ static PyObject* pybullet_getTetraMeshData(PyObject* self, PyObject* args, PyObj int physicsClientId = 0; static char* kwlist[] = {"bodyUniqueId", "flags", "physicsClientId", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|iiii", kwlist, &bodyUniqueId, &flags , &physicsClientId)) + if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|iii", kwlist, &bodyUniqueId, &flags , &physicsClientId)) { return NULL; } -- cgit v1.2.1