mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-23 10:11:33 +00:00
Support lights that do not have a model (Fixes #1361)
This commit is contained in:
parent
95b3026c7e
commit
a6788cfb0e
3 changed files with 87 additions and 76 deletions
|
@ -50,10 +50,10 @@ namespace MWClass
|
||||||
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
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);
|
renderingInterface.getObjects().insertModel(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1256,6 +1256,8 @@ Ogre::Vector3 Animation::getEnchantmentColor(MWWorld::Ptr item)
|
||||||
|
|
||||||
ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &model)
|
ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &model)
|
||||||
: Animation(ptr, ptr.getRefData().getBaseNode())
|
: Animation(ptr, ptr.getRefData().getBaseNode())
|
||||||
|
{
|
||||||
|
if (!model.empty())
|
||||||
{
|
{
|
||||||
setObjectRoot(model, false);
|
setObjectRoot(model, false);
|
||||||
|
|
||||||
|
@ -1274,6 +1276,12 @@ ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &mod
|
||||||
(small ? RV_StaticsSmall : RV_Statics) : RV_Misc,
|
(small ? RV_StaticsSmall : RV_Statics) : RV_Misc,
|
||||||
RQG_Main, RQG_Alpha, dist, !ptr.getClass().getEnchantment(ptr).empty(), &col);
|
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)
|
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));
|
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::AxisAlignedBox bounds = anim->getWorldBounds();
|
||||||
Ogre::Vector3 extents = bounds.getSize();
|
Ogre::Vector3 extents = bounds.getSize();
|
||||||
extents *= ptr.getRefData().getBaseNode()->getScale();
|
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()] = Ogre::AxisAlignedBox::BOX_NULL;
|
||||||
mBounds[ptr.getCell()].merge(bounds);
|
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() &&
|
if(ptr.getTypeName() == typeid(ESM::Static).name() &&
|
||||||
Settings::Manager::getBool("use static geometry", "Objects") &&
|
Settings::Manager::getBool("use static geometry", "Objects") &&
|
||||||
anim->canBatch())
|
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. */
|
* it. Would require associating the Ptr with the StaticGeometry. */
|
||||||
anim.reset();
|
anim.reset();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(anim.get() != NULL)
|
if(anim.get() != NULL)
|
||||||
mObjects.insert(std::make_pair(ptr, anim.release()));
|
mObjects.insert(std::make_pair(ptr, anim.release()));
|
||||||
|
|
Loading…
Reference in a new issue