Merge pull request #2468 from xhan0619/fix-sleep

Fix sleep
This commit is contained in:
erwincoumans
2019-11-06 12:07:20 -08:00
committed by GitHub
4 changed files with 27 additions and 21 deletions

View File

@@ -28,6 +28,7 @@
#include "../Importers/ImportURDFDemo/BulletUrdfImporter.h" #include "../Importers/ImportURDFDemo/BulletUrdfImporter.h"
#include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h" #include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h"
#include "../Importers/ImportURDFDemo/URDF2Bullet.h" #include "../Importers/ImportURDFDemo/URDF2Bullet.h"
#include "../Utils/b3BulletDefaultFileIO.h"
#include "../CommonInterfaces/CommonMultiBodyBase.h" #include "../CommonInterfaces/CommonMultiBodyBase.h"
#include "../CommonInterfaces/CommonGraphicsAppInterface.h" #include "../CommonInterfaces/CommonGraphicsAppInterface.h"
#include "../CommonInterfaces/CommonParameterInterface.h" #include "../CommonInterfaces/CommonParameterInterface.h"
@@ -272,23 +273,24 @@ void GraspDeformable::initPhysics()
// create a soft block // create a soft block
if (1) if (1)
{ {
char relative_path[1024]; char absolute_path[1024];
// b3FileUtils::findFile("banana.vtk", relative_path, 1024); b3BulletDefaultFileIO fileio;
// b3FileUtils::findFile("ball.vtk", relative_path, 1024); fileio.findResourcePath("ditto.vtk", absolute_path, 1024);
// b3FileUtils::findFile("deformable_crumpled_napkin_sim.vtk", relative_path, 1024); // fileio.findResourcePath("banana.vtk", absolute_path, 1024);
// b3FileUtils::findFile("single_tet.vtk", relative_path, 1024); // fileio.findResourcePath("ball.vtk", absolute_path, 1024);
// b3FileUtils::findFile("tube.vtk", relative_path, 1024); // fileio.findResourcePath("deformable_crumpled_napkin_sim.vtk", absolute_path, 1024);
// b3FileUtils::findFile("torus.vtk", relative_path, 1024); // fileio.findResourcePath("single_tet.vtk", absolute_path, 1024);
// b3FileUtils::findFile("paper_roll.vtk", relative_path, 1024); // fileio.findResourcePath("tube.vtk", absolute_path, 1024);
// b3FileUtils::findFile("bread.vtk", relative_path, 1024); // fileio.findResourcePath("torus.vtk", absolute_path, 1024);
b3FileUtils::findFile("ditto.vtk", relative_path, 1024); // fileio.findResourcePath("paper_roll.vtk", absolute_path, 1024);
// b3FileUtils::findFile("boot.vtk", relative_path, 1024); // fileio.findResourcePath("bread.vtk", absolute_path, 1024);
// fileio.findResourcePath("boot.vtk", absolute_path, 1024);
// btSoftBody* psb = btSoftBodyHelpers::CreateFromTetGenData(getDeformableDynamicsWorld()->getWorldInfo(), // btSoftBody* psb = btSoftBodyHelpers::CreateFromTetGenData(getDeformableDynamicsWorld()->getWorldInfo(),
// TetraCube::getElements(), // TetraCube::getElements(),
// 0, // 0,
// TetraCube::getNodes(), // TetraCube::getNodes(),
// false, true, true); // false, true, true);
btSoftBody* psb = btSoftBodyHelpers::CreateFromVtkFile(getDeformableDynamicsWorld()->getWorldInfo(), relative_path); btSoftBody* psb = btSoftBodyHelpers::CreateFromVtkFile(getDeformableDynamicsWorld()->getWorldInfo(), absolute_path);
// psb->scale(btVector3(30, 30, 30)); // for banana // psb->scale(btVector3(30, 30, 30)); // for banana
psb->scale(btVector3(.7, .7, .7)); psb->scale(btVector3(.7, .7, .7));

View File

@@ -103,6 +103,7 @@ void btDeformableBackwardEulerObjective::applyForce(TVStack& force, bool setZero
btSoftBody* psb = m_softBodies[i]; btSoftBody* psb = m_softBodies[i];
if (!psb->isActive()) if (!psb->isActive())
{ {
counter += psb->m_nodes.size();
continue; continue;
} }
for (int j = 0; j < psb->m_nodes.size(); ++j) for (int j = 0; j < psb->m_nodes.size(); ++j)

View File

@@ -18,7 +18,7 @@
#include "btDeformableBodySolver.h" #include "btDeformableBodySolver.h"
#include "btSoftBodyInternals.h" #include "btSoftBodyInternals.h"
#include "LinearMath/btQuickprof.h" #include "LinearMath/btQuickprof.h"
static const int kMaxConjugateGradientIterations = 200; static const int kMaxConjugateGradientIterations = 50;
btDeformableBodySolver::btDeformableBodySolver() btDeformableBodySolver::btDeformableBodySolver()
: m_numNodes(0) : m_numNodes(0)
, m_cg(kMaxConjugateGradientIterations) , m_cg(kMaxConjugateGradientIterations)
@@ -251,6 +251,7 @@ void btDeformableBodySolver::updateVelocity()
psb->m_maxSpeedSquared = 0; psb->m_maxSpeedSquared = 0;
if (!psb->isActive()) if (!psb->isActive())
{ {
counter += psb->m_nodes.size();
continue; continue;
} }
for (int j = 0; j < psb->m_nodes.size(); ++j) for (int j = 0; j < psb->m_nodes.size(); ++j)
@@ -275,6 +276,7 @@ void btDeformableBodySolver::updateTempPosition()
btSoftBody* psb = m_softBodies[i]; btSoftBody* psb = m_softBodies[i];
if (!psb->isActive()) if (!psb->isActive())
{ {
counter += psb->m_nodes.size();
continue; continue;
} }
for (int j = 0; j < psb->m_nodes.size(); ++j) for (int j = 0; j < psb->m_nodes.size(); ++j)
@@ -307,6 +309,7 @@ void btDeformableBodySolver::setupDeformableSolve(bool implicit)
btSoftBody* psb = m_softBodies[i]; btSoftBody* psb = m_softBodies[i];
if (!psb->isActive()) if (!psb->isActive())
{ {
counter += psb->m_nodes.size();
continue; continue;
} }
for (int j = 0; j < psb->m_nodes.size(); ++j) for (int j = 0; j < psb->m_nodes.size(); ++j)

View File

@@ -175,7 +175,7 @@ public:
btSoftBody::Tetra& tetra = psb->m_tetras[j]; btSoftBody::Tetra& tetra = psb->m_tetras[j];
btMatrix3x3 P; btMatrix3x3 P;
firstPiola(psb->m_tetraScratches[j],P); firstPiola(psb->m_tetraScratches[j],P);
#if USE_SVD #ifdef USE_SVD
if (max_p > 0) if (max_p > 0)
{ {
// since we want to clamp the principal stress to max_p, we only need to // since we want to clamp the principal stress to max_p, we only need to