From 236d39d2ec20be7ffe68d21b632eb5e845d77a89 Mon Sep 17 00:00:00 2001 From: Chuyuan Kelly Fu Date: Sun, 13 Feb 2022 21:16:24 -0800 Subject: [PATCH] reset deformable velocity --- .../PhysicsServerCommandProcessor.cpp | 17 ++++++++++++++--- examples/SharedMemory/SharedMemoryPublic.h | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 9f1c7b98a..2506a767f 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -5512,13 +5512,24 @@ bool PhysicsServerCommandProcessor::processResetMeshDataCommand(const struct Sha int numVertices = psb->m_nodes.size(); if (clientCmd.m_resetMeshDataArgs.m_numVertices == numVertices) { + if(clientCmd.m_updateFlags & B3_MESH_DATA_SIMULATION_MESH_VELOCITY){ for (int i = 0; i < numVertices; ++i) { btSoftBody::Node& n = psb->m_nodes[i]; - n.m_x.setValue(vertexUpload[i*3+0], vertexUpload[i*3+1],vertexUpload[i*3+2]); + n.m_v.setValue(vertexUpload[i*3+0], vertexUpload[i*3+1],vertexUpload[i*3+2]); + n.m_vn.setValue(vertexUpload[i*3+0], vertexUpload[i*3+1],vertexUpload[i*3+2]); } - serverStatusOut.m_type = CMD_RESET_MESH_DATA_COMPLETED; - } + } + else{ + for (int i = 0; i < numVertices; ++i) + { + btSoftBody::Node& n = psb->m_nodes[i]; + n.m_x.setValue(vertexUpload[i*3+0], vertexUpload[i*3+1],vertexUpload[i*3+2]); + n.m_q.setValue(vertexUpload[i*3+0], vertexUpload[i*3+1],vertexUpload[i*3+2]); + } + } + serverStatusOut.m_type = CMD_RESET_MESH_DATA_COMPLETED; + } } #endif //SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD } diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h index b1a560339..90143b55e 100644 --- a/examples/SharedMemory/SharedMemoryPublic.h +++ b/examples/SharedMemory/SharedMemoryPublic.h @@ -467,7 +467,7 @@ enum eMeshDataFlags B3_MESH_DATA_SIMULATION_MESH=1, B3_MESH_DATA_SIMULATION_INDICES=2, B3_MESH_DATA_GRAPHICS_INDICES=4, - B3_MESH_DATA_SIMULATION_MESH_VELOCITY=8, + B3_MESH_DATA_SIMULATION_MESH_VELOCITY=8, }; enum eMeshDataEnum