mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 00:11:34 +00:00
Modernize NiUVData, NiLinesData, NiTriBasedGeomData
This commit is contained in:
parent
384a398b62
commit
fda6b0b4f8
4 changed files with 14 additions and 13 deletions
|
@ -85,7 +85,7 @@ namespace Nif
|
||||||
{
|
{
|
||||||
NiGeometryData::read(nif);
|
NiGeometryData::read(nif);
|
||||||
|
|
||||||
mNumTriangles = nif->getUShort();
|
nif->read(mNumTriangles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NiTriShapeData::read(NIFStream* nif)
|
void NiTriShapeData::read(NIFStream* nif)
|
||||||
|
@ -150,15 +150,15 @@ namespace Nif
|
||||||
{
|
{
|
||||||
if (flags[i] & 1)
|
if (flags[i] & 1)
|
||||||
{
|
{
|
||||||
lines.emplace_back(i);
|
mLines.emplace_back(i);
|
||||||
lines.emplace_back(i + 1);
|
mLines.emplace_back(i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there are just two vertices, they can be connected twice. Probably isn't critical.
|
// If there are just two vertices, they can be connected twice. Probably isn't critical.
|
||||||
if (flags[num - 1] & 1)
|
if (flags[num - 1] & 1)
|
||||||
{
|
{
|
||||||
lines.emplace_back(num - 1);
|
mLines.emplace_back(num - 1);
|
||||||
lines.emplace_back(0);
|
mLines.emplace_back(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,10 +207,10 @@ namespace Nif
|
||||||
|
|
||||||
void NiUVData::read(NIFStream* nif)
|
void NiUVData::read(NIFStream* nif)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (FloatKeyMapPtr& keys : mKeyList)
|
||||||
{
|
{
|
||||||
mKeyList[i] = std::make_shared<FloatKeyMap>();
|
keys = std::make_shared<FloatKeyMap>();
|
||||||
mKeyList[i]->read(nif);
|
keys->read(nif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Nif
|
||||||
// Abstract
|
// Abstract
|
||||||
struct NiTriBasedGeomData : public NiGeometryData
|
struct NiTriBasedGeomData : public NiGeometryData
|
||||||
{
|
{
|
||||||
size_t mNumTriangles;
|
uint16_t mNumTriangles;
|
||||||
|
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,8 @@ namespace Nif
|
||||||
struct NiLinesData : public NiGeometryData
|
struct NiLinesData : public NiGeometryData
|
||||||
{
|
{
|
||||||
// Lines, series of indices that correspond to connected vertices.
|
// Lines, series of indices that correspond to connected vertices.
|
||||||
std::vector<unsigned short> lines;
|
// NB: assumes <=65536 number of vertices
|
||||||
|
std::vector<uint16_t> mLines;
|
||||||
|
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
};
|
};
|
||||||
|
@ -103,7 +104,7 @@ namespace Nif
|
||||||
|
|
||||||
struct NiUVData : public Record
|
struct NiUVData : public Record
|
||||||
{
|
{
|
||||||
FloatKeyMapPtr mKeyList[4];
|
std::array<FloatKeyMapPtr, 4> mKeyList;
|
||||||
|
|
||||||
void read(NIFStream* nif) override;
|
void read(NIFStream* nif) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace
|
||||||
for (const osg::Vec3f& vertex : vertices)
|
for (const osg::Vec3f& vertex : vertices)
|
||||||
mesh.findOrAddVertex(Misc::Convert::toBullet(vertex), false);
|
mesh.findOrAddVertex(Misc::Convert::toBullet(vertex), false);
|
||||||
|
|
||||||
mesh.preallocateIndices(static_cast<int>(data.mNumTriangles * 3));
|
mesh.preallocateIndices(static_cast<int>(data.mNumTriangles) * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillTriangleMesh(btTriangleMesh& mesh, const Nif::NiTriShapeData& data)
|
void fillTriangleMesh(btTriangleMesh& mesh, const Nif::NiTriShapeData& data)
|
||||||
|
|
|
@ -1458,7 +1458,7 @@ namespace NifOsg
|
||||||
if (niGeometryData->recType != Nif::RC_NiLinesData)
|
if (niGeometryData->recType != Nif::RC_NiLinesData)
|
||||||
return;
|
return;
|
||||||
auto data = static_cast<const Nif::NiLinesData*>(niGeometryData);
|
auto data = static_cast<const Nif::NiLinesData*>(niGeometryData);
|
||||||
const auto& line = data->lines;
|
const auto& line = data->mLines;
|
||||||
if (line.empty())
|
if (line.empty())
|
||||||
return;
|
return;
|
||||||
geometry->addPrimitiveSet(
|
geometry->addPrimitiveSet(
|
||||||
|
|
Loading…
Reference in a new issue