mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-13 05:10:08 +00:00
make the impulse scaled with nodal mass. all binary mode files contains all modes info.
This commit is contained in:
parent
f6dbbd4e66
commit
237333d030
@ -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<btScalar> 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));
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -168,7 +168,6 @@ void btDeformableBackwardEulerObjective::applyForce(TVStack& force, bool setZero
|
||||
{
|
||||
if (psb->m_reducedModel)
|
||||
{
|
||||
btScalar scale = 100;
|
||||
// get reduced force
|
||||
btAlignedObjectArray<btScalar> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user