Add NiTriBasedGeomData abstraction

7220-lua-add-a-general-purpose-lexical-parser
Alexei Kotov 2 years ago
parent 5eba755174
commit d39127cc3d

@ -118,14 +118,18 @@ namespace Nif
nif->skip(4); // Additional data
}
void NiTriShapeData::read(NIFStream* nif)
void NiTriBasedGeomData::read(NIFStream* nif)
{
NiGeometryData::read(nif);
mNumTriangles = nif->getUShort();
}
/*int tris =*/nif->getUShort();
void NiTriShapeData::read(NIFStream* nif)
{
NiTriBasedGeomData::read(nif);
// We have three times as many vertices as triangles, so this
// is always equal to tris*3.
// is always equal to mNumTriangles * 3.
int cnt = nif->getInt();
bool hasTriangles = true;
if (nif->getVersion() > NIFFile::NIFVersion::VER_OB_OLD)
@ -147,9 +151,7 @@ namespace Nif
void NiTriStripsData::read(NIFStream* nif)
{
NiGeometryData::read(nif);
mNumTriangles = nif->getUShort();
NiTriBasedGeomData::read(nif);
// Number of triangle strips
int numStrips = nif->getUShort();

@ -43,7 +43,15 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct NiTriShapeData : public NiGeometryData
// Abstract
struct NiTriBasedGeomData : public NiGeometryData
{
size_t mNumTriangles;
void read(NIFStream* nif) override;
};
struct NiTriShapeData : public NiTriBasedGeomData
{
// Triangles, three vertex indices per triangle
std::vector<unsigned short> triangles;
@ -51,10 +59,8 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct NiTriStripsData : public NiGeometryData
struct NiTriStripsData : public NiTriBasedGeomData
{
size_t mNumTriangles;
// Triangle strips, series of vertex indices.
std::vector<std::vector<unsigned short>> strips;

Loading…
Cancel
Save