Merge branch 'particles' into 'master'

Make NIF particle node handling more generic

See merge request OpenMW/openmw!425
pull/593/head
psi29a 4 years ago
commit 2c6e8eb195

@ -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());

@ -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;

@ -47,8 +47,9 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
factory["NiTriShape"] = {&construct <NiTriShape> , RC_NiTriShape };
factory["NiTriStrips"] = {&construct <NiTriStrips> , RC_NiTriStrips };
factory["NiLines"] = {&construct <NiLines> , RC_NiLines };
factory["NiRotatingParticles"] = {&construct <NiRotatingParticles> , RC_NiRotatingParticles };
factory["NiAutoNormalParticles"] = {&construct <NiAutoNormalParticles> , RC_NiAutoNormalParticles };
factory["NiParticles"] = {&construct <NiParticles> , RC_NiParticles };
factory["NiRotatingParticles"] = {&construct <NiParticles> , RC_NiParticles };
factory["NiAutoNormalParticles"] = {&construct <NiParticles> , RC_NiParticles };
factory["NiCamera"] = {&construct <NiCamera> , RC_NiCamera };
factory["RootCollisionNode"] = {&construct <NiNode> , RC_RootCollisionNode };
factory["NiTexturingProperty"] = {&construct <NiTexturingProperty> , RC_NiTexturingProperty };
@ -99,8 +100,9 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
factory["NiSkinData"] = {&construct <NiSkinData> , RC_NiSkinData };
factory["NiUVData"] = {&construct <NiUVData> , RC_NiUVData };
factory["NiPosData"] = {&construct <NiPosData> , RC_NiPosData };
factory["NiRotatingParticlesData"] = {&construct <NiRotatingParticlesData> , RC_NiRotatingParticlesData };
factory["NiAutoNormalParticlesData"] = {&construct <NiAutoNormalParticlesData> , RC_NiAutoNormalParticlesData };
factory["NiParticlesData"] = {&construct <NiParticlesData> , RC_NiParticlesData };
factory["NiRotatingParticlesData"] = {&construct <NiRotatingParticlesData> , RC_NiParticlesData };
factory["NiAutoNormalParticlesData"] = {&construct <NiParticlesData> , RC_NiParticlesData };
factory["NiSequenceStreamHelper"] = {&construct <NiSequenceStreamHelper> , RC_NiSequenceStreamHelper };
factory["NiSourceTexture"] = {&construct <NiSourceTexture> , RC_NiSourceTexture };
factory["NiSkinInstance"] = {&construct <NiSkinInstance> , RC_NiSkinInstance };

@ -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);
}
};

@ -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

@ -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<NiTriStripsData>;
using NiLinesDataPtr = RecordPtrT<NiLinesData>;
using NiSkinInstancePtr = RecordPtrT<NiSkinInstance>;
using NiSourceTexturePtr = RecordPtrT<NiSourceTexture>;
using NiRotatingParticlesDataPtr = RecordPtrT<NiRotatingParticlesData>;
using NiAutoNormalParticlesDataPtr = RecordPtrT<NiAutoNormalParticlesData>;
using NiParticlesDataPtr = RecordPtrT<NiParticlesData>;
using NiPalettePtr = RecordPtrT<NiPalette>;
using NiParticleModifierPtr = RecordPtrT<NiParticleModifier>;
using NiBoolDataPtr = RecordPtrT<NiBoolData>;

@ -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<const Nif::NiAutoNormalParticles*>(nifNode)->data.getPtr();
else if(nifNode->recType == Nif::RC_NiRotatingParticles)
particledata = static_cast<const Nif::NiRotatingParticles*>(nifNode)->data.getPtr();
else
const auto particleNode = static_cast<const Nif::NiParticles*>(nifNode);
if (particleNode->data.empty())
return;
const Nif::NiParticlesData* particledata = particleNode->data.getPtr();
osg::BoundingBox box;
int i=0;

Loading…
Cancel
Save