MAV with Tokamak, maybe a collision problem?

Blitz3D Forums/Blitz3D Userlibs/MAV with Tokamak, maybe a collision problem?

Hi peeps...

Ive just started using tokamak and have it working almost perfectly where ODE would just cough, choke and die...

i have a building, destroyable. Then i have the player who shoots a "cannon" spheres at the model.

All works for a while, but then suddenly when i click "shoot", boom. MAV on "toksim_advance"

WHat ive done is create a system where tokamak runs through a type, and i can "addobject"s to the scene.

Here is my INIT function and related const's:
Const Rigid_Bodies=5000,Animated_Bodies=2
Function Tok_init()
Local tbodies=rigid_bodies+animated_bodies

TOKSIM_SetRigidBodiesCount Rigid_Bodies
TOKSIM_SetAnimatedBodiesCount Animated_Bodies
TOKSIM_SetRigidParticleCount 0
TOKSIM_SetControllersCount 0
TOKSIM_SetGeometriesCount Rigid_bodies+Animated_Bodies ;Assuming each one only has one geometry.  Not true with more complex rigid bodies and animated bodies.
TOKSIM_CreateSimulator(0,-1.8,0)
TOKSIM_SetOverlappedPairsCount(TBodies*(TBodies-1)/2)
;SetGeometriesCount 
End Function



Here is how i create the objects:
b\body=Tokrb_create()
b\mesh=CreateCube()
ScaleMesh b\mesh,.5,.5,.5
ScaleEntity b\mesh,Length,height,width
b\geom=Tokrb_addbox(b\body,Length,height,width)
Tokrb_setmass(b\body,mass)
Tokrb_setposition b\body,x,y,z
PositionEntity b\mesh,x,y,z
TOKRB_SetBoxInertiaTensor b\body,Length,height,width,mass


I have a "life" parameter to all tokamak objects that when reaches 0, the tokamak object is freed as so:

tokrb_free b\body
TOKRB_RemoveGeometry(b\body%,b\Geom) ;Is this needed? error happens with and without.
FreeEntity b\mesh
delete B



heres the code that is executed when the player shoots:

sp.Tok_object=tok_createobject(1,EntityX(camera),EntityY(camera),EntityZ(camera),20,20,20,400):EntityColor sp\mesh,0,0,0:EntityShininess sp\mesh,1
sp\life=-150
TFormVector 0,0,55,camera,0
TOKRB_Setvelocity(sp\body,TFormedX(),TFormedY(),TFormedZ())


The spheres are created by code the same as the cubes above, just using the sphere commands

Are there any bugs i need to know about/avoid? what do i need to add to INIT to stop this from happening?