NxOgre::Actor crash app when destroyed, after a collision.

ronron

19-11-2008 04:56:01

Hi !

So i have a new problem :

After a collision detection, in the callback ( ontouch,etc ) i call a fonction who destroy the Actor.
But if there is no collision, everything runs fine. ( and my actors are destroyed without crash ), if there is a collision BOOM !!

And the debuger show me the line where i say to nxogre to render :/

Video in rar :
http://effcoding.free.fr/downloads/bug.rar

Please, I need help :/

mcaden

19-11-2008 06:08:23

I'm not sure of the solution, but I believe the cause has something to do with threading if that helps.

I haven't gotten around to destroying actors during gameplay, but I intend on not destroying them right away...merely disabling collisions and flagging them for deletion later (enemy corpses persist for a while, then fade away. I haven't put this into practice yet though.

ronron

19-11-2008 16:07:19

Wich member function disable the collision detection ?

I think it's the key of my problem, but Actor->disable() don't change anything, or maybe it's with the actors flags or something !

Do you think the best way is to re-use actor, or delete them with a delay after many frames ?

betajaen

19-11-2008 16:15:52

It's flags. But I can't remember shapes or actor.

reptor

19-11-2008 17:51:29

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

Maybe that's the problem, you are destroying PhysX objects inside a callback function and the documentation says that that should not be done.

betajaen

19-11-2008 17:52:46

We have a fantastic delay deletion functions in Scene that you can used, designed for this very purpose.

ronron

20-11-2008 02:38:34

Thanks for informations, i'll try them right now !

And I'll come back to say if it works !

ronron

20-11-2008 22:48:03

So, i can destroy my Actors.

After this information :

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

I make a class in order to destroy actors after 1 frame. I get the frame ID with the NxWorld->GetNbFrames(), and try to kill my actors 1 step after, and crash again !

In Fact if you use the NxWorld->GetNbFrames() command to get the frame ID, you must wait another one frame.

And then, when i destroy my actors after NxWorld->GetNbFrames()+2, everything runs fine.

betajean, I try your way too :

NxScene->batchDestroyActor( "actorX" , BT_NEXT_AVAIBLE_BATCH );
NxScene->destroyActorDelayed( Actor , true or false )

Unfortunatly theses functions crash my app too.


Thanks all for your time :)

betajaen

20-11-2008 23:16:21

Are you using those functions together?

Because they are unrelated. Use the destroyActorDelayed function, and I think you need a callback.

ronron

20-11-2008 23:36:37

Are you using those functions together?

Nope :) And "NxScene->batchDestroyActor( "actorX" , BT_NEXT_AVAIBLE_BATCH );" don't do anything.

Use the destroyActorDelayed function, and I think you need a callback.

The built-in callback seems to delete actors, but without a delay. And, of course, crahs the app.

Thanks for the delayed deletion callback link.