From 246b06ca279c293ef3f914b391b3935cd16b62d4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 13 Apr 2015 17:30:32 +0200 Subject: [PATCH] Forgot to add --- apps/openmw/mwrender/objects.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 764aa13c67..25d57aba08 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -139,8 +139,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool SceneUtil::FindByNameVisitor visitor("AttachLight"); ptr.getRefData().getBaseNode()->accept(visitor); - osg::Vec3f lightOffset (0.f, 0.f, 0.f); - osg::Group* attachTo = NULL; if (visitor.mFoundNode) { @@ -152,9 +150,13 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool osg::Group* objectRoot = anim->getOrCreateObjectRoot(); objectRoot->accept(computeBound); - lightOffset = computeBound.getBoundingBox().center(); + // PositionAttitudeTransform seems to be slightly faster than MatrixTransform + osg::ref_ptr trans(new osg::PositionAttitudeTransform); + trans->setPosition(computeBound.getBoundingBox().center()); - attachTo = objectRoot; + objectRoot->addChild(trans); + + attachTo = trans; } const ESM::Light* esmLight = ptr.get()->mBase; @@ -162,7 +164,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh, bool osg::ref_ptr lightSource = new SceneUtil::LightSource; osg::Light* light = new osg::Light; lightSource->setLight(light); - light->setPosition(osg::Vec4f(lightOffset.x(), lightOffset.y(), lightOffset.z(), 1.f)); float realRadius = esmLight->mData.mRadius * 2;