[solved] Vehicle Controller Object deletion

eagletree
Posts: 28
Joined: Sun Jul 31, 2011 11:20 pm

[solved] Vehicle Controller Object deletion

Post by eagletree »

I attempted to release memory in the manner I'd read it was supposed to be by removing and deleting objects in the reverse order I'd created them when building the vehicle. I have that working now, but found that two objects could not be released. I'm guessing that perhaps it is unnecessary to delete them. In the code below, the two I was unable to release are marked as comments. Is it okay not to delete these or am I creating a memory leak? No examples I could find removed the RayCastVehicle.

Code: Select all

				World->removeRigidBody(spawnedvehicle[n].chassis);
				delete spawnedvehicle[n].chassisshape;
				delete spawnedvehicle[n].compoundshape;
				delete spawnedvehicle[n].motionstate;
				delete spawnedvehicle[n].chassis;
				//delete spawnedvehicle[n].raycaster; //btDefaultVehicleRaycaster
				//delete spawnedvehicle[n].physicsvehicle; //btRayCastVehicle
Edit: the "solution"

I found that removeAction was necessary for what I show as "physicsvehicle" (the btRayCastVehicle) which then allowed me to do deletes on both raycaster (the btDefaultVehicleRaycaster) and the physicsvehicle.