World fails on reinitialization

odyeiop

22-02-2007 19:40:47

I seem to be having a problem with the physics world being created, destroyed, then created again later.

My project is set up so that I go from the Menu State, to a Playstate (each with their own respective Root, Scene Manager.. etc). If I am not usre nxOgre I can easily go back and forth between the two. Destroying the Menustate and loading the Playstate, and vice versa.

However, once I start to use nxOgre, it crashes on the second Playstate run.

mWorld = new nxOgre::world(mRoot);
physicsScene = mWorld->createScene("PhysWorld", mSceneMgr);

mWorld->destroyScene("PhysWorld");
if(soundManager) delete soundManager;


I was just wondering if there is any reason for this? I'm guessing that I do not have to destroy any objects made through the physicsScene as destroying the scene takes care of that, and that delete mWorld; takes care of the leftovers. I have tried a couple of things but to no avail.

Any and all help would be appreciated =)

betajaen

22-02-2007 19:49:06

As long as your not deleting world and creating it afterwards. Using scenes like that should be absolutely fine.

You could try mWorld->reset(), after the scene has been deleted though. Can you post the physics log?

odyeiop

22-02-2007 19:54:49

in my enter method for the Playstate I have a function that initializes all of my physics. When the Playstate shuts down I have a function that deletes all of my physics.

Enter Playstate
-> initialize Ogre
-> initialize viewports
-> initialize physics
-> etc. etc...

frame listeners.. does what the game does

at exit

delete physics stuff
delete ogre stuff

go to Menu state


if I run the playstate once and exit, this is the physics log that is generated
14:46:23.000862 Starting up NxOgre using versions:
-> PhysX SDK 2.6.2
-> Hardware None installed or none found.
-> NxOgre NxOgre 0.4.RC3 (Compatible: yes)
-> Ogre 1.2.4 'Dagon'
14:46:23.000862 Started.
14:46:23.000862 Creating scene 'PhysWorld'.
14:46:25.001132 Scene 'PhysWorld' (Software) shutting down
> 63 bodies
> 64 NxActors
> 1 controllables
> 0 fluids
14:46:25.001132 Deleting 'FakeFloor'.
14:46:25.001132 Deleting 'PhysWorld.floor'.
14:46:25.001132 Deleting 'churchTest.mesh'.
14:46:25.001132 Deleting 'cube.0'.
14:46:25.001132 Deleting 'cube.1'.
14:46:25.001132 Deleting 'p1'.
14:46:25.001132 Deleting 'p10'.
14:46:25.001132 Deleting 'p11'.
14:46:25.001132 Deleting 'p12'.
14:46:25.001132 Deleting 'p13'.
14:46:25.001132 Deleting 'p14'.
14:46:25.001132 Deleting 'p15'.
14:46:25.001132 Deleting 'p16'.
14:46:25.001132 Deleting 'p17'.
14:46:25.001132 Deleting 'p18'.
14:46:25.001132 Deleting 'p19'.
14:46:25.001132 Deleting 'p2'.
14:46:25.001132 Deleting 'p20'.
14:46:25.001132 Deleting 'p21'.
14:46:25.001132 Deleting 'p22'.
14:46:25.001132 Deleting 'p23'.
14:46:25.001132 Deleting 'p24'.
14:46:25.001132 Deleting 'p25'.
14:46:25.001132 Deleting 'p26'.
14:46:25.001132 Deleting 'p27'.
14:46:25.001132 Deleting 'p28'.
14:46:25.001132 Deleting 'p29'.
14:46:25.001132 Deleting 'p3'.
14:46:25.001132 Deleting 'p30'.
14:46:25.001132 Deleting 'p31'.
14:46:25.001132 Deleting 'p32'.
14:46:25.001132 Deleting 'p33'.
14:46:25.001132 Deleting 'p34'.
14:46:25.001132 Deleting 'p35'.
14:46:25.001132 Deleting 'p36'.
14:46:25.001132 Deleting 'p37'.
14:46:25.001132 Deleting 'p38'.
14:46:25.001132 Deleting 'p39'.
14:46:25.001132 Deleting 'p4'.
14:46:25.001132 Deleting 'p40'.
14:46:25.001132 Deleting 'p41'.
14:46:25.001132 Deleting 'p42'.
14:46:25.001132 Deleting 'p5'.
14:46:25.001132 Deleting 'p6'.
14:46:25.001132 Deleting 'p7'.
14:46:25.001132 Deleting 'p8'.
14:46:25.001132 Deleting 'p9'.
14:46:25.001132 Deleting 'pillar1'.
14:46:25.001132 Deleting 'pillar10'.
14:46:25.001132 Deleting 'pillar11'.
14:46:25.001132 Deleting 'pillar12'.
14:46:25.001132 Deleting 'pillar13'.
14:46:25.001132 Deleting 'pillar14'.
14:46:25.001132 Deleting 'pillar15'.
14:46:25.001132 Deleting 'pillar16'.
14:46:25.001132 Deleting 'pillar2'.
14:46:25.001132 Deleting 'pillar3'.
14:46:25.001132 Deleting 'pillar4'.
14:46:25.001132 Deleting 'pillar5'.
14:46:25.001132 Deleting 'pillar6'.
14:46:25.001132 Deleting 'pillar7'.
14:46:25.001132 Deleting 'pillar8'.
14:46:25.001132 Deleting 'pillar9'.
14:46:25.001132 Deleted Materials
14:46:25.001132 Deleted Material aliases.
14:46:25.001132 Released Scene.


if I run the playstate a second time and it crashes this is the physics log
14:45:19.001870 Starting up NxOgre using versions:
-> PhysX SDK 2.6.2
-> Hardware None installed or none found.
-> NxOgre NxOgre 0.4.RC3 (Compatible: yes)
-> Ogre 1.2.4 'Dagon'
14:45:19.001870 Started.
14:45:19.001870 Creating scene 'PhysWorld'.

odyeiop

22-02-2007 20:31:22

One thing I did notice now that I've looked at the log a little bit more carefully, is that the level collision(nxOgre::body), and the player's body collision (blueprint <character>) are not being deleted. Should they not be automatically deleted and logged when the physicsScene is removed?

betajaen

22-02-2007 21:03:37

blueprint<character> would be automatically be deleted when the function exits like another other non-pointer variable.

Tell me, are you deleting mWorld. Then later in the code creating it again? Because you can't do that.

odyeiop

22-02-2007 21:09:03

no, I have mWorld defined and created in the game class (base class for the program). It is created when the program is launched, and deleted when the program closes.

When I need to create an Ogre world in a new State I simple call

mWorld = nxOgre::world::getSingletonPtr();

I only clear the physicScene when the state is closed.

betajaen

22-02-2007 21:11:39

Interesting, I can't see why it would crash like that. The scene vector should be empty once cleared.

I'll do a bit of investigation and see how I go.

odyeiop

22-02-2007 21:15:24

Alrighty. Thanks a bunch =)

I'll keep plugging away at it and keep you updated if anything positive turns up.

odyeiop

06-03-2007 03:05:17

Well we still passed our alpha, even though we couldn't load the second level as we can't reinitialize the physics scene.

In 2 weeks we have our Beta, and I'm pretty sure that we'll fail if we can't get this working. I've tried a ton of things to get this to try and work, and can't seem to figure anythign out.

It loads fine the second, time (all the physics bodies load), and it starts the Framelistener, even goes through the first frame. At the end of the first frame is when it crashes. I"m guessing that this is when the physics listener starts.

If there is anything I can give, information, even files, to help you help me please let me know, as I am liking nxOgre (sans this) very much, and am now getting used to building in the SDK and working with it. I would also hate to have to do a HUGE overhaul and redo our game into Newton in a week.

So please, we really need help here =(

betajaen

06-03-2007 09:32:05

Check your private messages.

ELO

30-04-2007 17:55:06

We have the same problem here.

There will be a crash in NxCharacter.dll after
a second call to mWorld->createScene.

We are using the same versions as odyeiop (PhysX, nxOgre, Ogre).

We get no crash until blueprint<character> is used in our program.

Is there any solution ?

odyeiop

01-05-2007 04:52:42

IADT project?

ELO

01-05-2007 10:15:27

There are so many IADT projects out there...
Sorry, i dont know what you mean.