Hiding the rendering manager; crash eliminated

actorid
Jason Hooks 13 years ago
parent 965ff24597
commit d4f63443e6

@ -35,11 +35,13 @@ bool ExteriorCellRender::lightOutQuadInLin = false;
int ExteriorCellRender::uniqueID = 0;
ExteriorCellRender::ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
RenderingManager &_rendering, MWWorld::PhysicsSystem *physics)
: mCell(_cell), mEnvironment (environment), mRendering(_rendering), mPhysics(physics), mBase(NULL), mInsert(NULL), mAmbientMode (0)
OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot,MWWorld::PhysicsSystem *physics)
: mCell(_cell), mEnvironment (environment), mRenderer(renderer), mPhysics(physics), mBase(NULL), mInsert(NULL), mAmbientMode (0)
{
mMwRoot = mwRoot;
uniqueID = uniqueID +1;
sg = mRendering.getMgr()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
}
@ -127,7 +129,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
mNpcPart = parent->createChildSceneNode(sceneNodeName);
MeshPtr good2 = NifOgre::NIFLoader::load(mesh);
MovableObject *ent = mRendering.getMgr()->createEntity(mesh);
MovableObject *ent = mRenderer.getScene()->createEntity(mesh);
if(translateFirst){
@ -215,7 +217,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh)
assert (mInsert);
NifOgre::NIFLoader::load(mesh);
Entity *ent = mRendering.getMgr()->createEntity(mesh);
Entity *ent = mRenderer.getScene()->createEntity(mesh);
if(!isStatic)
{
@ -225,7 +227,7 @@ void ExteriorCellRender::insertMesh(const std::string &mesh)
{
sg->addEntity(ent,mInsert->_getDerivedPosition(),mInsert->_getDerivedOrientation(),mInsert->_getDerivedScale());
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
mRendering.getMgr()->destroyEntity(ent);
mRenderer.getScene()->destroyEntity(ent);
}
if (mInsertMesh.empty())
mInsertMesh = mesh;
@ -250,7 +252,7 @@ void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
{
assert (mInsert);
Ogre::Light *light = mRendering.getMgr()->createLight();
Ogre::Light *light = mRenderer.getScene()->createLight();
light->setDiffuseColour (r, g, b);
float cval=0.0f, lval=0.0f, qval=0.0f;
@ -306,7 +308,7 @@ void ExteriorCellRender::configureAmbient()
// Create a "sun" that shines light downwards. It doesn't look
// completely right, but leave it for now.
Ogre::Light *light = mRendering.getMgr()->createLight();
Ogre::Light *light = mRenderer.getScene()->createLight();
Ogre::ColourValue colour;
colour.setAsABGR (mCell.cell->ambi.sunlight);
light->setDiffuseColour (colour);
@ -323,9 +325,9 @@ void ExteriorCellRender::configureFog()
float high = 4500 + 9000 * (1-mCell.cell->ambi.fogDensity);
float low = 200;
mRendering.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
mRendering.getCamera()->setFarClipDistance (high + 10);
mRendering.getViewport()->setBackgroundColour (color);
mRenderer.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
mRenderer.getCamera()->setFarClipDistance (high + 10);
mRenderer.getViewport()->setBackgroundColour (color);
}
void ExteriorCellRender::setAmbientMode()
@ -334,17 +336,17 @@ void ExteriorCellRender::setAmbientMode()
{
case 0:
mRendering.getMgr()->setAmbientLight(mAmbientColor);
mRenderer.getScene()->setAmbientLight(mAmbientColor);
break;
case 1:
mRendering.getMgr()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
mRenderer.getScene()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
break;
case 2:
mRendering.getMgr()->setAmbientLight(ColourValue(1,1,1));
mRenderer.getScene()->setAmbientLight(ColourValue(1,1,1));
break;
}
}
@ -352,7 +354,7 @@ void ExteriorCellRender::setAmbientMode()
void ExteriorCellRender::show()
{
// FIXME: this one may be the bug
mBase = mRendering.getRoot()->createChildSceneNode();
mBase = mMwRoot->createChildSceneNode();
configureAmbient();
configureFog();
@ -401,14 +403,14 @@ void ExteriorCellRender::destroy()
{
destroyAllAttachedMovableObjects(mBase);
mBase->removeAndDestroyAllChildren();
mRendering.getMgr()->destroySceneNode(mBase);
mRenderer.getScene()->destroySceneNode(mBase);
}
mBase = 0;
if (sg)
{
mRendering.getMgr()->destroyStaticGeometry (sg);
mRenderer.getScene()->destroyStaticGeometry (sg);
sg = 0;
}
}
@ -435,21 +437,21 @@ void ExteriorCellRender::toggleLight()
void ExteriorCellRender::enable (const std::string& handle)
{
if (!handle.empty())
mRendering.getMgr()->getSceneNode (handle)->setVisible (true);
mRenderer.getScene()->getSceneNode (handle)->setVisible (true);
}
void ExteriorCellRender::disable (const std::string& handle)
{
if (!handle.empty())
mRendering.getMgr()->getSceneNode (handle)->setVisible (false);
mRenderer.getScene()->getSceneNode (handle)->setVisible (false);
}
void ExteriorCellRender::deleteObject (const std::string& handle)
{
if (!handle.empty())
{
Ogre::SceneNode *node = mRendering.getMgr()->getSceneNode (handle);
Ogre::SceneNode *node = mRenderer.getScene()->getSceneNode (handle);
node->removeAndDestroyAllChildren();
mRendering.getMgr()->destroySceneNode (node);
mRenderer.getScene()->destroySceneNode (node);
}
}

@ -49,7 +49,8 @@ namespace MWRender
ESMS::CellStore<MWWorld::RefData> &mCell;
MWWorld::Environment &mEnvironment;
RenderingManager &mRendering;
OEngine::Render::OgreRenderer& mRenderer;
Ogre::SceneNode *mMwRoot;
MWWorld::PhysicsSystem *mPhysics;
/// The scene node that contains all objects belonging to this
@ -103,7 +104,7 @@ namespace MWRender
public:
ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
RenderingManager &_rendering, MWWorld::PhysicsSystem *physics);
OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot, MWWorld::PhysicsSystem *physics);
virtual ~ExteriorCellRender() { destroy(); }

@ -109,7 +109,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
MeshPtr good2 = NifOgre::NIFLoader::load(mesh);
MovableObject *ent = mRendering.getMgr()->createEntity(mesh);
MovableObject *ent = mRenderer.getScene()->createEntity(mesh);
//ent->extr
// MovableObject *ent2 = scene.getMgr()->createEntity(bounds
@ -186,7 +186,7 @@ void InteriorCellRender::insertMesh(const std::string &mesh)
assert (insert);
NifOgre::NIFLoader::load(mesh);
MovableObject *ent = mRendering.getMgr()->createEntity(mesh);
MovableObject *ent = mRenderer.getScene()->createEntity(mesh);
insert->attachObject(ent);
if (mInsertMesh.empty())
@ -212,7 +212,7 @@ void InteriorCellRender::insertLight(float r, float g, float b, float radius)
{
assert (insert);
Ogre::Light *light = mRendering.getMgr()->createLight();
Ogre::Light *light = mRenderer.getScene()->createLight();
light->setDiffuseColour (r, g, b);
float cval=0.0f, lval=0.0f, qval=0.0f;
@ -268,7 +268,7 @@ void InteriorCellRender::configureAmbient()
// Create a "sun" that shines light downwards. It doesn't look
// completely right, but leave it for now.
Ogre::Light *light = mRendering.getMgr()->createLight();
Ogre::Light *light = mRenderer.getScene()->createLight();
Ogre::ColourValue colour;
colour.setAsABGR (cell.cell->ambi.sunlight);
light->setDiffuseColour (colour);
@ -285,9 +285,9 @@ void InteriorCellRender::configureFog()
float high = 4500 + 9000 * (1-cell.cell->ambi.fogDensity);
float low = 200;
mRendering.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
mRendering.getCamera()->setFarClipDistance (high + 10);
mRendering.getViewport()->setBackgroundColour (color);
mRenderer.getScene()->setFog (FOG_LINEAR, color, 0, low, high);
mRenderer.getCamera()->setFarClipDistance (high + 10);
mRenderer.getViewport()->setBackgroundColour (color);
}
void InteriorCellRender::setAmbientMode()
@ -296,24 +296,24 @@ void InteriorCellRender::setAmbientMode()
{
case 0:
mRendering.getMgr()->setAmbientLight(ambientColor);
mRenderer.getScene()->setAmbientLight(ambientColor);
break;
case 1:
mRendering.getMgr()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1));
mRenderer.getScene()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1));
break;
case 2:
mRendering.getMgr()->setAmbientLight(ColourValue(1,1,1));
mRenderer.getScene()->setAmbientLight(ColourValue(1,1,1));
break;
}
}
void InteriorCellRender::show()
{
base = mRendering.getRoot()->createChildSceneNode();
base = mMwRoot->createChildSceneNode();
configureAmbient();
configureFog();
@ -332,7 +332,7 @@ void InteriorCellRender::destroy()
if(base)
{
base->removeAndDestroyAllChildren();
mRendering.getMgr()->destroySceneNode(base);
mRenderer.getScene()->destroySceneNode(base);
}
base = NULL;
@ -360,22 +360,22 @@ void InteriorCellRender::toggleLight()
void InteriorCellRender::enable (const std::string& handle)
{
if (!handle.empty())
mRendering.getMgr()->getSceneNode (handle)->setVisible (true);
mRenderer.getScene()->getSceneNode (handle)->setVisible (true);
}
void InteriorCellRender::disable (const std::string& handle)
{
if (!handle.empty())
mRendering.getMgr()->getSceneNode (handle)->setVisible (false);
mRenderer.getScene()->getSceneNode (handle)->setVisible (false);
}
void InteriorCellRender::deleteObject (const std::string& handle)
{
if (!handle.empty())
{
Ogre::SceneNode *node = mRendering.getMgr()->getSceneNode (handle);
Ogre::SceneNode *node = mRenderer.getScene()->getSceneNode (handle);
node->removeAndDestroyAllChildren();
mRendering.getMgr()->destroySceneNode (node);
mRenderer.getScene()->destroySceneNode (node);
}
}

@ -48,7 +48,8 @@ namespace MWRender
ESMS::CellStore<MWWorld::RefData> &cell;
MWWorld::Environment &mEnvironment;
MWRender::RenderingManager &mRendering;
OEngine::Render::OgreRenderer& mRenderer;
Ogre::SceneNode *mMwRoot;
MWWorld::PhysicsSystem *mPhysics;
/// The scene node that contains all objects belonging to this
@ -95,9 +96,10 @@ namespace MWRender
public:
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
RenderingManager &_rendering, MWWorld::PhysicsSystem *physics)
: cell(_cell), mEnvironment (environment), mRendering(_rendering), base(NULL), insert(NULL), ambientMode (0)
OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot, MWWorld::PhysicsSystem *physics)
: cell(_cell), mEnvironment (environment), mRenderer(renderer), base(NULL), insert(NULL), ambientMode (0)
{
mMwRoot = mwRoot;
mPhysics = physics;
}

@ -29,7 +29,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
//std::cout << "ONE";
rend.createScene("PlayerCam", 55, 5);
mSkyManager = MWRender::SkyManager::create(rend.getWindow(), getCamera(), resDir);
mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir);
// Set default mipmap level (NB some APIs ignore this)
TextureManager::getSingleton().setDefaultNumMipmaps(5);
@ -54,10 +54,9 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
playerNode->pitch(Degree(90));
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
cameraPitchNode->attachObject(getCamera());
std::cout <<"TWOF\n";
cameraPitchNode->attachObject(rend.getCamera());
mPlayer = new MWRender::Player (getCamera(), playerNode->getName());
mPlayer = new MWRender::Player (rend.getCamera(), playerNode->getName());
//std::cout << "Three";
}

@ -77,9 +77,8 @@ class RenderingManager {
int skyGetMasserPhase() const;
int skyGetSecundaPhase() const;
void skySetMoonColour (bool red);
OEngine::Render::OgreRenderer& getOgreRenderer(){return rend;}
Ogre::SceneManager *getMgr() { return rend.getScene(); }
Ogre::Camera *getCamera() { return rend.getCamera(); }
Ogre::Viewport *getViewport() { return rend.getViewport(); }
Ogre::SceneNode *getRoot() { return mwRoot; }
MWRender::Player *getPlayer() { return mPlayer; }
private:

@ -137,7 +137,7 @@ namespace MWWorld
{
Ptr::CellStore *cell = mWorld->getExterior(x, y);
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mRendering, mPhysics));
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mRenderer, mMwRoot, mPhysics));
}
}
@ -168,10 +168,12 @@ namespace MWWorld
mCellChanged = true;
}
Scene::Scene (Environment& environment, World *world, MWRender::RenderingManager& rm, PhysicsSystem *physics)
: mRendering(rm), mCurrentCell (0),
//We need the ogre renderer and a scene node.
Scene::Scene (Environment& environment, World *world, OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot, PhysicsSystem *physics)
: mRenderer(renderer), mCurrentCell (0),
mCellChanged (false), mEnvironment (environment), mWorld(world), mPhysics(physics)
{
mMwRoot = mwRoot;
}
Scene::~Scene()
@ -205,7 +207,7 @@ namespace MWWorld
std::cout << "cellName:" << cellName << std::endl;
Ptr::CellStore *cell = mWorld->getInterior(cellName);
loadCell (cell, new MWRender::InteriorCellRender (*cell, mEnvironment, mRendering, mPhysics));
loadCell (cell, new MWRender::InteriorCellRender (*cell, mEnvironment, mRenderer, mMwRoot, mPhysics));
// adjust player
mCurrentCell = cell;

@ -57,7 +57,8 @@ namespace MWWorld
private:
MWRender::RenderingManager mRendering;
OEngine::Render::OgreRenderer& mRenderer;
Ogre::SceneNode *mMwRoot;
Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells;
bool mCellChanged;
@ -69,7 +70,7 @@ namespace MWWorld
bool adjustPlayerPos = true);
public:
Scene (Environment& environment, World *world, MWRender::RenderingManager& rm, PhysicsSystem *physics);
Scene (Environment& environment, World *world, OEngine::Render::OgreRenderer& renderer, Ogre::SceneNode *mwRoot, PhysicsSystem *physics);
~Scene();

@ -179,6 +179,7 @@ namespace MWWorld
: mRendering (renderer,resDir), mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
mSky (false), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), mDebugging(physEng)
{
std::cout << "Creating myworld\n";
mPhysEngine = physEng;
mPhysics = new PhysicsSystem(renderer, physEng);
@ -206,7 +207,8 @@ namespace MWWorld
mPhysEngine = physEng;
mWorldScene = new Scene(environment, this, mRendering, mPhysics);
mWorldScene = new Scene(environment, this, mRendering.getOgreRenderer(), mRendering.getRoot(), mPhysics);
std::cout << "After mworldscene\n";
}
@ -214,8 +216,10 @@ namespace MWWorld
{
delete mWorldScene;
delete mGlobalVariables;
delete mPlayer;
delete mPhysics;
delete mPlayer;
}
const ESM::Cell *World::getExterior (const std::string& cellName) const

Loading…
Cancel
Save