mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
For light objects without an AttachLight bone, attach the light to the center of the object instead of the origin.
This commit is contained in:
parent
7e816c826b
commit
1ae2d3c6ab
3 changed files with 16 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -49,6 +49,12 @@ 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 ()));
|
||||
}
|
||||
}
|
||||
|
||||
void Objects::setMwRoot(Ogre::SceneNode* root)
|
||||
|
@ -219,11 +225,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 +297,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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue