Skip to content

Commit

Permalink
Merge branch 'nif' into 'master'
Browse files Browse the repository at this point in the history
Modernize NIF loader, part 4

See merge request OpenMW/openmw!3427
  • Loading branch information
psi29a committed Sep 15, 2023
2 parents 3e038d4 + 2f8229a commit 64e4a33
Show file tree
Hide file tree
Showing 20 changed files with 631 additions and 680 deletions.
18 changes: 9 additions & 9 deletions apps/openmw_test_suite/nif/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -55,15 +55,15 @@ 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.target = NiObjectNETPtr(nullptr);
value.mNext = NiTimeControllerPtr(nullptr);
value.mFlags = 0;
value.mFrequency = 0;
value.mPhase = 0;
value.mTimeStart = 0;
value.mTimeStop = 0;
value.mTarget = NiObjectNETPtr(nullptr);
}
}

Expand Down
10 changes: 5 additions & 5 deletions apps/openmw_test_suite/nifloader/testbulletnifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down Expand Up @@ -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;

Expand All @@ -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),
Expand Down
18 changes: 9 additions & 9 deletions components/nif/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Nif
void post(Reader& nif) override { mNext.post(nif); }
};

struct Controller : public Record
struct NiTimeController : public Record
{
enum Flags
{
Expand All @@ -36,17 +36,17 @@ namespace Nif
Mask = 6
};

ControllerPtr next;
int flags;
float frequency, phase;
float timeStart, timeStop;
NiObjectNETPtr target;
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
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 64e4a33

Please sign in to comment.