1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Read a bunch more extra data records

NiStringsExtraData, BSExtraData, BSBoneLODExtraData, BSClothExtraData, BSDecalPlacementVectorExtraData, BSDistantObjectExtraData, BSDistantObjectLargeRefExtraData, BSWArray
This commit is contained in:
Alexei Kotov 2023-09-20 00:59:23 +03:00
parent 38d0ece366
commit a39182f7de
4 changed files with 115 additions and 0 deletions

View File

@ -10,6 +10,13 @@ namespace Nif
nif->readVector(mData, mRecordSize);
}
void NiStringsExtraData::read(NIFStream* nif)
{
Extra::read(nif);
nif->getSizedStrings(mData, nif->get<uint32_t>());
}
void NiTextKeyExtraData::read(NIFStream* nif)
{
Extra::read(nif);
@ -94,4 +101,39 @@ namespace Nif
nif->read(mControlsBaseSkeleton);
}
void BSBoneLODExtraData::read(NIFStream* nif)
{
Extra::read(nif);
mData.resize(nif->get<uint32_t>());
for (BoneLOD& lod : mData)
lod.read(nif);
}
void BSBoneLODExtraData::BoneLOD::read(NIFStream* nif)
{
nif->read(mDistance);
nif->read(mBone);
}
void BSDecalPlacementVectorExtraData::read(NIFStream* nif)
{
NiFloatExtraData::read(nif);
mBlocks.resize(nif->get<uint16_t>());
for (Block& block : mBlocks)
block.read(nif);
}
void BSDecalPlacementVectorExtraData::Block::read(NIFStream* nif)
{
nif->readVector(mPoints, nif->get<uint16_t>());
nif->readVector(mNormals, mPoints.size());
}
void BSClothExtraData::read(NIFStream* nif)
{
nif->readVector(mData, nif->get<uint32_t>());
}
}

View File

@ -38,10 +38,15 @@ namespace Nif
using NiStringExtraData = TypedExtra<std::string>;
using NiVectorExtraData = TypedExtra<osg::Vec4f>;
using BSDistantObjectExtraData = TypedExtra<uint32_t>;
using BSDistantObjectLargeRefExtraData = TypedExtra<bool>;
using NiBinaryExtraData = TypedVectorExtra<uint8_t>;
using NiFloatsExtraData = TypedVectorExtra<float>;
using NiIntegersExtraData = TypedVectorExtra<uint32_t>;
using BSWArray = TypedVectorExtra<int32_t>;
// Distinct from NiBinaryExtraData, uses mRecordSize as its size
struct NiExtraData : public Extra
{
@ -50,6 +55,14 @@ namespace Nif
void read(NIFStream* nif) override;
};
// != TypedVectorExtra<std::string>, doesn't use the string table
struct NiStringsExtraData : public Extra
{
std::vector<std::string> mData;
void read(NIFStream* nif) override;
};
struct NiVertWeightsExtraData : public Extra
{
void read(NIFStream* nif) override;
@ -115,5 +128,47 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct BSBoneLODExtraData : public Extra
{
struct BoneLOD
{
uint32_t mDistance;
std::string mBone;
void read(NIFStream* nif);
};
std::vector<BoneLOD> mData;
void read(NIFStream* nif) override;
};
struct BSDecalPlacementVectorExtraData : public NiFloatExtraData
{
struct Block
{
std::vector<osg::Vec3f> mPoints;
std::vector<osg::Vec3f> mNormals;
void read(NIFStream* nif);
};
std::vector<Block> mBlocks;
void read(NIFStream* nif) override;
};
struct BSExtraData : NiExtraData
{
void read(NIFStream* nif) override { }
};
struct BSClothExtraData : BSExtraData
{
std::vector<uint8_t> mData;
void read(NIFStream* nif) override;
};
}
#endif

View File

@ -200,6 +200,7 @@ namespace Nif
{ "NiIntegerExtraData", &construct<NiIntegerExtraData, RC_NiIntegerExtraData> },
{ "NiIntegersExtraData", &construct<NiIntegersExtraData, RC_NiIntegersExtraData> },
{ "NiVectorExtraData", &construct<NiVectorExtraData, RC_NiVectorExtraData> },
{ "NiStringsExtraData", &construct<NiStringsExtraData, RC_NiStringsExtraData> },
{ "NiStringPalette", &construct<NiStringPalette, RC_NiStringPalette> },
// Bethesda bounds
@ -214,7 +215,16 @@ namespace Nif
{ "BSInvMarker", &construct<BSInvMarker, RC_BSInvMarker> },
// Other Bethesda records
{ "BSExtraData", &construct<BSExtraData, RC_BSExtraData> },
{ "BSBehaviorGraphExtraData", &construct<BSBehaviorGraphExtraData, RC_BSBehaviorGraphExtraData> },
{ "BSBoneLODExtraData", &construct<BSBoneLODExtraData, RC_BSBoneLODExtraData> },
{ "BSClothExtraData", &construct <BSClothExtraData, RC_BSClothExtraData> },
{ "BSDecalPlacementVectorExtraData",
&construct<BSDecalPlacementVectorExtraData, RC_BSDecalPlacementVectorExtraData> },
{ "BSDistantObjectExtraData", &construct<BSDistantObjectExtraData, RC_BSDistantObjectExtraData> },
{ "BSDistantObjectLargeRefExtraData",
&construct<BSDistantObjectLargeRefExtraData, RC_BSDistantObjectLargeRefExtraData> },
{ "BSWArray", &construct<BSWArray, RC_BSWArray> },
{ "BSXFlags", &construct<NiIntegerExtraData, RC_BSXFlags> },
// GEOMETRY

View File

@ -57,10 +57,16 @@ namespace Nif
RC_bhkSphereShape,
RC_BSBehaviorGraphExtraData,
RC_BSBound,
RC_BSBoneLODExtraData,
RC_BSClothExtraData,
RC_BSDecalPlacementVectorExtraData,
RC_BSDismemberSkinInstance,
RC_BSDistantObjectExtraData,
RC_BSDistantObjectLargeRefExtraData,
RC_BSEffectShaderProperty,
RC_BSEffectShaderPropertyColorController,
RC_BSEffectShaderPropertyFloatController,
RC_BSExtraData,
RC_BSFurnitureMarker,
RC_BSInvMarker,
RC_BSLightingShaderProperty,
@ -78,6 +84,7 @@ namespace Nif
RC_BSShaderProperty,
RC_BSShaderTextureSet,
RC_BSTriShape,
RC_BSWArray,
RC_BSXFlags,
RC_hkPackedNiTriStripsData,
RC_NiAlphaAccumulator,
@ -156,6 +163,7 @@ namespace Nif
RC_NiSphericalCollider,
RC_NiStencilProperty,
RC_NiStringExtraData,
RC_NiStringsExtraData,
RC_NiStringPalette,
RC_NiSwitchNode,
RC_NiTextKeyExtraData,