1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 09:53:51 +00:00

Zinis branch merge

This commit is contained in:
Jason Hooks 2012-01-22 15:02:38 -05:00
commit ec94ecacaf
12 changed files with 182 additions and 169 deletions

View file

@ -74,7 +74,7 @@ void OMW::Engine::updateFocusReport (float duration)
mFocusTDiff = 0; mFocusTDiff = 0;
std::string name; std::string name;
std::string handle = mEnvironment.mWorld->getFacedHandle(); std::string handle = mEnvironment.mWorld->getFacedHandle();
if (!handle.empty()) if (!handle.empty())
@ -84,7 +84,7 @@ void OMW::Engine::updateFocusReport (float duration)
if (!ptr.isEmpty()){ if (!ptr.isEmpty()){
name = MWWorld::Class::get (ptr).getName (ptr); name = MWWorld::Class::get (ptr).getName (ptr);
} }
} }
if (name!=mFocusName) if (name!=mFocusName)
@ -287,7 +287,7 @@ void OMW::Engine::setReportFocus (bool report)
void OMW::Engine::go() void OMW::Engine::go()
{ {
mFocusTDiff = 0; mFocusTDiff = 0;
assert (!mEnvironment.mWorld); assert (!mEnvironment.mWorld);
assert (!mCellName.empty()); assert (!mCellName.empty());
assert (!mMaster.empty()); assert (!mMaster.empty());
@ -416,41 +416,36 @@ void OMW::Engine::go()
void OMW::Engine::activate() void OMW::Engine::activate()
{ {
// TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside std::string handle = mEnvironment.mWorld->getFacedHandle();
// the input handling functions. Looks like this will require an OpenEngine modification.
try if (handle.empty())
return;
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
mEnvironment);
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
if (!script.empty())
{ {
std::string handle = mEnvironment.mWorld->getFacedHandle(); mEnvironment.mWorld->getLocalScripts().setIgnore (ptr);
if (handle.empty()) mScriptManager->run (script, interpreterContext);
return;
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
mEnvironment);
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
if (!script.empty())
{
mEnvironment.mWorld->getLocalScripts().setIgnore (ptr);
mScriptManager->run (script, interpreterContext);
}
if (!interpreterContext.hasActivationBeenHandled())
{
interpreterContext.executeActivation();
}
} }
catch (const std::exception& e)
if (!interpreterContext.hasActivationBeenHandled())
{ {
std::cerr << "Activation failed: " << e.what() << std::endl; interpreterContext.executeActivation();
} }
} }

View file

@ -31,11 +31,11 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
Ogre::SceneNode* cellnode; Ogre::SceneNode* cellnode;
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end()) if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
{ {
//Create the scenenode and put it in the map //Create the scenenode and put it in the map
cellnode = root->createChildSceneNode(); cellnode = root->createChildSceneNode();
mCellSceneNodes[ptr.getCell()] = cellnode; mCellSceneNodes[ptr.getCell()] = cellnode;
} }
else else
{ {
cellnode = mCellSceneNodes[ptr.getCell()]; cellnode = mCellSceneNodes[ptr.getCell()];
} }
@ -64,7 +64,7 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){
ptr.getRefData().setBaseNode(insert); ptr.getRefData().setBaseNode(insert);
isStatic = static_; isStatic = static_;
} }
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
Ogre::SceneNode* insert = ptr.getRefData().getBaseNode(); Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
@ -79,8 +79,8 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
} }
else else
{ {
Ogre::StaticGeometry* sg; Ogre::StaticGeometry* sg = 0;
if(mSG.find(ptr.getCell()) == mSG.end()) if(mSG.find(ptr.getCell()) == mSG.end())
{ {
uniqueID = uniqueID +1; uniqueID = uniqueID +1;
sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); sg = mRend.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
@ -95,10 +95,10 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale()); sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000)); sg->setRegionDimensions(Ogre::Vector3(100000,10000,100000));
mRend.getScene()->destroyEntity(ent); mRend.getScene()->destroyEntity(ent);
} }
} }
void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius){
@ -135,30 +135,42 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
insert->attachObject(light); insert->attachObject(light);
} }
void Objects::deleteObject (const std::string& handle) bool Objects::deleteObject (const MWWorld::Ptr& ptr)
{ {
if (!handle.empty()) if (Ogre::SceneNode *base = ptr.getRefData().getBaseNode())
{ {
Ogre::SceneNode *node = mRend.getScene()->getSceneNode (handle); Ogre::SceneNode *parent = base->getParentSceneNode();
node->removeAndDestroyAllChildren();
mRend.getScene()->destroySceneNode (node); for (std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *>::const_iterator iter (
mCellSceneNodes.begin()); iter!=mCellSceneNodes.end(); ++iter)
if (iter->second==parent)
{
base->removeAndDestroyAllChildren();
mRend.getScene()->destroySceneNode (base);
ptr.getRefData().setBaseNode (0);
return true;
}
return false;
} }
return true;
} }
void Objects::removeCell(MWWorld::Ptr::CellStore* store){ void Objects::removeCell(MWWorld::Ptr::CellStore* store){
if(mCellSceneNodes.find(store) != mCellSceneNodes.end()) if(mCellSceneNodes.find(store) != mCellSceneNodes.end())
{ {
Ogre::SceneNode* base = mCellSceneNodes[store]; Ogre::SceneNode* base = mCellSceneNodes[store];
base->removeAndDestroyAllChildren(); base->removeAndDestroyAllChildren();
mCellSceneNodes.erase(store); mCellSceneNodes.erase(store);
mRend.getScene()->destroySceneNode(base); mRend.getScene()->destroySceneNode(base);
base = 0; base = 0;
} }
if(mSG.find(store) != mSG.end()) if(mSG.find(store) != mSG.end())
{ {
Ogre::StaticGeometry* sg = mSG[store]; Ogre::StaticGeometry* sg = mSG[store];
mSG.erase(store); mSG.erase(store);
mRend.getScene()->destroyStaticGeometry (sg); mRend.getScene()->destroyStaticGeometry (sg);
sg = 0; sg = 0;
@ -167,9 +179,7 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store){
void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell){ void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell){
if(mSG.find(&cell) != mSG.end()) if(mSG.find(&cell) != mSG.end())
{ {
Ogre::StaticGeometry* sg = mSG[&cell]; Ogre::StaticGeometry* sg = mSG[&cell];
sg->build(); sg->build();
} }
} }

View file

@ -10,9 +10,9 @@
namespace MWRender{ namespace MWRender{
class Objects{ class Objects{
OEngine::Render::OgreRenderer &mRend; OEngine::Render::OgreRenderer &mRend;
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes; std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mSG; std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mSG;
Ogre::SceneNode* mwRoot; Ogre::SceneNode* mwRoot;
bool isStatic; bool isStatic;
static int uniqueID; static int uniqueID;
@ -36,14 +36,13 @@ public:
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius); void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
void deleteObject (const std::string& handle);
bool deleteObject (const MWWorld::Ptr& ptr);
///< \return found?
void removeCell(MWWorld::Ptr::CellStore* store); void removeCell(MWWorld::Ptr::CellStore* store);
void buildStaticGeometry(ESMS::CellStore<MWWorld::RefData> &cell); void buildStaticGeometry(ESMS::CellStore<MWWorld::RefData> &cell);
void setMwRoot(Ogre::SceneNode* root); void setMwRoot(Ogre::SceneNode* root);
/// insert a light related to the most recent insertBegin call.
}; };
} }
#endif #endif

View file

@ -21,14 +21,11 @@ namespace MWRender {
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine) :rend(_rend), mDebugging(engine), objects(rend) RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine)
:rend(_rend), objects(rend), mDebugging(engine)
{ {
rend.createScene("PlayerCam", 55, 5);
mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir);
//std::cout << "ONE";
rend.createScene("PlayerCam", 55, 5);
mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir);
// Set default mipmap level (NB some APIs ignore this) // Set default mipmap level (NB some APIs ignore this)
TextureManager::getSingleton().setDefaultNumMipmaps(5); TextureManager::getSingleton().setDefaultNumMipmaps(5);
@ -41,7 +38,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
// the screen (when x is to the right.) This is the orientation that // the screen (when x is to the right.) This is the orientation that
// Morrowind uses, and it automagically makes everything work as it // Morrowind uses, and it automagically makes everything work as it
// should. // should.
//std::cout << "TWO";
SceneNode *rt = rend.getScene()->getRootSceneNode(); SceneNode *rt = rend.getScene()->getRootSceneNode();
mwRoot = rt->createChildSceneNode(); mwRoot = rt->createChildSceneNode();
mwRoot->pitch(Degree(-90)); mwRoot->pitch(Degree(-90));
@ -57,6 +53,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
cameraPitchNode->attachObject(rend.getCamera()); cameraPitchNode->attachObject(rend.getCamera());
mPlayer = new MWRender::Player (rend.getCamera(), playerNode); mPlayer = new MWRender::Player (rend.getCamera(), playerNode);
mWater = 0; mWater = 0;
//std::cout << "Three"; //std::cout << "Three";
@ -64,24 +61,23 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
RenderingManager::~RenderingManager () RenderingManager::~RenderingManager ()
{ {
delete mPlayer; delete mPlayer;
delete mSkyManager; delete mSkyManager;
} }
MWRender::Npcs& RenderingManager::getNPCs(){ MWRender::Npcs& RenderingManager::getNPCs(){
return npcs; return npcs;
} }
MWRender::Objects& RenderingManager::getObjects(){ MWRender::Objects& RenderingManager::getObjects(){
return objects; return objects;
} }
MWRender::Creatures& RenderingManager::getCreatures(){ MWRender::Creatures& RenderingManager::getCreatures(){
return creatures; return creatures;
} }
MWRender::Player& RenderingManager::getPlayer(){ MWRender::Player& RenderingManager::getPlayer(){
return (*mPlayer); return (*mPlayer);
} }
void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){ void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){
objects.removeCell(store); objects.removeCell(store);
@ -92,17 +88,33 @@ void RenderingManager::removeWater (){
mWater = 0; mWater = 0;
} }
} }
void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store)
{
objects.buildStaticGeometry (*store);
}
void RenderingManager::addObject (const MWWorld::Ptr& ptr){ void RenderingManager::addObject (const MWWorld::Ptr& ptr){
const MWWorld::Class& class_ = const MWWorld::Class& class_ =
MWWorld::Class::get (ptr); MWWorld::Class::get (ptr);
class_.insertObjectRendering(ptr, *this); class_.insertObjectRendering(ptr, *this);
}
void RenderingManager::removeObject (const MWWorld::Ptr& ptr){
} }
void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position){ void RenderingManager::removeObject (const MWWorld::Ptr& ptr)
{
if (!objects.deleteObject (ptr))
{
/// \todo delete non-object MW-references
}
} }
void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position)
{
/// \todo move this to the rendering-subsystems
rend.getScene()->getSceneNode (ptr.getRefData().getHandle())->
setPosition (position);
}
void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale){ void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale){
} }
@ -112,17 +124,12 @@ void RenderingManager::rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quate
void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store){ void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store){
} }
void RenderingManager::setPhysicsDebugRendering (bool){
}
bool RenderingManager::getPhysicsDebugRendering() const{
return true;
}
void RenderingManager::update (float duration){ void RenderingManager::update (float duration){
} }
void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store){ void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){
if(store->cell->data.flags & store->cell->HasWater){ if(store->cell->data.flags & store->cell->HasWater){
if(mWater == 0) if(mWater == 0)
mWater = new MWRender::Water(rend.getCamera(), store->cell); mWater = new MWRender::Water(rend.getCamera(), store->cell);
@ -168,7 +175,7 @@ void RenderingManager::skySetMoonColour (bool red)
mSkyManager->setMoonColour(red); mSkyManager->setMoonColour(red);
} }
bool RenderingManager::toggleRenderMode(int mode){ bool RenderingManager::toggleRenderMode(int mode){
return mDebugging.toggleRenderMode(mode); return mDebugging.toggleRenderMode(mode);
} }
void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell) void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)

View file

@ -4,7 +4,6 @@
#include "sky.hpp" #include "sky.hpp"
#include "debugging.hpp" #include "debugging.hpp"
//Commented out for now, possibly do an ifdef if necessary, cla
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -45,30 +44,42 @@ namespace MWWorld
namespace MWRender namespace MWRender
{ {
class RenderingManager: private RenderingInterface { class RenderingManager: private RenderingInterface {
private:
virtual MWRender::Npcs& getNPCs();
virtual MWRender::Creatures& getCreatures();
virtual MWRender::Objects& getObjects();
public: public:
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine); RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine);
virtual ~RenderingManager(); virtual ~RenderingManager();
virtual MWRender::Npcs& getNPCs();
virtual MWRender::Creatures& getCreatures();
virtual MWRender::Objects& getObjects();
virtual MWRender::Player& getPlayer();
void cellAdded (MWWorld::Ptr::CellStore *store);
void toggleLight();
bool toggleRenderMode(int mode);
void removeCell (MWWorld::Ptr::CellStore *store); // TODO do we want this?
virtual MWRender::Player& getPlayer(); /// \todo move this to private again as soon as
/// MWWorld::Player has been rewritten to not need access
/// to internal details of the rendering system anymore
void toggleLight();
bool toggleRenderMode(int mode);
void removeCell (MWWorld::Ptr::CellStore *store);
/// \todo this function should be removed later. Instead the rendering subsystems should track
/// when rebatching is needed and update automatically at the end of each frame.
void cellAdded (MWWorld::Ptr::CellStore *store);
void waterAdded(MWWorld::Ptr::CellStore *store);
void removeWater(); void removeWater();
void addObject (const MWWorld::Ptr& ptr); void addObject (const MWWorld::Ptr& ptr);
void removeObject (const MWWorld::Ptr& ptr); void removeObject (const MWWorld::Ptr& ptr);
void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position); void moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position);
void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale); void scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale);
void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation); void rotateObject (const MWWorld::Ptr& ptr, const::Ogre::Quaternion& orientation);
@ -76,12 +87,9 @@ class RenderingManager: private RenderingInterface {
/// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell).
void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store); void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::Ptr::CellStore *store);
void setPhysicsDebugRendering (bool);
bool getPhysicsDebugRendering() const;
void update (float duration); void update (float duration);
void skyEnable (); void skyEnable ();
void skyDisable (); void skyDisable ();
void skySetHour (double hour); void skySetHour (double hour);
@ -89,15 +97,12 @@ class RenderingManager: private RenderingInterface {
int skyGetMasserPhase() const; int skyGetMasserPhase() const;
int skyGetSecundaPhase() const; int skyGetSecundaPhase() const;
void skySetMoonColour (bool red); void skySetMoonColour (bool red);
OEngine::Render::OgreRenderer& getOgreRenderer(){return rend;} void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
Ogre::SceneManager *getMgr() { return rend.getScene(); } /// configure fog according to cell
Ogre::SceneNode *getRoot() { return mwRoot; }
void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
/// configure fog according to cell
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell); void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
private: private:
void setAmbientMode(); void setAmbientMode();
SkyManager* mSkyManager; SkyManager* mSkyManager;
OEngine::Render::OgreRenderer &rend; OEngine::Render::OgreRenderer &rend;
@ -107,23 +112,23 @@ class RenderingManager: private RenderingInterface {
MWRender::Water *mWater; MWRender::Water *mWater;
MWRender::Objects objects; MWRender::Objects objects;
// 0 normal, 1 more bright, 2 max
// 0 normal, 1 more bright, 2 max
int mAmbientMode; int mAmbientMode;
Ogre::ColourValue mAmbientColor; Ogre::ColourValue mAmbientColor;
/// Root node for all objects added to the scene. This is rotated so /// Root node for all objects added to the scene. This is rotated so
/// that the OGRE coordinate system matches that used internally in /// that the OGRE coordinate system matches that used internally in
/// Morrowind. /// Morrowind.
Ogre::SceneNode *mwRoot; Ogre::SceneNode *mwRoot;
Ogre::RaySceneQuery *mRaySceneQuery; Ogre::RaySceneQuery *mRaySceneQuery;
OEngine::Physic::PhysicEngine* eng; OEngine::Physic::PhysicEngine* eng;
MWRender::Player *mPlayer; MWRender::Player *mPlayer;
MWRender::Debugging mDebugging; MWRender::Debugging mDebugging;
}; };
} }

View file

@ -7,9 +7,10 @@ namespace MWRender {
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false); Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "Water", false);
} catch(...) { } catch(...) {
} }
std::cout << "Water Constructor\n";
mTop = cell->water; mTop = cell->water;
std::cout << "Making water\n";
mIsUnderwater = false; mIsUnderwater = false;
mCamera->addListener(this); mCamera->addListener(this);
@ -27,25 +28,24 @@ namespace MWRender {
mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); mWaterNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
//if(!(cell->data.flags & cell->Interior))
//{ if(!(cell->data.flags & cell->Interior))
mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY)); {
//} mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY));
//else }
// mWaterNode->setPosition(10000, 0, 10000); //Don't mess with y
mWaterNode->attachObject(mWater); mWaterNode->attachObject(mWater);
} }
Water::~Water() { Water::~Water() {
Ogre::MeshManager::getSingleton().remove("water");
mCamera->removeListener(this); mCamera->removeListener(this);
mWaterNode->detachObject(mWater); mWaterNode->detachObject(mWater);
mSceneManager->destroyEntity(mWater); mSceneManager->destroyEntity(mWater);
mSceneManager->destroySceneNode(mWaterNode); mSceneManager->destroySceneNode(mWaterNode);
Ogre::MeshManager::getSingleton().remove("water");
//Ogre::TextureManager::getSingleton().remove("refraction"); //Ogre::TextureManager::getSingleton().remove("refraction");
//Ogre::TextureManager::getSingleton().remove("reflection"); //Ogre::TextureManager::getSingleton().remove("reflection");
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport); Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);

View file

@ -22,7 +22,7 @@ namespace MWWorld
playerPos[0] = playerPos[1] = playerPos[2] = 0; playerPos[0] = playerPos[1] = playerPos[2] = 0;
std::cout << renderer->getHandle(); std::cout << renderer->getHandle();
mPlayer.mData.setBaseNode(renderer->getNode()); mPlayer.mData.setBaseNode(renderer->getNode());
/// \todo Do not make a copy of classes defined in esm/p records. /// \todo Do not make a copy of classes defined in esm/p records.
mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
@ -35,7 +35,7 @@ namespace MWWorld
void Player::setPos(float x, float y, float z) void Player::setPos(float x, float y, float z)
{ {
/// \todo This fcuntion should be removed during the mwrender-refactoring. /// \todo This fcuntion should be removed during the mwrender-refactoring.
mWorld.moveObject (getPlayer(), x, y, z); mWorld.moveObject (getPlayer(), x, y, z);
} }

View file

@ -47,8 +47,11 @@ namespace MWWorld
public: public:
RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true), /// @param cr Used to copy constant data such as position into this class where it can
mCount (1), mPosition(cr.pos), mBaseNode(0) {} /// be altered without effecting the original data. This makes it possible
/// to reset the position as the orignal data is still held in the CellRef
RefData(const ESMS::CellRef& cr) : mBaseNode(0), mHasLocals (false), mEnabled (true),
mCount (1), mPosition(cr.pos) {}
std::string getHandle() std::string getHandle()

View file

@ -63,6 +63,8 @@ namespace MWWorld
mRendering.removeCell(active);
active->forEach<ListHandles>(functor); active->forEach<ListHandles>(functor);
{ {
@ -95,6 +97,7 @@ namespace MWWorld
mActiveCells.insert(cell); mActiveCells.insert(cell);
if(result.second){ if(result.second){
insertCell(*cell, mEnvironment); insertCell(*cell, mEnvironment);
mRendering.cellAdded(cell);
mRendering.configureAmbient(*cell); mRendering.configureAmbient(*cell);
} }
@ -179,7 +182,7 @@ namespace MWWorld
assert (iter!=mActiveCells.end()); assert (iter!=mActiveCells.end());
mCurrentCell = *iter; mCurrentCell = *iter;
std::cout << "GridX: " << mCurrentCell->cell->data.gridX << "GridY: " << mCurrentCell->cell->data.gridY << "\n";
// adjust player // adjust player
playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos); playerCellChange (mWorld->getExterior(X, Y), position, adjustPlayerPos);
@ -188,7 +191,7 @@ namespace MWWorld
mWorld->adjustSky(); mWorld->adjustSky();
mCellChanged = true; mCellChanged = true;
mRendering.cellAdded(mCurrentCell); mRendering.waterAdded(mCurrentCell);
} }
//We need the ogre renderer and a scene node. //We need the ogre renderer and a scene node.
@ -239,7 +242,8 @@ namespace MWWorld
mWorld->adjustSky(); mWorld->adjustSky();
mCellChanged = true; mCellChanged = true;
mRendering.cellAdded(cell);
mRendering.waterAdded(cell);
} }
void Scene::changeToExteriorCell (const ESM::Position& position) void Scene::changeToExteriorCell (const ESM::Position& position)

View file

@ -6,16 +6,17 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <openengine/bullet/physic.hpp>
#include <components/esm_store/cell_store.hpp> #include <components/esm_store/cell_store.hpp>
#include "physicssystem.hpp" #include "../mwrender/renderingmanager.hpp"
#include "../mwrender/renderinginterface.hpp"
#include "physicssystem.hpp"
#include "refdata.hpp" #include "refdata.hpp"
#include "ptr.hpp" #include "ptr.hpp"
#include "globals.hpp" #include "globals.hpp"
#include "../mwrender/renderingmanager.hpp"
#include "../mwrender/renderinginterface.hpp"
#include <openengine/bullet/physic.hpp>
namespace Ogre namespace Ogre
{ {
@ -58,7 +59,6 @@ namespace MWWorld
private: private:
//OEngine::Render::OgreRenderer& mRenderer; //OEngine::Render::OgreRenderer& mRenderer;
Ogre::SceneNode *mMwRoot;
Ptr::CellStore* mCurrentCell; // the cell, the player is in Ptr::CellStore* mCurrentCell; // the cell, the player is in
CellStoreCollection mActiveCells; CellStoreCollection mActiveCells;
bool mCellChanged; bool mCellChanged;
@ -69,8 +69,8 @@ namespace MWWorld
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
bool adjustPlayerPos = true); bool adjustPlayerPos = true);
public: public:
Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics);
@ -100,9 +100,6 @@ namespace MWWorld
void markCellAsUnchanged(); void markCellAsUnchanged();
// std::string getFacedHandle();
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::Environment& environment); void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::Environment& environment);
}; };
} }

View file

@ -163,7 +163,7 @@ namespace MWWorld
mEsm.open (masterPath.string()); mEsm.open (masterPath.string());
mStore.load (mEsm); mStore.load (mEsm);
MWRender::Player* play = &(mRendering.getPlayer()); MWRender::Player* play = &(mRendering.getPlayer());
mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this); mPlayer = new MWWorld::Player (play, mStore.npcs.find ("player"), *this);
mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0)); mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0));
@ -319,12 +319,12 @@ namespace MWWorld
{ {
reference.getRefData().enable(); reference.getRefData().enable();
//render->enable (reference.getRefData().getHandle()); //render->enable (reference.getRefData().getHandle());
if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end()) if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end())
Class::get (reference).enable (reference, mEnvironment); Class::get (reference).enable (reference, mEnvironment);
} }
} }
@ -334,14 +334,14 @@ namespace MWWorld
{ {
reference.getRefData().disable(); reference.getRefData().disable();
//render->disable (reference.getRefData().getHandle()); //render->disable (reference.getRefData().getHandle());
if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){ if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){
Class::get (reference).disable (reference, mEnvironment); Class::get (reference).disable (reference, mEnvironment);
mEnvironment.mSoundManager->stopSound3D (reference); mEnvironment.mSoundManager->stopSound3D (reference);
} }
} }
} }
@ -499,9 +499,9 @@ namespace MWWorld
{ {
ptr.getRefData().setCount (0); ptr.getRefData().setCount (0);
if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){ if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){
Class::get (ptr).disable (ptr, mEnvironment); // Class::get (ptr).disable (ptr, mEnvironment); /// \todo this line needs to be removed
mEnvironment.mSoundManager->stopSound3D (ptr); mEnvironment.mSoundManager->stopSound3D (ptr);
mPhysics->removeObject (ptr.getRefData().getHandle()); mPhysics->removeObject (ptr.getRefData().getHandle());
@ -509,11 +509,6 @@ namespace MWWorld
mLocalScripts.remove (ptr); mLocalScripts.remove (ptr);
} }
//Should this go here or inside the for loop?
mRendering.getObjects().deleteObject (ptr.getRefData().getHandle());
ptr.getRefData().setBaseNode(0);
} }
} }
@ -547,11 +542,9 @@ namespace MWWorld
} }
} }
// \todo cell change for non-player ref /// \todo cell change for non-player ref
// \todo this should go into the new scene class and eventually into the objects/actors classes. mRendering.moveObject (ptr, Ogre::Vector3 (x, y, z));
mRendering.getMgr()->getSceneNode (ptr.getRefData().getHandle())->
setPosition (Ogre::Vector3 (x, y, z));
} }
void World::moveObject (Ptr ptr, float x, float y, float z) void World::moveObject (Ptr ptr, float x, float y, float z)

@ -1 +1 @@
Subproject commit 26b9d0fdc374fac648f6293e1d4a4abdc2c20c19 Subproject commit 2f5eca9d878526bdd9dce93ece7f42093b481545