1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-14 01:19:59 +00:00

Merge pull request #6 from scrawl/lights

For light objects without an AttachLight bone, attach the light to the c...
This commit is contained in:
ChrisKCat 2013-02-24 14:12:53 -08:00
commit 9e7b559b09
3 changed files with 17 additions and 5 deletions

View File

@ -38,7 +38,7 @@ namespace MWClass
if (!model.empty())
objects.insertMesh(ptr, "meshes\\" + model, true);
else
objects.insertLight(ptr, NULL);
objects.insertLight(ptr, NULL, Ogre::Vector3(0,0,0));
}
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const

View File

@ -49,6 +49,13 @@ void Objects::clearSceneNode (Ogre::SceneNode *node)
node->detachObject (object);
mRenderer.getScene()->destroyMovableObject (object);
}
Ogre::Node::ChildNodeIterator it = node->getChildIterator ();
while (it.hasMoreElements ())
{
clearSceneNode(static_cast<Ogre::SceneNode*>(it.getNext ()));
}
node->removeAndDestroyAllChildren ();
}
void Objects::setMwRoot(Ogre::SceneNode* root)
@ -219,11 +226,11 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
if (light)
{
insertLight(ptr, entities.mSkelBase);
insertLight(ptr, entities.mSkelBase, bounds.getCenter() - insert->_getDerivedPosition());
}
}
void Objects::insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase)
void Objects::insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase, Ogre::Vector3 fallbackCenter)
{
Ogre::SceneNode* insert = mRenderer.getScene()->getSceneNode(ptr.getRefData().getHandle());
assert(insert);
@ -291,9 +298,14 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase)
// If there's an AttachLight bone, attach the light to that, otherwise attach it to the base scene node
if (skelBase && skelBase->getSkeleton ()->hasBone ("AttachLight"))
{
skelBase->attachObjectToBone ("AttachLight", light);
}
else
insert->attachObject(light);
{
Ogre::SceneNode* childNode = insert->createChildSceneNode (fallbackCenter);
childNode->attachObject(light);
}
mLights.push_back(info);
}

View File

@ -74,7 +74,7 @@ public:
~Objects(){}
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool light=false);
void insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase);
void insertLight (const MWWorld::Ptr& ptr, Ogre::Entity* skelBase, Ogre::Vector3 fallbackCenter);
void enableLights();
void disableLights();