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.
Change Height/Radius of Capsule Object when Loaded in world?
-
- Posts: 19
- Joined: Wed Aug 27, 2014 5:02 pm
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Change Height/Radius of Capsule Object when Loaded in wo
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: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.
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());
Also note that the collision shape can't be shared by more than one body, unless you want to share the scaling as well.
-
- Posts: 19
- Joined: Wed Aug 27, 2014 5:02 pm
Re: Change Height/Radius of Capsule Object when Loaded in wo
Thanks, seems like this should work.
If I can avoid deleting and reading the object all the better.
If I can avoid deleting and reading the object all the better.