Support lights that do not have a model (Fixes #1361)

deque
scrawl 11 years ago
parent 95b3026c7e
commit a6788cfb0e

@ -50,10 +50,10 @@ namespace MWClass
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{
const std::string model = getModel(ptr);
if(!model.empty()) {
// Insert even if model is empty, so that the light is added
renderingInterface.getObjects().insertModel(ptr, model);
}
}
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{

@ -1257,6 +1257,8 @@ Ogre::Vector3 Animation::getEnchantmentColor(MWWorld::Ptr item)
ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &model)
: Animation(ptr, ptr.getRefData().getBaseNode())
{
if (!model.empty())
{
setObjectRoot(model, false);
Ogre::Vector3 extents = getWorldBounds().getSize();
@ -1273,6 +1275,12 @@ ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &mod
setRenderProperties(mObjectRoot, (mPtr.getTypeName() == typeid(ESM::Static).name()) ?
(small ? RV_StaticsSmall : RV_Statics) : RV_Misc,
RQG_Main, RQG_Alpha, dist, !ptr.getClass().getEnchantment(ptr).empty(), &col);
}
else
{
// No model given. Create an object root anyway, so that lights can be added to it if needed.
mObjectRoot = NifOgre::ObjectScenePtr (new NifOgre::ObjectScene(mInsert->getCreator()));
}
}
void ObjectAnimation::addLight(const ESM::Light *light)

@ -79,6 +79,11 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
std::auto_ptr<ObjectAnimation> anim(new ObjectAnimation(ptr, mesh));
if(ptr.getTypeName() == typeid(ESM::Light).name())
anim->addLight(ptr.get<ESM::Light>()->mBase);
if (!mesh.empty())
{
Ogre::AxisAlignedBox bounds = anim->getWorldBounds();
Ogre::Vector3 extents = bounds.getSize();
extents *= ptr.getRefData().getBaseNode()->getScale();
@ -94,9 +99,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL;
mBounds[ptr.getCell()].merge(bounds);
if(ptr.getTypeName() == typeid(ESM::Light).name())
anim->addLight(ptr.get<ESM::Light>()->mBase);
if(ptr.getTypeName() == typeid(ESM::Static).name() &&
Settings::Manager::getBool("use static geometry", "Objects") &&
anim->canBatch())
@ -153,6 +155,7 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
* it. Would require associating the Ptr with the StaticGeometry. */
anim.reset();
}
}
if(anim.get() != NULL)
mObjects.insert(std::make_pair(ptr, anim.release()));

Loading…
Cancel
Save