diff options
author | Chuyuan Kelly Fu <fuchuyuan@google.com> | 2022-02-13 20:49:09 -0800 |
---|---|---|
committer | Chuyuan Kelly Fu <fuchuyuan@google.com> | 2022-02-18 17:47:54 -0800 |
commit | 07de08a38e0f94332017982185be3d526b9fe3c5 (patch) | |
tree | 741dc09c1b1bd65126cee06ae0191a34f968123f | |
parent | fb3b306af19aac4d7581702a7676c2452fb9658a (diff) | |
download | bullet3-07de08a38e0f94332017982185be3d526b9fe3c5.tar.gz |
request mesh velocity
-rw-r--r-- | examples/SharedMemory/PhysicsServerCommandProcessor.cpp | 14 | ||||
-rw-r--r-- | examples/SharedMemory/SharedMemoryPublic.h | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 0d826af41..9f1c7b98a 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -5606,6 +5606,8 @@ bool PhysicsServerCommandProcessor::processRequestMeshDataCommand(const struct S { separateRenderMesh = (psb->m_renderNodes.size() != 0); } + bool requestVelocity = flags & B3_MESH_DATA_SIMULATION_MESH_VELOCITY; + int numVertices = separateRenderMesh ? psb->m_renderNodes.size() : psb->m_nodes.size(); int maxNumVertices = bufferSizeInBytes / totalBytesPerVertex - 1; int numVerticesRemaining = numVertices - clientCmd.m_requestMeshDataArgs.m_startingVertex; @@ -5614,14 +5616,22 @@ bool PhysicsServerCommandProcessor::processRequestMeshDataCommand(const struct S { if (separateRenderMesh) { - const btSoftBody::RenderNode& n = psb->m_renderNodes[i + clientCmd.m_requestMeshDataArgs.m_startingVertex]; + if(requestVelocity){ + b3Warning("Request mesh velocity not implemented for Render Mesh."); + return hasStatus; + } verticesOut[i].setValue(n.m_x.x(), n.m_x.y(), n.m_x.z()); } else { const btSoftBody::Node& n = psb->m_nodes[i + clientCmd.m_requestMeshDataArgs.m_startingVertex]; - verticesOut[i].setValue(n.m_x.x(), n.m_x.y(), n.m_x.z()); + if(!requestVelocity){ + verticesOut[i].setValue(n.m_x.x(), n.m_x.y(), n.m_x.z()); + } + else{ + verticesOut[i].setValue(n.m_v.x(), n.m_v.y(), n.m_v.z()); + } } } sizeInBytes = verticesCopied * sizeof(btVector3); diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h index 2649fc44d..b1a560339 100644 --- a/examples/SharedMemory/SharedMemoryPublic.h +++ b/examples/SharedMemory/SharedMemoryPublic.h @@ -465,8 +465,9 @@ struct b3MeshVertex enum eMeshDataFlags { B3_MESH_DATA_SIMULATION_MESH=1, - B3_MESH_DATA_SIMULATION_INDICES, - B3_MESH_DATA_GRAPHICS_INDICES, + B3_MESH_DATA_SIMULATION_INDICES=2, + B3_MESH_DATA_GRAPHICS_INDICES=4, + B3_MESH_DATA_SIMULATION_MESH_VELOCITY=8, }; enum eMeshDataEnum |