Merge branch 'nifgobrrrr' into 'master'

More NIF stuff

See merge request OpenMW/openmw!324
pull/593/head
psi29a 4 years ago
commit ee22081ae1

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

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

@ -75,8 +75,6 @@ class NiAutoNormalParticlesData : public NiGeometryData
public:
int numParticles{0};
float particleRadius;
int activeCount;
std::vector<float> particleRadii, sizes, rotationAngles;

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

@ -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<unsigned int> data;
void read(NIFStream *nif);
};
struct NiBinaryExtraData : public Extra
{
std::vector<char> 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<float> data;
void read(NIFStream *nif);
};
} // Namespace
#endif

@ -105,10 +105,17 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
factory["NiSkinInstance"] = {&construct <NiSkinInstance> , RC_NiSkinInstance };
factory["NiLookAtController"] = {&construct <NiLookAtController> , RC_NiLookAtController };
factory["NiPalette"] = {&construct <NiPalette> , RC_NiPalette };
factory["NiIntegerExtraData"] = {&construct <NiIntegerExtraData> , RC_NiIntegerExtraData };
factory["NiIntegersExtraData"] = {&construct <NiIntegersExtraData> , RC_NiIntegersExtraData };
factory["NiBinaryExtraData"] = {&construct <NiBinaryExtraData> , RC_NiBinaryExtraData };
factory["NiBooleanExtraData"] = {&construct <NiBooleanExtraData> , RC_NiBooleanExtraData };
factory["NiVectorExtraData"] = {&construct <NiVectorExtraData> , RC_NiVectorExtraData };
factory["NiColorExtraData"] = {&construct <NiVectorExtraData> , RC_NiColorExtraData };
factory["NiFloatExtraData"] = {&construct <NiFloatExtraData> , RC_NiFloatExtraData };
factory["NiFloatsExtraData"] = {&construct <NiFloatsExtraData> , RC_NiFloatsExtraData };
return factory;
}
///Make the factory map used for parsing the file
static const std::map<std::string,RecordFactoryEntry> factories = makeFactory();

@ -162,7 +162,6 @@ struct NiWireframeProperty : public Property
}
};
// The rest are all struct-based
template <typename T>
struct StructPropT : Property

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

@ -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 &copy, 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<osg::
{
}
FlipController::FlipController()
: mTexSlot(0)
, mDelta(0.f)
{
}
FlipController::FlipController(const FlipController &copy, const osg::CopyOp &copyop)
: StateSetUpdater(copy, copyop)
, Controller(copy)

@ -268,11 +268,11 @@ namespace NifOsg
{
private:
FloatInterpolator mData;
double mStartingTime;
double mStartingTime{0};
public:
RollController(const Nif::NiFloatData *data);
RollController();
RollController() = default;
RollController(const RollController& copy, const osg::CopyOp& copyop);
virtual void operator() (osg::Node* node, osg::NodeVisitor* nv);
@ -326,14 +326,14 @@ namespace NifOsg
class FlipController : public SceneUtil::StateSetUpdater, public SceneUtil::Controller
{
private:
int mTexSlot;
float mDelta;
int mTexSlot{0};
float mDelta{0.f};
std::vector<osg::ref_ptr<osg::Texture2D> > mTextures;
public:
FlipController(const Nif::NiFlipController* ctrl, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures);
FlipController(int texSlot, float delta, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures);
FlipController();
FlipController() = default;
FlipController(const FlipController& copy, const osg::CopyOp& copyop);
META_Object(NifOsg, FlipController)

Loading…
Cancel
Save