Rename Controller->NiTimeController, update NiTimeController and related code

macos_ci_fix
Alexei Kotov 1 year ago
parent 04d3f6a42d
commit 0fe095303f

@ -20,7 +20,7 @@ namespace Nif::Testing
{
value.mExtra = ExtraPtr(nullptr);
value.mExtraList = ExtraList();
value.mController = ControllerPtr(nullptr);
value.mController = NiTimeControllerPtr(nullptr);
}
inline void init(NiAVObject& value)
@ -55,14 +55,14 @@ namespace Nif::Testing
value.mRoot = NiAVObjectPtr(nullptr);
}
inline void init(Controller& value)
inline void init(NiTimeController& value)
{
value.next = ControllerPtr(nullptr);
value.flags = 0;
value.frequency = 0;
value.phase = 0;
value.timeStart = 0;
value.timeStop = 0;
value.mNext = NiTimeControllerPtr(nullptr);
value.mFlags = 0;
value.mFrequency = 0;
value.mPhase = 0;
value.mTimeStart = 0;
value.mTimeStop = 0;
value.mTarget = NiObjectNETPtr(nullptr);
}
}

@ -300,7 +300,7 @@ namespace
Nif::NiStringExtraData mNiStringExtraData;
Nif::NiStringExtraData mNiStringExtraData2;
Nif::NiIntegerExtraData mNiIntegerExtraData;
Nif::Controller mController;
Nif::NiTimeController mController;
btTransform mTransform{ btMatrix3x3(btQuaternion(btVector3(1, 0, 0), 0.5f)), btVector3(1, 2, 3) };
btTransform mTransformScale2{ btMatrix3x3(btQuaternion(btVector3(1, 0, 0), 0.5f)), btVector3(2, 4, 6) };
btTransform mTransformScale3{ btMatrix3x3(btQuaternion(btVector3(1, 0, 0), 0.5f)), btVector3(3, 6, 9) };
@ -817,11 +817,11 @@ namespace
TEST_F(TestBulletNifLoader, for_tri_shape_child_node_with_controller_should_return_animated_shape)
{
mController.recType = Nif::RC_NiKeyframeController;
mController.flags |= Nif::Controller::Flag_Active;
mController.mFlags |= Nif::NiTimeController::Flag_Active;
copy(mTransform, mNiTriShape.mTransform);
mNiTriShape.mTransform.mScale = 3;
mNiTriShape.mParents.push_back(&mNiNode);
mNiTriShape.mController = Nif::ControllerPtr(&mController);
mNiTriShape.mController = Nif::NiTimeControllerPtr(&mController);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
mNiNode.mTransform.mScale = 4;
@ -847,14 +847,14 @@ namespace
TEST_F(TestBulletNifLoader, for_two_tri_shape_children_nodes_where_one_with_controller_should_return_animated_shape)
{
mController.recType = Nif::RC_NiKeyframeController;
mController.flags |= Nif::Controller::Flag_Active;
mController.mFlags |= Nif::NiTimeController::Flag_Active;
copy(mTransform, mNiTriShape.mTransform);
mNiTriShape.mTransform.mScale = 3;
mNiTriShape.mParents.push_back(&mNiNode);
copy(mTransform, mNiTriShape2.mTransform);
mNiTriShape2.mTransform.mScale = 3;
mNiTriShape2.mParents.push_back(&mNiNode);
mNiTriShape2.mController = Nif::ControllerPtr(&mController);
mNiTriShape2.mController = Nif::NiTimeControllerPtr(&mController);
mNiNode.mChildren = Nif::NiAVObjectList{
Nif::NiAVObjectPtr(&mNiTriShape),
Nif::NiAVObjectPtr(&mNiTriShape2),

@ -21,7 +21,7 @@ namespace Nif
void post(Reader& nif) override { mNext.post(nif); }
};
struct Controller : public Record
struct NiTimeController : public Record
{
enum Flags
{
@ -36,17 +36,17 @@ namespace Nif
Mask = 6
};
ControllerPtr next;
int flags;
float frequency, phase;
float timeStart, timeStop;
NiTimeControllerPtr mNext;
uint16_t mFlags;
float mFrequency, mPhase;
float mTimeStart, mTimeStop;
NiObjectNETPtr mTarget;
void read(NIFStream* nif) override;
void post(Reader& nif) override;
bool isActive() const { return flags & Flag_Active; }
ExtrapolationMode extrapolationMode() const { return static_cast<ExtrapolationMode>(flags & Mask); }
bool isActive() const { return mFlags & Flag_Active; }
ExtrapolationMode extrapolationMode() const { return static_cast<ExtrapolationMode>(mFlags & Mask); }
};
/// Abstract object that has a name, extra data and controllers
@ -55,7 +55,7 @@ namespace Nif
std::string mName;
ExtraPtr mExtra;
ExtraList mExtraList;
ControllerPtr mController;
NiTimeControllerPtr mController;
void read(NIFStream* nif) override;
void post(Reader& nif) override;

@ -9,21 +9,21 @@
namespace Nif
{
void Controller::read(NIFStream* nif)
void NiTimeController::read(NIFStream* nif)
{
next.read(nif);
flags = nif->getUShort();
frequency = nif->getFloat();
phase = nif->getFloat();
timeStart = nif->getFloat();
timeStop = nif->getFloat();
mTarget.read(nif);
mNext.read(nif);
nif->read(mFlags);
nif->read(mFrequency);
nif->read(mPhase);
nif->read(mTimeStart);
nif->read(mTimeStop);
if (nif->getVersion() >= NIFStream::generateVersion(3, 3, 0, 13))
mTarget.read(nif);
}
void Controller::post(Reader& nif)
void NiTimeController::post(Reader& nif)
{
next.post(nif);
mNext.post(nif);
mTarget.post(nif);
}
@ -109,7 +109,7 @@ namespace Nif
nif->read(mWeight);
mTextKeys.read(nif);
mExtrapolationMode = static_cast<Controller::ExtrapolationMode>(nif->getUInt());
mExtrapolationMode = static_cast<NiTimeController::ExtrapolationMode>(nif->getUInt());
mFrequency = nif->getFloat();
if (nif->getVersion() <= NIFStream::generateVersion(10, 4, 0, 1))
nif->read(mPhase);
@ -142,7 +142,7 @@ namespace Nif
void NiInterpController::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 104)
&& nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 108))
@ -166,7 +166,7 @@ namespace Nif
void NiParticleSystemController::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
velocity = nif->getFloat();
velocityRandom = nif->getFloat();
@ -220,7 +220,7 @@ namespace Nif
void NiParticleSystemController::post(Reader& nif)
{
Controller::post(nif);
NiTimeController::post(nif);
emitter.post(nif);
affectors.post(nif);
@ -234,7 +234,7 @@ namespace Nif
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
mTargetColor = static_cast<TargetColor>(nif->get<uint16_t>() & 3);
else
mTargetColor = static_cast<TargetColor>((flags >> 4) & 3);
mTargetColor = static_cast<TargetColor>((mFlags >> 4) & 3);
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 103))
mData.read(nif);
@ -249,7 +249,7 @@ namespace Nif
void NiLookAtController::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
nif->read(mLookAtFlags);
@ -258,19 +258,19 @@ namespace Nif
void NiLookAtController::post(Reader& nif)
{
Controller::post(nif);
NiTimeController::post(nif);
mLookAt.post(nif);
}
void NiPathController::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
nif->read(mPathFlags);
else
mPathFlags = (flags >> 16);
mPathFlags = (mFlags >> 16);
nif->read(mBankDirection);
nif->read(mMaxBankAngle);
@ -282,7 +282,7 @@ namespace Nif
void NiPathController::post(Reader& nif)
{
Controller::post(nif);
NiTimeController::post(nif);
mPathData.post(nif);
mPercentData.post(nif);
@ -290,7 +290,7 @@ namespace Nif
void NiUVController::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
nif->read(mUvSet);
mData.read(nif);
@ -298,7 +298,7 @@ namespace Nif
void NiUVController::post(Reader& nif)
{
Controller::post(nif);
NiTimeController::post(nif);
mData.post(nif);
}
@ -427,7 +427,7 @@ namespace Nif
mTexSlot = static_cast<NiTexturingProperty::TextureType>(nif->get<uint32_t>());
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 103))
{
nif->read(timeStart);
nif->read(mTimeStart);
nif->read(mDelta);
}
readRecordList(nif, mSources);
@ -460,7 +460,7 @@ namespace Nif
void bhkBlendController::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
uint32_t numKeys;
nif->read(numKeys);
@ -486,7 +486,7 @@ namespace Nif
void NiControllerManager::read(NIFStream* nif)
{
Controller::read(nif);
NiTimeController::read(nif);
nif->read(mCumulative);
readRecordList(nif, mSequences);
@ -495,7 +495,7 @@ namespace Nif
void NiControllerManager::post(Reader& nif)
{
Controller::post(nif);
NiTimeController::post(nif);
postRecordList(nif, mSequences);
mObjectPalette.post(nif);

@ -12,7 +12,7 @@ namespace Nif
{
std::string mTargetName;
NiInterpolatorPtr mInterpolator;
ControllerPtr mController;
NiTimeControllerPtr mController;
NiBlendInterpolatorPtr mBlendInterpolator;
uint16_t mBlendIndex;
uint8_t mPriority;
@ -49,7 +49,7 @@ namespace Nif
struct NiControllerSequence : public NiSequence
{
float mWeight{ 1.f };
Controller::ExtrapolationMode mExtrapolationMode{ Controller::ExtrapolationMode::Constant };
NiTimeController::ExtrapolationMode mExtrapolationMode{ NiTimeController::ExtrapolationMode::Constant };
float mFrequency{ 1.f };
float mPhase{ 1.f };
float mStartTime, mStopTime;
@ -62,7 +62,7 @@ namespace Nif
};
// Base class for controllers that use NiInterpolators to animate objects.
struct NiInterpController : public Controller
struct NiInterpController : public NiTimeController
{
// Usually one of the flags.
bool mManagerControlled{ false };
@ -94,7 +94,7 @@ namespace Nif
{
};
struct NiParticleSystemController : public Controller
struct NiParticleSystemController : public NiTimeController
{
enum BSPArrayController
{
@ -151,7 +151,7 @@ namespace Nif
void post(Reader& nif) override;
bool noAutoAdjust() const { return emitFlags & EmitFlag_NoAutoAdjust; }
bool emitAtVertex() const { return flags & BSPArrayController_AtVertex; }
bool emitAtVertex() const { return mFlags & BSPArrayController_AtVertex; }
};
using NiBSPArrayController = NiParticleSystemController;
@ -172,7 +172,7 @@ namespace Nif
void post(Reader& nif) override;
};
struct NiPathController : public Controller
struct NiPathController : public NiTimeController
{
enum Flags
{
@ -197,7 +197,7 @@ namespace Nif
void post(Reader& nif) override;
};
struct NiLookAtController : public Controller
struct NiLookAtController : public NiTimeController
{
enum Flags
{
@ -213,7 +213,7 @@ namespace Nif
void post(Reader& nif) override;
};
struct NiUVController : public Controller
struct NiUVController : public NiTimeController
{
NiUVDataPtr mData;
uint16_t mUvSet;
@ -295,7 +295,7 @@ namespace Nif
void post(Reader& nif) override;
};
struct bhkBlendController : public Controller
struct bhkBlendController : public NiTimeController
{
void read(NIFStream* nif) override;
};
@ -314,7 +314,7 @@ namespace Nif
void read(NIFStream* nif) override;
};
struct NiControllerManager : public Controller
struct NiControllerManager : public NiTimeController
{
bool mCumulative;
NiControllerSequenceList mSequences;

@ -9,7 +9,7 @@ namespace Nif
struct NiParticleModifier : public Record
{
NiParticleModifierPtr mNext;
ControllerPtr mController;
NiTimeControllerPtr mController;
void read(NIFStream* nif) override;
void post(Reader& nif) override;

@ -116,7 +116,7 @@ namespace Nif
struct NiUVData;
struct NiPosData;
struct NiVisData;
struct Controller;
struct NiTimeController;
struct NiObjectNET;
struct NiSkinData;
struct NiFloatData;
@ -157,7 +157,7 @@ namespace Nif
using NiUVDataPtr = RecordPtrT<NiUVData>;
using NiPosDataPtr = RecordPtrT<NiPosData>;
using NiVisDataPtr = RecordPtrT<NiVisData>;
using ControllerPtr = RecordPtrT<Controller>;
using NiTimeControllerPtr = RecordPtrT<NiTimeController>;
using NiObjectNETPtr = RecordPtrT<NiObjectNET>;
using NiSkinDataPtr = RecordPtrT<NiSkinData>;
using NiMorphDataPtr = RecordPtrT<NiMorphData>;

@ -255,7 +255,7 @@ namespace NifBullet
if (node.recType == Nif::RC_NiCollisionSwitch && !node.collisionActive())
return;
for (Nif::ControllerPtr ctrl = node.mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = node.mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (args.mAnimated)
break;

@ -15,11 +15,11 @@
namespace NifOsg
{
ControllerFunction::ControllerFunction(const Nif::Controller* ctrl)
: mFrequency(ctrl->frequency)
, mPhase(ctrl->phase)
, mStartTime(ctrl->timeStart)
, mStopTime(ctrl->timeStop)
ControllerFunction::ControllerFunction(const Nif::NiTimeController* ctrl)
: mFrequency(ctrl->mFrequency)
, mPhase(ctrl->mPhase)
, mStartTime(ctrl->mTimeStart)
, mStopTime(ctrl->mTimeStop)
, mExtrapolationMode(ctrl->extrapolationMode())
{
}
@ -31,7 +31,7 @@ namespace NifOsg
return time;
switch (mExtrapolationMode)
{
case Nif::Controller::ExtrapolationMode::Cycle:
case Nif::NiTimeController::ExtrapolationMode::Cycle:
{
float delta = mStopTime - mStartTime;
if (delta <= 0)
@ -40,7 +40,7 @@ namespace NifOsg
float remainder = (cycles - std::floor(cycles)) * delta;
return mStartTime + remainder;
}
case Nif::Controller::ExtrapolationMode::Reverse:
case Nif::NiTimeController::ExtrapolationMode::Reverse:
{
float delta = mStopTime - mStartTime;
if (delta <= 0)
@ -55,7 +55,7 @@ namespace NifOsg
return mStopTime - remainder;
}
case Nif::Controller::ExtrapolationMode::Constant:
case Nif::NiTimeController::ExtrapolationMode::Constant:
default:
return std::clamp(time, mStartTime, mStopTime);
}

@ -191,10 +191,10 @@ namespace NifOsg
float mPhase;
float mStartTime;
float mStopTime;
Nif::Controller::ExtrapolationMode mExtrapolationMode;
Nif::NiTimeController::ExtrapolationMode mExtrapolationMode;
public:
ControllerFunction(const Nif::Controller* ctrl);
ControllerFunction(const Nif::NiTimeController* ctrl);
float calculate(float value) const override;

@ -293,8 +293,8 @@ namespace NifOsg
auto textKeyExtraData = static_cast<const Nif::NiTextKeyExtraData*>(extraList[0].getPtr());
extractTextKeys(textKeyExtraData, target.mTextKeys);
Nif::ControllerPtr ctrl = seq->mController;
for (size_t i = 1; i < extraList.size() && !ctrl.empty(); i++, (ctrl = ctrl->next))
Nif::NiTimeControllerPtr ctrl = seq->mController;
for (size_t i = 1; i < extraList.size() && !ctrl.empty(); i++, (ctrl = ctrl->mNext))
{
Nif::ExtraPtr extra = extraList[i];
if (extra->recType != Nif::RC_NiStringExtraData || ctrl->recType != Nif::RC_NiKeyframeController)
@ -449,7 +449,7 @@ namespace NifOsg
animflags, hasStencilProperty);
}
static void setupController(const Nif::Controller* ctrl, SceneUtil::Controller* toSetup, int animflags)
static void setupController(const Nif::NiTimeController* ctrl, SceneUtil::Controller* toSetup, int animflags)
{
bool autoPlay = animflags & Nif::NiNode::AnimFlag_AutoPlay;
if (autoPlay)
@ -725,7 +725,7 @@ namespace NifOsg
if (nifNode->isHidden())
{
bool hasVisController = false;
for (Nif::ControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
hasVisController |= (ctrl->recType == Nif::RC_NiVisController);
if (hasVisController)
@ -858,7 +858,7 @@ namespace NifOsg
SceneUtil::CompositeStateSetUpdater* composite, const std::vector<unsigned int>& boundTextures,
int animflags)
{
for (Nif::ControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (!ctrl->isActive())
continue;
@ -884,7 +884,7 @@ namespace NifOsg
void handleNodeControllers(const Nif::NiAVObject* nifNode, osg::Node* node, int animflags, bool& isAnimated)
{
for (Nif::ControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (!ctrl->isActive())
continue;
@ -962,7 +962,7 @@ namespace NifOsg
void handleMaterialControllers(const Nif::Property* materialProperty,
SceneUtil::CompositeStateSetUpdater* composite, int animflags, const osg::Material* baseMaterial)
{
for (Nif::ControllerPtr ctrl = materialProperty->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = materialProperty->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (!ctrl->isActive())
continue;
@ -1012,7 +1012,7 @@ namespace NifOsg
void handleTextureControllers(const Nif::Property* texProperty, SceneUtil::CompositeStateSetUpdater* composite,
Resource::ImageManager* imageManager, osg::StateSet* stateset, int animflags)
{
for (Nif::ControllerPtr ctrl = texProperty->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = texProperty->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (!ctrl->isActive())
continue;
@ -1200,7 +1200,7 @@ namespace NifOsg
partctrl->horizontalAngle, partctrl->verticalDir, partctrl->verticalAngle, partctrl->lifetime,
partctrl->lifetimeRandom);
emitter->setShooter(shooter);
emitter->setFlags(partctrl->flags);
emitter->setFlags(partctrl->mFlags);
if (partctrl->recType == Nif::RC_NiBSPArrayController && partctrl->emitAtVertex())
{
@ -1252,7 +1252,7 @@ namespace NifOsg
partsys->setSortMode(osgParticle::ParticleSystem::SORT_BACK_TO_FRONT);
const Nif::NiParticleSystemController* partctrl = nullptr;
for (Nif::ControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (!ctrl->isActive())
continue;
@ -1483,7 +1483,7 @@ namespace NifOsg
if (geom->empty())
return;
osg::ref_ptr<osg::Drawable> drawable;
for (Nif::ControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->next)
for (Nif::NiTimeControllerPtr ctrl = nifNode->mController; !ctrl.empty(); ctrl = ctrl->mNext)
{
if (!ctrl->isActive())
continue;

Loading…
Cancel
Save