diff --git a/examples/ReducedDeformableDemo/BasicTest.cpp b/examples/ReducedDeformableDemo/BasicTest.cpp index ece6dfa23..ae2a81bc0 100644 --- a/examples/ReducedDeformableDemo/BasicTest.cpp +++ b/examples/ReducedDeformableDemo/BasicTest.cpp @@ -223,13 +223,6 @@ void BasicTest::initPhysics() for (int k = 0; k < 3; ++k) psb->m_x0[3 * i + k] = psb->m_nodes[i].m_x[k]; - std::ofstream outfile1("before_map.txt"); - for (int i = 0; i < psb->m_nodes.size(); ++i) { - for (int k = 0; k < 3; ++k) - outfile1 << psb->m_nodes[i].m_x[k] << '\n'; - } - outfile1.close(); - getDeformableDynamicsWorld()->addSoftBody(psb); psb->scale(btVector3(2, 2, 2)); psb->translate(btVector3(0, 7, 0)); @@ -242,6 +235,13 @@ void BasicTest::initPhysics() psb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN; psb->m_sleepingThreshold = 0; btSoftBodyHelpers::generateBoundaryFaces(psb); + + std::string M_file("../../../examples/SoftDemo/M_diag_mat.bin"); + btAlignedObjectArray mass_array; + btSoftBodyHelpers::readBinary(mass_array, 0, 3 * m_nFull, 3 * m_nFull, M_file.c_str()); + // assign mass to nodes + for (int i = 0; i < psb->m_nodes.size(); ++i) + psb->m_nodes[i].m_im = mass_array[3 * i]; // here we use m_im as the actual mass not the mass inverse psb->setVelocity(btVector3(0, -COLLIDING_VELOCITY, 0)); diff --git a/examples/SoftDemo/K_r_diag_mat.bin b/examples/SoftDemo/K_r_diag_mat.bin index f3f0e6922..1e3df0cea 100644 Binary files a/examples/SoftDemo/K_r_diag_mat.bin and b/examples/SoftDemo/K_r_diag_mat.bin differ diff --git a/examples/SoftDemo/M_r_diag_mat.bin b/examples/SoftDemo/M_r_diag_mat.bin index e4e3106d0..75af6a435 100644 Binary files a/examples/SoftDemo/M_r_diag_mat.bin and b/examples/SoftDemo/M_r_diag_mat.bin differ diff --git a/examples/SoftDemo/eigenvalues.bin b/examples/SoftDemo/eigenvalues.bin index 870103f7c..80794642c 100644 Binary files a/examples/SoftDemo/eigenvalues.bin and b/examples/SoftDemo/eigenvalues.bin differ diff --git a/examples/SoftDemo/modes.bin b/examples/SoftDemo/modes.bin index 5ff7d8e54..c971c0261 100644 Binary files a/examples/SoftDemo/modes.bin and b/examples/SoftDemo/modes.bin differ diff --git a/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp b/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp index b03acff7e..19f868bda 100644 --- a/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp +++ b/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp @@ -168,7 +168,6 @@ void btDeformableBackwardEulerObjective::applyForce(TVStack& force, bool setZero { if (psb->m_reducedModel) { - btScalar scale = 100; // get reduced force btAlignedObjectArray reduced_force; reduced_force.resize(psb->m_reducedDofs.size(), 0); @@ -181,10 +180,8 @@ void btDeformableBackwardEulerObjective::applyForce(TVStack& force, bool setZero // reduced_force[r] += scale * psb->m_modes[r][3 * i + k] * force[i][k]; // std::cout << reduced_force[r] << '\t'; - - //TODO: increase stiffness - // reduced_force[r] += scale * psb->m_Kr[r] * psb->m_reducedDofs[r]; - reduced_force[r] += scale * psb->m_Kr[r] * (psb->m_reducedDofs[r] + 0.1 * psb->m_reducedVelocity[r]); + + reduced_force[r] += psb->m_Kr[r] * (psb->m_reducedDofs[r] + 0.1 * psb->m_reducedVelocity[r]); // std::cout << reduced_force[r] << '\n'; // std::cout << psb->m_Kr[r] << "\t" << psb->m_reducedDofs[r] << "\n"; } @@ -192,14 +189,14 @@ void btDeformableBackwardEulerObjective::applyForce(TVStack& force, bool setZero // apply impulses to reduced deformable objects static btScalar sim_time = 0; - static btScalar target_vel = 5; + static btScalar target_vel = 20; static bool apply_impulse = true; if (psb->m_reducedModel && apply_impulse && sim_time > 1) { sim_time += m_dt; apply_impulse = false; - btScalar f_imp = (target_vel - psb->m_nodes[0].m_v[1]) / m_dt;// TODO: need full mass? + btScalar f_imp = psb->m_nodes[i].m_im * (target_vel - psb->m_nodes[0].m_v[1]) / m_dt; for (int i = 0; i < psb->m_reducedDofs.size(); ++i) { reduced_force[i] += psb->m_modes[i][0 * 3 + 1] * f_imp;