Refactor NiSwitchNode and NiLODNode

macos_ci_fix
Alexei Kotov 1 year ago
parent c9300cac31
commit 5b0bc97db0

@ -234,8 +234,8 @@ namespace Nif
NiNode::read(nif); NiNode::read(nif);
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0)) if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
nif->read(switchFlags); nif->read(mSwitchFlags);
nif->read(initialIndex); nif->read(mInitialIndex);
} }
void NiLODNode::read(NIFStream* nif) void NiLODNode::read(NIFStream* nif)
@ -249,13 +249,13 @@ namespace Nif
} }
if (nif->getVersion() >= NIFFile::NIFVersion::VER_MW) if (nif->getVersion() >= NIFFile::NIFVersion::VER_MW)
nif->read(lodCenter); nif->read(mLODCenter);
lodLevels.resize(nif->get<uint32_t>()); mLODLevels.resize(nif->get<uint32_t>());
for (LODRange& level : lodLevels) for (LODRange& level : mLODLevels)
{ {
nif->read(level.minRange); nif->read(level.mMinRange);
nif->read(level.maxRange); nif->read(level.mMaxRange);
} }
} }

@ -189,8 +189,8 @@ namespace Nif
// A node used as the base to switch between child nodes, such as for LOD levels. // A node used as the base to switch between child nodes, such as for LOD levels.
struct NiSwitchNode : NiNode struct NiSwitchNode : NiNode
{ {
uint16_t switchFlags; uint16_t mSwitchFlags;
uint32_t initialIndex; uint32_t mInitialIndex;
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };
@ -199,12 +199,12 @@ namespace Nif
{ {
struct LODRange struct LODRange
{ {
float minRange; float mMinRange;
float maxRange; float mMaxRange;
}; };
osg::Vec3f lodCenter; osg::Vec3f mLODCenter;
std::vector<LODRange> lodLevels; std::vector<LODRange> mLODLevels;
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };

@ -463,11 +463,11 @@ namespace NifOsg
osg::ref_ptr<osg::LOD> lod(new osg::LOD); osg::ref_ptr<osg::LOD> lod(new osg::LOD);
lod->setName(niLodNode->mName); lod->setName(niLodNode->mName);
lod->setCenterMode(osg::LOD::USER_DEFINED_CENTER); lod->setCenterMode(osg::LOD::USER_DEFINED_CENTER);
lod->setCenter(niLodNode->lodCenter); lod->setCenter(niLodNode->mLODCenter);
for (unsigned int i = 0; i < niLodNode->lodLevels.size(); ++i) for (unsigned int i = 0; i < niLodNode->mLODLevels.size(); ++i)
{ {
const Nif::NiLODNode::LODRange& range = niLodNode->lodLevels[i]; const Nif::NiLODNode::LODRange& range = niLodNode->mLODLevels[i];
lod->setRange(i, range.minRange, range.maxRange); lod->setRange(i, range.mMinRange, range.mMaxRange);
} }
lod->setRangeMode(osg::LOD::DISTANCE_FROM_EYE_POINT); lod->setRangeMode(osg::LOD::DISTANCE_FROM_EYE_POINT);
return lod; return lod;
@ -478,7 +478,7 @@ namespace NifOsg
osg::ref_ptr<osg::Switch> switchNode(new osg::Switch); osg::ref_ptr<osg::Switch> switchNode(new osg::Switch);
switchNode->setName(niSwitchNode->mName); switchNode->setName(niSwitchNode->mName);
switchNode->setNewChildDefaultValue(false); switchNode->setNewChildDefaultValue(false);
switchNode->setSingleChildOn(niSwitchNode->initialIndex); switchNode->setSingleChildOn(niSwitchNode->mInitialIndex);
return switchNode; return switchNode;
} }

Loading…
Cancel
Save