mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
Modernize NiTriStripsData
This commit is contained in:
parent
fda6b0b4f8
commit
eba0ab444b
5 changed files with 19 additions and 20 deletions
|
@ -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>({ 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>({ 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>({ Nif::NodePtr(&mNiTriShape) }));
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include "data.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include "exception.hpp"
|
||||
#include "nifkey.hpp"
|
||||
#include "node.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
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<unsigned short> lengths;
|
||||
uint16_t numStrips;
|
||||
nif->read(numStrips);
|
||||
std::vector<uint16_t> 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)
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Nif
|
|||
struct NiTriStripsData : public NiTriBasedGeomData
|
||||
{
|
||||
// Triangle strips, series of vertex indices.
|
||||
std::vector<std::vector<unsigned short>> strips;
|
||||
std::vector<std::vector<unsigned short>> mStrips;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
};
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace
|
|||
void fillTriangleMesh(btTriangleMesh& mesh, const Nif::NiTriStripsData& data)
|
||||
{
|
||||
prepareTriangleMesh(mesh, data);
|
||||
for (const std::vector<unsigned short>& strip : data.strips)
|
||||
for (const std::vector<unsigned short>& strip : data.mStrips)
|
||||
{
|
||||
if (strip.size() < 3)
|
||||
continue;
|
||||
|
@ -99,7 +99,7 @@ namespace
|
|||
return {};
|
||||
|
||||
auto data = static_cast<const Nif::NiTriStripsData*>(geometry.data.getPtr());
|
||||
if (data->strips.empty())
|
||||
if (data->mStrips.empty())
|
||||
return {};
|
||||
|
||||
return function(static_cast<const Nif::NiTriStripsData&>(*data));
|
||||
|
|
|
@ -1442,7 +1442,7 @@ namespace NifOsg
|
|||
return;
|
||||
auto data = static_cast<const Nif::NiTriStripsData*>(niGeometryData);
|
||||
bool hasGeometry = false;
|
||||
for (const std::vector<unsigned short>& strip : data->strips)
|
||||
for (const std::vector<unsigned short>& strip : data->mStrips)
|
||||
{
|
||||
if (strip.size() < 3)
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue