Skip to content
Snippets Groups Projects
Commit 2b75481d authored by tuanthienbk's avatar tuanthienbk
Browse files

fix minor bugs

parent 88d0168d
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,9 @@ void PbdObject::init(int nCons, ...)
exit(0);
}
}
state->setUniformMass(va_arg(args,double));
if (nCons > 0)
{
char* gstring = va_arg(args,char*);
......@@ -148,8 +151,6 @@ void PbdObject::init(int nCons, ...)
m_pbdModel->setNumberOfInterations(va_arg(args,int));
}
state->setUniformMass(va_arg(args,double));
if (m_physicsToCollidingGeomMap && m_collidingGeometry)
{
m_pbdModel->setProximity(va_arg(args,double));
......
......@@ -2,32 +2,14 @@
namespace imstk {
void PbdState::computeAABB(double &min_x, double &max_x, double &min_y, double &max_y, double &min_z, double &max_z)
{
min_x = 1e6;
max_x = -1e6;
min_y = 1e6;
max_y = -1e6;
min_z = 1e6;
max_z = -1e6;
for (int i = 0; i < m_pos.size(); ++i) {
Vec3d& p = m_pos[i];
if (p[0] < min_x) min_x = p[0];
if (p[0] > max_x) max_x = p[0];
if (p[1] < min_y) min_y = p[1];
if (p[1] > max_y) max_y = p[1];
if (p[2] < min_z) min_z = p[2];
if (p[2] > max_z) max_z = p[2];
}
}
void PbdState::integratePosition()
{
for (int i = 0; i < m_pos.size(); ++i) {
if (m_invMass[i] > 0) {
if (m_invMass[i] != 0.0) {
m_vel[i] += (m_acc[i] + gravity)*dt;
m_oldPos[i] = m_pos[i];
m_pos[i] += m_vel[i]*dt;
}
}
}
......@@ -35,7 +17,7 @@ void PbdState::integratePosition()
void PbdState::integrateVelocity()
{
for (int i = 0; i < m_pos.size(); ++i) {
if (m_invMass[i] > 0) {
if (m_invMass[i] != 0.0) {
m_vel[i] = (m_pos[i] - m_oldPos[i])/dt;
}
}
......
......@@ -60,7 +60,7 @@ public:
}
inline void setFixedPoint(const unsigned int& idx)
{
{
if ( idx < m_pos.size())
m_invMass[idx] = 0;
}
......@@ -88,7 +88,6 @@ public:
void integrateVelocity();
void computeAABB(double& min_x, double& max_x, double& min_y, double& max_y, double& min_z, double& max_z);
};
}
......
......@@ -925,11 +925,12 @@ void testPbdVolume()
deformableObj->setPhysicsToVisualMap(oneToOneNodalMap); //assign the computed map
deformableObj->init(/*Number of Constraints*/1,
/*Constraint configuration*/"FEM NeoHookean 100.0 0.3",
/*Mass*/1.0,
/*Gravity*/"0 -9.8 0",
/*TimeStep*/0.001,
/*FixedPoint*/"51 127 178",
/*NumberOfIterationInConstraintSolver*/5,
/*Mass*/1.0);
/*NumberOfIterationInConstraintSolver*/5
);
scene->addSceneObject(deformableObj);
......@@ -1009,11 +1010,12 @@ void testPbdCloth()
deformableObj->init(/*Number of constraints*/2,
/*Constraint configuration*/"Distance 0.1",
/*Constraint configuration*/"Dihedral 0.001",
/*Mass*/1.0,
/*Gravity*/"0 -9.8 0",
/*TimeStep*/0.001,
/*FixedPoint*/"1 20",
/*NumberOfIterationInConstraintSolver*/5,
/*Mass*/1.0);
/*NumberOfIterationInConstraintSolver*/5
);
scene->addSceneObject(deformableObj);
sdk->setCurrentScene("PositionBasedDynamicsTest");
......@@ -1055,11 +1057,11 @@ void testPbdCollision()
deformableObj->setPhysicsToVisualMap(oneToOneNodalMap); //assign the computed map
deformableObj->init(/*Number of Constraints*/1,
/*Constraint configuration*/"FEM NeoHookean 100.0 0.3",
/*Mass*/1.0,
/*Gravity*/"0 -9.8 0",
/*TimeStep*/0.001,
/*FixedPoint*/"",
/*NumberOfIterationInConstraintSolver*/5,
/*Mass*/1.0,
/*Proximity*/0.1,
/*Contact stiffness*/0.01);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment