@@ -66,9 +66,11 @@ int main( int argc, char **argv )
6666 MiniGL::setViewport (40 .0f , 0 .1f , 500 .0f , Vector3r (5.0 , 10.0 , 30.0 ), Vector3r (5.0 , 0.0 , 0.0 ));
6767
6868 TwType enumType2 = TwDefineEnum (" SimulationMethodType" , NULL , 0 );
69- TwAddVarCB (MiniGL::getTweakBar (), " SimulationMethod" , enumType2, setSimulationMethod, getSimulationMethod, &simulationMethod, " label='Simulation method' enum='0 {None}, 1 {Distance constraints}, 2 {FEM based PBD}, 3 {Strain based dynamics}' group=Simulation" );
69+ TwAddVarCB (MiniGL::getTweakBar (), " SimulationMethod" , enumType2, setSimulationMethod, getSimulationMethod, &simulationMethod,
70+ " label='Simulation method' enum='0 {None}, 1 {Distance constraints}, 2 {FEM based PBD}, 3 {Strain based dynamics}, 4 {XPBD distance constraints}' group=Simulation" );
7071 TwType enumType3 = TwDefineEnum (" BendingMethodType" , NULL , 0 );
71- TwAddVarCB (MiniGL::getTweakBar (), " BendingMethod" , enumType3, setBendingMethod, getBendingMethod, &bendingMethod, " label='Bending method' enum='0 {None}, 1 {Dihedral angle}, 2 {Isometric bending}' group=Bending" );
72+ TwAddVarCB (MiniGL::getTweakBar (), " BendingMethod" , enumType3, setBendingMethod, getBendingMethod, &bendingMethod,
73+ " label='Bending method' enum='0 {None}, 1 {Dihedral angle}, 2 {Isometric bending}, 3 {XPBD isometric bending}' group=Bending" );
7274
7375 MiniGL::mainLoop ();
7476
@@ -223,6 +225,8 @@ void createMesh()
223225 // init constraints
224226 for (unsigned int cm = 0 ; cm < model->getTriangleModels ().size (); cm++)
225227 {
228+ model->setValue <Real>(SimulationModel::CLOTH_STIFFNESS, 1.0 );
229+ model->setValue <Real>(SimulationModel::CLOTH_BENDING_STIFFNESS, 0.01 );
226230 if (simulationMethod == 1 )
227231 {
228232 const unsigned int offset = model->getTriangleModels ()[cm]->getIndexOffset ();
@@ -264,6 +268,20 @@ void createMesh()
264268 model->addStrainTriangleConstraint (v1, v2, v3);
265269 }
266270 }
271+ else if (simulationMethod == 4 )
272+ {
273+ model->setValue <Real>(SimulationModel::CLOTH_STIFFNESS, 100000 );
274+ const unsigned int offset = model->getTriangleModels ()[cm]->getIndexOffset ();
275+ const unsigned int nEdges = model->getTriangleModels ()[cm]->getParticleMesh ().numEdges ();
276+ const IndexedFaceMesh::Edge* edges = model->getTriangleModels ()[cm]->getParticleMesh ().getEdges ().data ();
277+ for (unsigned int i = 0 ; i < nEdges; i++)
278+ {
279+ const unsigned int v1 = edges[i].m_vert [0 ] + offset;
280+ const unsigned int v2 = edges[i].m_vert [1 ] + offset;
281+
282+ model->addDistanceConstraint_XPBD (v1, v2);
283+ }
284+ }
267285 if (bendingMethod != 0 )
268286 {
269287 const unsigned int offset = model->getTriangleModels ()[cm]->getIndexOffset ();
@@ -308,6 +326,11 @@ void createMesh()
308326 model->addDihedralConstraint (vertex1, vertex2, vertex3, vertex4);
309327 else if (bendingMethod == 2 )
310328 model->addIsometricBendingConstraint (vertex1, vertex2, vertex3, vertex4);
329+ else if (bendingMethod == 3 )
330+ {
331+ model->setValue <Real>(SimulationModel::CLOTH_BENDING_STIFFNESS, 100.0 );
332+ model->addIsometricBendingConstraint_XPBD (vertex1, vertex2, vertex3, vertex4);
333+ }
311334 }
312335 }
313336 }
0 commit comments