diff --git a/apps/openmw_test_suite/nif/node.hpp b/apps/openmw_test_suite/nif/node.hpp new file mode 100644 index 0000000000..318a7416ad --- /dev/null +++ b/apps/openmw_test_suite/nif/node.hpp @@ -0,0 +1,73 @@ +#ifndef OPENMW_TEST_SUITE_NIF_NODE_H +#define OPENMW_TEST_SUITE_NIF_NODE_H + +#include +#include + +namespace Nif::Testing +{ + inline void init(Transformation& value) + { + value = Transformation::getIdentity(); + } + + inline void init(Extra& value) + { + value.next = ExtraPtr(nullptr); + } + + inline void init(Named& value) + { + value.extra = ExtraPtr(nullptr); + value.extralist = ExtraList(); + value.controller = ControllerPtr(nullptr); + } + + inline void init(Node& value) + { + init(static_cast(value)); + value.flags = 0; + init(value.trafo); + value.hasBounds = false; + value.parents.push_back(nullptr); + value.isBone = false; + } + + inline void init(NiGeometry& value) + { + init(static_cast(value)); + value.data = NiGeometryDataPtr(nullptr); + value.skin = NiSkinInstancePtr(nullptr); + } + + inline void init(NiTriShape& value) + { + init(static_cast(value)); + value.recType = RC_NiTriShape; + } + + inline void init(NiTriStrips& value) + { + init(static_cast(value)); + value.recType = RC_NiTriStrips; + } + + inline void init(NiSkinInstance& value) + { + value.data = NiSkinDataPtr(nullptr); + value.root = NodePtr(nullptr); + } + + inline void init(Controller& value) + { + value.next = ControllerPtr(nullptr); + value.flags = 0; + value.frequency = 0; + value.phase = 0; + value.timeStart = 0; + value.timeStop = 0; + value.target = NamedPtr(nullptr); + } +} + +#endif diff --git a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp index 2d0447bcf0..066da7b607 100644 --- a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp +++ b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp @@ -1,3 +1,5 @@ +#include "../nif/node.hpp" + #include #include #include @@ -260,71 +262,9 @@ static bool operator==(const btCollisionShape& lhs, const btCollisionShape& rhs) namespace { using namespace testing; + using namespace Nif::Testing; using NifBullet::BulletNifLoader; - void init(Nif::Transformation& value) - { - value = Nif::Transformation::getIdentity(); - } - - void init(Nif::Extra& value) - { - value.next = Nif::ExtraPtr(nullptr); - } - - void init(Nif::Named& value) - { - value.extra = Nif::ExtraPtr(nullptr); - value.extralist = Nif::ExtraList(); - value.controller = Nif::ControllerPtr(nullptr); - } - - void init(Nif::Node& value) - { - init(static_cast(value)); - value.flags = 0; - init(value.trafo); - value.hasBounds = false; - value.parents.push_back(nullptr); - value.isBone = false; - } - - void init(Nif::NiGeometry& value) - { - init(static_cast(value)); - value.data = Nif::NiGeometryDataPtr(nullptr); - value.skin = Nif::NiSkinInstancePtr(nullptr); - } - - void init(Nif::NiTriShape& value) - { - init(static_cast(value)); - value.recType = Nif::RC_NiTriShape; - } - - void init(Nif::NiTriStrips& value) - { - init(static_cast(value)); - value.recType = Nif::RC_NiTriStrips; - } - - void init(Nif::NiSkinInstance& value) - { - value.data = Nif::NiSkinDataPtr(nullptr); - value.root = Nif::NodePtr(nullptr); - } - - void init(Nif::Controller& value) - { - value.next = Nif::ControllerPtr(nullptr); - value.flags = 0; - value.frequency = 0; - value.phase = 0; - value.timeStart = 0; - value.timeStop = 0; - value.target = Nif::NamedPtr(nullptr); - } - void copy(const btTransform& src, Nif::Transformation& dst) { dst.pos = osg::Vec3f(src.getOrigin().x(), src.getOrigin().y(), src.getOrigin().z());