From 6a78b4bb071dd614c89d57b4f90cbceb9b40d895 Mon Sep 17 00:00:00 2001 From: jingyuc Date: Sun, 30 Jan 2022 21:12:05 -0800 Subject: [PATCH] clean up: rename the *ReducedSoftBody* as *ReducedDeformableBody* for clarity --- .../ConservationTest.cpp | 18 ++-- examples/ReducedDeformableDemo/FreeFall.cpp | 12 +-- .../ReducedDeformableDemo/FrictionSlope.cpp | 12 +-- .../ReducedDeformableDemo/ModeVisualizer.cpp | 16 +-- .../ReducedDeformableDemo/ReducedCollide.cpp | 12 +-- .../ReducedDeformableDemo/ReducedGrasp.cpp | 12 +-- .../ReducedGraspBenchmark.cpp | 14 +-- .../ReducedMotorGrasp.cpp | 12 +-- .../ReducedDeformableDemo/ReducedPress.cpp | 12 +-- .../ReducedDeformableDemo/Springboard.cpp | 14 +-- .../PhysicsServerCommandProcessor.cpp | 16 +-- ...ftBody.cpp => btReducedDeformableBody.cpp} | 100 +++++++++--------- ...edSoftBody.h => btReducedDeformableBody.h} | 6 +- ...cpp => btReducedDeformableBodyHelpers.cpp} | 42 ++++---- .../btReducedDeformableBodyHelpers.h | 29 +++++ ....cpp => btReducedDeformableBodySolver.cpp} | 42 ++++---- ...lver.h => btReducedDeformableBodySolver.h} | 16 +-- .../btReducedDeformableContactConstraint.cpp | 8 +- .../btReducedDeformableContactConstraint.h | 14 +-- .../btReducedSoftBodyHelpers.h | 29 ----- .../btDeformableMultiBodyDynamicsWorld.h | 1 - 21 files changed, 218 insertions(+), 219 deletions(-) rename src/BulletSoftBody/BulletReducedSoftBody/{btReducedSoftBody.cpp => btReducedDeformableBody.cpp} (84%) rename src/BulletSoftBody/BulletReducedSoftBody/{btReducedSoftBody.h => btReducedDeformableBody.h} (97%) rename src/BulletSoftBody/BulletReducedSoftBody/{btReducedSoftBodyHelpers.cpp => btReducedDeformableBodyHelpers.cpp} (71%) create mode 100644 src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h rename src/BulletSoftBody/BulletReducedSoftBody/{btReducedSoftBodySolver.cpp => btReducedDeformableBodySolver.cpp} (83%) rename src/BulletSoftBody/BulletReducedSoftBody/{btReducedSoftBodySolver.h => btReducedDeformableBodySolver.h} (82%) delete mode 100644 src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h diff --git a/examples/ReducedDeformableDemo/ConservationTest.cpp b/examples/ReducedDeformableDemo/ConservationTest.cpp index d33072dea..8566707e0 100644 --- a/examples/ReducedDeformableDemo/ConservationTest.cpp +++ b/examples/ReducedDeformableDemo/ConservationTest.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -38,7 +38,7 @@ class ConservationTest : public CommonDeformableBodyBase bool first_step; // get deformed shape - void getDeformedShape(btReducedSoftBody* rsb, const int mode_n, const btScalar scale = 1) + void getDeformedShape(btReducedDeformableBody* rsb, const int mode_n, const btScalar scale = 1) { // for (int i = 0; i < rsb->m_nodes.size(); ++i) // for (int k = 0; k < 3; ++k) @@ -88,7 +88,7 @@ public: m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1], targetPos[2]); } - void checkMomentum(btReducedSoftBody* rsb) + void checkMomentum(btReducedDeformableBody* rsb) { btVector3 x_com(0, 0, 0); btVector3 total_linear(0, 0, 0); @@ -148,7 +148,7 @@ public: void stepSimulation(float deltaTime) { // add initial deformation - btReducedSoftBody* rsb = static_cast(static_cast(m_dynamicsWorld)->getSoftBodyArray()[0]); + btReducedDeformableBody* rsb = static_cast(static_cast(m_dynamicsWorld)->getSoftBodyArray()[0]); if (first_step /* && !rsb->m_bUpdateRtCst*/) { getDeformedShape(rsb, 0, 1); @@ -169,7 +169,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); @@ -202,7 +202,7 @@ void ConservationTest::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btVector3 gravity = btVector3(0, 0, 0); reducedSoftBodySolver->setGravity(gravity); @@ -216,7 +216,7 @@ void ConservationTest::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.1); diff --git a/examples/ReducedDeformableDemo/FreeFall.cpp b/examples/ReducedDeformableDemo/FreeFall.cpp index 6370a4199..faa805b0d 100644 --- a/examples/ReducedDeformableDemo/FreeFall.cpp +++ b/examples/ReducedDeformableDemo/FreeFall.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -86,7 +86,7 @@ public: void createReducedDeformableObject(const btVector3& origin, const btQuaternion& rotation) { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.01); @@ -127,7 +127,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); // btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), flag); @@ -161,7 +161,7 @@ void FreeFall::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver(); sol->setDeformableSolver(reducedSoftBodySolver); diff --git a/examples/ReducedDeformableDemo/FrictionSlope.cpp b/examples/ReducedDeformableDemo/FrictionSlope.cpp index dcb497da1..c20be4bff 100644 --- a/examples/ReducedDeformableDemo/FrictionSlope.cpp +++ b/examples/ReducedDeformableDemo/FrictionSlope.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -102,7 +102,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); // btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), flag); @@ -174,7 +174,7 @@ void FrictionSlope::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btVector3 gravity = btVector3(0, -10, 0); reducedSoftBodySolver->setGravity(gravity); @@ -187,7 +187,7 @@ void FrictionSlope::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.01); diff --git a/examples/ReducedDeformableDemo/ModeVisualizer.cpp b/examples/ReducedDeformableDemo/ModeVisualizer.cpp index 6480cbb54..84414418e 100644 --- a/examples/ReducedDeformableDemo/ModeVisualizer.cpp +++ b/examples/ReducedDeformableDemo/ModeVisualizer.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -36,14 +36,14 @@ class ModeVisualizer : public CommonDeformableBodyBase btScalar sim_time; // get deformed shape - void getDeformedShape(btReducedSoftBody* rsb, const int mode_n, const btScalar time_term = 1) + void getDeformedShape(btReducedDeformableBody* rsb, const int mode_n, const btScalar time_term = 1) { for (int i = 0; i < rsb->m_nodes.size(); ++i) for (int k = 0; k < 3; ++k) rsb->m_nodes[i].m_x[k] = rsb->m_x0[i][k] + rsb->m_modes[mode_n][3 * i + k] * time_term; } - btVector3 computeMassWeightedColumnSum(btReducedSoftBody* rsb, const int mode_n) + btVector3 computeMassWeightedColumnSum(btReducedDeformableBody* rsb, const int mode_n) { btVector3 sum(0, 0, 0); for (int i = 0; i < rsb->m_nodes.size(); ++i) @@ -85,7 +85,7 @@ public: void stepSimulation(float deltaTime) { - btReducedSoftBody* rsb = static_cast(static_cast(m_dynamicsWorld)->getSoftBodyArray()[0]); + btReducedDeformableBody* rsb = static_cast(static_cast(m_dynamicsWorld)->getSoftBodyArray()[0]); sim_time += deltaTime; int n_mode = floor(visualize_mode); @@ -124,7 +124,7 @@ void ModeVisualizer::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver(); sol->setDeformableSolver(reducedSoftBodySolver); @@ -135,7 +135,7 @@ void ModeVisualizer::initPhysics() // create volumetric soft body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.1); diff --git a/examples/ReducedDeformableDemo/ReducedCollide.cpp b/examples/ReducedDeformableDemo/ReducedCollide.cpp index a64c01497..a44e9d31e 100644 --- a/examples/ReducedDeformableDemo/ReducedCollide.cpp +++ b/examples/ReducedDeformableDemo/ReducedCollide.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -162,7 +162,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); @@ -188,7 +188,7 @@ void ReducedCollide::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btVector3 gravity = btVector3(0, 0, 0); reducedSoftBodySolver->setGravity(gravity); @@ -204,7 +204,7 @@ void ReducedCollide::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.1); diff --git a/examples/ReducedDeformableDemo/ReducedGrasp.cpp b/examples/ReducedDeformableDemo/ReducedGrasp.cpp index 470ef0cc4..3fc320f87 100644 --- a/examples/ReducedDeformableDemo/ReducedGrasp.cpp +++ b/examples/ReducedDeformableDemo/ReducedGrasp.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -111,7 +111,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - // btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + // btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); // { // btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); // btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); @@ -262,7 +262,7 @@ void ReducedGrasp::initPhysics() m_broadphase = new btDbvtBroadphase(); // btDeformableBodySolver* solver = new btDeformableBodySolver(); - btReducedSoftBodySolver* solver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* solver = new btReducedDeformableBodySolver(); btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver(); sol->setDeformableSolver(solver); @@ -278,7 +278,7 @@ void ReducedGrasp::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.015); diff --git a/examples/ReducedDeformableDemo/ReducedGraspBenchmark.cpp b/examples/ReducedDeformableDemo/ReducedGraspBenchmark.cpp index 5c5ea07a4..96361123a 100644 --- a/examples/ReducedDeformableDemo/ReducedGraspBenchmark.cpp +++ b/examples/ReducedDeformableDemo/ReducedGraspBenchmark.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -88,7 +88,7 @@ public: if (run_reduced) { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.01); @@ -156,7 +156,7 @@ public: std::cout << "Running full deformable\n"; } - // btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + // btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); // getDeformableDynamicsWorld()->addSoftBody(rsb); // rsb->getCollisionShape()->setMargin(0.01); @@ -196,7 +196,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); @@ -219,7 +219,7 @@ void ReducedGraspBenchmark::initPhysics() if (run_reduced) { - btReducedSoftBodySolver* solver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* solver = new btReducedDeformableBodySolver(); btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver(); sol->setDeformableSolver(solver); diff --git a/examples/ReducedDeformableDemo/ReducedMotorGrasp.cpp b/examples/ReducedDeformableDemo/ReducedMotorGrasp.cpp index 3085dbad0..0efe31d3a 100644 --- a/examples/ReducedDeformableDemo/ReducedMotorGrasp.cpp +++ b/examples/ReducedDeformableDemo/ReducedMotorGrasp.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "BulletDynamics/Featherstone/btMultiBodyJointMotor.h" @@ -181,7 +181,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), fDrawFlags::Faces);// deformableWorld->getDrawFlags()); @@ -215,7 +215,7 @@ void ReducedMotorGrasp::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); // btVector3 gravity = btVector3(0, 0, 0); btVector3 gravity = btVector3(0, -9.81, 0); reducedSoftBodySolver->setGravity(gravity); @@ -317,7 +317,7 @@ void ReducedMotorGrasp::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.001); diff --git a/examples/ReducedDeformableDemo/ReducedPress.cpp b/examples/ReducedDeformableDemo/ReducedPress.cpp index fd76e2bdc..3ffd1273a 100644 --- a/examples/ReducedDeformableDemo/ReducedPress.cpp +++ b/examples/ReducedDeformableDemo/ReducedPress.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -109,7 +109,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); @@ -171,7 +171,7 @@ void ReducedPress::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btVector3 gravity = btVector3(0, 0, 0); reducedSoftBodySolver->setGravity(gravity); @@ -188,7 +188,7 @@ void ReducedPress::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.015); diff --git a/examples/ReducedDeformableDemo/Springboard.cpp b/examples/ReducedDeformableDemo/Springboard.cpp index 40217de1f..b44343cfa 100644 --- a/examples/ReducedDeformableDemo/Springboard.cpp +++ b/examples/ReducedDeformableDemo/Springboard.cpp @@ -15,9 +15,9 @@ ///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files. #include "btBulletDynamicsCommon.h" #include "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" #include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -81,7 +81,7 @@ public: { sim_time += internalTimeStep; - btReducedSoftBody* rsb = static_cast(getDeformableDynamicsWorld()->getSoftBodyArray()[0]); + btReducedDeformableBody* rsb = static_cast(getDeformableDynamicsWorld()->getSoftBodyArray()[0]); // std::ofstream myfile("fixed_node.txt", std::ios_base::app); // myfile << sim_time << "\t" << rsb->m_nodes[0].m_x[0] - rsb->m_x0[0][0] << "\t" @@ -98,7 +98,7 @@ public: for (int i = 0; i < deformableWorld->getSoftBodyArray().size(); i++) { - btReducedSoftBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); + btReducedDeformableBody* rsb = static_cast(deformableWorld->getSoftBodyArray()[i]); { btSoftBodyHelpers::DrawFrame(rsb, deformableWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(rsb, deformableWorld->getDebugDrawer(), deformableWorld->getDrawFlags()); @@ -127,7 +127,7 @@ void Springboard::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btReducedSoftBodySolver* reducedSoftBodySolver = new btReducedSoftBodySolver(); + btReducedDeformableBodySolver* reducedSoftBodySolver = new btReducedDeformableBodySolver(); btVector3 gravity = btVector3(0, -10, 0); reducedSoftBodySolver->setGravity(gravity); @@ -141,7 +141,7 @@ void Springboard::initPhysics() // create volumetric reduced deformable body { - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes); getDeformableDynamicsWorld()->addSoftBody(rsb); rsb->getCollisionShape()->setMargin(0.1); diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index b830cbcbb..48c4d520e 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -121,9 +121,9 @@ #include "BulletSoftBody/btDeformableBodySolver.h" #include "BulletSoftBody/btDeformableMultiBodyConstraintSolver.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h" -#include "BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h" +#include "BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h" #endif //SKIP_DEFORMABLE_BODY #include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h" @@ -1668,7 +1668,7 @@ struct PhysicsServerCommandProcessorInternalData btDeformableMousePickingForce* m_mouseForce; btScalar m_maxPickingForce; btDeformableBodySolver* m_deformablebodySolver; - btReducedSoftBodySolver* m_reducedSoftBodySolver; + btReducedDeformableBodySolver* m_reducedSoftBodySolver; btAlignedObjectArray m_lf; #endif @@ -2738,7 +2738,7 @@ void PhysicsServerCommandProcessor::createEmptyDynamicsWorld(int flags) else if (flags & RESET_USE_REDUCED_DEFORMABLE_WORLD) { // reduced deformable - m_data->m_reducedSoftBodySolver = new btReducedSoftBodySolver(); + m_data->m_reducedSoftBodySolver = new btReducedDeformableBodySolver(); btDeformableMultiBodyConstraintSolver* solver = new btDeformableMultiBodyConstraintSolver; m_data->m_solver = solver; solver->setDeformableSolver(m_data->m_reducedSoftBodySolver); @@ -9556,7 +9556,7 @@ bool PhysicsServerCommandProcessor::processDeformable(const UrdfDeformable& defo bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfReducedDeformable& reduced_deformable, const btVector3& pos, const btQuaternion& orn, int* bodyUniqueId, char* bufferServerToClient, int bufferSizeInBytes, btScalar scale, bool useSelfCollision) { #ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD - btReducedSoftBody* rsb = NULL; + btReducedDeformableBody* rsb = NULL; CommonFileIOInterface* fileIO(m_data->m_pluginManager.getFileIOInterface()); char relativeFileName[1024]; char pathPrefix[1024]; @@ -9591,7 +9591,7 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfReducedDe btDeformableMultiBodyDynamicsWorld* deformWorld = getDeformableWorld(); if (deformWorld) { - rsb = btReducedSoftBodyHelpers::createFromVtkFile(deformWorld->getWorldInfo(), out_found_sim_filename.c_str()); + rsb = btReducedDeformableBodyHelpers::createFromVtkFile(deformWorld->getWorldInfo(), out_found_sim_filename.c_str()); if (!rsb) { printf("Load reduced deformable failed\n"); @@ -9602,7 +9602,7 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfReducedDe rsb->setReducedModes(reduced_deformable.m_numModes, rsb->m_nodes.size()); rsb->setStiffnessScale(reduced_deformable.m_stiffnessScale); rsb->setDamping(0, reduced_deformable.m_damping); // damping alpha is set to 0 by default - btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, pathPrefix); + btReducedDeformableBodyHelpers::readReducedDeformableInfoFromFiles(rsb, pathPrefix); // set total mass rsb->setTotalMass(reduced_deformable.m_mass); } diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.cpp similarity index 84% rename from src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp rename to src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.cpp index fcf2f6f8c..e3cd1a90b 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.cpp @@ -1,11 +1,11 @@ -#include "btReducedSoftBody.h" +#include "btReducedDeformableBody.h" #include "../btSoftBodyInternals.h" -#include "btReducedSoftBodyHelpers.h" +#include "btReducedDeformableBodyHelpers.h" #include "LinearMath/btTransformUtil.h" #include #include -btReducedSoftBody::btReducedSoftBody(btSoftBodyWorldInfo* worldInfo, int node_count, const btVector3* x, const btScalar* m) +btReducedDeformableBody::btReducedDeformableBody(btSoftBodyWorldInfo* worldInfo, int node_count, const btVector3* x, const btScalar* m) : btSoftBody(worldInfo, node_count, x, m) { m_rigidOnly = false; //! only use rigid frame to debug @@ -44,7 +44,7 @@ btReducedSoftBody::btReducedSoftBody(btSoftBodyWorldInfo* worldInfo, int node_co m_rigidTransformWorld.setIdentity(); } -void btReducedSoftBody::setReducedModes(int num_modes, int full_size) +void btReducedDeformableBody::setReducedModes(int num_modes, int full_size) { m_nReduced = num_modes; m_nFull = full_size; @@ -60,7 +60,7 @@ void btReducedSoftBody::setReducedModes(int num_modes, int full_size) m_localMomentArm.resize(m_nFull); } -void btReducedSoftBody::setMassProps(const tDenseArray& mass_array) +void btReducedDeformableBody::setMassProps(const tDenseArray& mass_array) { btScalar total_mass = 0; btVector3 CoM(0, 0, 0); @@ -79,7 +79,7 @@ void btReducedSoftBody::setMassProps(const tDenseArray& mass_array) m_initialCoM = CoM / total_mass; } -void btReducedSoftBody::setInertiaProps() +void btReducedDeformableBody::setInertiaProps() { // make sure the initial CoM is at the origin (0,0,0) // for (int i = 0; i < m_nFull; ++i) @@ -100,39 +100,39 @@ void btReducedSoftBody::setInertiaProps() m_interpolateInvInertiaTensorWorld = m_invInertiaTensorWorld; } -void btReducedSoftBody::setRigidVelocity(const btVector3& v) +void btReducedDeformableBody::setRigidVelocity(const btVector3& v) { m_linearVelocity = v; } -void btReducedSoftBody::setRigidAngularVelocity(const btVector3& omega) +void btReducedDeformableBody::setRigidAngularVelocity(const btVector3& omega) { m_angularVelocity = omega; } -void btReducedSoftBody::setStiffnessScale(const btScalar ks) +void btReducedDeformableBody::setStiffnessScale(const btScalar ks) { m_ksScale = ks; } -void btReducedSoftBody::setMassScale(const btScalar rho) +void btReducedDeformableBody::setMassScale(const btScalar rho) { m_rhoScale = rho; } -void btReducedSoftBody::setFixedNodes(const int n_node) +void btReducedDeformableBody::setFixedNodes(const int n_node) { m_fixedNodes.push_back(n_node); m_nodes[n_node].m_im = 0; // set inverse mass to be zero for the constraint solver. } -void btReducedSoftBody::setDamping(const btScalar alpha, const btScalar beta) +void btReducedDeformableBody::setDamping(const btScalar alpha, const btScalar beta) { m_dampingAlpha = alpha; m_dampingBeta = beta; } -void btReducedSoftBody::internalInitialization() +void btReducedDeformableBody::internalInitialization() { // zeroing endOfTimeStepZeroing(); @@ -144,7 +144,7 @@ void btReducedSoftBody::internalInitialization() updateExternalForceProjectMatrix(false); } -void btReducedSoftBody::updateLocalMomentArm() +void btReducedDeformableBody::updateLocalMomentArm() { TVStack delta_x; delta_x.resize(m_nFull); @@ -165,7 +165,7 @@ void btReducedSoftBody::updateLocalMomentArm() } } -void btReducedSoftBody::updateExternalForceProjectMatrix(bool initialized) +void btReducedDeformableBody::updateExternalForceProjectMatrix(bool initialized) { // if not initialized, need to compute both P_A and Cq // otherwise, only need to udpate Cq @@ -218,7 +218,7 @@ void btReducedSoftBody::updateExternalForceProjectMatrix(bool initialized) } } -void btReducedSoftBody::endOfTimeStepZeroing() +void btReducedDeformableBody::endOfTimeStepZeroing() { for (int i = 0; i < m_nReduced; ++i) { @@ -232,7 +232,7 @@ void btReducedSoftBody::endOfTimeStepZeroing() // std::cout << "zeroed!\n"; } -void btReducedSoftBody::applyInternalVelocityChanges() +void btReducedDeformableBody::applyInternalVelocityChanges() { m_linearVelocity += m_internalDeltaLinearVelocity; m_angularVelocity += m_internalDeltaAngularVelocity; @@ -245,12 +245,12 @@ void btReducedSoftBody::applyInternalVelocityChanges() } } -void btReducedSoftBody::predictIntegratedTransform(btScalar dt, btTransform& predictedTransform) +void btReducedDeformableBody::predictIntegratedTransform(btScalar dt, btTransform& predictedTransform) { btTransformUtil::integrateTransform(m_rigidTransformWorld, m_linearVelocity, m_angularVelocity, dt, predictedTransform); } -void btReducedSoftBody::updateReducedDofs(btScalar solverdt) +void btReducedDeformableBody::updateReducedDofs(btScalar solverdt) { for (int r = 0; r < m_nReduced; ++r) { @@ -258,7 +258,7 @@ void btReducedSoftBody::updateReducedDofs(btScalar solverdt) } } -void btReducedSoftBody::mapToFullPosition(const btTransform& ref_trans) +void btReducedDeformableBody::mapToFullPosition(const btTransform& ref_trans) { btVector3 origin = ref_trans.getOrigin(); btMatrix3x3 rotation = ref_trans.getBasis(); @@ -271,7 +271,7 @@ void btReducedSoftBody::mapToFullPosition(const btTransform& ref_trans) } } -void btReducedSoftBody::updateReducedVelocity(btScalar solverdt) +void btReducedDeformableBody::updateReducedVelocity(btScalar solverdt) { // update reduced velocity for (int r = 0; r < m_nReduced; ++r) @@ -284,7 +284,7 @@ void btReducedSoftBody::updateReducedVelocity(btScalar solverdt) } } -void btReducedSoftBody::mapToFullVelocity(const btTransform& ref_trans) +void btReducedDeformableBody::mapToFullVelocity(const btTransform& ref_trans) { // compute the reduced contribution to the angular velocity // btVector3 sum_linear(0, 0, 0); @@ -326,7 +326,7 @@ void btReducedSoftBody::mapToFullVelocity(const btTransform& ref_trans) } } -const btVector3 btReducedSoftBody::computeTotalAngularMomentum() const +const btVector3 btReducedDeformableBody::computeTotalAngularMomentum() const { btVector3 L_rigid = m_invInertiaTensorWorld.inverse() * m_angularVelocity; btVector3 L_reduced(0, 0, 0); @@ -352,7 +352,7 @@ const btVector3 btReducedSoftBody::computeTotalAngularMomentum() const return L_rigid + L_reduced; } -const btVector3 btReducedSoftBody::computeNodeFullVelocity(const btTransform& ref_trans, int n_node) const +const btVector3 btReducedDeformableBody::computeNodeFullVelocity(const btTransform& ref_trans, int n_node) const { btVector3 v_from_reduced(0, 0, 0); btVector3 r_com = ref_trans.getBasis() * m_localMomentArm[n_node]; @@ -371,7 +371,7 @@ const btVector3 btReducedSoftBody::computeNodeFullVelocity(const btTransform& re return vel; } -const btVector3 btReducedSoftBody::internalComputeNodeDeltaVelocity(const btTransform& ref_trans, int n_node) const +const btVector3 btReducedDeformableBody::internalComputeNodeDeltaVelocity(const btTransform& ref_trans, int n_node) const { btVector3 deltaV_from_reduced(0, 0, 0); btVector3 r_com = ref_trans.getBasis() * m_localMomentArm[n_node]; @@ -392,7 +392,7 @@ const btVector3 btReducedSoftBody::internalComputeNodeDeltaVelocity(const btTran return deltaV; } -void btReducedSoftBody::proceedToTransform(btScalar dt, bool end_of_time_step) +void btReducedDeformableBody::proceedToTransform(btScalar dt, bool end_of_time_step) { btTransformUtil::integrateTransform(m_rigidTransformWorld, m_linearVelocity, m_angularVelocity, dt, m_interpolationWorldTransform); updateInertiaTensor(); @@ -401,7 +401,7 @@ void btReducedSoftBody::proceedToTransform(btScalar dt, bool end_of_time_step) m_invInertiaTensorWorld = m_interpolateInvInertiaTensorWorld; } -void btReducedSoftBody::transformTo(const btTransform& trs) +void btReducedDeformableBody::transformTo(const btTransform& trs) { btTransform current_transform = getRigidTransform(); btTransform new_transform(trs.getBasis() * current_transform.getBasis().transpose(), @@ -409,7 +409,7 @@ void btReducedSoftBody::transformTo(const btTransform& trs) transform(new_transform); } -void btReducedSoftBody::transform(const btTransform& trs) +void btReducedDeformableBody::transform(const btTransform& trs) { m_transform_lock = true; @@ -454,7 +454,7 @@ void btReducedSoftBody::transform(const btTransform& trs) internalInitialization(); } -void btReducedSoftBody::scale(const btVector3& scl) +void btReducedDeformableBody::scale(const btVector3& scl) { // Scaling the mesh after transform is applied is not allowed btAssert(!m_transform_lock); @@ -493,7 +493,7 @@ void btReducedSoftBody::scale(const btVector3& scl) internalInitialization(); } -void btReducedSoftBody::setTotalMass(btScalar mass, bool fromfaces) +void btReducedDeformableBody::setTotalMass(btScalar mass, bool fromfaces) { // Changing the total mass after transform is applied is not allowed btAssert(!m_transform_lock); @@ -520,7 +520,7 @@ void btReducedSoftBody::setTotalMass(btScalar mass, bool fromfaces) internalInitialization(); } -void btReducedSoftBody::updateRestNodalPositions() +void btReducedDeformableBody::updateRestNodalPositions() { // update reset nodal position m_x0.resize(m_nFull); @@ -532,7 +532,7 @@ void btReducedSoftBody::updateRestNodalPositions() // reference notes: // https://ocw.mit.edu/courses/aeronautics-and-astronautics/16-07-dynamics-fall-2009/lecture-notes/MIT16_07F09_Lec26.pdf -void btReducedSoftBody::updateLocalInertiaTensorFromNodes() +void btReducedDeformableBody::updateLocalInertiaTensorFromNodes() { btMatrix3x3 inertia_tensor; inertia_tensor.setZero(); @@ -561,13 +561,13 @@ void btReducedSoftBody::updateLocalInertiaTensorFromNodes() m_invInertiaLocal = inertia_tensor.inverse(); } -void btReducedSoftBody::updateInitialInertiaTensor(const btMatrix3x3& rotation) +void btReducedDeformableBody::updateInitialInertiaTensor(const btMatrix3x3& rotation) { // m_invInertiaTensorWorldInitial = rotation.scaled(m_invInertiaLocal) * rotation.transpose(); m_invInertiaTensorWorldInitial = rotation * m_invInertiaLocal * rotation.transpose(); } -void btReducedSoftBody::updateModesByRotation(const btMatrix3x3& rotation) +void btReducedDeformableBody::updateModesByRotation(const btMatrix3x3& rotation) { for (int r = 0; r < m_nReduced; ++r) { @@ -584,18 +584,18 @@ void btReducedSoftBody::updateModesByRotation(const btMatrix3x3& rotation) } } -void btReducedSoftBody::updateInertiaTensor() +void btReducedDeformableBody::updateInertiaTensor() { m_invInertiaTensorWorld = m_rigidTransformWorld.getBasis() * m_invInertiaTensorWorldInitial * m_rigidTransformWorld.getBasis().transpose(); } -void btReducedSoftBody::applyDamping(btScalar timeStep) +void btReducedDeformableBody::applyDamping(btScalar timeStep) { m_linearVelocity *= btScalar(1) - m_linearDamping; m_angularDamping *= btScalar(1) - m_angularDamping; } -void btReducedSoftBody::applyCentralImpulse(const btVector3& impulse) +void btReducedDeformableBody::applyCentralImpulse(const btVector3& impulse) { m_linearVelocity += impulse * m_linearFactor * m_inverseMass; #if defined(BT_CLAMP_VELOCITY_TO) && BT_CLAMP_VELOCITY_TO > 0 @@ -603,7 +603,7 @@ void btReducedSoftBody::applyCentralImpulse(const btVector3& impulse) #endif } -void btReducedSoftBody::applyTorqueImpulse(const btVector3& torque) +void btReducedDeformableBody::applyTorqueImpulse(const btVector3& torque) { m_angularVelocity += m_interpolateInvInertiaTensorWorld * torque * m_angularFactor; #if defined(BT_CLAMP_VELOCITY_TO) && BT_CLAMP_VELOCITY_TO > 0 @@ -611,7 +611,7 @@ void btReducedSoftBody::applyTorqueImpulse(const btVector3& torque) #endif } -void btReducedSoftBody::internalApplyRigidImpulse(const btVector3& impulse, const btVector3& rel_pos) +void btReducedDeformableBody::internalApplyRigidImpulse(const btVector3& impulse, const btVector3& rel_pos) { if (m_inverseMass == btScalar(0.)) { @@ -625,14 +625,14 @@ void btReducedSoftBody::internalApplyRigidImpulse(const btVector3& impulse, cons m_internalDeltaAngularVelocity += m_interpolateInvInertiaTensorWorld * torque * m_angularFactor; } -btVector3 btReducedSoftBody::getRelativePos(int n_node) +btVector3 btReducedDeformableBody::getRelativePos(int n_node) { btMatrix3x3 rotation = m_interpolationWorldTransform.getBasis(); btVector3 ri = rotation * m_localMomentArm[n_node]; return ri; } -btMatrix3x3 btReducedSoftBody::getImpulseFactor(int n_node) +btMatrix3x3 btReducedDeformableBody::getImpulseFactor(int n_node) { // relative position btMatrix3x3 rotation = m_interpolationWorldTransform.getBasis(); @@ -692,7 +692,7 @@ btMatrix3x3 btReducedSoftBody::getImpulseFactor(int n_node) return m_rigidOnly ? K1 : K1 + K2; } -void btReducedSoftBody::internalApplyFullSpaceImpulse(const btVector3& impulse, const btVector3& rel_pos, int n_node, btScalar dt) +void btReducedDeformableBody::internalApplyFullSpaceImpulse(const btVector3& impulse, const btVector3& rel_pos, int n_node, btScalar dt) { if (!m_rigidOnly) { @@ -720,7 +720,7 @@ void btReducedSoftBody::internalApplyFullSpaceImpulse(const btVector3& impulse, internalApplyRigidImpulse(impulse, rel_pos); } -void btReducedSoftBody::applyFullSpaceNodalForce(const btVector3& f_ext, int n_node) +void btReducedDeformableBody::applyFullSpaceNodalForce(const btVector3& f_ext, int n_node) { // f_local = R^-1 * f_ext //TODO: interpoalted transfrom // btVector3 f_local = m_rigidTransformWorld.getBasis().transpose() * f_ext; @@ -741,13 +741,13 @@ void btReducedSoftBody::applyFullSpaceNodalForce(const btVector3& f_ext, int n_n } } -void btReducedSoftBody::applyRigidGravity(const btVector3& gravity, btScalar dt) +void btReducedDeformableBody::applyRigidGravity(const btVector3& gravity, btScalar dt) { // update rigid frame velocity m_linearVelocity += dt * gravity; } -void btReducedSoftBody::applyReducedElasticForce(const tDenseArray& reduce_dofs) +void btReducedDeformableBody::applyReducedElasticForce(const tDenseArray& reduce_dofs) { for (int r = 0; r < m_nReduced; ++r) { @@ -755,7 +755,7 @@ void btReducedSoftBody::applyReducedElasticForce(const tDenseArray& reduce_dofs) } } -void btReducedSoftBody::applyReducedDampingForce(const tDenseArray& reduce_vel) +void btReducedDeformableBody::applyReducedDampingForce(const tDenseArray& reduce_vel) { for (int r = 0; r < m_nReduced; ++r) { @@ -763,22 +763,22 @@ void btReducedSoftBody::applyReducedDampingForce(const tDenseArray& reduce_vel) } } -btScalar btReducedSoftBody::getTotalMass() const +btScalar btReducedDeformableBody::getTotalMass() const { return m_mass; } -btTransform& btReducedSoftBody::getRigidTransform() +btTransform& btReducedDeformableBody::getRigidTransform() { return m_rigidTransformWorld; } -const btVector3& btReducedSoftBody::getLinearVelocity() const +const btVector3& btReducedDeformableBody::getLinearVelocity() const { return m_linearVelocity; } -const btVector3& btReducedSoftBody::getAngularVelocity() const +const btVector3& btReducedDeformableBody::getAngularVelocity() const { return m_angularVelocity; } \ No newline at end of file diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h similarity index 97% rename from src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h rename to src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h index 99fcdb568..a0b21afed 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.h +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBody.h @@ -8,7 +8,7 @@ #include "LinearMath/btTransform.h" // Reduced deformable body is a simplified deformable object embedded in a rigid frame. -class btReducedSoftBody : public btSoftBody +class btReducedDeformableBody : public btSoftBody { public: // @@ -99,9 +99,9 @@ class btReducedSoftBody : public btSoftBody // // Api // - btReducedSoftBody(btSoftBodyWorldInfo* worldInfo, int node_count, const btVector3* x, const btScalar* m); + btReducedDeformableBody(btSoftBodyWorldInfo* worldInfo, int node_count, const btVector3* x, const btScalar* m); - ~btReducedSoftBody() {} + ~btReducedDeformableBody() {} // // initializing helpers diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.cpp b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.cpp similarity index 71% rename from src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.cpp rename to src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.cpp index ef9faf0a1..9efd16acc 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.cpp +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.cpp @@ -1,47 +1,47 @@ -#include "btReducedSoftBodyHelpers.h" +#include "btReducedDeformableBodyHelpers.h" #include "../btSoftBodyHelpers.h" #include #include #include -btReducedSoftBody* btReducedSoftBodyHelpers::createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes) +btReducedDeformableBody* btReducedDeformableBodyHelpers::createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes) { std::string filepath("../../../data/reduced_beam/"); // std::string filename = filepath + "beam_mesh.vtk"; std::string filename = filepath + "beam_mesh_origin.vtk"; - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str()); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createFromVtkFile(worldInfo, filename.c_str()); rsb->setReducedModes(num_modes, rsb->m_nodes.size()); - btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str()); + btReducedDeformableBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str()); return rsb; } -btReducedSoftBody* btReducedSoftBodyHelpers::createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes) +btReducedDeformableBody* btReducedDeformableBodyHelpers::createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes) { std::string filepath("../../../data/reduced_cube/"); std::string filename = filepath + "cube_mesh.vtk"; - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str()); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createFromVtkFile(worldInfo, filename.c_str()); rsb->setReducedModes(num_modes, rsb->m_nodes.size()); - btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str()); + btReducedDeformableBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str()); return rsb; } -btReducedSoftBody* btReducedSoftBodyHelpers::createReducedTorus(btSoftBodyWorldInfo& worldInfo, const int num_modes) +btReducedDeformableBody* btReducedDeformableBodyHelpers::createReducedTorus(btSoftBodyWorldInfo& worldInfo, const int num_modes) { std::string filepath("../../../data/reduced_torus/"); std::string filename = filepath + "torus_mesh.vtk"; - btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str()); + btReducedDeformableBody* rsb = btReducedDeformableBodyHelpers::createFromVtkFile(worldInfo, filename.c_str()); rsb->setReducedModes(num_modes, rsb->m_nodes.size()); - btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str()); + btReducedDeformableBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str()); return rsb; } -btReducedSoftBody* btReducedSoftBodyHelpers::createFromVtkFile(btSoftBodyWorldInfo& worldInfo, const char* vtk_file) +btReducedDeformableBody* btReducedDeformableBodyHelpers::createFromVtkFile(btSoftBodyWorldInfo& worldInfo, const char* vtk_file) { std::ifstream fs; fs.open(vtk_file); @@ -119,7 +119,7 @@ btReducedSoftBody* btReducedSoftBodyHelpers::createFromVtkFile(btSoftBodyWorldIn indices[indices_count++] = tet; } } - btReducedSoftBody* rsb = new btReducedSoftBody(&worldInfo, n_points, &X[0], 0); + btReducedDeformableBody* rsb = new btReducedDeformableBody(&worldInfo, n_points, &X[0], 0); for (int i = 0; i < n_tets; ++i) { @@ -149,25 +149,25 @@ btReducedSoftBody* btReducedSoftBodyHelpers::createFromVtkFile(btSoftBodyWorldIn return rsb; } -void btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(btReducedSoftBody* rsb, const char* file_path) +void btReducedDeformableBodyHelpers::readReducedDeformableInfoFromFiles(btReducedDeformableBody* rsb, const char* file_path) { // read in eigenmodes, stiffness and mass matrices std::string eigenvalues_file = std::string(file_path) + "eigenvalues.bin"; - btReducedSoftBodyHelpers::readBinaryVec(rsb->m_eigenvalues, rsb->m_nReduced, eigenvalues_file.c_str()); + btReducedDeformableBodyHelpers::readBinaryVec(rsb->m_eigenvalues, rsb->m_nReduced, eigenvalues_file.c_str()); std::string Kr_file = std::string(file_path) + "K_r_diag_mat.bin"; - btReducedSoftBodyHelpers::readBinaryVec(rsb->m_Kr, rsb->m_nReduced, Kr_file.c_str()); + btReducedDeformableBodyHelpers::readBinaryVec(rsb->m_Kr, rsb->m_nReduced, Kr_file.c_str()); // std::string Mr_file = std::string(file_path) + "M_r_diag_mat.bin"; - // btReducedSoftBodyHelpers::readBinaryVec(rsb->m_Mr, rsb->m_nReduced, Mr_file.c_str()); + // btReducedDeformableBodyHelpers::readBinaryVec(rsb->m_Mr, rsb->m_nReduced, Mr_file.c_str()); std::string modes_file = std::string(file_path) + "modes.bin"; - btReducedSoftBodyHelpers::readBinaryMat(rsb->m_modes, rsb->m_nReduced, 3 * rsb->m_nFull, modes_file.c_str()); + btReducedDeformableBodyHelpers::readBinaryMat(rsb->m_modes, rsb->m_nReduced, 3 * rsb->m_nFull, modes_file.c_str()); // read in full nodal mass std::string M_file = std::string(file_path) + "M_diag_mat.bin"; btAlignedObjectArray mass_array; - btReducedSoftBodyHelpers::readBinaryVec(mass_array, rsb->m_nFull, M_file.c_str()); + btReducedDeformableBodyHelpers::readBinaryVec(mass_array, rsb->m_nFull, M_file.c_str()); rsb->setMassProps(mass_array); // calculate the inertia tensor in the local frame @@ -178,7 +178,7 @@ void btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(btReducedSoftB } // read in a vector from the binary file -void btReducedSoftBodyHelpers::readBinaryVec(btReducedSoftBody::tDenseArray& vec, +void btReducedDeformableBodyHelpers::readBinaryVec(btReducedDeformableBody::tDenseArray& vec, const unsigned int n_size, // #entries read const char* file) { @@ -200,7 +200,7 @@ void btReducedSoftBodyHelpers::readBinaryVec(btReducedSoftBody::tDenseArray& vec } // read in a matrix from the binary file -void btReducedSoftBodyHelpers::readBinaryMat(btReducedSoftBody::tDenseMatrix& mat, +void btReducedDeformableBodyHelpers::readBinaryMat(btReducedDeformableBody::tDenseMatrix& mat, const unsigned int n_modes, // #modes, outer array size const unsigned int n_full, // inner array size const char* file) @@ -228,7 +228,7 @@ void btReducedSoftBodyHelpers::readBinaryMat(btReducedSoftBody::tDenseMatrix& ma f_in.close(); } -void btReducedSoftBodyHelpers::calculateLocalInertia(btVector3& inertia, const btScalar mass, const btVector3& half_extents, const btVector3& margin) +void btReducedDeformableBodyHelpers::calculateLocalInertia(btVector3& inertia, const btScalar mass, const btVector3& half_extents, const btVector3& margin) { btScalar lx = btScalar(2.) * (half_extents[0] + margin[0]); btScalar ly = btScalar(2.) * (half_extents[1] + margin[1]); diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h new file mode 100644 index 000000000..dc8fc4363 --- /dev/null +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodyHelpers.h @@ -0,0 +1,29 @@ +#ifndef BT_REDUCED_SOFT_BODY_HELPERS_H +#define BT_REDUCED_SOFT_BODY_HELPERS_H + +#include "btReducedDeformableBody.h" + +struct btReducedDeformableBodyHelpers +{ + // create a beam + static btReducedDeformableBody* createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes); + // create a cube + static btReducedDeformableBody* createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes); + // create a torus + static btReducedDeformableBody* createReducedTorus(btSoftBodyWorldInfo& worldInfo, const int num_modes); + + // read in geometry info from Vtk file + static btReducedDeformableBody* createFromVtkFile(btSoftBodyWorldInfo& worldInfo, const char* vtk_file); + // read in all reduced files + static void readReducedDeformableInfoFromFiles(btReducedDeformableBody* rsb, const char* file_path); + // read in a binary vector + static void readBinaryVec(btReducedDeformableBody::tDenseArray& vec, const unsigned int n_size, const char* file); + // read in a binary matrix + static void readBinaryMat(btReducedDeformableBody::tDenseMatrix& mat, const unsigned int n_modes, const unsigned int n_full, const char* file); + + // calculate the local inertia tensor for a box shape reduced deformable object + static void calculateLocalInertia(btVector3& inertia, const btScalar mass, const btVector3& half_extents, const btVector3& margin); +}; + + +#endif // BT_REDUCED_SOFT_BODY_HELPERS_H \ No newline at end of file diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.cpp similarity index 83% rename from src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp rename to src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.cpp index c283036aa..1d812d907 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.cpp @@ -1,7 +1,7 @@ -#include "btReducedSoftBodySolver.h" +#include "btReducedDeformableBodySolver.h" #include "../btDeformableMultiBodyDynamicsWorld.h" -btReducedSoftBodySolver::btReducedSoftBodySolver() +btReducedDeformableBodySolver::btReducedDeformableBodySolver() { m_ascendOrder = true; m_reducedSolver = true; @@ -10,12 +10,12 @@ btReducedSoftBodySolver::btReducedSoftBodySolver() m_gravity = btVector3(0, 0, 0); } -void btReducedSoftBodySolver::setGravity(const btVector3& gravity) +void btReducedDeformableBodySolver::setGravity(const btVector3& gravity) { m_gravity = gravity; } -void btReducedSoftBodySolver::reinitialize(const btAlignedObjectArray& bodies, btScalar dt) +void btReducedDeformableBodySolver::reinitialize(const btAlignedObjectArray& bodies, btScalar dt) { m_softBodies.copyFromArray(bodies); bool nodeUpdated = updateNodes(); @@ -58,7 +58,7 @@ void btReducedSoftBodySolver::reinitialize(const btAlignedObjectArray(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); rsb->m_contactNodesList.clear(); } @@ -66,7 +66,7 @@ void btReducedSoftBodySolver::reinitialize(const btAlignedObjectArray(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); rsb->m_nodeIndexOffset = sum; sum += rsb->m_nodes.size(); } @@ -74,7 +74,7 @@ void btReducedSoftBodySolver::reinitialize(const btAlignedObjectArray(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); if (!rsb->isActive()) { continue; @@ -136,11 +136,11 @@ void btReducedSoftBodySolver::predictReduceDeformableMotion(btScalar solverdt) } } -void btReducedSoftBodySolver::applyExplicitForce(btScalar solverdt) +void btReducedDeformableBodySolver::applyExplicitForce(btScalar solverdt) { for (int i = 0; i < m_softBodies.size(); ++i) { - btReducedSoftBody* rsb = static_cast(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); // apply gravity to the rigid frame, get m_linearVelocity at time^* rsb->applyRigidGravity(m_gravity, solverdt); @@ -160,11 +160,11 @@ void btReducedSoftBodySolver::applyExplicitForce(btScalar solverdt) } } -void btReducedSoftBodySolver::applyTransforms(btScalar timeStep) +void btReducedDeformableBodySolver::applyTransforms(btScalar timeStep) { for (int i = 0; i < m_softBodies.size(); ++i) { - btReducedSoftBody* rsb = static_cast(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); // rigid motion rsb->proceedToTransform(timeStep, true); @@ -193,11 +193,11 @@ void btReducedSoftBodySolver::applyTransforms(btScalar timeStep) } } -void btReducedSoftBodySolver::setConstraints(const btContactSolverInfo& infoGlobal) +void btReducedDeformableBodySolver::setConstraints(const btContactSolverInfo& infoGlobal) { for (int i = 0; i < m_softBodies.size(); ++i) { - btReducedSoftBody* rsb = static_cast(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); if (!rsb->isActive()) { continue; @@ -252,11 +252,11 @@ void btReducedSoftBodySolver::setConstraints(const btContactSolverInfo& infoGlob } } -void btReducedSoftBodySolver::pairConstraintWithSolverBody(btSolverBody& solverBody) +void btReducedDeformableBodySolver::pairConstraintWithSolverBody(btSolverBody& solverBody) { for (int i = 0; i < m_softBodies.size(); ++i) { - btReducedSoftBody* rsb = static_cast(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); // node vs rigid contact for (int k = 0; k < m_nodeRigidConstraints[i].size(); ++k) @@ -275,7 +275,7 @@ void btReducedSoftBodySolver::pairConstraintWithSolverBody(btSolverBody& solverB } } -btScalar btReducedSoftBodySolver::solveContactConstraints(btCollisionObject** deformableBodies, int numDeformableBodies, const btContactSolverInfo& infoGlobal) +btScalar btReducedDeformableBodySolver::solveContactConstraints(btCollisionObject** deformableBodies, int numDeformableBodies, const btContactSolverInfo& infoGlobal) { btScalar residualSquare = 0; @@ -284,7 +284,7 @@ btScalar btReducedSoftBodySolver::solveContactConstraints(btCollisionObject** de btAlignedObjectArray m_orderNonContactConstraintPool; btAlignedObjectArray m_orderContactConstraintPool; - btReducedSoftBody* rsb = static_cast(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); // shuffle the order of applying constraint m_orderNonContactConstraintPool.resize(m_staticConstraints[i].size()); @@ -349,12 +349,12 @@ btScalar btReducedSoftBodySolver::solveContactConstraints(btCollisionObject** de return residualSquare; } -void btReducedSoftBodySolver::deformableBodyInternalWriteBack() +void btReducedDeformableBodySolver::deformableBodyInternalWriteBack() { // reduced deformable update for (int i = 0; i < m_softBodies.size(); ++i) { - btReducedSoftBody* rsb = static_cast(m_softBodies[i]); + btReducedDeformableBody* rsb = static_cast(m_softBodies[i]); rsb->applyInternalVelocityChanges(); } m_ascendOrder = true; diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h similarity index 82% rename from src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h rename to src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h index 808bdb9e9..82e68427d 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.h +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableBodySolver.h @@ -1,13 +1,13 @@ -#ifndef BT_REDUCED_SOFT_BODY_SOLVER_H -#define BT_REDUCED_SOFT_BODY_SOLVER_H +#ifndef BT_REDUCED_DEFORMABLE_BODY_DYNAMICS_WORLD_H +#define BT_REDUCED_DEFORMABLE_BODY_DYNAMICS_WORLD_H #include "../btDeformableBodySolver.h" -#include "btReducedSoftBody.h" +#include "btReducedDeformableBody.h" #include "btReducedDeformableContactConstraint.h" -class btReducedSoftBody; +class btReducedDeformableBody; -class btReducedSoftBodySolver : public btDeformableBodySolver +class btReducedDeformableBodySolver : public btDeformableBodySolver { protected: bool m_ascendOrder; @@ -25,8 +25,8 @@ class btReducedSoftBodySolver : public btDeformableBodySolver btAlignedObjectArray > m_nodeRigidConstraints; btAlignedObjectArray > m_faceRigidConstraints; - btReducedSoftBodySolver(); - ~btReducedSoftBodySolver() {} + btReducedDeformableBodySolver(); + ~btReducedDeformableBodySolver() {} virtual void setGravity(const btVector3& gravity); @@ -62,4 +62,4 @@ class btReducedSoftBodySolver : public btDeformableBodySolver }; -#endif // BT_REDUCED_SOFT_BODY_DYNAMICS_WORLD_H \ No newline at end of file +#endif // BT_REDUCED_DEFORMABLE_BODY_DYNAMICS_WORLD_H \ No newline at end of file diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.cpp b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.cpp index 00a48c194..1ede391ca 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.cpp +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.cpp @@ -3,7 +3,7 @@ // ================= static constraints =================== btReducedDeformableStaticConstraint::btReducedDeformableStaticConstraint( - btReducedSoftBody* rsb, + btReducedDeformableBody* rsb, btSoftBody::Node* node, const btVector3& ri, const btVector3& x0, @@ -57,7 +57,7 @@ btVector3 btReducedDeformableStaticConstraint::getDeltaVa() const // ================= base contact constraints =================== btReducedDeformableRigidContactConstraint::btReducedDeformableRigidContactConstraint( - btReducedSoftBody* rsb, + btReducedDeformableBody* rsb, const btSoftBody::DeformableRigidContact& c, const btContactSolverInfo& infoGlobal, btScalar dt) @@ -318,7 +318,7 @@ void btReducedDeformableRigidContactConstraint::calculateTangentialImpulse(btSca // ================= node vs rigid constraints =================== btReducedDeformableNodeRigidContactConstraint::btReducedDeformableNodeRigidContactConstraint( - btReducedSoftBody* rsb, + btReducedDeformableBody* rsb, const btSoftBody::DeformableNodeRigidContact& contact, const btContactSolverInfo& infoGlobal, btScalar dt) @@ -534,7 +534,7 @@ void btReducedDeformableNodeRigidContactConstraint::applyImpulse(const btVector3 // ================= face vs rigid constraints =================== btReducedDeformableFaceRigidContactConstraint::btReducedDeformableFaceRigidContactConstraint( - btReducedSoftBody* rsb, + btReducedDeformableBody* rsb, const btSoftBody::DeformableFaceRigidContact& contact, const btContactSolverInfo& infoGlobal, btScalar dt, diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.h b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.h index fbbd29583..4f666b034 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.h +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedDeformableContactConstraint.h @@ -1,11 +1,11 @@ #include "../btDeformableContactConstraint.h" -#include "btReducedSoftBody.h" +#include "btReducedDeformableBody.h" // ================= static constraints =================== class btReducedDeformableStaticConstraint : public btDeformableStaticConstraint { public: - btReducedSoftBody* m_rsb; + btReducedDeformableBody* m_rsb; btScalar m_dt; btVector3 m_ri; btVector3 m_targetPos; @@ -16,7 +16,7 @@ class btReducedDeformableStaticConstraint : public btDeformableStaticConstraint btScalar m_appliedImpulse; btScalar m_erp; - btReducedDeformableStaticConstraint(btReducedSoftBody* rsb, + btReducedDeformableStaticConstraint(btReducedDeformableBody* rsb, btSoftBody::Node* node, const btVector3& ri, const btVector3& x0, @@ -46,7 +46,7 @@ class btReducedDeformableRigidContactConstraint : public btDeformableRigidContac int m_nodeQueryIndex; - btReducedSoftBody* m_rsb; + btReducedDeformableBody* m_rsb; btSolverBody* m_solverBody; btScalar m_dt; @@ -84,7 +84,7 @@ class btReducedDeformableRigidContactConstraint : public btDeformableRigidContac btVector3 m_linearComponentTangent; btVector3 m_angularComponentTangent; - btReducedDeformableRigidContactConstraint(btReducedSoftBody* rsb, + btReducedDeformableRigidContactConstraint(btReducedDeformableBody* rsb, const btSoftBody::DeformableRigidContact& c, const btContactSolverInfo& infoGlobal, btScalar dt); @@ -122,7 +122,7 @@ class btReducedDeformableNodeRigidContactConstraint : public btReducedDeformable public: btSoftBody::Node* m_node; - btReducedDeformableNodeRigidContactConstraint(btReducedSoftBody* rsb, + btReducedDeformableNodeRigidContactConstraint(btReducedDeformableBody* rsb, const btSoftBody::DeformableNodeRigidContact& contact, const btContactSolverInfo& infoGlobal, btScalar dt); @@ -164,7 +164,7 @@ class btReducedDeformableFaceRigidContactConstraint : public btReducedDeformable btSoftBody::Face* m_face; bool m_useStrainLimiting; - btReducedDeformableFaceRigidContactConstraint(btReducedSoftBody* rsb, + btReducedDeformableFaceRigidContactConstraint(btReducedDeformableBody* rsb, const btSoftBody::DeformableFaceRigidContact& contact, const btContactSolverInfo& infoGlobal, btScalar dt, diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h b/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h deleted file mode 100644 index 3f6f84068..000000000 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodyHelpers.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef BT_REDUCED_SOFT_BODY_HELPERS_H -#define BT_REDUCED_SOFT_BODY_HELPERS_H - -#include "btReducedSoftBody.h" - -struct btReducedSoftBodyHelpers -{ - // create a beam - static btReducedSoftBody* createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes); - // create a cube - static btReducedSoftBody* createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes); - // create a torus - static btReducedSoftBody* createReducedTorus(btSoftBodyWorldInfo& worldInfo, const int num_modes); - - // read in geometry info from Vtk file - static btReducedSoftBody* createFromVtkFile(btSoftBodyWorldInfo& worldInfo, const char* vtk_file); - // read in all reduced files - static void readReducedDeformableInfoFromFiles(btReducedSoftBody* rsb, const char* file_path); - // read in a binary vector - static void readBinaryVec(btReducedSoftBody::tDenseArray& vec, const unsigned int n_size, const char* file); - // read in a binary matrix - static void readBinaryMat(btReducedSoftBody::tDenseMatrix& mat, const unsigned int n_modes, const unsigned int n_full, const char* file); - - // calculate the local inertia tensor for a box shape reduced deformable object - static void calculateLocalInertia(btVector3& inertia, const btScalar mass, const btVector3& half_extents, const btVector3& margin); -}; - - -#endif // BT_REDUCED_SOFT_BODY_HELPERS_H \ No newline at end of file diff --git a/src/BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h b/src/BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h index b47d0e073..5971ecd9a 100644 --- a/src/BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h +++ b/src/BulletSoftBody/btDeformableMultiBodyDynamicsWorld.h @@ -21,7 +21,6 @@ #include "btDeformableMassSpringForce.h" // #include "btDeformableBodySolver.h" #include "btDeformableMultiBodyConstraintSolver.h" -#include "BulletReducedSoftBody/btReducedSoftBody.h" #include "btSoftBodyHelpers.h" #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" #include