google-code-export / bullet

Automatically exported from code.google.com/p/bullet
0 stars 0 forks source link

btSphereShape::setMargin() is a no-op #408

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
2.76

I know the PDF docs say "Don’t override the collision margin for spheres." 
but some code (for example btKinematicCharacterController.cpp) modifies the 
margin without knowing the exact type of the object:

> btScalar margin = m_convexShape->getMargin();
> m_convexShape->setMargin(margin + m_addedMargin);
> // ... do sweep test ...
> m_convexShape->setMargin(margin);

Currently, btSphereShape::setMargin() is effectively a no-op; it does not 
affect the return value of btSphereShape::getMargin().  This causes a failure 
in some of our character proxy code when we use spheres as the ghost shape.

I suggest having setMargin() affect the radius (and therefore getMargin()), 
something like so:

+    void setRadius(btScalar radius)
+    {
+        m_implicitShapeDimensions.setX(radius / m_localScaling.getX());
+    }
     virtual void   setMargin(btScalar margin)
     {
-        btConvexInternalShape::setMargin(margin);
+        setRadius(margin);
     }
     virtual btScalar   getMargin() const
     {
         //to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
         //this means, non-uniform scaling is not supported anymore
         return getRadius();
     }

Original issue reported on code.google.com by paul.dubois@gmail.com on 16 Jul 2010 at 6:55

GoogleCodeExporter commented 9 years ago

Although it is a good idea, it will break the API and we try to keep the API 
stable for Bullet 2.x.

We will consider the change for Bullet 3.x.

Thanks for the feedback,
Erwin

Original comment by erwin.coumans on 16 Jul 2010 at 4:49