custom implicit geometry shape

woqk
Posts: 2
Joined: Fri Dec 19, 2014 12:11 am

custom implicit geometry shape

Post by woqk »

hi, I want to make a custom shape wth implicit geometry, like sphere, box, cone, capsule etc.

For testing, I take btCapsuleShape and make it to return the implicit surface of a sphere.

support vector function:
btVector3 v_norm = v0 / v0.length2();
return v_norm * getRadius();

I change this in all places I find code related to capsule.

Result: shape looks like sphere, but with many triangles, not smooth like btSphereShape. When in contact, the shape jumps on surface and falls through surfaces a little then gets pushed back to top.

What am I doing wrong?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: custom implicit geometry shape

Post by drleviathan »

I'm mildly interested in figuring out what you did wrong but I don't think you've provided enough information for your question to be answered. All I can say at this point is that altering the normal of the btCapsuleShape is not enough to change its behavior for collisions. You'd also need to change the behavior of these methods:

btCapsuleShape::localGetSupportingVertexWithoutMargin()
btCapsuleShape::batchedUnitVectorGetSupportingVertexWithoutMargin()

And the capsule-specific stuff inside:

btConvexShape::localGetSupportVertexWithoutMarginNonVirtual()

Some other things that would be nice to know are:

Are you using Bullet3 or Bullet2?

Where is a link to the files that you've changed? Sometimes it is necessary to look at the code.
woqk
Posts: 2
Joined: Fri Dec 19, 2014 12:11 am

Re: custom implicit geometry shape

Post by woqk »

diff against latest git clone is attached, covers all places in the code that found with grep -i capsule

tried also without adding new method localGetSupportingVertex(), but actual calls seem to be to the btConvexShape::getMarginNonVirtual method anyway. ground shape is box (shouldn't matter because collision between btSphereShape and modified capsule also shows same behaviour). also aabb and center of mass are correct (debug drawer)

code for adding object:

Code: Select all

btCollisionShape* shape1 = new btCapsuleShape(2., 30.);
m_collisionShapes.push_back(shape1);
//collisionConfiguration->setConvexConvexMultipointIterations(...)
//shape1->setMargin(5.); // no effect
tTransform tr1;
tr1.setIdentity();
tr1.setOrigin(btVector3(0., 2., 0.));
base_body = localCreateRigidBody(20., tr1, shape1);
base_body->setActivationState(DISABLE_DEACTIVATION);
//base_body->setContactProcessingThreshold(0.01); // no effect
localCreateRigidBody is the same as in the demos.

thanks.........
You do not have the required permissions to view the files attached to this post.