From 8ce9f7b9cf8b63498aa3cb95bdb6dd454e4b8340 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 20 Oct 2023 17:39:58 +0300 Subject: [PATCH] Read BSPackedCombinedSharedGeomDataExtra --- components/nif/extra.cpp | 46 +++++++++++++++++++++++++++++++++++++ components/nif/extra.hpp | 47 ++++++++++++++++++++++++++++++++++++++ components/nif/niffile.cpp | 2 ++ components/nif/record.hpp | 1 + 4 files changed, 96 insertions(+) diff --git a/components/nif/extra.cpp b/components/nif/extra.cpp index 1fc24e5f89..2d222f5a54 100644 --- a/components/nif/extra.cpp +++ b/components/nif/extra.cpp @@ -162,4 +162,50 @@ namespace Nif nif->getSizedStrings(mPointNames, nif->get()); } + void BSPackedGeomDataCombined::read(NIFStream* nif) + { + nif->read(mGrayscaleToPaletteScale); + nif->read(mTransform); + nif->read(mBoundingSphere); + } + + void BSPackedGeomObject::read(NIFStream* nif) + { + nif->read(mFileHash); + nif->read(mDataOffset); + } + + void BSPackedSharedGeomData::read(NIFStream* nif) + { + nif->read(mNumVertices); + nif->read(mLODLevels); + nif->read(mLOD0TriCount); + nif->read(mLOD0TriOffset); + nif->read(mLOD1TriCount); + nif->read(mLOD1TriOffset); + nif->read(mLOD2TriCount); + nif->read(mLOD2TriOffset); + mCombined.resize(nif->get()); + for (BSPackedGeomDataCombined& data : mCombined) + data.read(nif); + mVertexDesc.read(nif); + } + + void BSPackedCombinedSharedGeomDataExtra::read(NIFStream* nif) + { + NiExtraData::read(nif); + + mVertexDesc.read(nif); + nif->read(mNumVertices); + nif->read(mNumTriangles); + nif->read(mFlags1); + nif->read(mFlags2); + mObjects.resize(nif->get()); + for (BSPackedGeomObject& object : mObjects) + object.read(nif); + mObjectData.resize(mObjects.size()); + for (BSPackedSharedGeomData& objectData : mObjectData) + objectData.read(nif); + } + } diff --git a/components/nif/extra.hpp b/components/nif/extra.hpp index 0808e91b16..1efa4ae7bb 100644 --- a/components/nif/extra.hpp +++ b/components/nif/extra.hpp @@ -2,6 +2,7 @@ #define OPENMW_COMPONENTS_NIF_EXTRA_HPP #include "base.hpp" +#include "node.hpp" namespace Nif { @@ -199,5 +200,51 @@ namespace Nif }; }; + struct BSPackedGeomDataCombined + { + float mGrayscaleToPaletteScale; + NiTransform mTransform; + osg::BoundingSpheref mBoundingSphere; + + void read(NIFStream* nif); + }; + + struct BSPackedGeomObject + { + uint32_t mFileHash; + uint32_t mDataOffset; + + void read(NIFStream* nif); + }; + + struct BSPackedSharedGeomData + { + uint32_t mNumVertices; + uint32_t mLODLevels; + uint32_t mLOD0TriCount; + uint32_t mLOD0TriOffset; + uint32_t mLOD1TriCount; + uint32_t mLOD1TriOffset; + uint32_t mLOD2TriCount; + uint32_t mLOD2TriOffset; + std::vector mCombined; + BSVertexDesc mVertexDesc; + + void read(NIFStream* nif); + }; + + struct BSPackedCombinedSharedGeomDataExtra : NiExtraData + { + BSVertexDesc mVertexDesc; + uint32_t mNumVertices; + uint32_t mNumTriangles; + uint32_t mFlags1; + uint32_t mFlags2; + std::vector mObjects; + std::vector mObjectData; + + void read(NIFStream* nif) override; + }; + } #endif diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 202c551a05..35a9eee787 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -256,6 +256,8 @@ namespace Nif { "BSDistantObjectLargeRefExtraData", &construct }, { "BSEyeCenterExtraData", &construct }, + { "BSPackedCombinedSharedGeomDataExtra", + &construct }, { "BSPositionData", &construct }, { "BSWArray", &construct }, { "BSXFlags", &construct }, diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 0679bd862a..79958b361d 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -108,6 +108,7 @@ namespace Nif RC_BSMultiBoundSphere, RC_BSNiAlphaPropertyTestRefController, RC_BSPackedAdditionalGeometryData, + RC_BSPackedCombinedSharedGeomDataExtra, RC_BSParentVelocityModifier, RC_BSPositionData, RC_BSProceduralLightningController,