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

@ -416,16 +416,16 @@ void OMW::Engine::go()
void OMW::Engine::activate()
{
// TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside
// the input handling functions. Looks like this will require an OpenEngine modification.
try
{
std::string handle = mEnvironment.mWorld->getFacedHandle();
if (handle.empty())
return;
MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle);
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
@ -447,11 +447,6 @@ void OMW::Engine::activate()
{
interpreterContext.executeActivation();
}
}
catch (const std::exception& e)
{
std::cerr << "Activation failed: " << e.what() << std::endl;
}
}
void OMW::Engine::setCompileAll (bool all)

View file

@ -79,7 +79,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh){
}
else
{
Ogre::StaticGeometry* sg;
Ogre::StaticGeometry* sg = 0;
if(mSG.find(ptr.getCell()) == mSG.end())
{
uniqueID = uniqueID +1;
@ -135,14 +135,26 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
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);
node->removeAndDestroyAllChildren();
mRend.getScene()->destroySceneNode (node);
Ogre::SceneNode *parent = base->getParentSceneNode();
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){
@ -171,5 +183,3 @@ void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell){
sg->build();
}
}

View file

@ -36,14 +36,13 @@ public:
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
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 deleteObject (const std::string& handle);
bool deleteObject (const MWWorld::Ptr& ptr);
///< \return found?
void removeCell(MWWorld::Ptr::CellStore* store);
void buildStaticGeometry(ESMS::CellStore<MWWorld::RefData> &cell);
void setMwRoot(Ogre::SceneNode* root);
/// insert a light related to the most recent insertBegin call.
};
}
#endif

View file

@ -21,12 +21,9 @@ 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)
{
//std::cout << "ONE";
rend.createScene("PlayerCam", 55, 5);
mSkyManager = MWRender::SkyManager::create(rend.getWindow(), rend.getCamera(), resDir);
@ -41,7 +38,6 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
// the screen (when x is to the right.) This is the orientation that
// Morrowind uses, and it automagically makes everything work as it
// should.
//std::cout << "TWO";
SceneNode *rt = rend.getScene()->getRootSceneNode();
mwRoot = rt->createChildSceneNode();
mwRoot->pitch(Degree(-90));
@ -57,6 +53,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
cameraPitchNode->attachObject(rend.getCamera());
mPlayer = new MWRender::Player (rend.getCamera(), playerNode);
mWater = 0;
//std::cout << "Three";
@ -81,7 +78,6 @@ MWRender::Player& RenderingManager::getPlayer(){
return (*mPlayer);
}
void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store){
objects.removeCell(store);
@ -92,17 +88,33 @@ void RenderingManager::removeWater (){
mWater = 0;
}
}
void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store)
{
objects.buildStaticGeometry (*store);
}
void RenderingManager::addObject (const MWWorld::Ptr& ptr){
const MWWorld::Class& class_ =
MWWorld::Class::get (ptr);
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){
}
@ -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::setPhysicsDebugRendering (bool){
}
bool RenderingManager::getPhysicsDebugRendering() const{
return true;
}
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(mWater == 0)
mWater = new MWRender::Water(rend.getCamera(), store->cell);

View file

@ -4,7 +4,6 @@
#include "sky.hpp"
#include "debugging.hpp"
//Commented out for now, possibly do an ifdef if necessary, cla
#include "../mwworld/class.hpp"
@ -49,21 +48,33 @@ namespace MWRender
class RenderingManager: private RenderingInterface {
private:
virtual MWRender::Npcs& getNPCs();
virtual MWRender::Creatures& getCreatures();
virtual MWRender::Objects& getObjects();
public:
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine);
virtual ~RenderingManager();
virtual MWRender::Npcs& getNPCs();
virtual MWRender::Creatures& getCreatures();
virtual MWRender::Objects& getObjects();
virtual MWRender::Player& getPlayer();
void cellAdded (MWWorld::Ptr::CellStore *store);
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 do we want this?
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 addObject (const MWWorld::Ptr& ptr);
@ -77,9 +88,6 @@ class RenderingManager: private RenderingInterface {
/// \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 setPhysicsDebugRendering (bool);
bool getPhysicsDebugRendering() const;
void update (float duration);
void skyEnable ();
@ -89,9 +97,6 @@ class RenderingManager: private RenderingInterface {
int skyGetMasserPhase() const;
int skyGetSecundaPhase() const;
void skySetMoonColour (bool red);
OEngine::Render::OgreRenderer& getOgreRenderer(){return rend;}
Ogre::SceneManager *getMgr() { return rend.getScene(); }
Ogre::SceneNode *getRoot() { return mwRoot; }
void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
/// configure fog according to cell
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
@ -107,6 +112,8 @@ class RenderingManager: private RenderingInterface {
MWRender::Water *mWater;
MWRender::Objects objects;
// 0 normal, 1 more bright, 2 max
int mAmbientMode;
@ -122,8 +129,6 @@ class RenderingManager: private RenderingInterface {
MWRender::Player *mPlayer;
MWRender::Debugging mDebugging;
};
}

View file

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

View file

@ -47,8 +47,11 @@ namespace MWWorld
public:
RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true),
mCount (1), mPosition(cr.pos), mBaseNode(0) {}
/// @param cr Used to copy constant data such as position into this class where it can
/// 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()

View file

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

View file

@ -6,16 +6,17 @@
#include <boost/filesystem.hpp>
#include <openengine/bullet/physic.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 "ptr.hpp"
#include "globals.hpp"
#include "../mwrender/renderingmanager.hpp"
#include "../mwrender/renderinginterface.hpp"
#include <openengine/bullet/physic.hpp>
namespace Ogre
{
@ -58,7 +59,6 @@ namespace MWWorld
private:
//OEngine::Render::OgreRenderer& mRenderer;
Ogre::SceneNode *mMwRoot;
Ptr::CellStore* mCurrentCell; // the cell, the player is in
CellStoreCollection mActiveCells;
bool mCellChanged;
@ -100,9 +100,6 @@ namespace MWWorld
void markCellAsUnchanged();
// std::string getFacedHandle();
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::Environment& environment);
};
}

View file

@ -501,7 +501,7 @@ namespace MWWorld
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);
mPhysics->removeObject (ptr.getRefData().getHandle());
@ -509,11 +509,6 @@ namespace MWWorld
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.getMgr()->getSceneNode (ptr.getRefData().getHandle())->
setPosition (Ogre::Vector3 (x, y, z));
mRendering.moveObject (ptr, Ogre::Vector3 (x, y, z));
}
void World::moveObject (Ptr ptr, float x, float y, float z)

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