Make Lights with OffDefault flag not emit light nor particles when placed in a cell (Fixes #1796)

deque
scrawl 11 years ago
parent 8866b5f860
commit 28fe81df90

@ -56,8 +56,11 @@ namespace MWClass
{
const std::string model = getModel(ptr);
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
// 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

@ -1431,6 +1431,15 @@ void ObjectAnimation::addLight(const ESM::Light *light)
addExtraLight(mInsert->getCreator(), mObjectRoot, light);
}
void ObjectAnimation::removeParticles()
{
for (unsigned int i=0; i<mObjectRoot->mParticles.size(); ++i)
{
mObjectRoot->mSceneMgr->destroyParticleSystem(mObjectRoot->mParticles[i]);
}
mObjectRoot->mParticles.clear();
}
class FindEntityTransparency {
public:

@ -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);

@ -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<ObjectAnimation> anim(new ObjectAnimation(ptr, mesh));
if(ptr.getTypeName() == typeid(ESM::Light).name())
anim->addLight(ptr.get<ESM::Light>()->mBase);
{
if (addLight)
anim->addLight(ptr.get<ESM::Light>()->mBase);
else
anim->removeParticles();
}
if (!mesh.empty())
{

@ -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);

@ -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

Loading…
Cancel
Save