diff --git a/components/nif/controller.cpp b/components/nif/controller.cpp index a3c81f96da..84c43bafcf 100644 --- a/components/nif/controller.cpp +++ b/components/nif/controller.cpp @@ -287,15 +287,15 @@ namespace Nif { Controller::read(nif); - uvSet = nif->getUShort(); - data.read(nif); + nif->read(mUvSet); + mData.read(nif); } void NiUVController::post(Reader& nif) { Controller::post(nif); - data.post(nif); + mData.post(nif); } void NiKeyframeController::read(NIFStream* nif) diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 730cda5bd6..87bfe615a0 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -213,8 +213,8 @@ namespace Nif struct NiUVController : public Controller { - NiUVDataPtr data; - unsigned int uvSet; + NiUVDataPtr mData; + uint16_t mUvSet; void read(NIFStream* nif) override; void post(Reader& nif) override; diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index 018b650dbd..d424d7f56b 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -255,9 +255,7 @@ namespace NifOsg } } - UVController::UVController() {} - - UVController::UVController(const Nif::NiUVData* data, const std::set& textureUnits) + UVController::UVController(const Nif::NiUVData* data, const std::set& textureUnits) : mUTrans(data->mKeyList[0], 0.f) , mVTrans(data->mKeyList[1], 0.f) , mUScale(data->mKeyList[2], 1.f) @@ -281,8 +279,8 @@ namespace NifOsg void UVController::setDefaults(osg::StateSet* stateset) { osg::ref_ptr texMat(new osg::TexMat); - for (std::set::const_iterator it = mTextureUnits.begin(); it != mTextureUnits.end(); ++it) - stateset->setTextureAttributeAndModes(*it, texMat, osg::StateAttribute::ON); + for (unsigned int unit : mTextureUnits) + stateset->setTextureAttributeAndModes(unit, texMat, osg::StateAttribute::ON); } void UVController::apply(osg::StateSet* stateset, osg::NodeVisitor* nv) diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index 613aa7dc16..f830cf1c4c 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -262,9 +262,9 @@ namespace NifOsg class UVController : public SceneUtil::StateSetUpdater, public SceneUtil::Controller { public: - UVController(); + UVController() = default; UVController(const UVController&, const osg::CopyOp&); - UVController(const Nif::NiUVData* data, const std::set& textureUnits); + UVController(const Nif::NiUVData* data, const std::set& textureUnits); META_Object(NifOsg, UVController) @@ -276,7 +276,7 @@ namespace NifOsg FloatInterpolator mVTrans; FloatInterpolator mUScale; FloatInterpolator mVScale; - std::set mTextureUnits; + std::set mTextureUnits; }; class VisController : public SceneUtil::NodeCallback, public SceneUtil::Controller diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 8a4a62b017..76dfd7a315 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -865,18 +865,17 @@ namespace NifOsg if (ctrl->recType == Nif::RC_NiUVController) { const Nif::NiUVController* niuvctrl = static_cast(ctrl.getPtr()); - if (niuvctrl->data.empty()) + if (niuvctrl->mData.empty()) continue; - const unsigned int uvSet = niuvctrl->uvSet; - std::set texUnits; - // UVController should work only for textures which use a given UV Set, usually 0. + std::set texUnits; + // UVController should only work for textures which use the given UV Set. for (unsigned int i = 0; i < boundTextures.size(); ++i) { - if (boundTextures[i] == uvSet) + if (boundTextures[i] == niuvctrl->mUvSet) texUnits.insert(i); } - osg::ref_ptr uvctrl = new UVController(niuvctrl->data.getPtr(), texUnits); + osg::ref_ptr uvctrl = new UVController(niuvctrl->mData.getPtr(), texUnits); setupController(niuvctrl, uvctrl, animflags); composite->addController(uvctrl); }