Crash on vehicle deletion

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Crash on vehicle deletion

Postby pHySiQuE » Mon Jan 05, 2015 5:24 pm

This is how my vehicle gets deleted:
Code: Select all
   NewtonDynamicsVehicle::~NewtonDynamicsVehicle()
   {
      if (vehicle)
      {
         manager->DestroyController(vehicle);
         vehicle = NULL;
      }
      delete manager;
   }


When the body gets deleted, after the above code is run, I get this error:
Image1.jpg
Image1.jpg (179.07 KiB) Viewed 2542 times
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Crash on vehicle deletion

Postby Julio Jerez » Mon Jan 05, 2015 5:55 pm

Code: Select all
 NewtonDynamicsVehicle::~NewtonDynamicsVehicle()
   {
      if (vehicle)
      {
         manager->DestroyController(vehicle);
         vehicle = NULL;
      }

//what is this?
      delete manager;
   }

I do not remember that on any newton code. why do you delete the manager when you delete a controller?
how did that ever work?
basically the vehicle will work one time and will crash on delete because you call delete the manage from the own callback itself, upon return the pointer to the manager will be garbage.

Even if Manager pointe it not used in return, this mean you are doing the worse of all possible implementation, you are using one manager per vehicle.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crash on vehicle deletion

Postby pHySiQuE » Mon Jan 05, 2015 6:52 pm

So I should use one vehicle manager per newton world, and deleting the world will automatically delete the manager?
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Crash on vehicle deletion

Postby Julio Jerez » Mon Jan 05, 2015 7:08 pm

No,

Managers are a convenient way for grouping simulations be types. you can group then any way you want but grouping one vehicle one manager is the worse thing you can do.
you could simple make one vehicle manager and have the world destroying it if you want.

a Manager is not different than the collision system which hold collision shape and apply simila functions to those eobjects, or the dynamics manager that hold dynamics bodies and so on.
but if you make one manage per vehicle you are serializing the simulation, it will be like making every static collision a scene collision.

when you create a manager you know when you deleted it,
I do no remember but I believe the engine does not delete them.
you can think of the vehicle manager as the world for vehicles.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron