From a8e9f2df675337e93e2ff73f56e248d6810c537e Mon Sep 17 00:00:00 2001 From: Allofich Date: Mon, 19 Sep 2016 04:44:30 +0900 Subject: [PATCH] Cleanup --- apps/openmw/mwrender/util.cpp | 16 +++++----------- components/nifosg/nifloader.cpp | 23 ++++++++++------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwrender/util.cpp b/apps/openmw/mwrender/util.cpp index dbb990584..aa8aaccbc 100644 --- a/apps/openmw/mwrender/util.cpp +++ b/apps/openmw/mwrender/util.cpp @@ -14,9 +14,8 @@ namespace MWRender class TextureOverrideVisitor : public osg::NodeVisitor { public: - TextureOverrideVisitor(int refID, std::string texture, Resource::ResourceSystem* resourcesystem) + TextureOverrideVisitor(std::string texture, Resource::ResourceSystem* resourcesystem) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) - , mRefID(refID) , mTexture(texture) , mResourcesystem(resourcesystem) { @@ -26,26 +25,21 @@ class TextureOverrideVisitor : public osg::NodeVisitor { int index; osg::ref_ptr nodePtr(&node); - if (node.getUserValue("NiTexturingPropertyIndex", index)) + if (node.getUserValue("overrideFx", index)) { - if (mRefID == index) + if (index == 1) overrideTexture(mTexture, mResourcesystem, nodePtr); } traverse(node); } - int mRefID; std::string mTexture; Resource::ResourceSystem* mResourcesystem; }; void overrideFirstRootTexture(const std::string &texture, Resource::ResourceSystem *resourceSystem, osg::ref_ptr node) { - int index; - if (node->getUserValue("overrideIndex", index)) - { - TextureOverrideVisitor overrideVisitor(index, texture, resourceSystem); - node->accept(overrideVisitor); - } + TextureOverrideVisitor overrideVisitor(texture, resourceSystem); + node->accept(overrideVisitor); } void overrideTexture(const std::string &texture, Resource::ResourceSystem *resourceSystem, osg::ref_ptr node) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 5557a4d63..7823b3634 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -277,11 +277,13 @@ namespace NifOsg public: /// @param filename used for warning messages. LoaderImpl(const std::string& filename) - : mFilename(filename) + : mFilename(filename), mFirstRootTextureIndex(-1), mFoundFirstRootTexturingProperty(false) { } std::string mFilename; + size_t mFirstRootTextureIndex; + bool mFoundFirstRootTexturingProperty; static void loadKf(Nif::NIFFilePtr nif, KeyframeHolder& target) { @@ -372,26 +374,21 @@ namespace NifOsg void applyNodeProperties(const Nif::Node *nifNode, osg::Node *applyTo, SceneUtil::CompositeStateSetUpdater* composite, Resource::ImageManager* imageManager, std::vector& boundTextures, int animflags) { const Nif::PropertyList& props = nifNode->props; - bool foundFirstRootTexturingProperty = false; for (size_t i = 0; i parent == NULL && props[i].getPtr()->recType == Nif::RC_NiTexturingProperty) + // Get the lowest numbered recIndex of the NiTexturingProperty root node. + // This is what is overridden when a spell effect "particle texture" is used. + if (nifNode->parent == NULL && !mFoundFirstRootTexturingProperty && props[i].getPtr()->recType == Nif::RC_NiTexturingProperty) { - int index = props[i].getPtr()->recIndex; - applyTo->setUserValue("overrideIndex", index); - foundFirstRootTexturingProperty = true; + mFirstRootTextureIndex = props[i].getPtr()->recIndex; + mFoundFirstRootTexturingProperty = true; } else if (props[i].getPtr()->recType == Nif::RC_NiTexturingProperty) { - int index = props[i].getPtr()->recIndex; - applyTo->setUserValue("NiTexturingPropertyIndex", index); + if (props[i].getPtr()->recIndex == mFirstRootTextureIndex) + applyTo->setUserValue("overrideFx", 1); } handleProperty(props[i].getPtr(), applyTo, composite, imageManager, boundTextures, animflags); }