addChildShape and removeChildShape in vehicle

razer
Posts: 82
Joined: Sun Apr 04, 2010 10:08 pm

addChildShape and removeChildShape in vehicle

Post by razer »

I have designed vehicle that controls rigidBody built from compound shape.
Vehicle dynamically adds and removes shapes from compound shape.

After doing that Everything works until rigidBody reaches triangle mesh static body.
Then I get exception

Code: Select all

Unhandled exception at 0x0ce197c1 (MyGame01.dll) in C4.exe: 0xC0000005: Access violation reading location 0xabfdfdfd.

Code: Select all

>	MyGame01.dll!btCompoundLeafCallback::ProcessChildShape(btCollisionShape * childShape=0x0debd660, int index=4)  Line 145 + 0x33 bytes	C++
 	MyGame01.dll!btCompoundLeafCallback::Process(const btDbvtNode * leaf=)  Line 174	C++
 	MyGame01.dll!btDbvt::collideTV<btCompoundLeafCallback>(const btDbvtNode * root=, const btDbvtAabbMm & vol=, btCompoundLeafCallback & policy=)  Line 935	C++
 	MyGame01.dll!btCompoundCollisionAlgorithm::processCollision(btCollisionObject * body0=, btCollisionObject * body1=, const btDispatcherInfo & dispatchInfo=, btManifoldResult * resultOut=)  Line 244	C++
 	MyGame01.dll!btCollisionDispatcher::defaultNearCallback(btBroadphasePair & collisionPair=, btCollisionDispatcher & dispatcher=, const btDispatcherInfo & dispatchInfo=)  Line 269	C++
 	MyGame01.dll!btCollisionPairCallback::processOverlap(btBroadphasePair & pair={...})  Line 224 + 0x1f bytes	C++
 	MyGame01.dll!btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback * callback=0x0018f7ac, btDispatcher * dispatcher=0x096bfce0)  Line 387 + 0x11 bytes	C++
 	MyGame01.dll!btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache * pairCache=0x0cfd4800, const btDispatcherInfo & dispatchInfo={...}, btDispatcher * dispatcher=0x096bfce0)  Line 242	C++
 	MyGame01.dll!btCollisionWorld::performDiscreteCollisionDetection()  Line 193	C++
 	MyGame01.dll!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668)  Line 386	C++
 	MyGame01.dll!btDiscreteDynamicsWorld::stepSimulation(float timeStep=0.017999999, int maxSubSteps=10, float fixedTimeStep=0.016666668)  Line 353	C++

I add 4 spheres. Exception occurs when sphere are removed but not immediately.

May be I should call add/remove in btActionInterface::updateAction and I should do it in different place.

e.g. outside of simulation loop.

Please, advise, Thanks
razer
Posts: 82
Joined: Sun Apr 04, 2010 10:08 pm

Re: addChildShape and removeChildShape in vehicle

Post by razer »

I found workaround by using updateChildTransform but still interesting if it is possible to use add/remove methods as updateChildTransform may not always for any object.
Grimreaper85
Posts: 4
Joined: Mon Feb 15, 2010 1:29 am

Re: addChildShape and removeChildShape in vehicle

Post by Grimreaper85 »

Before you remove, try calling this.
m_dynamicsWorld->getPairCache()->cleanProxyFromPairs( rigidBody->getBroadphaseHandle(), m_dynamicsWorld->getDispatcher() );
razer
Posts: 82
Joined: Sun Apr 04, 2010 10:08 pm

Re: addChildShape and removeChildShape in vehicle

Post by razer »

Grimreaper85 wrote:Before you remove, try calling this.
m_dynamicsWorld->getPairCache()->cleanProxyFromPairs( rigidBody->getBroadphaseHandle(), m_dynamicsWorld->getDispatcher() );
Thanks You. It has not helped.