Tokamak MAV due to FREEing RBs?

Blitz3D Forums/Blitz3D Userlibs/Tokamak MAV due to FREEing RBs?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have a 'big' tokamak system coded in my game.
Sweenie, I have to say you did an excellent job with the wrapper, ... you are on my Credits :)

It has happened a lot of time since I had a toka-bug, and it is working pretty much stable.

One tip when working with ragdolls (or whenever you use Joints)

ALWAYS delete the Joints BEFORE the RigidBodies,

the next is INCORRECT:
TOKRB_Free(RB) ;<- this is the RB connected with the joint
TOKJOINT_Free(Joint) 


the next is the right way :)
TOKJOINT_Free(Joint)
TOKRB_Free(RB) ;<- this is the RB connected with the joint

But, to make it better, in my code, after freeing the Joints I'm leaving
the RBs alive for one more tick, and then I delete them.

If you free a joint after the RB that are connected to it, sooner or
later you will get a MAV at the TOKSIM_Advance().

This way, I have tested spawning and deleting more than 200 ragdolls and
everthing work fine, no memory leak, no MAVs, ... :)

Hope it helps!
Paolo.