How to replace TOKAMAK objects
Blitz3D Forums/Blitz3D Userlibs/How to replace TOKAMAK objects
| ||
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() |
| ||
Try moving the rb you want to remove, away from the other bodies before you remove it from the sim. That is, * Move the body far away(so that it won't collide with anything) * Then advance the simulation on timestep * Remove it. This is one of Tokamak's nasty bugs and the workaround that seem to work best. |
| ||
Okay, I'll give that a go. Thanks |
| ||
That's worked perfectly. Thanks a lot Sweenie! |