Destroying dynamic objects

Towelie
Posts: 9
Joined: Mon Sep 20, 2010 10:07 am

Destroying dynamic objects

Post by Towelie »

Hi, i have some trouble with destroying dynamic objects particularly with btRaycastvehicle.
Here i`m destroying my vehicle:

Code: Select all

delete btChassis->getMotionState();
	
	delete engine;
	delete mVehicle;
	delete btChassis;
	delete mVehicleRayCaster;
	delete mWheelShape;
But at next call 'stepSimulation' throw up exception at function saveKinematicState in bullet-2.77\src\BulletDynamics\Dynamics\btRigidBody.cpp

Code: Select all

	if (getMotionState())
			getMotionState()->getWorldTransform(m_worldTransform);
Unhandled exception at 0x01277f28 in Game.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
I`m using BtOgre to connect Bullet & Ogre with own MotionState but i think it can`t be the reason of the exception.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Destroying dynamic objects

Post by dphil »

Do you remove your objects from the world before deleting?

world->removeCollisionObject(...);
or
world->removeRigidBody(...);