Problem with removing rigid bodies

Post Reply
Pottus
Posts: 6
Joined: Mon Nov 17, 2014 11:15 pm

Problem with removing rigid bodies

Post by Pottus »

I have my simulation working just like it should it created the world, creates rigid bodies and adds them and does all the collision checks properly. The issue I am having however comes when I try to remove rigid bodies for some reason it always results in a crash. I've tried tons of different things, read over lots of examples but the result is always the same does anyone have any ideas of why this might be happening?

Code: Select all

		for (uint16_t i = 0; i < sphereShape.size(); i++)
		{
			collisionWorld->removeRigidBody(sphereRigidBody[i]);
			delete sphereRigidBody[i];
			delete spherePosition[i];
			delete sphereShape[i];
		}

		for (uint16_t i = 0; i < boxShape.size(); i++)
		{
			collisionWorld->removeRigidBody(boxRigidBody[i]);
			delete boxRigidBody[i];
			delete boxShape[i];
			delete boxPosition[i];
		}

		if (HasMesh)
		{
			collisionWorld->removeRigidBody(meshRigidBody);
			delete meshRigidBody;
			delete meshshape;
			delete meshposition;
			delete trimesh;	
		}
Crash Log

20:00:44] [debug] #0 02d97c71 in btCollisionObject::getBroadphaseHandle () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
[20:00:44] [debug] #1 02d94886 in btCollisionWorld::removeCollisionObject () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
[20:00:44] [debug] #2 02d5d80c in btDiscreteDynamicsWorld::removeRigidBody () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
[20:00:44] [debug] #3 02cfd8fb in ColAndreasMapObject::~ColAndreasMapObject () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
[20:00:44] [debug] #4 02cffa8b in ColAndreasMapObject::`scalar deleting destructor' () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
[20:00:44] [debug] #5 02d07e23 in ObjectManager::removeObjectManager () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
[20:00:44] [debug] #6 02cf70e1 in CA_DestroyObject () from E:\mainbackup2\Saved SAMP Installs\03z_test\plugins\colandreas.DLL
Pottus
Posts: 6
Joined: Mon Nov 17, 2014 11:15 pm

Re: Problem with removing rigid bodies

Post by Pottus »

Okay I solved it now the issue was I was declaring a new pointer instead of using the one declared in private when creating the class so it was not saving the pointer simple mistake a lot of hair pulled.
Post Reply