@@ -1027,7 +1027,7 @@ namespace NifOsg
1027
1027
}
1028
1028
1029
1029
osg::ref_ptr<osg::Texture2D> attachTexture (const std::string& name, osg::ref_ptr<osg::Image> image, bool wrapS,
1030
- bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int >& boundTextures) const
1030
+ bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int >& boundTextures)
1031
1031
{
1032
1032
osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D (image);
1033
1033
if (image)
@@ -1038,22 +1038,23 @@ namespace NifOsg
1038
1038
if (stateset)
1039
1039
{
1040
1040
stateset->setTextureAttributeAndModes (texUnit, texture2d, osg::StateAttribute::ON);
1041
- stateset->setTextureAttributeAndModes (
1042
- texUnit, new SceneUtil::TextureType (name), osg::StateAttribute::ON);
1041
+ osg::ref_ptr<SceneUtil::TextureType> textureType = new SceneUtil::TextureType (name);
1042
+ textureType = shareAttribute (textureType);
1043
+ stateset->setTextureAttributeAndModes (texUnit, textureType, osg::StateAttribute::ON);
1043
1044
}
1044
1045
boundTextures.emplace_back (uvSet);
1045
1046
return texture2d;
1046
1047
}
1047
1048
1048
1049
osg::ref_ptr<osg::Texture2D> attachExternalTexture (const std::string& name, const std::string& path, bool wrapS,
1049
- bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int >& boundTextures) const
1050
+ bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int >& boundTextures)
1050
1051
{
1051
1052
return attachTexture (name, getTextureImage (path), wrapS, wrapT, uvSet, stateset, boundTextures);
1052
1053
}
1053
1054
1054
1055
osg::ref_ptr<osg::Texture2D> attachNiSourceTexture (const std::string& name, const Nif::NiSourceTexture* st,
1055
1056
bool wrapS, bool wrapT, unsigned int uvSet, osg::StateSet* stateset,
1056
- std::vector<unsigned int >& boundTextures) const
1057
+ std::vector<unsigned int >& boundTextures)
1057
1058
{
1058
1059
return attachTexture (name, handleSourceTexture (st), wrapS, wrapT, uvSet, stateset, boundTextures);
1059
1060
}
0 commit comments