problems with deleting actors in a callback

Black'Tea

24-11-2007 22:32:56

Sometimes, when my program does the callback, there´s a runtime error (circa every 5th call).

errormessage:
R6025
- pure virtual function call


void Callback::onStartTouch(Actor *a, Actor *b)
{
mRoot->mScene->destroyActor(a->getName());
mRoot->mScene->destroyActor(b->getName());
};

Aiursrage2k

24-11-2007 22:38:17

Not sure about the pure virtual error. You probably should not delete an actor in the on touch function, put in a queue and delete at the end of the frame.

betajaen

24-11-2007 22:52:29

What Aiursrage2k said. PhysX gets really really picky if you do things like that.

The state of the SDK should not be modified from within the onTrigger() routine. In particular, objects should not be created or destroyed. If it is necessary to modify a state, then the updates should be stored to a buffer and performed after the simulation step.

In the future when States and Batching come around, the situation will be a lot easier.

Black'Tea

24-11-2007 23:16:58

It works.

Thanks a lot.