Skip to content

Commit 27f52d2

Browse files
committed
Merge branch 'sharetexturetype' into 'master'
Share texture type attributes See merge request OpenMW/openmw!4431
2 parents 540eee9 + 964dafd commit 27f52d2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

components/nifosg/nifloader.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ namespace NifOsg
10271027
}
10281028

10291029
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)
10311031
{
10321032
osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D(image);
10331033
if (image)
@@ -1038,22 +1038,23 @@ namespace NifOsg
10381038
if (stateset)
10391039
{
10401040
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);
10431044
}
10441045
boundTextures.emplace_back(uvSet);
10451046
return texture2d;
10461047
}
10471048

10481049
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)
10501051
{
10511052
return attachTexture(name, getTextureImage(path), wrapS, wrapT, uvSet, stateset, boundTextures);
10521053
}
10531054

10541055
osg::ref_ptr<osg::Texture2D> attachNiSourceTexture(const std::string& name, const Nif::NiSourceTexture* st,
10551056
bool wrapS, bool wrapT, unsigned int uvSet, osg::StateSet* stateset,
1056-
std::vector<unsigned int>& boundTextures) const
1057+
std::vector<unsigned int>& boundTextures)
10571058
{
10581059
return attachTexture(name, handleSourceTexture(st), wrapS, wrapT, uvSet, stateset, boundTextures);
10591060
}

0 commit comments

Comments
 (0)