diff --git a/Examples/MultipleScenes/multipleScenes.cpp b/Examples/MultipleScenes/multipleScenes.cpp index 1087ddb0035e5adf375f41b9be9c43d29ca1c373..abeee6b13e91d5c3d07ea42c9cc66212790196cc 100644 --- a/Examples/MultipleScenes/multipleScenes.cpp +++ b/Examples/MultipleScenes/multipleScenes.cpp @@ -159,7 +159,7 @@ createClothScene(std::shared_ptr<SimulationManager> simManager, const char* scen // Other parameters pbdParams->m_uniformMassValue = 1.0; pbdParams->m_gravity = Vec3d(0, -9.8, 0); - pbdParams->m_dt = 0.03; + pbdParams->m_DefaultDt = 0.03; pbdParams->m_maxIter = 5; // Set the parameters diff --git a/Examples/PBD/PBDCloth/pbdClothExample.cpp b/Examples/PBD/PBDCloth/pbdClothExample.cpp index 08cc288f951470dbee0ffbd00895353a2b4eb3ce..a6241dcd4184a29f2a3560b8f45d3b5d21e49dee 100644 --- a/Examples/PBD/PBDCloth/pbdClothExample.cpp +++ b/Examples/PBD/PBDCloth/pbdClothExample.cpp @@ -42,8 +42,8 @@ main() StdVectorOfVec3d vertList; const double width = 10.0; const double height = 10.0; - const int nRows = 11; - const int nCols = 11; + const int nRows = 16; + const int nCols = 16; vertList.resize(nRows * nCols); const double dy = width / (double)(nCols - 1); const double dx = height / (double)(nRows - 1); @@ -64,8 +64,22 @@ main() for (std::size_t j = 0; j < nCols - 1; j++) { SurfaceMesh::TriangleArray tri[2]; - tri[0] = { { i* nCols + j, (i + 1) * nCols + j, i* nCols + j + 1 } }; - tri[1] = { { (i + 1) * nCols + j + 1, i* nCols + j + 1, (i + 1) * nCols + j } }; + const size_t index1 = i * nCols + j; + const size_t index2 = index1 + nCols; + const size_t index3 = index1 + 1; + const size_t index4 = index2 + 1; + + // Interleave [/][\] + if (i % 2 ^ j % 2) + { + tri[0] = { { index1, index2, index3 } }; + tri[1] = { { index4, index3, index2 } }; + } + else + { + tri[0] = { { index2, index4, index1 } }; + tri[1] = { { index4, index3, index1 } }; + } triangles.push_back(tri[0]); triangles.push_back(tri[1]); } @@ -94,7 +108,7 @@ main() // Other parameters pbdParams->m_uniformMassValue = 1.0; pbdParams->m_gravity = Vec3d(0, -9.8, 0); - pbdParams->m_dt = 0.03; + pbdParams->m_DefaultDt = 0.005; pbdParams->m_maxIter = 5; // Set the parameters diff --git a/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp b/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp index 79d8892d46fdab1c985029fdd459da5ca57f1b8e..aa670f72b4ff2d771dace948cd363cdb631deaaf 100644 --- a/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp +++ b/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp @@ -125,7 +125,7 @@ generateDragon(const std::shared_ptr<imstk::Scene>& scene, // Other parameters pbdParams->m_uniformMassValue = 5.0; pbdParams->m_gravity = Vec3d(0, -1.0, 0); - pbdParams->m_dt = 0.01; + pbdParams->m_DefaultDt = 0.01; pbdParams->m_maxIter = 20; pbdParams->m_proximity = 0.5; pbdParams->m_contactStiffness = 0.1; diff --git a/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp b/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp index 3f4d3bfb166fcbb09e2449b8784a2c8845dc8824..9b814028fc1a6310adce158114861c1609747ead 100644 --- a/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp +++ b/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp @@ -85,7 +85,7 @@ main() // Other parameters pbdParams->m_uniformMassValue = 1.0; pbdParams->m_gravity = Vec3d(0, -10.0, 0); - pbdParams->m_dt = 0.02; + pbdParams->m_DefaultDt = 0.01; pbdParams->m_maxIter = 5; pbdParams->m_proximity = 0.3; pbdParams->m_contactStiffness = 0.1; diff --git a/Examples/PBD/PBDFluids/PBDFluidsExample.cpp b/Examples/PBD/PBDFluids/PBDFluidsExample.cpp index 90e2470489800304e6272db4dbcc1b1f39ae3c21..6ad21b5c9ac1dd746e513ba0fcebed5e893c00fa 100644 --- a/Examples/PBD/PBDFluids/PBDFluidsExample.cpp +++ b/Examples/PBD/PBDFluids/PBDFluidsExample.cpp @@ -72,7 +72,7 @@ main() // Other parameters pbdParams->m_uniformMassValue = 1.0; pbdParams->m_gravity = Vec3d(0, -9.8, 0); - pbdParams->m_dt = 0.05; + pbdParams->m_DefaultDt = 0.01; pbdParams->m_maxIter = 2; pbdParams->m_proximity = 0.01; pbdParams->m_contactStiffness = 0.2; diff --git a/Examples/PBD/PBDString/pbdStringExample.cpp b/Examples/PBD/PBDString/pbdStringExample.cpp index 2596f31429db30aed46683f21082436f4f87963f..c94f3cdee96f1dd0fcf5b3836aa10f64a6aa5d63 100644 --- a/Examples/PBD/PBDString/pbdStringExample.cpp +++ b/Examples/PBD/PBDString/pbdStringExample.cpp @@ -36,15 +36,15 @@ int main() { auto simManager = std::make_shared<SimulationManager>(); - auto scene = simManager->createNewScene("PBDString"); + auto scene = simManager->createNewScene("PBDString"); // Setup N separate string simulations with varying bend stiffnesses - const unsigned int numStrings = 8; - const unsigned int numVerts = 30; - const double stringSpacing = 2.0; // How far each string is apart - const double stringLength = 10.0; // Total length of string - const Color startColor = Color::Red; // Color of first string - const Color endColor = Color::Green; // Color of last string + const unsigned int numStrings = 8; + const unsigned int numVerts = 30; + const double stringSpacing = 2.0; // How far each string is apart + const double stringLength = 10.0; // Total length of string + const Color startColor = Color::Red; // Color of first string + const Color endColor = Color::Green; // Color of last string struct PbdSim { @@ -92,10 +92,10 @@ main() sims[i].params = std::make_shared<PBDModelConfig>(); sims[i].params->enableConstraint(PbdConstraint::Type::Distance, 0.001); sims[i].params->enableConstraint(PbdConstraint::Type::Bend, static_cast<double>(i) * 0.1 / numStrings + 0.001); - sims[i].params->m_fixedNodeIds = { 0 }; // Fix the first node in each string + sims[i].params->m_fixedNodeIds = { 0 }; sims[i].params->m_uniformMassValue = 5.0; sims[i].params->m_gravity = Vec3d(0, -9.8, 0); - sims[i].params->m_dt = 0.0005; + sims[i].params->m_DefaultDt = 0.0005; sims[i].params->m_maxIter = 5; // Set the parameters @@ -125,10 +125,10 @@ main() scene->getCamera()->setPosition(0.0, 0.0, 15.0); // Move the points every frame - double t = 0.0; - const double dt = 0.0005; - const double radius = 1.5; - auto movePoints = + double t = 0.0; + const double dt = 0.0005; + const double radius = 1.5; + auto movePoints = [&sims, &t, dt, radius](Module* module) { for (unsigned int i = 0; i < sims.size(); i++) @@ -136,9 +136,9 @@ main() Vec3d pos = sims[i].model->getCurrentState()->getVertexPosition(0); // Move in circle, derivatives of parametric eq of circle sims[i].model->getCurrentState()->setVertexPosition(0, imstk::Vec3d( - pos.x() + -std::sin(t) * radius * dt, - pos.y(), - pos.z() + std::cos(t) * radius * dt)); + pos.x() + -std::sin(t) * radius * dt, + pos.y(), + pos.z() + std::cos(t) * radius * dt)); } t += dt; };