Hi all, I used Bullet for couple of months and started to use the OpenCL solvers provided in the release 2.83.
I used ~46K spheres( r=0.1f ) with b3GpuRigidBodyPipeline::createPoint2PointConstraint(...) to approximate a cloth draping on a
static sphere ( R=5.f ). However, the result looks quite bad as shown in the picture. The problem is the distance bewteen each pair of constrainted spheres
is not limited by the constraint. The approximated cloth is too elastic. I tried Fixed constraint but gave an even worst result.
For the general 6Dof constraint, I cannot really understand the physical meaning by just reading the codes. It there any suggestion to have a tight constraint?
A simplified mesh (~15K sphere) to show the network and the constraints failure.
OpenCL constraints elasticity problem
-
- Posts: 4
- Joined: Thu Nov 26, 2015 2:33 pm
OpenCL constraints elasticity problem
Last edited by ihmc3jn09hk on Fri Nov 27, 2015 6:05 am, edited 1 time in total.
-
- Posts: 73
- Joined: Fri May 01, 2015 8:23 pm
Re: OpenCL constraints elasticity problem
Ive used the bullet gpu pipeline and constraints post the code you may be doing something wrong ill take a look at it.
-
- Posts: 4
- Joined: Thu Nov 26, 2015 2:33 pm
Re: OpenCL constraints elasticity problem
Let focuses on the setupScene() part cuz the rest is just the referencing to the Bullet OpenCL examples.
Code: Select all
struct BPCL_RB_Data
class b3GpuRigidBodyPipeline* m_rigidBodyPipeline;
class b3GpuNarrowPhase* m_np;
class b3GpuBroadphaseInterface* m_bp;
class b3DynamicBvhBroadphase* m_broadphaseDbvt;
b3Config m_config;
}
void initPhysics()
{
...
BPCL_RB_Data* m_pRigidBodyData = new BPCL_RB_Data(); //Initialized the data somewhere
...
setupScene();
m_pRigidBodyData->m_rigidBodyPipeline->writeAllInstancesToGpu();
m_pRigidBodyData->m_np->writeAllBodiesToGpu();
m_pRigidBodyData->m_bp->writeAabbsToGpu();
...
}
void setupScene(){
float radius = 5.f;
int index = 0;
int colIndex = m_pRigidBodyData->m_np->registerSphereShape(radius);
{ //Static body
float mass = 0.f;
b3Vector3 position=b3MakeVector3(0.f, 5.f, 0.f);
b3Quaternion orn(0.f, 0.f, 0.f, 1.f );
int pid = m_pRigidBodyData->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index, false );
++index;
}
...
vList; <------ Contains the mesh vertices with all normals pointing upward (y-dir) (0,1,0)
...
{
float mass = 1e-3f,
radius = 1e-1f;
int colIndex = m_pRigidBodyData->m_np->registerSphereShape(radius);
//Build the rigid body network
foreach ( auto v, vList ){
b3Vector4 position=b3MakeVector4(v.x(), v.y(), v.z(), 0);
b3Quaternion orn( 0.f, 0.f, 0.f, 1.f );
int pid = m_pRigidBodyData->m_rigidBodyPipeline->registerPhysicsInstance( mass, position, orn, colIndex, index, false );
++index;
}
}
...
linksList; <------ Contains the mesh edges with indices to the vertices
...
const int numLinks = linksList.Count();
for (int i = 0; i < numLinks; ++i )
{
const 2dex& _2d = linksList[i];
int ptAID = _2d.i,
ptBID = _2d.j;
b3Vector4 pivotA = vList[ptAID],
pivotB = vList[ptBID];
b3Quaternion ornA( 0.f, 0.f, 0.f, 1.f ),
ornB( 0.f, 0.f, 0.f, 1.f );
b3Vector3 pivotWorld = (pivotA + pivotB)*0.5f;
b3Transform transA, transB;
transA.setIdentity();
transA.setOrigin(pivotA);
transA.setRotation(ornA);
transB.setIdentity();
transB.setOrigin(pivotB);
transB.setRotation(ornB);
b3Vector3 pivotInA = transA.inverse()*pivotWorld;
b3Vector3 pivotInB = transB.inverse()*pivotWorld;
b3Transform frameInA, frameInB;
frameInA.setIdentity();
frameInB.setIdentity();
frameInA.setOrigin(pivotInA);
frameInB.setOrigin(pivotInB);
b3Quaternion relTargetAB = frameInA.getRotation()*frameInB.getRotation().inverse();
//b3Generic6DofConstraint* p6Dof = new b3Generic6DofConstraint(ptAID + 1, ptBID + 1,frameInA, frameInB, true, (const b3RigidBodyData*) m_pRigidBodyData->m_rigidBodyPipeline->getBodyBuffer()); //Dont know how to use
//m_pRigidBodyData->m_rigidBodyPipeline->addConstraint( p6Dof );
int cid = m_pRigidBodyData->m_rigidBodyPipeline->createPoint2PointConstraint(ptAID + 1, ptBID + 1, pivotInA, pivotInB, 1e5f); //Offset 1 for the registered big sphere
//int cid = m_pRigidBodyData->m_rigidBodyPipeline->createFixedConstraint(ptAID + 1, ptBID + 1, pivotInA, pivotInB, relTargetAB, 100000.f);
}
}
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: OpenCL constraints elasticity problem
The OpenCL rigid body constraint solver only uses 4 solver iterations by default, which is likely not enough for your simulation.
You could try using a smaller time step and more iterations.
There is also an cloth-specific OpenCL implementation based on verlet integration/position based dynamics.
I removed in recent versions of Bullet, but you could digg up an older version of Bullet and check it out.
Furthermore, there is an implicit cloth by Stan Melax in Bullet/examples/Experiments/ImplicitCloth. You could try that out as well.
You could try using a smaller time step and more iterations.
There is also an cloth-specific OpenCL implementation based on verlet integration/position based dynamics.
I removed in recent versions of Bullet, but you could digg up an older version of Bullet and check it out.
Furthermore, there is an implicit cloth by Stan Melax in Bullet/examples/Experiments/ImplicitCloth. You could try that out as well.
-
- Posts: 3
- Joined: Thu Dec 31, 2015 8:22 pm
Re: OpenCL constraints elasticity problem
Can you please share the code for creating the GUI?
Thanks.
Thanks.