From 3296dadf60aaca9d5b60edd92e35d9612cfeae5b Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sat, 23 Sep 2023 11:27:18 +0300 Subject: [PATCH] Read BSPSysMultiTargetEmitterCtlr and bone LOD controllers --- components/nif/controller.cpp | 44 +++++++++++++++++++++++++++++++++++ components/nif/controller.hpp | 18 ++++++++++++++ components/nif/niffile.cpp | 5 ++++ components/nif/particle.cpp | 15 ++++++++++++ components/nif/particle.hpp | 9 +++++++ components/nif/record.hpp | 2 ++ components/nif/recordptr.hpp | 5 ++++ 7 files changed, 98 insertions(+) diff --git a/components/nif/controller.cpp b/components/nif/controller.cpp index 3f4d5a6380..6a48ea1e4f 100644 --- a/components/nif/controller.cpp +++ b/components/nif/controller.cpp @@ -460,6 +460,50 @@ namespace Nif mData.post(nif); } + void NiBoneLODController::read(NIFStream* nif) + { + NiTimeController::read(nif); + + nif->read(mLOD); + mNodeGroups.resize(nif->get()); + nif->read(mNumNodeGroups); + for (NiAVObjectList& group : mNodeGroups) + readRecordList(nif, group); + + if (nif->getBethVersion() != 0 || nif->getVersion() < NIFStream::generateVersion(4, 2, 2, 0)) + return; + + mSkinnedShapeGroups.resize(nif->get()); + for (std::vector& group : mSkinnedShapeGroups) + { + group.resize(nif->get()); + for (SkinInfo& info : group) + { + info.mShape.read(nif); + info.mSkin.read(nif); + } + } + readRecordList(nif, mShapeGroups); + } + + void NiBoneLODController::post(Reader& nif) + { + NiTimeController::post(nif); + + for (NiAVObjectList& group : mNodeGroups) + postRecordList(nif, group); + + for (std::vector& group : mSkinnedShapeGroups) + { + for (SkinInfo& info : group) + { + info.mShape.post(nif); + info.mSkin.post(nif); + } + } + postRecordList(nif, mShapeGroups); + } + void bhkBlendController::read(NIFStream* nif) { NiTimeController::read(nif); diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 97f948167b..b6c71e1548 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -300,6 +300,24 @@ namespace Nif void post(Reader& nif) override; }; + struct NiBoneLODController : NiTimeController + { + struct SkinInfo + { + NiTriBasedGeomPtr mShape; + NiSkinInstancePtr mSkin; + }; + + uint32_t mLOD; + uint32_t mNumNodeGroups; + std::vector mNodeGroups; + std::vector> mSkinnedShapeGroups; + NiTriBasedGeomList mShapeGroups; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + struct bhkBlendController : public NiTimeController { void read(NIFStream* nif) override; diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 10a53234f1..e0f6ee422e 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -118,6 +118,7 @@ namespace Nif { "NiVisController", &construct }, // Gamebryo + { "NiBoneLODController", &construct }, { "NiControllerManager", &construct }, { "NiLightDimmerController", &construct }, { "NiTransformController", &construct }, @@ -154,6 +155,7 @@ namespace Nif { "BSLightingShaderPropertyFloatController", &construct }, { "bhkBlendController", &construct }, + { "NiBSBoneLODController", &construct }, // Interpolators, Gamebryo { "NiBlendBoolInterpolator", &construct }, @@ -353,6 +355,9 @@ namespace Nif { "NiPSysInitialRotAngleVarCtlr", &construct }, { "NiPSysModifierActiveCtlr", &construct }, + // Modifier controllers, Bethesda + { "BSPSysMultiTargetEmitterCtlr", &construct }, + // Modifier controller data, Gamebryo { "NiPSysEmitterCtlrData", &construct }, diff --git a/components/nif/particle.cpp b/components/nif/particle.cpp index 63eff520b3..95440af26b 100644 --- a/components/nif/particle.cpp +++ b/components/nif/particle.cpp @@ -597,6 +597,21 @@ namespace Nif mVisInterpolator.post(nif); } + void BSPSysMultiTargetEmitterCtlr::read(NIFStream* nif) + { + NiPSysEmitterCtlr::read(nif); + + nif->read(mMaxEmitters); + mMasterPSys.read(nif); + } + + void BSPSysMultiTargetEmitterCtlr::post(Reader& nif) + { + NiPSysEmitterCtlr::post(nif); + + mMasterPSys.post(nif); + } + void NiPSysEmitterCtlrData::read(NIFStream* nif) { mFloatKeyList = std::make_shared(); diff --git a/components/nif/particle.hpp b/components/nif/particle.hpp index 732649fabe..a2b0567b3b 100644 --- a/components/nif/particle.hpp +++ b/components/nif/particle.hpp @@ -476,6 +476,15 @@ namespace Nif void post(Reader& nif) override; }; + struct BSPSysMultiTargetEmitterCtlr : NiPSysEmitterCtlr + { + uint16_t mMaxEmitters; + BSMasterParticleSystemPtr mMasterPSys; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + struct NiPSysEmitterCtlrData : Record { FloatKeyMapPtr mFloatKeyList; diff --git a/components/nif/record.hpp b/components/nif/record.hpp index d0a51581c4..ea37ad4654 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -98,6 +98,7 @@ namespace Nif RC_BSPSysArrayEmitter, RC_BSPSysInheritVelocityModifier, RC_BSPSysLODModifier, + RC_BSPSysMultiTargetEmitterCtlr, RC_BSPSysRecycleBoundModifier, RC_BSPSysScaleModifier, RC_BSPSysSimpleColorModifier, @@ -130,6 +131,7 @@ namespace Nif RC_NiBlendFloatInterpolator, RC_NiBlendPoint3Interpolator, RC_NiBlendTransformInterpolator, + RC_NiBoneLODController, RC_NiBoolData, RC_NiBooleanExtraData, RC_NiBoolInterpolator, diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index 50d16d5eac..0a7bd0ccbd 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -129,6 +129,7 @@ namespace Nif struct NiSourceTexture; struct NiPalette; struct NiParticleModifier; + struct BSMasterParticleSystem; struct NiParticleSystem; struct NiPSysCollider; struct NiPSysColliderManager; @@ -138,6 +139,7 @@ namespace Nif struct NiBoolData; struct NiSkinPartition; struct BSShaderTextureSet; + struct NiTriBasedGeom; struct NiGeometryData; struct BSShaderProperty; struct NiAlphaProperty; @@ -177,6 +179,7 @@ namespace Nif using NiSourceTexturePtr = RecordPtrT; using NiPalettePtr = RecordPtrT; using NiParticleModifierPtr = RecordPtrT; + using BSMasterParticleSystemPtr = RecordPtrT; using NiParticleSystemPtr = RecordPtrT; using NiPSysColliderPtr = RecordPtrT; using NiPSysColliderManagerPtr = RecordPtrT; @@ -185,6 +188,7 @@ namespace Nif using NiBoolDataPtr = RecordPtrT; using NiSkinPartitionPtr = RecordPtrT; using BSShaderTextureSetPtr = RecordPtrT; + using NiTriBasedGeomPtr = RecordPtrT; using NiGeometryDataPtr = RecordPtrT; using BSShaderPropertyPtr = RecordPtrT; using NiAlphaPropertyPtr = RecordPtrT; @@ -216,6 +220,7 @@ namespace Nif using bhkEntityList = RecordListT; using NiControllerSequenceList = RecordListT; using NiPSysModifierList = RecordListT; + using NiTriBasedGeomList = RecordListT; } // Namespace #endif