summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten Behn <46872913+MaartenBehn@users.noreply.github.com>2022-12-22 19:27:16 +0100
committerMaarten Behn <46872913+MaartenBehn@users.noreply.github.com>2022-12-22 19:27:16 +0100
commit54cdf3993325273ec976f0308a00d70b0d06536b (patch)
tree2b195481c7a2b05990b4989c6394e46c04606c88
parent2b4757f51298d52b04eb052f19cc0e9c5f9b2e57 (diff)
downloadbullet3-54cdf3993325273ec976f0308a00d70b0d06536b.tar.gz
extending wrapper
-rw-r--r--examples/SharedMemory/PhysicsClient.h2
-rw-r--r--examples/SharedMemory/PhysicsClientC_API.cpp21
-rw-r--r--examples/SharedMemory/PhysicsClientC_API.h2
-rw-r--r--examples/SharedMemory/PhysicsClientSharedMemory.cpp28
-rw-r--r--examples/SharedMemory/PhysicsClientSharedMemory.h2
-rw-r--r--examples/SharedMemory/PhysicsDirect.cpp12
-rw-r--r--examples/SharedMemory/PhysicsDirect.h2
-rw-r--r--examples/SharedMemory/PhysicsLoopBack.cpp5
-rw-r--r--examples/SharedMemory/PhysicsLoopBack.h2
-rw-r--r--examples/SharedMemory/PhysicsServerCommandProcessor.cpp7
-rw-r--r--examples/SharedMemory/SharedMemoryPublic.h5
-rw-r--r--examples/pybullet/pybullet.c11
12 files changed, 90 insertions, 9 deletions
diff --git a/examples/SharedMemory/PhysicsClient.h b/examples/SharedMemory/PhysicsClient.h
index 33c139ef1..8fc863f27 100644
--- a/examples/SharedMemory/PhysicsClient.h
+++ b/examples/SharedMemory/PhysicsClient.h
@@ -67,6 +67,8 @@ public:
virtual void getCachedMeshData(struct b3MeshData* meshData) = 0;
+ virtual void getCachedTetraMeshData(struct b3TetraMeshData* meshData) = 0;
+
virtual void getCachedVREvents(struct b3VREventsData* vrEventsData) = 0;
virtual void getCachedKeyboardEvents(struct b3KeyboardEventsData* keyboardEventsData) = 0;
diff --git a/examples/SharedMemory/PhysicsClientC_API.cpp b/examples/SharedMemory/PhysicsClientC_API.cpp
index f464c5b70..71bdd5c54 100644
--- a/examples/SharedMemory/PhysicsClientC_API.cpp
+++ b/examples/SharedMemory/PhysicsClientC_API.cpp
@@ -1567,6 +1567,18 @@ B3_SHARED_API void b3GetMeshDataSetFlags(b3SharedMemoryCommandHandle commandHand
}
}
+B3_SHARED_API void b3GetTetraMeshDataSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags)
+{
+ struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
+ b3Assert(command);
+ b3Assert(command->m_type == CMD_REQUEST_TETRA_MESH_DATA);
+ if (command->m_type == CMD_REQUEST_TETRA_MESH_DATA)
+ {
+ command->m_updateFlags = B3_TETRA_MESH_DATA_FLAGS;
+ command->m_requestMeshDataArgs.m_flags = flags;
+ }
+}
+
B3_SHARED_API void b3GetMeshDataSimulationMesh(b3SharedMemoryCommandHandle commandHandle)
{
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
@@ -1592,6 +1604,15 @@ B3_SHARED_API void b3GetMeshData(b3PhysicsClientHandle physClient, struct b3Mesh
}
}
+B3_SHARED_API void b3GetTetraMeshData(b3PhysicsClientHandle physClient, struct b3TetraMeshData* meshData)
+{
+ PhysicsClient* cl = (PhysicsClient*)physClient;
+ if (cl)
+ {
+ cl->getCachedTetraMeshData(meshData);
+ }
+}
+
B3_SHARED_API int b3CreateVisualShapeAddSphere(b3SharedMemoryCommandHandle commandHandle, double radius)
{
return b3CreateCollisionShapeAddSphere(commandHandle, radius);
diff --git a/examples/SharedMemory/PhysicsClientC_API.h b/examples/SharedMemory/PhysicsClientC_API.h
index 4313d24ec..563272942 100644
--- a/examples/SharedMemory/PhysicsClientC_API.h
+++ b/examples/SharedMemory/PhysicsClientC_API.h
@@ -538,8 +538,10 @@ extern "C"
B3_SHARED_API void b3MeshDataSimulationMeshVelocity(b3SharedMemoryCommandHandle commandHandle);
B3_SHARED_API void b3GetMeshDataSetCollisionShapeIndex(b3SharedMemoryCommandHandle commandHandle, int shapeIndex);
B3_SHARED_API void b3GetMeshDataSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
+ B3_SHARED_API void b3GetTetraMeshDataSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
B3_SHARED_API void b3GetMeshData(b3PhysicsClientHandle physClient, struct b3MeshData* meshData);
+ B3_SHARED_API void b3GetTetraMeshData(b3PhysicsClientHandle physClient, struct b3TetraMeshData* meshData);
B3_SHARED_API b3SharedMemoryCommandHandle b3ResetMeshDataCommandInit(b3PhysicsClientHandle physClient, int bodyUniqueId, int num_vertices, const double* vertices);
diff --git a/examples/SharedMemory/PhysicsClientSharedMemory.cpp b/examples/SharedMemory/PhysicsClientSharedMemory.cpp
index 3512fe3ef..1d8d966a7 100644
--- a/examples/SharedMemory/PhysicsClientSharedMemory.cpp
+++ b/examples/SharedMemory/PhysicsClientSharedMemory.cpp
@@ -54,6 +54,7 @@ struct PhysicsClientSharedMemoryInternalData
btAlignedObjectArray<b3CollisionShapeData> m_cachedCollisionShapes;
b3MeshData m_cachedMeshData;
+ b3TetraMeshData m_cachedTetraMeshData;
btAlignedObjectArray<b3MeshVertex> m_cachedVertexPositions;
btAlignedObjectArray<b3VRControllerEvent> m_cachedVREvents;
@@ -1074,6 +1075,24 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus()
b3Warning("Request mesh data failed");
break;
}
+ case CMD_REQUEST_TETRA_MESH_DATA_COMPLETED:
+ {
+ m_data->m_cachedVertexPositions.resize(serverCmd.m_sendMeshDataArgs.m_startingVertex + serverCmd.m_sendMeshDataArgs.m_numVerticesCopied);
+ btVector3* verticesReceived = (btVector3*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
+ for (int i = 0; i < serverCmd.m_sendMeshDataArgs.m_numVerticesCopied; i++)
+ {
+ m_data->m_cachedVertexPositions[i + serverCmd.m_sendMeshDataArgs.m_startingVertex].x = verticesReceived[i].x();
+ m_data->m_cachedVertexPositions[i + serverCmd.m_sendMeshDataArgs.m_startingVertex].y = verticesReceived[i].y();
+ m_data->m_cachedVertexPositions[i + serverCmd.m_sendMeshDataArgs.m_startingVertex].z = verticesReceived[i].z();
+ m_data->m_cachedVertexPositions[i + serverCmd.m_sendMeshDataArgs.m_startingVertex].w = verticesReceived[i].w();
+ }
+ break;
+ }
+ case CMD_REQUEST_TETRA_MESH_DATA_FAILED:
+ {
+ b3Warning("Request tetra mesh data failed");
+ break;
+ }
case CMD_CALCULATED_INVERSE_DYNAMICS_COMPLETED:
{
break;
@@ -2088,6 +2107,15 @@ void PhysicsClientSharedMemory::getCachedMeshData(struct b3MeshData* meshData)
*meshData = m_data->m_cachedMeshData;
}
+void PhysicsClientSharedMemory::getCachedTetraMeshData(struct b3TetraMeshData* meshData)
+{
+ m_data->m_cachedTetraMeshData.m_numVertices = m_data->m_cachedVertexPositions.size();
+
+ m_data->m_cachedTetraMeshData.m_vertices = m_data->m_cachedTetraMeshData.m_numVertices ? &m_data->m_cachedVertexPositions[0] : 0;
+
+ *meshData = m_data->m_cachedTetraMeshData;
+}
+
const float* PhysicsClientSharedMemory::getDebugLinesFrom() const
{
if (m_data->m_debugLinesFrom.size())
diff --git a/examples/SharedMemory/PhysicsClientSharedMemory.h b/examples/SharedMemory/PhysicsClientSharedMemory.h
index f1a67c525..cf9113c6d 100644
--- a/examples/SharedMemory/PhysicsClientSharedMemory.h
+++ b/examples/SharedMemory/PhysicsClientSharedMemory.h
@@ -80,6 +80,8 @@ public:
virtual void getCachedMeshData(struct b3MeshData* meshData);
+ virtual void getCachedTetraMeshData(struct b3TetraMeshData* meshData);
+
virtual void getCachedVREvents(struct b3VREventsData* vrEventsData);
virtual void getCachedKeyboardEvents(struct b3KeyboardEventsData* keyboardEventsData);
diff --git a/examples/SharedMemory/PhysicsDirect.cpp b/examples/SharedMemory/PhysicsDirect.cpp
index a8aa72a60..f12057ae0 100644
--- a/examples/SharedMemory/PhysicsDirect.cpp
+++ b/examples/SharedMemory/PhysicsDirect.cpp
@@ -67,6 +67,7 @@ struct PhysicsDirectInternalData
btAlignedObjectArray<b3CollisionShapeData> m_cachedCollisionShapes;
b3MeshData m_cachedMeshData;
+ b3TetraMeshData m_cachedTetraMeshData;
btAlignedObjectArray<b3MeshVertex> m_cachedVertexPositions;
btAlignedObjectArray<b3VRControllerEvent> m_cachedVREvents;
@@ -99,6 +100,7 @@ struct PhysicsDirectInternalData
m_timeOutInSeconds(1e30)
{
memset(&m_cachedMeshData.m_numVertices, 0, sizeof(b3MeshData));
+ memset(&m_cachedTetraMeshData.m_numVertices, 0, sizeof(b3TetraMeshData));
memset(&m_command, 0, sizeof(m_command));
memset(&m_serverStatus, 0, sizeof(m_serverStatus));
memset(m_bulletStreamDataServerToClient, 0, sizeof(m_bulletStreamDataServerToClient));
@@ -1691,6 +1693,16 @@ void PhysicsDirect::getCachedMeshData(struct b3MeshData* meshData)
*meshData = m_data->m_cachedMeshData;
}
+void PhysicsDirect::getCachedTetraMeshData(struct b3TetraMeshData* meshData)
+{
+ m_data->m_cachedTetraMeshData.m_numVertices = m_data->m_cachedVertexPositions.size();
+
+ m_data->m_cachedTetraMeshData.m_vertices = m_data->m_cachedTetraMeshData.m_numVertices ? &m_data->m_cachedVertexPositions[0] : 0;
+
+ *meshData = m_data->m_cachedTetraMeshData;
+}
+
+
void PhysicsDirect::getCachedContactPointInformation(struct b3ContactInformation* contactPointData)
{
contactPointData->m_numContactPoints = m_data->m_cachedContactPoints.size();
diff --git a/examples/SharedMemory/PhysicsDirect.h b/examples/SharedMemory/PhysicsDirect.h
index 0d33f8119..441b58e74 100644
--- a/examples/SharedMemory/PhysicsDirect.h
+++ b/examples/SharedMemory/PhysicsDirect.h
@@ -106,6 +106,8 @@ public:
virtual void getCachedMeshData(struct b3MeshData* meshData);
+ virtual void getCachedTetraMeshData(struct b3TetraMeshData* meshData);
+
virtual void getCachedVREvents(struct b3VREventsData* vrEventsData);
virtual void getCachedKeyboardEvents(struct b3KeyboardEventsData* keyboardEventsData);
diff --git a/examples/SharedMemory/PhysicsLoopBack.cpp b/examples/SharedMemory/PhysicsLoopBack.cpp
index 58e4d59c7..427da31e8 100644
--- a/examples/SharedMemory/PhysicsLoopBack.cpp
+++ b/examples/SharedMemory/PhysicsLoopBack.cpp
@@ -183,6 +183,11 @@ void PhysicsLoopBack::getCachedMeshData(struct b3MeshData* meshData)
return m_data->m_physicsClient->getCachedMeshData(meshData);
}
+void PhysicsLoopBack::getCachedTetraMeshData(struct b3TetraMeshData* meshData)
+{
+ return m_data->m_physicsClient->getCachedTetraMeshData(meshData);
+}
+
void PhysicsLoopBack::getCachedContactPointInformation(struct b3ContactInformation* contactPointData)
{
return m_data->m_physicsClient->getCachedContactPointInformation(contactPointData);
diff --git a/examples/SharedMemory/PhysicsLoopBack.h b/examples/SharedMemory/PhysicsLoopBack.h
index 4626aac81..2b6eb87f2 100644
--- a/examples/SharedMemory/PhysicsLoopBack.h
+++ b/examples/SharedMemory/PhysicsLoopBack.h
@@ -78,6 +78,8 @@ public:
virtual void getCachedMeshData(struct b3MeshData* meshData);
+ virtual void getCachedTetraMeshData(struct b3TetraMeshData* meshData);
+
virtual void getCachedVREvents(struct b3VREventsData* vrEventsData);
virtual void getCachedKeyboardEvents(struct b3KeyboardEventsData* keyboardEventsData);
diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
index 2f788bf2c..202ed6c9b 100644
--- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
+++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
@@ -5721,8 +5721,8 @@ bool PhysicsServerCommandProcessor::processRequestMeshDataCommand(const struct S
bool PhysicsServerCommandProcessor::processRequestTetraMeshDataCommand(const struct SharedMemoryCommand& clientCmd, struct SharedMemoryStatus& serverStatusOut, char* bufferServerToClient, int bufferSizeInBytes)
{
bool hasStatus = true;
- BT_PROFILE("CMD_REQUEST_MESH_DATA");
- serverStatusOut.m_type = CMD_REQUEST_MESH_DATA_FAILED;
+ BT_PROFILE("CMD_REQUEST_TETRA_MESH_DATA");
+ serverStatusOut.m_type = CMD_REQUEST_TETRA_MESH_DATA_FAILED;
serverStatusOut.m_numDataStreamBytes = 0;
int sizeInBytes = 0;
@@ -5733,8 +5733,6 @@ bool PhysicsServerCommandProcessor::processRequestTetraMeshDataCommand(const str
btVector3* verticesOut = (btVector3*)bufferServerToClient;
const btCollisionShape* colShape = 0;
-#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
-
if (bodyHandle->m_softBody)
{
btSoftBody* psb = bodyHandle->m_softBody;
@@ -5758,7 +5756,6 @@ bool PhysicsServerCommandProcessor::processRequestTetraMeshDataCommand(const str
serverStatusOut.m_sendMeshDataArgs.m_startingVertex = clientCmd.m_requestMeshDataArgs.m_startingVertex;
serverStatusOut.m_sendMeshDataArgs.m_numVerticesRemaining = numVerticesRemaining - verticesCopied;
}
-#endif //SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
}
serverStatusOut.m_numDataStreamBytes = sizeInBytes;
diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h
index 9b7598e0b..4e3f6d3f3 100644
--- a/examples/SharedMemory/SharedMemoryPublic.h
+++ b/examples/SharedMemory/SharedMemoryPublic.h
@@ -486,6 +486,11 @@ struct b3MeshData
struct b3MeshVertex* m_vertices;
};
+enum eTetraMeshDataEnum
+{
+ B3_TETRA_MESH_DATA_FLAGS=2,
+};
+
struct b3TetraMeshData
{
int m_numVertices;
diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c
index 4d62b5f8e..242ed98dd 100644
--- a/examples/pybullet/pybullet.c
+++ b/examples/pybullet/pybullet.c
@@ -9196,7 +9196,7 @@ static PyObject* pybullet_getTetraMeshData(PyObject* self, PyObject* args, PyObj
b3PhysicsClientHandle sm = 0;
b3SharedMemoryCommandHandle command;
b3SharedMemoryStatusHandle statusHandle;
- struct b3MeshData meshData;
+ struct b3TetraMeshData meshData;
int statusType;
int flags = -1;
@@ -9215,7 +9215,7 @@ static PyObject* pybullet_getTetraMeshData(PyObject* self, PyObject* args, PyObj
command = b3GetTetraMeshDataCommandInit(sm, bodyUniqueId);
if (flags >= 0)
{
- b3GetMeshDataSetFlags(command, flags);
+ b3GetTetraMeshDataSetFlags(command, flags);
}
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
@@ -9225,7 +9225,7 @@ static PyObject* pybullet_getTetraMeshData(PyObject* self, PyObject* args, PyObj
int i;
PyObject* pyVertexData;
PyObject* pyListMeshData = PyTuple_New(2);
- b3GetMeshData(sm, &meshData);
+ b3GetTetraMeshData(sm, &meshData);
PyTuple_SetItem(pyListMeshData, 0, PyInt_FromLong(meshData.m_numVertices));
pyVertexData = PyTuple_New(meshData.m_numVertices);
PyTuple_SetItem(pyListMeshData, 1, pyVertexData);
@@ -9242,7 +9242,7 @@ static PyObject* pybullet_getTetraMeshData(PyObject* self, PyObject* args, PyObj
return pyListMeshData;
}
- PyErr_SetString(SpamError, "getMeshData failed");
+ PyErr_SetString(SpamError, "getTetraMeshData failed");
return NULL;
}
@@ -12702,6 +12702,9 @@ static PyMethodDef SpamMethods[] = {
{"getMeshData", (PyCFunction)pybullet_getMeshData, METH_VARARGS | METH_KEYWORDS,
"Get mesh data. Returns vertices etc from the mesh."},
+ {"getTetraMeshData", (PyCFunction)pybullet_getTetraMeshData, METH_VARARGS | METH_KEYWORDS,
+ "Get mesh data. Returns tetra from the mesh."},
+
{"resetMeshData", (PyCFunction)pybullet_resetMeshData, METH_VARARGS | METH_KEYWORDS,
"Reset mesh data. Only implemented for deformable bodies."},