diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 464c78e9f..8c2decb72 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -56,8 +56,11 @@ namespace MWClass { const std::string model = getModel(ptr); + MWWorld::LiveCellRef *ref = + ptr.get(); + // Insert even if model is empty, so that the light is added - renderingInterface.getObjects().insertModel(ptr, model); + renderingInterface.getObjects().insertModel(ptr, model, false, !(ref->mBase->mData.mFlags & ESM::Light::OffDefault)); } void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index e2054c6d1..1fa9c611d 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1431,6 +1431,15 @@ void ObjectAnimation::addLight(const ESM::Light *light) addExtraLight(mInsert->getCreator(), mObjectRoot, light); } +void ObjectAnimation::removeParticles() +{ + for (unsigned int i=0; imParticles.size(); ++i) + { + mObjectRoot->mSceneMgr->destroyParticleSystem(mObjectRoot->mParticles[i]); + } + mObjectRoot->mParticles.clear(); +} + class FindEntityTransparency { public: diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index a282e34ed..dc4244c39 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -324,6 +324,7 @@ public: ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &model); void addLight(const ESM::Light *light); + void removeParticles(); bool canBatch() const; void fillBatch(Ogre::StaticGeometry *sg); diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index d9e20e1f8..96decbb36 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -73,14 +73,19 @@ void Objects::insertBegin(const MWWorld::Ptr& ptr) ptr.getRefData().setBaseNode(insert); } -void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool batch) +void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool batch, bool addLight) { insertBegin(ptr); std::auto_ptr anim(new ObjectAnimation(ptr, mesh)); if(ptr.getTypeName() == typeid(ESM::Light).name()) - anim->addLight(ptr.get()->mBase); + { + if (addLight) + anim->addLight(ptr.get()->mBase); + else + anim->removeParticles(); + } if (!mesh.empty()) { diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 02e974e2d..7f740dbab 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -41,7 +41,7 @@ public: , mRootNode(NULL) {} ~Objects(){} - void insertModel(const MWWorld::Ptr& ptr, const std::string &model, bool batch=false); + void insertModel(const MWWorld::Ptr& ptr, const std::string &model, bool batch=false, bool addLight=false); ObjectAnimation* getAnimation(const MWWorld::Ptr &ptr); diff --git a/components/esm/loadligh.hpp b/components/esm/loadligh.hpp index 74eb37197..ffc291609 100644 --- a/components/esm/loadligh.hpp +++ b/components/esm/loadligh.hpp @@ -25,7 +25,7 @@ struct Light Negative = 0x004, // Negative light - i.e. darkness Flicker = 0x008, Fire = 0x010, - OffDefault = 0x020, // Off by default + OffDefault = 0x020, // Off by default - does not burn while placed in a cell, but can burn when equipped by an NPC FlickerSlow = 0x040, Pulse = 0x080, PulseSlow = 0x100