From 07de08a38e0f94332017982185be3d526b9fe3c5 Mon Sep 17 00:00:00 2001 From: Chuyuan Kelly Fu Date: Sun, 13 Feb 2022 20:49:09 -0800 Subject: [PATCH] request mesh velocity --- .../SharedMemory/PhysicsServerCommandProcessor.cpp | 14 ++++++++++++-- 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