diff --git a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp index 49030a8902..3560c1cd61 100644 --- a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp +++ b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp @@ -338,7 +338,7 @@ namespace mNiTriStripsData.vertices = { osg::Vec3f(0, 0, 0), osg::Vec3f(1, 0, 0), osg::Vec3f(1, 1, 0), osg::Vec3f(0, 1, 0) }; mNiTriStripsData.mNumTriangles = 2; - mNiTriStripsData.strips = { { 0, 1, 2, 3 } }; + mNiTriStripsData.mStrips = { { 0, 1, 2, 3 } }; mNiTriStrips.data = Nif::NiGeometryDataPtr(&mNiTriStripsData); } }; @@ -1260,7 +1260,7 @@ namespace TEST_F(TestBulletNifLoader, should_ignore_tri_strips_data_with_empty_strips) { - mNiTriStripsData.strips.clear(); + mNiTriStripsData.mStrips.clear(); Nif::NIFFile file("test.nif"); file.mRoots.push_back(&mNiTriStrips); @@ -1275,7 +1275,7 @@ namespace TEST_F(TestBulletNifLoader, for_static_mesh_should_ignore_tri_strips_data_with_less_than_3_strips) { - mNiTriStripsData.strips.front() = { 0, 1 }; + mNiTriStripsData.mStrips.front() = { 0, 1 }; Nif::NIFFile file("test.nif"); file.mRoots.push_back(&mNiTriStrips); @@ -1293,7 +1293,7 @@ namespace mNiTriShape.parents.push_back(&mNiNode); mNiNode.children = Nif::NodeList(std::vector({ Nif::NodePtr(&mNiTriShape) })); mNiNode.recType = Nif::RC_AvoidNode; - mNiTriStripsData.strips.front() = { 0, 1 }; + mNiTriStripsData.mStrips.front() = { 0, 1 }; Nif::NIFFile file("test.nif"); file.mRoots.push_back(&mNiTriStrips); @@ -1308,7 +1308,7 @@ namespace TEST_F(TestBulletNifLoader, for_animated_mesh_should_ignore_tri_strips_data_with_less_than_3_strips) { - mNiTriStripsData.strips.front() = { 0, 1 }; + mNiTriStripsData.mStrips.front() = { 0, 1 }; mNiTriStrips.parents.push_back(&mNiNode); mNiNode.children = Nif::NodeList(std::vector({ Nif::NodePtr(&mNiTriStrips) })); @@ -1325,7 +1325,7 @@ namespace TEST_F(TestBulletNifLoader, should_not_add_static_mesh_with_no_triangles_to_compound_shape) { - mNiTriStripsData.strips.front() = { 0, 1 }; + mNiTriStripsData.mStrips.front() = { 0, 1 }; mNiTriShape.parents.push_back(&mNiNode); mNiNode.children = Nif::NodeList(std::vector({ Nif::NodePtr(&mNiTriShape) })); diff --git a/components/nif/data.cpp b/components/nif/data.cpp index 910c67cdd7..453fa64564 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -1,10 +1,11 @@ #include "data.hpp" + +#include + #include "exception.hpp" #include "nifkey.hpp" #include "node.hpp" -#include - namespace Nif { void NiGeometryData::read(NIFStream* nif) @@ -117,22 +118,20 @@ namespace Nif { NiTriBasedGeomData::read(nif); - // Number of triangle strips - int numStrips = nif->getUShort(); - - std::vector lengths; + uint16_t numStrips; + nif->read(numStrips); + std::vector lengths; nif->readVector(lengths, numStrips); - // "Has Strips" flag. Exceptionally useful. bool hasStrips = true; if (nif->getVersion() > NIFFile::NIFVersion::VER_OB_OLD) - hasStrips = nif->getBoolean(); + nif->read(hasStrips); if (!hasStrips || !numStrips) return; - strips.resize(numStrips); + mStrips.resize(numStrips); for (int i = 0; i < numStrips; i++) - nif->readVector(strips[i], lengths[i]); + nif->readVector(mStrips[i], lengths[i]); } void NiLinesData::read(NIFStream* nif) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index e853a30c33..8cde0a705f 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -63,7 +63,7 @@ namespace Nif struct NiTriStripsData : public NiTriBasedGeomData { // Triangle strips, series of vertex indices. - std::vector> strips; + std::vector> mStrips; void read(NIFStream* nif) override; }; diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 4ef1a35903..199a6f749d 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -54,7 +54,7 @@ namespace void fillTriangleMesh(btTriangleMesh& mesh, const Nif::NiTriStripsData& data) { prepareTriangleMesh(mesh, data); - for (const std::vector& strip : data.strips) + for (const std::vector& strip : data.mStrips) { if (strip.size() < 3) continue; @@ -99,7 +99,7 @@ namespace return {}; auto data = static_cast(geometry.data.getPtr()); - if (data->strips.empty()) + if (data->mStrips.empty()) return {}; return function(static_cast(*data)); diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 868cdfa137..f34fc4591f 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1442,7 +1442,7 @@ namespace NifOsg return; auto data = static_cast(niGeometryData); bool hasGeometry = false; - for (const std::vector& strip : data->strips) + for (const std::vector& strip : data->mStrips) { if (strip.size() < 3) continue;