Further cleanup in NiGeometryData, update NiParticlesData to 20.2.0.7

macos_ci_fix
Alexei Kotov 1 year ago
parent fd3b24e2e6
commit efe1c66536

@ -13,7 +13,7 @@ namespace Nif
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 114)) if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 114))
nif->read(mGroupId); nif->read(mGroupId);
// Note: has special meaning for NiPSysData // Note: has special meaning for NiPSysData (unimplemented)
nif->read(mNumVertices); nif->read(mNumVertices);
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0)) if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
@ -22,21 +22,19 @@ namespace Nif
nif->read(mCompressFlags); nif->read(mCompressFlags);
} }
bool hasVertices; if (nif->get<bool>())
nif->read(hasVertices);
if (hasVertices)
nif->readVector(mVertices, mNumVertices); nif->readVector(mVertices, mNumVertices);
if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0)) if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0))
{
nif->read(mDataFlags); nif->read(mDataFlags);
if (nif->getVersion() == NIFFile::NIFVersion::VER_BGS if (nif->getVersion() == NIFFile::NIFVersion::VER_BGS
&& nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO3) && nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO3)
nif->read(mMaterialHash); nif->read(mMaterialHash);
}
bool hasNormals; if (nif->get<bool>())
nif->read(hasNormals);
if (hasNormals)
{ {
nif->readVector(mNormals, mNumVertices); nif->readVector(mNormals, mNumVertices);
if (mDataFlags & DataFlag_HasTangents) if (mDataFlags & DataFlag_HasTangents)
@ -48,9 +46,7 @@ namespace Nif
nif->read(mBoundingSphere); nif->read(mBoundingSphere);
bool hasColors; if (nif->get<bool>())
nif->read(hasColors);
if (hasColors)
nif->readVector(mColors, mNumVertices); nif->readVector(mColors, mNumVertices);
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0)) if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0))
@ -65,12 +61,9 @@ namespace Nif
if (nif->getVersion() == NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() > 0) if (nif->getVersion() == NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() > 0)
numUVs &= DataFlag_HasUV; numUVs &= DataFlag_HasUV;
} }
else if (!nif->get<bool>())
numUVs = 0;
bool hasUVs = true;
if (nif->getVersion() <= NIFFile::NIFVersion::VER_MW)
nif->read(hasUVs);
if (hasUVs)
{
mUVList.resize(numUVs); mUVList.resize(numUVs);
for (std::vector<osg::Vec2f>& list : mUVList) for (std::vector<osg::Vec2f>& list : mUVList)
{ {
@ -79,14 +72,14 @@ namespace Nif
for (osg::Vec2f& uv : list) for (osg::Vec2f& uv : list)
uv.y() = 1.f - uv.y(); uv.y() = 1.f - uv.y();
} }
}
if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0)) if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0))
{
nif->read(mConsistencyType); nif->read(mConsistencyType);
if (nif->getVersion() >= NIFStream::generateVersion(20, 0, 0, 4)) if (nif->getVersion() >= NIFStream::generateVersion(20, 0, 0, 4))
nif->skip(4); // Additional data nif->skip(4); // Additional data
} }
}
void NiTriBasedGeomData::read(NIFStream* nif) void NiTriBasedGeomData::read(NIFStream* nif)
{ {
@ -165,31 +158,45 @@ namespace Nif
// Should always match the number of vertices // Should always match the number of vertices
if (nif->getVersion() <= NIFFile::NIFVersion::VER_MW) if (nif->getVersion() <= NIFFile::NIFVersion::VER_MW)
nif->read(mNumParticles); nif->read(mNumParticles);
else if (nif->getVersion() != NIFFile::NIFVersion::VER_BGS || nif->getBethVersion() == 0)
mNumParticles = mNumVertices;
bool numRadii = 1; bool numRadii = 1;
if (nif->getVersion() > NIFStream::generateVersion(10, 0, 1, 0)) if (nif->getVersion() > NIFStream::generateVersion(10, 0, 1, 0))
{ numRadii = nif->get<bool>() ? mNumParticles : 0;
numRadii = mNumVertices;
if (!nif->get<bool>() || (nif->getVersion() == NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() > 0))
numRadii = 0;
}
nif->readVector(mRadii, numRadii); nif->readVector(mRadii, numRadii);
nif->read(mActiveCount); nif->read(mActiveCount);
if (nif->get<bool>()) if (nif->get<bool>())
nif->readVector(mSizes, mNumVertices); nif->readVector(mSizes, mNumParticles);
if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0)) if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0))
{ {
if (nif->get<bool>()) if (nif->get<bool>())
nif->readVector(mRotations, mNumVertices); nif->readVector(mRotations, mNumParticles);
if (nif->getVersion() >= NIFStream::generateVersion(20, 0, 0, 4)) if (nif->getVersion() >= NIFStream::generateVersion(20, 0, 0, 4))
{ {
if (nif->get<bool>()) if (nif->get<bool>())
nif->readVector(mRotationAngles, mNumVertices); nif->readVector(mRotationAngles, mNumParticles);
if (nif->get<bool>()) if (nif->get<bool>())
nif->readVector(mRotationAxes, mNumVertices); nif->readVector(mRotationAxes, mNumParticles);
if (nif->getVersion() == NIFFile::NIFVersion::VER_BGS && nif->getBethVersion() > 0)
{
nif->read(mHasTextureIndices);
uint32_t numSubtextureOffsets;
if (nif->getBethVersion() <= 34)
numSubtextureOffsets = nif->get<uint8_t>();
else
nif->read(numSubtextureOffsets);
nif->readVector(mSubtextureOffsets, numSubtextureOffsets);
if (nif->getBethVersion() > 34)
{
nif->read(mAspectRatio);
nif->read(mAspectFlags);
nif->read(mAspectRatio2);
nif->read(mAspectSpeed);
nif->read(mAspectSpeed2);
}
}
} }
} }
} }

@ -104,6 +104,13 @@ namespace Nif
std::vector<float> mRotationAngles; std::vector<float> mRotationAngles;
std::vector<osg::Vec3f> mRotationAxes; std::vector<osg::Vec3f> mRotationAxes;
bool mHasTextureIndices{ false };
std::vector<osg::Vec4f> mSubtextureOffsets;
float mAspectRatio{ 1.f };
uint16_t mAspectFlags{ 0 };
float mAspectRatio2;
float mAspectSpeed, mAspectSpeed2;
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
}; };

Loading…
Cancel
Save