Statemanaging and PLSM2?

nyxojaele

22-02-2006 18:44:03

I have a statemanager setup, similar in idea to the one that was posted as a tutorial a while back on the Ogre wiki.

It would seem that I have a problem trying to change states, but ONLY when the state I'm changing -from- is using the PLSM2 SceneManager (and I've called setWorldGeometry() for it, obviously...) The test I'm doing is taking an already existing and fully functioning state change, and simply replacing this line

mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);

with this

mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_REAL_FAR);
mSceneMgr->setWorldGeometry("paginglandscape2.cfg");


I always get an assertion failed in OgrePagingLandScapeHorizon.cpp on line 51, complaining about ms_Singleton.

No call stack in returned, but if I hit f5 (to tell it to continue...) after it breaks, it gives me a call stack when it [obviously] breaks again, which looks like this:

Plugin_PagingLandScapeSceneManager2.dll!04b343be()
[Frames below may be incorrect and/or missing, no symbols loaded for Plugin_PagingLandScapeSceneManager2.dll]
Plugin_PagingLandScapeSceneManager2.dll!04ac36dd()
> OgreMain_d.dll!Ogre::Root::_fireFrameStarted(Ogre::FrameEvent & evt={...}) Line 577 + 0x28 bytes C++
OgreMain_d.dll!Ogre::Root::_fireFrameStarted() Line 622 C++
OgreMain_d.dll!Ogre::Root::renderOneFrame() Line 697 + 0x8 bytes C++
OgreMain_d.dll!Ogre::Root::startRendering() Line 690 + 0x8 bytes C++
FFVI-Nyx.exe!application::go(gameState * state=0x00597bd8) Line 44 + 0xe bytes C++
FFVI-Nyx.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00222096, int nShowCmd=1) Line 17 + 0x1a bytes C++
FFVI-Nyx.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
FFVI-Nyx.exe!WinMainCRTStartup() Line 403 C


So my question is this: Is there something specific I have to do to ... "unsetWorldGeometry" or some such, so I can successfully switch SceneManagers?

tuan kuranes

22-02-2006 18:57:07

I always get an assertion failed in OgrePagingLandScapeHorizon.cpp on line 51, complaining about ms_Singleton.
I need the stack at that point.
Is there something specific I have to do to ... "unsetWorldGeometry" or some such, so I can successfully switch SceneManagers?
Can you use separate cameras for each SM ?

nyxojaele

22-02-2006 19:38:50

I need the stack at that point.

Well, I guess technically it returns a stack, but tells me:

No symbols are loaded for any call stack frame. The source code can not be displayed.

The callstack that DOES appear is this:

> msvcr80d.dll!0088f4ad()
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr80d.dll]
CEGUIBase_d.dll!00ba813b()
CEGUIBase_d.dll!00ba807b()
CEGUIBase_d.dll!00ba89c7()


Now that kinda makes me think it's CEGUI, but the thing that points me more towards it being PLSM2 is when I walk thru my code, up to the point of assertion error..

When using ST_EXTERIOR_CLOSE, and I change states, then walk thru the code into Ogre's _fireFrameStarted function, it hits a loop where it iterates thru all the registered frameListeners and calls their frameStarted functions. The list of frameListeners is as follows:

[application] (my own frameListener)
[Ogre::ParticleSystemManager]
[Ogre::FrameTimeControllerValue]
[Ogre::EventProcessor]


But if I change to ST_EXTERIOR_REAL_FAR, the list when I get there is this:

[application] (my own frameListener)
[Ogre::ParticleSystemManager]
[Ogre::FrameTimeControllerValue]
[Ogre::EventProcessor]
[] 0x06054148
^-__vfptr
^-[0]
^-[1]
^-[2]


Notice there's no names on anything in that last frameListener item, so I have no clue what it is, all it has is memory addresses.

The assertion happens when the code executes this line in _fireFrameStarted() of ogreroot.cpp:

if (!(*i)->frameStarted(evt))

At this point, the variable i is a pointer to that unnamed frameListener in the list from ST_EXTERIOR_REAL_FAR.

Since I have to go to work right away, I'm going to see if I can disable CEGUI after I get back to see if that's the problem. But since this only occurs when I change the sceneManager to PLSM2 (I've tried a couple other sceneManagers, they're okay!), I think it's pretty safe to assume it's something to do with PLSM2...

Can you use separate cameras for each SM ?

I'm not entirely sure what you mean. If you're asking what I think you're asking, then this is your answer (hehe):

When each state is exited, it removes all viewports and destroys all cameras. When each state is entered, it creates the viewport and camera needed by it. So, each state (and thus, each sceneManager USED by each state) has their own viewport & camera combination.

Falagard

22-02-2006 20:44:46

It's probably CEGUI. When you switch scene managers you have to tell CEGUI.



#include "OgreCEGUIRenderer.h"

ogreRenderer = static_cast<CEGUI::OgreCEGUIRenderer*>(guiRenderer);
ogreRenderer ->setTargetSceneManager(newSceneMgr);

nyxojaele

22-02-2006 23:52:11

That's exactly what I thought of when I was about 5 minutes from work- I'll give it a try and see.

<EDIT> Well, just tried it -- it looks like it successfully changes the SceneManager used by CEGUI, but I still get the exact same error.. I'm gonna see if I can't disable CEGUI without destroying my program, to see if that's it, anyways..</EDIT>

<EDIT2> I just commented out everything to do with my gui/CEGUI, and I still have the same problem, although with a different call stack now...

This is the callstack I get at the same point (_fireFrameStarted @ line 51 in ogreroot.cpp)

msvcr80d.dll!0087f4ad()
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr80d.dll]
> OgreMain_d.dll!std::_Iterator_base::~_Iterator_base() Line 151 + 0x45 bytes C++



I also tried different combinations for the states- here's my results:

ST_EXTERIOR_CLOSE -> ST_EXTERIOR_CLOSE = ok
ST_EXTERIOR_CLOSE -> ST_EXTERIOR_REAL FAR = ok
ST_EXTERIOR_REAL_FAR -> ST_EXTERIOR_REAL_FAR = ok
ST_EXTERIOR_REAL_FAR -> ST_EXTERIOR_CLOSE = -bad-;;

What's getting me, is that it appears to be the same assert you get when you try to make a 2nd singleton object... I don't get it;;

Oh, and I stepped thru the code again, it's still the same problem with that 1 frameListener that doesn't have a classname in my debugger...</EDIT2>

nyxojaele

23-02-2006 04:32:52

Okay, I've put together an incredibly simple application that implements the core of my state manager, starting up in PLSM2, and immediately attempting to switch over to ST_EXTERIOR_CLOSE. Getting the same problem. The following is the code:

Main.cpp
#include "gen_application.h"
#include "state_intro.h"

using namespace Ogre;

#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
#else
int main(int argc, char **argv)
#endif

{
application app;
try {
app.go(introState::getInstance());
} catch (Exception &e) {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == ORGE_PLATFORM_WIN32
MessageBox(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\n", e.getFullDescription().c_str());
#endif
}
return 0;
}


gen_application.h
#ifndef __GEN_APPLICATION_H__
#define __GEN_APPLICATION_H__

//#include "OgreSingleton.h"
//#include "OgreEventListeners.h"
#include <Ogre.h>

#define WINDOW_NAME "Nyx"

using namespace Ogre;

class gameState;

class application: public Singleton<application>, public FrameListener {
public:
application();
virtual ~application();

virtual void go(gameState *state);

//State stuff
const gameState *getCurrentState() { return mStates.back(); }
void changeState(gameState *state);
void pushState(gameState *state);
void popState();

protected:
Root *mRoot;
RenderWindow *mWindow;
ResourceGroupManager *mResGrpMgr;

bool setup();
bool configure();

bool frameStarted(const FrameEvent &evt);
bool frameEnded(const FrameEvent &evt);

private:
std::vector<gameState *> mStates;
};
template<> application *Singleton<application>::ms_Singleton = 0;

#endif


gen_application.cpp
#include "gen_application.h"
#include "state_gameState.h"

application::application(): mRoot(0) {}

application::~application() {
//Clean up the states
while (!mStates.empty()) {
mStates.back()->exit();
mStates.pop_back();
}
//Clean memory
if (mRoot) {
delete mRoot;
mRoot = NULL;
}
}

void application::go(gameState *state) {
if (!setup())
return;
changeState(state);
mRoot->startRendering();
}

bool application::setup() {
mRoot = new Root("plugins.f6c", "video.f6c", "general.log");

if (!configure())
return false;

mRoot->addFrameListener(this);

mResGrpMgr = ResourceGroupManager::getSingletonPtr();
mResGrpMgr->createResourceGroup("terrain");
mResGrpMgr->addResourceLocation(".", "FileSystem", "terrain");
mResGrpMgr->initialiseAllResourceGroups();

return true;
}

bool application::configure() {
if (!mRoot->restoreConfig()) {
if (!mRoot->showConfigDialog()) {
return false;
}
}
mWindow = mRoot->initialise(true, WINDOW_NAME);

//Set default Mipmap level
TextureManager::getSingleton().setDefaultNumMipmaps(5);
return true;
}

void application::changeState(gameState *state) {
//Cleanup the current state
if (!mStates.empty()) {
mStates.back()->exit();
mStates.pop_back();
}
//Store and init the new state
mStates.push_back(state);
mStates.back()->enter();
}
void application::pushState(gameState *state) {
//Pause current state
if (!mStates.empty()) {
mStates.back()->pause();
}

//Store and init the new state
mStates.push_back(state);
mStates.back()->enter();
}
void application::popState() {
//Clean up the current state
if (!mStates.empty()) {
mStates.back()->exit();
mStates.pop_back();
}
//Resume previous state
if (!mStates.empty()) {
mStates.back()->resume();
}
}

bool application::frameStarted(const Ogre::FrameEvent &evt) {
//Call frameStarted of current state
return mStates.back()->frameStarted(evt);
}
bool application::frameEnded(const Ogre::FrameEvent &evt) {
//Call frameEnded of current state
return mStates.back()->frameEnded(evt);
}


state_gamestate.h
#ifndef __STATE_GAMESTATE_H__
#define __STATE_GAMESTATE_H__

#include "Ogre.h"
#include "gen_application.h"

class gameState {
public:
virtual void enter() = 0;
virtual void exit() = 0;

virtual void pause() = 0;
virtual void resume() = 0;

virtual bool frameStarted(const FrameEvent &evt) = 0 {
return true;
}
virtual bool frameEnded(const FrameEvent &evt) = 0 {
return true;
}

void changeState(gameState *state) {
application::getSingletonPtr()->changeState(state);
}
void pushState(gameState *state) {
application::getSingletonPtr()->pushState(state);
}
void popState(gameState *state) {
application::getSingletonPtr()->popState();
}

protected:
gameState() {}
};

#endif


state_intro.h
#ifndef __STATE_INTRO_H__
#define __STATE_INTRO_H__

#include <Ogre.h>
#include "state_gamestate.h"

class introState: public gameState {
public:
void enter();
void exit();

void pause();
void resume();

bool frameStarted(const Ogre::FrameEvent &evt);
bool frameEnded(const Ogre::FrameEvent &evt);

static introState *getInstance() {
return &mIntroState;
}

protected:
introState() {}

Ogre::Root *mRoot;
Ogre::SceneManager *mSceneMgr;
Ogre::Viewport *mViewport;
Ogre::InputReader *mInputDevice;
Ogre::Camera *mCamera;

private:
static introState mIntroState;
};

#endif


state_intro.cpp
#include <OgreKeyEvent.h>
#include "state_intro.h"
#include "state_title.h"

using namespace Ogre;

introState introState::mIntroState;

void introState::enter() {
mRoot = Root::getSingletonPtr();

//mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);
mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_REAL_FAR);
mSceneMgr->setWorldGeometry("paginglandscape2.cfg");

mCamera = mSceneMgr->createCamera("IntroCamera");
mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera);
mViewport->setBackgroundColour(ColourValue(0.0549, 0.0157, 0.1216));
}

void introState::exit() {
mSceneMgr->clearScene();
mSceneMgr->destroyAllCameras();
mRoot->getAutoCreatedWindow()->removeAllViewports();
}

void introState::pause() {}

void introState::resume() {}

bool introState::frameStarted(const Ogre::FrameEvent &evt) {
application::getSingleton().changeState(titleState::getInstance());
return true;
}

bool introState::frameEnded(const Ogre::FrameEvent &evt) {
return true;
}


state_title.h
#ifndef __STATE_TITLE_H__
#define __STATE_TITLE_H__

#include <Ogre.h>
#include "state_gamestate.h"

class titleState: public gameState {
public:
void enter();
void exit();

void pause();
void resume();

bool frameStarted(const Ogre::FrameEvent &evt);
bool frameEnded(const Ogre::FrameEvent &evt);

static titleState *getInstance() {
return &mTitleState;
}

protected:
titleState() {}

Ogre::Root *mRoot;
Ogre::SceneManager *mSceneMgr;
Ogre::Viewport *mViewport;
Ogre::InputReader *mInputDevice;
Ogre::Camera *mCamera;

private:
static titleState mTitleState;
};

#endif


state_title.cpp
#include <OgreKeyEvent.h>
#include "state_title.h"

using namespace Ogre;

titleState titleState::mTitleState;

void titleState::enter() {
mRoot = Root::getSingletonPtr();

//mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_REAL_FAR);
//mSceneMgr->setWorldGeometry("paginglandscape2.cfg");
mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);

mCamera = mSceneMgr->createCamera("TitleCamera");
mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera);
mViewport->setBackgroundColour(ColourValue(0.5, 0.5, 0.5));
}

void titleState::exit() {
mSceneMgr->clearScene();
mSceneMgr->destroyAllCameras();
mRoot->getAutoCreatedWindow()->removeAllViewports();
}

void titleState::pause() {}

void titleState::resume() {}

bool titleState::frameStarted(const Ogre::FrameEvent &evt) {
return true;
}

bool titleState::frameEnded(const Ogre::FrameEvent &evt) {
return true;
}


This is all copy+pasted from my existing code, but INCREDIBLY stripped down to hopefully only the needed parts. There may still be some leftover stuff that's not useful, but it shouldn't interfere (maybe useless #includes, for example...)

Obviously, also, you'll need to provide the resources and whatnot yourself -- most of it right in the same directory as the .exe.

Basic synopsis: Program starts, loads first state (introState). The first frame that's rendered in that state attempts to change the state to titleState, and it does so, but then this is where our assert is.

tuan kuranes

23-02-2006 09:12:29

get call state when assert is raised (retry button).
not after bypassing assert.

ST_EXTERIOR_REAL_FAR -> ST_EXTERIOR_CLOSE = -bad-;;
And there is still the same assert about horizon ?
looks like it still tries to render in PLSM2...

If you want me to test that, could you provide a solution + project and code in a Zip, that you've checked it works so that I directly can debug the thing.

nyxojaele

23-02-2006 13:40:57

Yes, the last callstack I posted is from when the assert was raised (and I pressed the retry button).

Still the same assert. Complaining about ms_Singleton in OgrePagingLandScapeHorizon.cpp, line 51

I'm sending you a PM with the info to download the .zip

<EDIT>So I've finally managed to grab the latest CVS for PLSM2 & Ogre (since PLSM2 needed it..), recompiled them, copied the appropriate .dlls and whatnot to my trial application's directory so I'm using them now, and found I had to relearn how to acquire a sceneManager. I -hope- I got it right, as it seems to work..

So correct me if I'm wrong, but there's 2 ways to acquire a sceneManager now:

1) createSceneManager() [you would only use this the first time you're creating each of the scene managers...]

2) getSceneManager() [you would use this to call up a sceneManager previously created by createSceneManager()...]

Assuming that this is correct, I've modified my program to reflect this, and am getting similar results, with different line numbers:

pseudo-code:
createSM(ST_EXTERIOR_CLOSE) -> getSM(ST_EXTERIOR_CLOSE) = ok
createSM(ST_EXTERIOR_CLOSE) -> createSM(ST_EXTERIOR_REAL_FAR) = ok
createSM(ST_EXTERIOR_REAL_FAR) -> getSM(ST_EXTERIOR_REAL_FAR) = ok
createSM(ST_EXTERIOR_REAL_FAR) -> createSM(ST_EXTERIOR_CLOSE) = -bad-


The exact error given is as follows:
Unhandled exception at 0x042f588e
(Plugin_PagingLandScapeSceneManager2_d.dll) in State manager with PLSM2.exe: 0xC0000005: Access violation reading location 0x00000070


When I break, this is the callstack:
> Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeHorizon::prepare(const Ogre::PagingLandScapeCamera * cam=0x00000000) Line 87 + 0x3 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapePageManager::frameStarted(const Ogre::FrameEvent & evt={...}) Line 147 C++
OgreMain_d.dll!Ogre::Root::_fireFrameStarted(Ogre::FrameEvent & evt={...}) Line 614 + 0x28 bytes C++
OgreMain_d.dll!Ogre::Root::_fireFrameStarted() Line 659 C++
OgreMain_d.dll!Ogre::Root::renderOneFrame() Line 734 + 0x8 bytes C++
OgreMain_d.dll!Ogre::Root::startRendering() Line 727 + 0x8 bytes C++
State manager with PLSM2.exe!application::go(gameState * state=0x00422358) Line 23 + 0xe bytes C++
State manager with PLSM2.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x002220b6, int nShowCmd=1) Line 17 + 0x1a bytes C++
State manager with PLSM2.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
State manager with PLSM2.exe!WinMainCRTStartup() Line 403 C
kernel32.dll!7d4e6e1a()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]


And it puts me in ogrepaginglandscapehorizon.cpp on line 87:
if (material_enabled)

I'm putting together another code package for you, and I'll PM you the info again so you can grab it if you want. (Anybody know any easy to use file hosts for something temporary like this?)</EDIT>

tuan kuranes

24-02-2006 17:56:43

Ok, reproduced the bug thanks to your code.

Frame Listener registered by plsm2 to handle loading queues is queued to be removed from inside a fireStartFrame, and therefore, removed after whole startframe/Endframe is done, which means it can be called once after plsm2 was shutdown.

Fixed in CVS.

nyxojaele

25-02-2006 01:48:26

Awsome, glad to help! Now I'll have to grab CVS and hope it's applied the new code^^

nyxojaele

27-02-2006 02:54:39

New problem with same subject, so posting into the same thread.

This time the problem is with pausing & resuming a PLSM2 state. Now correct me if I'm wrong, but in theory, I'd think you should be able to -not- call clearScene(), so that you can once again "resume", and not have to re-add everything (SceneNodes, worldGeometry, etc..) to the SceneManager.

Especially now with the named Instances of SceneManagers, I'd think it even more possible than before.

Anyways, this is going on the assumption that the above is correct, and so here is the problem:

The only difference between actually -changing- states, and pausing/resuming states, really, is that "changing" a state calls clearScene() on the sceneManager you're changing from, and pause/resume doesn't. At least, in my current implementation.

So everything works fine and dandy like that, sorta.

I currently have another simple application setup to illustrate this. What it does, is starts in state1, and when you press F10, it "pauses" state1, and goes into state2. All is well. If you press F10 once again, it properly exits state2, and goes back to state1, and tells it to continue. Which it does.. sorta.

If you don't do anything at all to the camera while in state1, then there's no problems. But if you actually do something with the camera in state1..(move around a bit, sometimes something as simple as setting it to render in wireframe) before you switch to state2, and (usually I find you need to be in state2 for about 5 seconds...) switch to state2, then back. Once I'm back in state1, it all works BEAUTIFULLY, until I get the following error: (maybe... not even 1 second into rendering)

Assertion Failed!
Program: ...
File: ..\src\OgrePagingLandScapeOcclusionElement.cpp
Line: 41

Expression: nodeDataPerCam.find(cam->getID()) != nodeDataPerCam.end()


When I hit retry, I get this callstack:
msvcr80d.dll!0070f4ad()
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr80d.dll]
msvcr80d.dll!0075006f()
OgreMain_d.dll!10447d9d()
OgreMain_d.dll!10447dba()
OgreMain_d.dll!104fd8eb()
OgreMain_d.dll!10649dcb()
OgreMain_d.dll!10649dcb()
OgreMain_d.dll!1094384f()
OgreMain_d.dll!10943865()
OgreMain_d.dll!109438af()
OgreMain_d.dll!109438f2()
OgreMain_d.dll!10797f73()
> Plugin_PagingLandScapeSceneManager2_d.dll!std::_Iterator_base::_Adopt(const std::_Container_base * _Parent=0x00000000) Line 166 + 0xf bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!std::_Iterator_base::~_Iterator_base() Line 151 + 0x28 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!std::_Bidit<std::pair<unsigned int const ,Ogre::VisibilityData *>,int,std::pair<unsigned int const ,Ogre::VisibilityData *> const *,std::pair<unsigned int const ,Ogre::VisibilityData *> const &>::~_Bidit<std::pair<unsigned int const ,Ogre::VisibilityData *>,int,std::pair<unsigned int const ,Ogre::VisibilityData *> const *,std::pair<unsigned int const ,Ogre::VisibilityData *> const &>() + 0x16 bytes C++
0012e644()
Plugin_PagingLandScapeSceneManager2_d.dll!std::_Tree<std::_Tmap_traits<unsigned int,Ogre::VisibilityData *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Ogre::VisibilityData *> >,0> >::find(const unsigned int & _Keyval=3014702) Line 966 + 0xf bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::OcclusionElement::getNodeData(Ogre::PagingLandScapeOctreeCamera * cam=0x02099fa0) Line 41 + 0x86 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::ViewFrustumCullingTraversalDirect::onTree(Ogre::PagingLandScapeOctree & node={...}) Line 141 + 0x12 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeOctree::traversal(Ogre::Traversal & tr={...}) Line 152 + 0x12 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::Traversal::traverseChildren(Ogre::PagingLandScapeOctree & node={...}) Line 118 + 0x13 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::ViewFrustumCullingTraversalDirect::onTree(Ogre::PagingLandScapeOctree & node={...}) Line 132 + 0x13 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeOctree::traversal(Ogre::Traversal & tr={...}) Line 152 + 0x12 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::Traversal::traverseChildren(Ogre::PagingLandScapeOctree & node={...}) Line 106 + 0x13 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::ViewFrustumCullingTraversalDirect::onTree(Ogre::PagingLandScapeOctree & node={...}) Line 132 + 0x13 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeOctree::traversal(Ogre::Traversal & tr={...}) Line 152 + 0x12 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::Traversal::traverseChildren(Ogre::PagingLandScapeOctree & node={...}) Line 121 + 0x13 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::ViewFrustumCullingTraversalDirect::onTree(Ogre::PagingLandScapeOctree & node={...}) Line 132 + 0x13 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeOctree::traversal(Ogre::Traversal & tr={...}) Line 152 + 0x12 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeOctreeSceneManager::_findVisibleObjects(Ogre::Camera * cam=0x02099fa0, bool onlyShadowCasters=false) Line 920 + 0x21 bytes C++
OgreMain_d.dll!10a395b5()
OgreMain_d.dll!1064a16f()
OgreMain_d.dll!10b26bd2()
OgreMain_d.dll!109cb991()
OgreMain_d.dll!109d38bb()
RenderSystem_Direct3D9.dll!02228663()
OgreMain_d.dll!109d3857()
OgreMain_d.dll!109c1f68()
OgreMain_d.dll!10a2029d()
OgreMain_d.dll!10a1e24e()
OgreMain_d.dll!10a1e1b1()
State manager with PLSM2.exe!application::go(gameState * state=0x00424560) Line 29 + 0xe bytes C++
State manager with PLSM2.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x002220b6, int nShowCmd=1) Line 17 + 0x1a bytes C++
State manager with PLSM2.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
State manager with PLSM2.exe!WinMainCRTStartup() Line 403 C
kernel32.dll!7d4e6e1a()


and it puts me at line 166 of C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xutility

Now, I've figured out a very simple way to fix this in my code: All I have to do is call

setWorldGeometry("paginglandscape2.cfg");

again in my "resume" function of state1. But that kinda defeats the purpose of "pausing", seeing as it needs to reload all the terrain around the camera again;;

So, am I going about this in the wrong way? Or am I missing something I should be doing? Or is this an issue with PLSM2?

If need be, I can PM somebody with info on downloading my example app source code.

tuan kuranes

27-02-2006 08:11:23

the error in

Expression: nodeDataPerCam.find(cam->getID()) != nodeDataPerCam.end()

can be avoided removing the _VISIBILITYDEBUG from plugin project settings.

So, am I going about this in the wrong way? Or am I missing something I should be doing? Or is this an issue with PLSM2?

You obviously need a Pause mechanism in plsm2.
It could be done using setOption/getOption mechanism, and I'll add that asap to plsm2.

tuan kuranes

27-02-2006 09:19:10

added in CVS

bool isPaused = true;
setOption("pause", &isPaused );

isPaused = *(bool*)getOption("pause");

nyxojaele

28-02-2006 03:58:17

if removing _VISIBILITYDEBUG from the plugin project settings fixes the error, then is adding the "pause" option really necessary?

Also, I noticed 2 things: 1) The "pause" name seems misleading. As it's connected directly to PageManager's isEnabled, that would mean the bool values are opposing. ie setting "pause" to true means setting PageManager->isEnabled to true. 2) Setting "pause" to false doesn't seem to set the PageManager's mEnabled to false anyways. looking at the code, it -should- work, but doesn't for some reason, at least in my code. I'll look at it some more in a bit, but right now I'm happy that that error's gone- thanks!

tuan kuranes

28-02-2006 07:54:05

1) if not paused, pagemanager try to load/unload queue based on number of frames elapsed...
2) right, i'll change the misleading code.. now set pause to true set mEnabled to false.

nyxojaele

03-03-2006 04:44:55

I'm having some issues with this new pause feature...

Some code snippets (in case I'm doing something wrong...):

In my state pause function:
mPause = true;
mSceneMgr->setOption("pause", &mPause);


In my state resume function:
bool mPause = false;
mSceneMgr->setOption("pause", &mPause);


In my frameListener:
bool temp;
Root::getSingleton().getSceneManager("PLSM2Instance")->getOption("pause", &temp);
if (temp == false)
Root::getSingleton();

(with a break on the Root::getSingleton() line)

The problem is that I never reach that break...

I've followed the code right up to the point in OgrePagingLandScapeSceneManager.cpp where it calls mPageManager->setEnabled, and the value is good right up till that point... it just seems that mEnabled just -doesn't- get set in mPageManager, for some reason...

Any thoughts?

I think I'm going to try grabbing the CVS again to see if maybe it's something strange since I last got it, but this one's kinda getting to me. All simple code, yet it just seems to be ... ignoring what it should be doing, heh heh.

tuan kuranes

03-03-2006 13:23:59

Any thoughts?
Very strange, and when you debug into mPageManager->setEnabled() ? does it changes the value ? Perhaps a rebuild is needed...

And make sure you don't load the scene in middle of a pause, because calling Load() on pagemanager just reset pause to false (and enabled to true)

nyxojaele

04-03-2006 18:32:01

Okay, so I did some tests here.. Before grabbing the CVS, I stepped thru the code, watching the memory address directly where mPageManager's mEnabled is stored.

Before CVS (this is before you changed the code so "pause" and mEnabled are opposite), I was having issues making mEnabled change to false, it just didn't want to change.

I grabbed CVS, compiled, and whatnot, and now I can successfully change mEnabled to false, but I can't change it back to true anymore. The memory at that address just does not change.

My first thoughts were something in all that strange casting you have inside the setOption function. I'm pretty sure it's something in there, because on checking things out, no matter what value I pass in, once I'm sitting in the PageManager::setEnabled() function, the enabled variable is always equal to false.

tuan kuranes

06-03-2006 08:50:36

sorry you're right, missing a * after !
fixed in CVS

nyxojaele

06-03-2006 13:25:33

Awsome, I'm glad I'm not going insane as quickly as I thought^^

Glad to help!

nyxojaele

09-03-2006 03:16:20

Time to revive a dead thread! Albeit a recently deceased, it was deceased, nonetheless..

Still on the topic of StateManaging here. I noticed that when I run my example program, initially in the PLSM2 state (memory usage stabilizes at about 86mb), pause to another state, and then come back, immediately (almost), the PLSM2 SceneManager allocates an an additional 20mb or so of memory. But what gets me is that this only happens the FIRST time I pause & resume. Each time after that, something allocates more memory, but it's closer to 4kb or so... (which, as I understand things, -still- shouldn't be happening, but I'm more concerned about that 20mb!)

Anyways, I've been chasing it down, and narrowed it down to somewhere deep inside the PLSM2 SceneManager:

Line 635 of ogrepaginglandscapepage.cpp:
tr[ k ]->_Notify(pos, Cam);

Somewhere in that _Notify function is at least -some- of these allocations. I stopped chasing after this here because as it is, I'm in completely unfamiliar territory, and I have no idea what it is that I'm looking at here.

Here's the callstack for a point in time roughly where the allocations are occurring:
> Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapePage::_Notify(const Ogre::Vector3 & pos={...}, Ogre::PagingLandScapeCamera * Cam=0x049a8420) Line 635 C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapePageManager::updateLoadedPages() Line 309 + 0x10 bytes C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapePageManager::updatePaging(Ogre::PagingLandScapeCamera * cam=0x049a8420) Line 478 C++
Plugin_PagingLandScapeSceneManager2_d.dll!Ogre::PagingLandScapeSceneManager::_updateSceneGraph(Ogre::Camera * cam=0x049a8420) Line 330 C++
OgreMain_d.dll!Ogre::SceneManager::_renderScene(Ogre::Camera * camera=0x049a8420, Ogre::Viewport * vp=0x08c69a78, bool includeOverlays=true) Line 959 + 0x16 bytes C++
OgreMain_d.dll!Ogre::Camera::_renderScene(Ogre::Viewport * vp=0x08c69a78, bool includeOverlays=true) Line 387 + 0x2c bytes C++
OgreMain_d.dll!Ogre::Viewport::update() Line 189 C++
OgreMain_d.dll!Ogre::RenderTarget::update() Line 107 C++
OgreMain_d.dll!Ogre::RenderWindow::update(bool swap=true) Line 72 C++
RenderSystem_Direct3D9.dll!Ogre::D3D9RenderWindow::update(bool swap=true) Line 962 + 0xf bytes C++
OgreMain_d.dll!Ogre::RenderWindow::update() Line 63 + 0x14 bytes C++
OgreMain_d.dll!Ogre::RenderSystem::_updateAllRenderTargets() Line 100 + 0x26 bytes C++
OgreMain_d.dll!Ogre::Root::_updateAllRenderTargets() Line 995 + 0x1a bytes C++
OgreMain_d.dll!Ogre::Root::renderOneFrame() Line 739 C++
OgreMain_d.dll!Ogre::Root::startRendering() Line 727 + 0x8 bytes C++
State manager with PLSM2.exe!application::go(gameState * state=0x00425560) Line 27 + 0xe bytes C++
State manager with PLSM2.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x002220b6, int nShowCmd=1) Line 17 + 0x1a bytes C++
State manager with PLSM2.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
State manager with PLSM2.exe!WinMainCRTStartup() Line 403 C
kernel32.dll!7d4e6e1a()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]


Also, here is a zip of my example project, with everything you need except for the terrain itself, and the DLLs. Press F10 in the program to pause/resume the PLSM2 state.

http://www.savefile.com/files/6548851 (approx 1mb)

tuan kuranes

09-03-2006 19:17:43

I'll try to have a look asap.

nyxojaele

14-03-2006 04:50:18

Since I'm posting here on the forums, I thought I'd check up on the status here as well. Managed to find anything on this yet?

(Hmm... why do I get the feeling that I'm the only person bugging you with these problems... sorry about that Tuan;;)

tuan kuranes

14-03-2006 15:33:50

Just tested : you create a new camera at each resume()... you should create one per state in you code. (PLSM2 have per camera information on nodes... it takes place.)

nyxojaele

15-03-2006 01:20:02

Ah, so it is such. I'm sorry to have bothered you with a problem with my own code :oops:

Now the values go up and down when pausing/resuming, but sometimes it's slightly more, and sometimes it's slightly less.. Seems to hover around the same value tho, so I will for the time being consider this stable. Thanks for pointing that out! (it helped me find another bug too^^)