diff --git a/components/nif/controller.cpp b/components/nif/controller.cpp index 8d943b58a..07699239e 100644 --- a/components/nif/controller.cpp +++ b/components/nif/controller.cpp @@ -170,25 +170,13 @@ namespace Nif data.post(nif); } - void NiAlphaController::read(NIFStream *nif) + void NiFloatInterpController::read(NIFStream *nif) { Controller::read(nif); data.read(nif); } - void NiAlphaController::post(NIFFile *nif) - { - Controller::post(nif); - data.post(nif); - } - - void NiRollController::read(NIFStream *nif) - { - Controller::read(nif); - data.read(nif); - } - - void NiRollController::post(NIFFile *nif) + void NiFloatInterpController::post(NIFFile *nif) { Controller::post(nif); data.post(nif); diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index bf043fbdb..a527a4400 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -143,23 +143,16 @@ public: void post(NIFFile *nif); }; -class NiAlphaController : public Controller +struct NiFloatInterpController : public Controller { -public: NiFloatDataPtr data; void read(NIFStream *nif); void post(NIFFile *nif); }; -class NiRollController : public Controller -{ -public: - NiFloatDataPtr data; - - void read(NIFStream *nif); - void post(NIFFile *nif); -}; +class NiAlphaController : public NiFloatInterpController { }; +class NiRollController : public NiFloatInterpController { }; class NiGeomMorpherController : public Controller { diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 1519bd1b3..58d6cf755 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -75,8 +75,6 @@ class NiAutoNormalParticlesData : public NiGeometryData public: int numParticles{0}; - float particleRadius; - int activeCount; std::vector particleRadii, sizes, rotationAngles; diff --git a/components/nif/extra.cpp b/components/nif/extra.cpp index cb654d5a0..d08e5d738 100644 --- a/components/nif/extra.cpp +++ b/components/nif/extra.cpp @@ -29,6 +29,56 @@ void NiVertWeightsExtraData::read(NIFStream *nif) nif->skip(nif->getUShort() * sizeof(float)); // vertex weights I guess } +void NiIntegerExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + + data = nif->getUInt(); +} + +void NiIntegersExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + + unsigned int num = nif->getUInt(); + if (num) + nif->getUInts(data, num); +} + +void NiBinaryExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + unsigned int size = nif->getUInt(); + if (size) + nif->getChars(data, size); +} + +void NiBooleanExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + data = nif->getBoolean(); +} + +void NiVectorExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + data = nif->getVector4(); +} + +void NiFloatExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + + data = nif->getFloat(); +} + +void NiFloatsExtraData::read(NIFStream *nif) +{ + Extra::read(nif); + unsigned int num = nif->getUInt(); + if (num) + nif->getFloats(data, num); +} } diff --git a/components/nif/extra.hpp b/components/nif/extra.hpp index d935add55..0e8cc16bf 100644 --- a/components/nif/extra.hpp +++ b/components/nif/extra.hpp @@ -60,5 +60,54 @@ public: void read(NIFStream *nif); }; +struct NiIntegerExtraData : public Extra +{ + unsigned int data; + + void read(NIFStream *nif); +}; + +struct NiIntegersExtraData : public Extra +{ + std::vector data; + + void read(NIFStream *nif); +}; + +struct NiBinaryExtraData : public Extra +{ + std::vector data; + + void read(NIFStream *nif); +}; + +struct NiBooleanExtraData : public Extra +{ + bool data; + + void read(NIFStream *nif); +}; + +struct NiVectorExtraData : public Extra +{ + osg::Vec4f data; + + void read(NIFStream *nif); +}; + +struct NiFloatExtraData : public Extra +{ + float data; + + void read(NIFStream *nif); +}; + +struct NiFloatsExtraData : public Extra +{ + std::vector data; + + void read(NIFStream *nif); +}; + } // Namespace #endif diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 31c959964..8d65753d2 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -105,10 +105,17 @@ static std::map makeFactory() factory["NiSkinInstance"] = {&construct , RC_NiSkinInstance }; factory["NiLookAtController"] = {&construct , RC_NiLookAtController }; factory["NiPalette"] = {&construct , RC_NiPalette }; + factory["NiIntegerExtraData"] = {&construct , RC_NiIntegerExtraData }; + factory["NiIntegersExtraData"] = {&construct , RC_NiIntegersExtraData }; + factory["NiBinaryExtraData"] = {&construct , RC_NiBinaryExtraData }; + factory["NiBooleanExtraData"] = {&construct , RC_NiBooleanExtraData }; + factory["NiVectorExtraData"] = {&construct , RC_NiVectorExtraData }; + factory["NiColorExtraData"] = {&construct , RC_NiColorExtraData }; + factory["NiFloatExtraData"] = {&construct , RC_NiFloatExtraData }; + factory["NiFloatsExtraData"] = {&construct , RC_NiFloatsExtraData }; return factory; } - ///Make the factory map used for parsing the file static const std::map factories = makeFactory(); diff --git a/components/nif/property.hpp b/components/nif/property.hpp index e20d948f0..aeef0c027 100644 --- a/components/nif/property.hpp +++ b/components/nif/property.hpp @@ -162,7 +162,6 @@ struct NiWireframeProperty : public Property } }; - // The rest are all struct-based template struct StructPropT : Property diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 67202d2fe..f9bb613a0 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -101,7 +101,15 @@ enum RecordType RC_RootCollisionNode, RC_NiSphericalCollider, RC_NiLookAtController, - RC_NiPalette + RC_NiPalette, + RC_NiIntegerExtraData, + RC_NiIntegersExtraData, + RC_NiBinaryExtraData, + RC_NiBooleanExtraData, + RC_NiVectorExtraData, + RC_NiColorExtraData, + RC_NiFloatExtraData, + RC_NiFloatsExtraData }; /// Base class for all records diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index b6610728a..0f4c4a5bd 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -310,11 +310,6 @@ void VisController::operator() (osg::Node* node, osg::NodeVisitor* nv) RollController::RollController(const Nif::NiFloatData *data) : mData(data->mKeyList, 1.f) - , mStartingTime(0) -{ -} - -RollController::RollController() : mStartingTime(0) { } @@ -322,7 +317,7 @@ RollController::RollController(const RollController ©, const osg::CopyOp &co : osg::NodeCallback(copy, copyop) , Controller(copy) , mData(copy.mData) - , mStartingTime(0) + , mStartingTime(copy.mStartingTime) { } @@ -462,12 +457,6 @@ FlipController::FlipController(int texSlot, float delta, const std::vector > mTextures; public: FlipController(const Nif::NiFlipController* ctrl, const std::vector >& textures); FlipController(int texSlot, float delta, const std::vector >& textures); - FlipController(); + FlipController() = default; FlipController(const FlipController& copy, const osg::CopyOp& copyop); META_Object(NifOsg, FlipController)