diff --git a/components/nif/data.cpp b/components/nif/data.cpp index 235825e4a..415a013b3 100644 --- a/components/nif/data.cpp +++ b/components/nif/data.cpp @@ -184,7 +184,7 @@ void NiLinesData::read(NIFStream *nif) } } -void NiAutoNormalParticlesData::read(NIFStream *nif) +void NiParticlesData::read(NIFStream *nif) { NiGeometryData::read(nif); @@ -216,7 +216,7 @@ void NiAutoNormalParticlesData::read(NIFStream *nif) void NiRotatingParticlesData::read(NIFStream *nif) { - NiAutoNormalParticlesData::read(nif); + NiParticlesData::read(nif); if (nif->getVersion() <= NIFStream::generateVersion(4,2,2,0) && nif->getBoolean()) nif->getQuaternions(rotations, vertices.size()); diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 35f329573..908313f50 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -70,7 +70,7 @@ struct NiLinesData : public NiGeometryData void read(NIFStream *nif) override; }; -class NiAutoNormalParticlesData : public NiGeometryData +class NiParticlesData : public NiGeometryData { public: int numParticles{0}; @@ -84,7 +84,7 @@ public: void read(NIFStream *nif) override; }; -class NiRotatingParticlesData : public NiAutoNormalParticlesData +class NiRotatingParticlesData : public NiParticlesData { public: void read(NIFStream *nif) override; diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 7915908d1..67c864f47 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -47,8 +47,9 @@ static std::map makeFactory() factory["NiTriShape"] = {&construct , RC_NiTriShape }; factory["NiTriStrips"] = {&construct , RC_NiTriStrips }; factory["NiLines"] = {&construct , RC_NiLines }; - factory["NiRotatingParticles"] = {&construct , RC_NiRotatingParticles }; - factory["NiAutoNormalParticles"] = {&construct , RC_NiAutoNormalParticles }; + factory["NiParticles"] = {&construct , RC_NiParticles }; + factory["NiRotatingParticles"] = {&construct , RC_NiParticles }; + factory["NiAutoNormalParticles"] = {&construct , RC_NiParticles }; factory["NiCamera"] = {&construct , RC_NiCamera }; factory["RootCollisionNode"] = {&construct , RC_RootCollisionNode }; factory["NiTexturingProperty"] = {&construct , RC_NiTexturingProperty }; @@ -99,8 +100,9 @@ static std::map makeFactory() factory["NiSkinData"] = {&construct , RC_NiSkinData }; factory["NiUVData"] = {&construct , RC_NiUVData }; factory["NiPosData"] = {&construct , RC_NiPosData }; - factory["NiRotatingParticlesData"] = {&construct , RC_NiRotatingParticlesData }; - factory["NiAutoNormalParticlesData"] = {&construct , RC_NiAutoNormalParticlesData }; + factory["NiParticlesData"] = {&construct , RC_NiParticlesData }; + factory["NiRotatingParticlesData"] = {&construct , RC_NiParticlesData }; + factory["NiAutoNormalParticlesData"] = {&construct , RC_NiParticlesData }; factory["NiSequenceStreamHelper"] = {&construct , RC_NiSequenceStreamHelper }; factory["NiSourceTexture"] = {&construct , RC_NiSourceTexture }; factory["NiSkinInstance"] = {&construct , RC_NiSkinInstance }; diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 0b958d2c2..58397bdca 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -401,39 +401,22 @@ struct NiCamera : Node } }; -struct NiAutoNormalParticles : Node +struct NiParticles : NiGeometry { - NiAutoNormalParticlesDataPtr data; - + NiParticlesDataPtr data; void read(NIFStream *nif) override { Node::read(nif); data.read(nif); - nif->getInt(); // -1 - } - - void post(NIFFile *nif) override - { - Node::post(nif); - data.post(nif); - } -}; - -struct NiRotatingParticles : Node -{ - NiRotatingParticlesDataPtr data; - - void read(NIFStream *nif) override - { - Node::read(nif); - data.read(nif); - nif->getInt(); // -1 + skin.read(nif); + materialData.read(nif); } void post(NIFFile *nif) override { Node::post(nif); data.post(nif); + skin.post(nif); } }; diff --git a/components/nif/record.hpp b/components/nif/record.hpp index c5773643a..2217c588e 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -44,8 +44,7 @@ enum RecordType RC_NiTriShape, RC_NiTriStrips, RC_NiLines, - RC_NiRotatingParticles, - RC_NiAutoNormalParticles, + RC_NiParticles, RC_NiBSParticleNode, RC_NiCamera, RC_NiTexturingProperty, @@ -94,7 +93,7 @@ enum RecordType RC_NiUVData, RC_NiPosData, RC_NiRotatingParticlesData, - RC_NiAutoNormalParticlesData, + RC_NiParticlesData, RC_NiSequenceStreamHelper, RC_NiSourceTexture, RC_NiSkinInstance, @@ -119,7 +118,7 @@ enum RecordType RC_NiFloatInterpolator, RC_NiPoint3Interpolator, RC_NiBoolInterpolator, - RC_NiTransformInterpolator, + RC_NiTransformInterpolator }; /// Base class for all records diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index b40a17583..ed8f7ef6b 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -138,8 +138,7 @@ class NiTriShapeData; class NiTriStripsData; class NiSkinInstance; class NiSourceTexture; -class NiRotatingParticlesData; -class NiAutoNormalParticlesData; +class NiParticlesData; class NiPalette; struct NiParticleModifier; struct NiLinesData; @@ -167,8 +166,7 @@ using NiTriStripsDataPtr = RecordPtrT; using NiLinesDataPtr = RecordPtrT; using NiSkinInstancePtr = RecordPtrT; using NiSourceTexturePtr = RecordPtrT; -using NiRotatingParticlesDataPtr = RecordPtrT; -using NiAutoNormalParticlesDataPtr = RecordPtrT; +using NiParticlesDataPtr = RecordPtrT; using NiPalettePtr = RecordPtrT; using NiParticleModifierPtr = RecordPtrT; using NiBoolDataPtr = RecordPtrT; diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 4bc48637c..0db15237e 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -638,7 +638,7 @@ namespace NifOsg } } - if(nifNode->recType == Nif::RC_NiAutoNormalParticles || nifNode->recType == Nif::RC_NiRotatingParticles) + if (nifNode->recType == Nif::RC_NiParticles) handleParticleSystem(nifNode, node, composite, animflags); if (composite->getNumControllers() > 0) @@ -946,14 +946,12 @@ namespace NifOsg // Load the initial state of the particle system, i.e. the initial particles and their positions, velocity and colors. void handleParticleInitialState(const Nif::Node* nifNode, osgParticle::ParticleSystem* partsys, const Nif::NiParticleSystemController* partctrl) { - const Nif::NiAutoNormalParticlesData *particledata = nullptr; - if(nifNode->recType == Nif::RC_NiAutoNormalParticles) - particledata = static_cast(nifNode)->data.getPtr(); - else if(nifNode->recType == Nif::RC_NiRotatingParticles) - particledata = static_cast(nifNode)->data.getPtr(); - else + const auto particleNode = static_cast(nifNode); + if (particleNode->data.empty()) return; + const Nif::NiParticlesData* particledata = particleNode->data.getPtr(); + osg::BoundingBox box; int i=0;