From b45923ac39f5f921039365c36b35ff249aadfb60 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 22 Sep 2023 02:54:03 +0300 Subject: [PATCH] Read NiPSysSpawnModifier, NiPSysAgeDeathModifier --- components/nif/niffile.cpp | 4 ++++ components/nif/particle.cpp | 29 +++++++++++++++++++++++++++++ components/nif/particle.hpp | 23 +++++++++++++++++++++++ components/nif/record.hpp | 2 ++ components/nif/recordptr.hpp | 2 ++ 5 files changed, 60 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 196fe780cc..a89540ac15 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -292,6 +292,10 @@ namespace Nif { "NiParticleGrowFade", &construct }, { "NiParticleRotation", &construct }, + // Modifiers, Gamebryo + { "NiPSysAgeDeathModifier", &construct }, + { "NiPSysSpawnModifier", &construct }, + // Modifier controllers, Gamebryo { "NiPSysAirFieldAirFrictionCtlr", &construct }, { "NiPSysAirFieldInheritVelocityCtlr", diff --git a/components/nif/particle.cpp b/components/nif/particle.cpp index bd3b4dcddb..04da656e9d 100644 --- a/components/nif/particle.cpp +++ b/components/nif/particle.cpp @@ -238,6 +238,35 @@ namespace Nif mTarget.post(nif); } + void NiPSysAgeDeathModifier::read(NIFStream* nif) + { + NiPSysModifier::read(nif); + + nif->read(mSpawnOnDeath); + mSpawnModifier.read(nif); + } + + void NiPSysAgeDeathModifier::post(Reader& nif) + { + NiPSysModifier::post(nif); + + mSpawnModifier.post(nif); + } + + void NiPSysSpawnModifier::read(NIFStream* nif) + { + NiPSysModifier::read(nif); + + nif->read(mNumSpawnGenerations); + nif->read(mPercentageSpawned); + nif->read(mMinNumToSpawn); + nif->read(mMaxNumToSpawn); + nif->read(mSpawnSpeedVariation); + nif->read(mSpawnDirVariation); + nif->read(mLifespan); + nif->read(mLifespanVariation); + } + void NiPSysModifierCtlr::read(NIFStream* nif) { NiSingleInterpController::read(nif); diff --git a/components/nif/particle.hpp b/components/nif/particle.hpp index 4428347105..b556b0b285 100644 --- a/components/nif/particle.hpp +++ b/components/nif/particle.hpp @@ -177,6 +177,29 @@ namespace Nif void post(Reader& nif) override; }; + struct NiPSysAgeDeathModifier : NiPSysModifier + { + bool mSpawnOnDeath; + NiPSysSpawnModifierPtr mSpawnModifier; + + void read(NIFStream* nif) override; + void post(Reader& nif) override; + }; + + struct NiPSysSpawnModifier : NiPSysModifier + { + uint16_t mNumSpawnGenerations; + float mPercentageSpawned; + uint16_t mMinNumToSpawn; + uint16_t mMaxNumToSpawn; + float mSpawnSpeedVariation; + float mSpawnDirVariation; + float mLifespan; + float mLifespanVariation; + + void read(NIFStream* nif) override; + }; + // Abstract struct NiPSysModifierCtlr : NiSingleInterpController { diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 2073723ece..78bbb0f062 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -182,6 +182,7 @@ namespace Nif RC_NiPlanarCollider, RC_NiPoint3Interpolator, RC_NiPosData, + RC_NiPSysAgeDeathModifier, RC_NiPSysAirFieldAirFrictionCtlr, RC_NiPSysAirFieldInheritVelocityCtlr, RC_NiPSysAirFieldSpreadCtlr, @@ -204,6 +205,7 @@ namespace Nif RC_NiPSysInitialRotAngleCtlr, RC_NiPSysInitialRotAngleVarCtlr, RC_NiPSysModifierActiveCtlr, + RC_NiPSysSpawnModifier, RC_NiPSysUpdateCtlr, RC_NiRollController, RC_NiSequence, diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index 2355879ac6..6223740e31 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -132,6 +132,7 @@ namespace Nif struct NiParticleSystem; struct NiPSysEmitterCtlrData; struct NiPSysModifier; + struct NiPSysSpawnModifier; struct NiBoolData; struct NiSkinPartition; struct BSShaderTextureSet; @@ -175,6 +176,7 @@ namespace Nif using NiParticleModifierPtr = RecordPtrT; using NiParticleSystemPtr = RecordPtrT; using NiPSysEmitterCtlrDataPtr = RecordPtrT; + using NiPSysSpawnModifierPtr = RecordPtrT; using NiBoolDataPtr = RecordPtrT; using NiSkinPartitionPtr = RecordPtrT; using BSShaderTextureSetPtr = RecordPtrT;