How to replace TOKAMAK objects

Blitz3D Forums/Blitz3D Userlibs/How to replace TOKAMAK objects

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.

Hi,

I've got an array of actors, of custom type including fields for 3D geometry, TOKAMAK RB, and position/orientation/properties etc. I load this array with details describing each object (actor) and use two functions that create the 3D Blitz entities and the TOK RB's from the information in the array...

actors(n)\model = create_actor_geometry(actors(n))
actors(n)\TOK_obj = create_actor_TOK_object(actors(n))

I can clear the whole scene with this code...
For n=1 To NUM_ACTORS
		FreeEntity (actors(n)\model)
		actors(n)\visible=False
		TOKRB_Free (actors(n)\TOK_obj)
	Next

and load in objects in the same manner I initialise them, which works fine.

What I cannot do though is use this method to erase ONE tokamak object and replace it with another.

	FreeEntity (actors(n)\model)
	actors(n)\visible=False
	TOKRB_Free (actors(n)\TOK_obj)

	actors(n)\model = create_actor_geometry(actors(n))
	actors(n)\TOK_obj = create_actor_TOK_object(actors(n))


The results are erratic. The new object is created and updates as before, but collision is broken. The object responds to some TOX_ABs and TOK_RBs, and then passes through others. If I replace the object 2 or 3 times, I get a "Memory Access Violation" on the TOKSIM_Advance() function

Does anyone know what's causing this, or how I can replace one TOKAMAK object with another?

Note : I am advancing the simulation between calls to TOKRB_Free()