coverity_scan^2
Allofich 8 years ago
parent be96ff1fd1
commit a8e9f2df67

@ -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<osg::Node> 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<osg::Node> node)
{
int index;
if (node->getUserValue("overrideIndex", index))
{
TextureOverrideVisitor overrideVisitor(index, texture, resourceSystem);
TextureOverrideVisitor overrideVisitor(texture, resourceSystem);
node->accept(overrideVisitor);
}
}
void overrideTexture(const std::string &texture, Resource::ResourceSystem *resourceSystem, osg::ref_ptr<osg::Node> node)

@ -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<int>& boundTextures, int animflags)
{
const Nif::PropertyList& props = nifNode->props;
bool foundFirstRootTexturingProperty = false;
for (size_t i = 0; i <props.length(); ++i)
{
if (!props[i].empty())
{
// store the recIndex of the NiTexturingProperty. Used for spells when overriding textures.
// Get the lowest numbered one for the root node. This is what is overridden when a spell
// effect "particle texture" is used. For non-root nodes we keep setting until we have the highest
// numbered one, which is the one that displays in the game and can be overridden if it matches the
// lowest one on the root.
if (!foundFirstRootTexturingProperty && nifNode->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);
}

Loading…
Cancel
Save