Page 1 of 1

Change Height/Radius of Capsule Object when Loaded in world?

Posted: Wed Sep 17, 2014 7:43 pm
by tmason
Hello,

I have hopefully a simple question: I have a btCapsuleShape collision shape setup I am using as a simple character controller and it works decently.

Now I need to be able to change the width and height of the shape live in the environment; I tried recreating the shape within the environment but then the orientation/position data is off and the btCapsuleShape is not exactly placed where the old object was.

Is there a simple way to just change the radius/height of the existing object?

Thanks.

Re: Change Height/Radius of Capsule Object when Loaded in wo

Posted: Thu Sep 18, 2014 7:28 am
by Flix
Never tried, but I'd try the following steps:
1) remove the rigid body/collision object from the world
2) shape->setLocalScaling(btVector3(myScaling));// remember that capsule can be scaled in 2 dimensions only (e.g. btVector3(1.2,4.0,1.2) for Y capsule)
3) readd the rigid body/collision object to the world

Steps (1) and (3) can probably be replaced by:

Code: Select all

//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
at the end of the process.

Also note that the collision shape can't be shared by more than one body, unless you want to share the scaling as well.

Re: Change Height/Radius of Capsule Object when Loaded in wo

Posted: Thu Sep 18, 2014 9:59 am
by tmason
Thanks, seems like this should work.

If I can avoid deleting and reading the object all the better.