Read NiParticleSystem and its twins

Looks like NiPSysData is loading correctly
macos_ci_fix
Alexei Kotov 1 year ago
parent c800152ca2
commit a8946e06f6

@ -278,8 +278,13 @@ namespace Nif
{ "NiRotatingParticlesData", &construct<NiRotatingParticlesData, RC_NiParticlesData> },
// Geometry, Gamebryo
{ "NiParticleSystem", &construct<NiParticleSystem, RC_NiParticleSystem> },
{ "NiMeshParticleSystem", &construct<NiParticleSystem, RC_NiParticleSystem> },
{ "NiPSysData", &construct<NiPSysData, RC_NiPSysData> },
// Geometry, Bethesda
{ "BSStripParticleSystem", &construct<NiParticleSystem, RC_NiParticleSystem> },
// Modifiers, 4.0.0.2
{ "NiGravity", &construct<NiGravity, RC_NiGravity> },
{ "NiParticleColorModifier", &construct<NiParticleColorModifier, RC_NiParticleColorModifier> },

@ -150,6 +150,46 @@ namespace Nif
nif->readVector(mRotations, mNumVertices);
}
void NiParticleSystem::read(NIFStream* nif)
{
// Weird loading to account for inheritance differences starting from SSE
if (nif->getBethVersion() < NIFFile::BethVersion::BETHVER_SSE)
NiParticles::read(nif);
else
{
NiAVObject::read(nif);
nif->read(mBoundingSphere);
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_F76)
nif->readArray(mBoundMinMax);
mSkin.read(nif);
mShaderProperty.read(nif);
mAlphaProperty.read(nif);
mVertDesc.read(nif);
}
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_SKY)
{
nif->readArray(mNearFar);
if (nif->getBethVersion() >= NIFFile::BethVersion::BETHVER_SSE)
mData.read(nif);
}
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
{
nif->read(mWorldSpace);
readRecordList(nif, mModifiers);
}
}
void NiParticleSystem::post(Reader& nif)
{
NiParticles::post(nif);
postRecordList(nif, mModifiers);
}
void NiPSysData::read(NIFStream* nif)
{
NiParticlesData::read(nif);
@ -175,6 +215,19 @@ namespace Nif
}
}
void NiPSysModifier::read(NIFStream* nif)
{
nif->read(mName);
mOrder = static_cast<NiPSysModifierOrder>(nif->get<uint32_t>());
mTarget.read(nif);
nif->read(mActive);
}
void NiPSysModifier::post(Reader& nif)
{
mTarget.post(nif);
}
void NiPSysModifierCtlr::read(NIFStream* nif)
{
NiSingleInterpController::read(nif);

@ -4,6 +4,7 @@
#include "base.hpp"
#include "controller.hpp"
#include "data.hpp"
#include "node.hpp"
namespace Nif
{
@ -114,6 +115,19 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct NiParticleSystem : NiParticles
{
osg::BoundingSpheref mBoundingSphere;
std::array<float, 6> mBoundMinMax;
BSVertexDesc mVertDesc;
std::array<uint16_t, 4> mNearFar;
bool mWorldSpace{ true };
NiPSysModifierList mModifiers;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
struct NiPSysData : NiParticlesData
{
std::vector<NiParticleInfo> mParticles;
@ -124,6 +138,35 @@ namespace Nif
void read(NIFStream* nif) override;
};
// Abstract
struct NiPSysModifier : Record
{
enum class NiPSysModifierOrder : uint32_t
{
KillOldParticles = 0,
BSLOD = 1,
Emitter = 1000,
Spawn = 2000,
BSStripUpdateFO3 = 2500,
General = 3000,
Force = 4000,
Collider = 5000,
PosUpdate = 6000,
PostPosUpdate = 6500,
WorldshiftPartspawn = 6600,
BoundUpdate = 7000,
BSStripUpdateSK = 8000,
};
std::string mName;
NiPSysModifierOrder mOrder;
NiParticleSystemPtr mTarget;
bool mActive;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
};
// Abstract
struct NiPSysModifierCtlr : NiSingleInterpController
{

@ -172,6 +172,7 @@ namespace Nif
RC_NiParticleRotation,
RC_NiParticles,
RC_NiParticlesData,
RC_NiParticleSystem,
RC_NiParticleSystemController,
RC_NiPathController,
RC_NiPathInterpolator,

@ -129,7 +129,9 @@ namespace Nif
struct NiSourceTexture;
struct NiPalette;
struct NiParticleModifier;
struct NiParticleSystem;
struct NiPSysEmitterCtlrData;
struct NiPSysModifier;
struct NiBoolData;
struct NiSkinPartition;
struct BSShaderTextureSet;
@ -171,6 +173,7 @@ namespace Nif
using NiSourceTexturePtr = RecordPtrT<NiSourceTexture>;
using NiPalettePtr = RecordPtrT<NiPalette>;
using NiParticleModifierPtr = RecordPtrT<NiParticleModifier>;
using NiParticleSystemPtr = RecordPtrT<NiParticleSystem>;
using NiPSysEmitterCtlrDataPtr = RecordPtrT<NiPSysEmitterCtlrData>;
using NiBoolDataPtr = RecordPtrT<NiBoolData>;
using NiSkinPartitionPtr = RecordPtrT<NiSkinPartition>;
@ -204,6 +207,7 @@ namespace Nif
using bhkSerializableList = RecordListT<bhkSerializable>;
using bhkEntityList = RecordListT<bhkEntity>;
using NiControllerSequenceList = RecordListT<NiControllerSequence>;
using NiPSysModifierList = RecordListT<NiPSysModifier>;
} // Namespace
#endif

Loading…
Cancel
Save