Use normalized path for KeyframeManager::get

master
elsid 1 month ago
parent 17203c5071
commit a550a8af36
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -295,6 +295,9 @@ namespace
using namespace Nif::Testing; using namespace Nif::Testing;
using NifBullet::BulletNifLoader; using NifBullet::BulletNifLoader;
constexpr VFS::Path::NormalizedView testNif("test.nif");
constexpr VFS::Path::NormalizedView xtestNif("xtest.nif");
void copy(const btTransform& src, Nif::NiTransform& dst) void copy(const btTransform& src, Nif::NiTransform& dst)
{ {
dst.mTranslation = osg::Vec3f(src.getOrigin().x(), src.getOrigin().y(), src.getOrigin().z()); dst.mTranslation = osg::Vec3f(src.getOrigin().x(), src.getOrigin().y(), src.getOrigin().z());
@ -366,7 +369,7 @@ namespace
TEST_F(TestBulletNifLoader, for_zero_num_roots_should_return_default) TEST_F(TestBulletNifLoader, for_zero_num_roots_should_return_default)
{ {
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mHash = mHash; file.mHash = mHash;
const auto result = mLoader.load(file); const auto result = mLoader.load(file);
@ -380,7 +383,7 @@ namespace
TEST_F(TestBulletNifLoader, should_ignore_nullptr_root) TEST_F(TestBulletNifLoader, should_ignore_nullptr_root)
{ {
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(nullptr); file.mRoots.push_back(nullptr);
file.mHash = mHash; file.mHash = mHash;
@ -393,7 +396,7 @@ namespace
TEST_F(TestBulletNifLoader, for_default_root_nif_node_should_return_default) TEST_F(TestBulletNifLoader, for_default_root_nif_node_should_return_default)
{ {
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNode); file.mRoots.push_back(&mNode);
file.mHash = mHash; file.mHash = mHash;
@ -408,7 +411,7 @@ namespace
{ {
mNode.recType = Nif::RC_RootCollisionNode; mNode.recType = Nif::RC_RootCollisionNode;
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNode); file.mRoots.push_back(&mNode);
file.mHash = mHash; file.mHash = mHash;
@ -421,7 +424,7 @@ namespace
TEST_F(TestBulletNifLoader, for_default_root_nif_node_and_filename_starting_with_x_should_return_default) TEST_F(TestBulletNifLoader, for_default_root_nif_node_and_filename_starting_with_x_should_return_default)
{ {
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNode); file.mRoots.push_back(&mNode);
file.mHash = mHash; file.mHash = mHash;
@ -439,7 +442,7 @@ namespace
mNode.mBounds.mBox.mExtents = osg::Vec3f(1, 2, 3); mNode.mBounds.mBox.mExtents = osg::Vec3f(1, 2, 3);
mNode.mBounds.mBox.mCenter = osg::Vec3f(-1, -2, -3); mNode.mBounds.mBox.mCenter = osg::Vec3f(-1, -2, -3);
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNode); file.mRoots.push_back(&mNode);
file.mHash = mHash; file.mHash = mHash;
@ -461,7 +464,7 @@ namespace
mNode.mParents.push_back(&mNiNode); mNode.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -487,7 +490,7 @@ namespace
mNiNode.mBounds.mBox.mCenter = osg::Vec3f(-4, -5, -6); mNiNode.mBounds.mBox.mCenter = osg::Vec3f(-4, -5, -6);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -519,7 +522,7 @@ namespace
mNiNode.mBounds.mBox.mCenter = osg::Vec3f(-7, -8, -9); mNiNode.mBounds.mBox.mCenter = osg::Vec3f(-7, -8, -9);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode), Nif::NiAVObjectPtr(&mNode2) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode), Nif::NiAVObjectPtr(&mNode2) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -551,7 +554,7 @@ namespace
mNiNode.mBounds.mBox.mCenter = osg::Vec3f(-7, -8, -9); mNiNode.mBounds.mBox.mCenter = osg::Vec3f(-7, -8, -9);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode), Nif::NiAVObjectPtr(&mNode2) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNode), Nif::NiAVObjectPtr(&mNode2) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -570,7 +573,7 @@ namespace
mNode.mBounds.mBox.mExtents = osg::Vec3f(1, 2, 3); mNode.mBounds.mBox.mExtents = osg::Vec3f(1, 2, 3);
mNode.mBounds.mBox.mCenter = osg::Vec3f(-1, -2, -3); mNode.mBounds.mBox.mCenter = osg::Vec3f(-1, -2, -3);
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNode); file.mRoots.push_back(&mNode);
file.mHash = mHash; file.mHash = mHash;
@ -583,7 +586,7 @@ namespace
TEST_F(TestBulletNifLoader, for_tri_shape_root_node_should_return_static_shape) TEST_F(TestBulletNifLoader, for_tri_shape_root_node_should_return_static_shape)
{ {
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiTriShape); file.mRoots.push_back(&mNiTriShape);
file.mHash = mHash; file.mHash = mHash;
@ -609,7 +612,7 @@ namespace
mNiTriShape.mBounds.mBox.mExtents = osg::Vec3f(1, 2, 3); mNiTriShape.mBounds.mBox.mExtents = osg::Vec3f(1, 2, 3);
mNiTriShape.mBounds.mBox.mCenter = osg::Vec3f(-1, -2, -3); mNiTriShape.mBounds.mBox.mCenter = osg::Vec3f(-1, -2, -3);
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiTriShape); file.mRoots.push_back(&mNiTriShape);
file.mHash = mHash; file.mHash = mHash;
@ -634,7 +637,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -661,7 +664,7 @@ namespace
mNiNode2.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode2.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
mNiTriShape.mParents.push_back(&mNiNode2); mNiTriShape.mParents.push_back(&mNiNode2);
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -687,7 +690,7 @@ namespace
mNiTriShape2.mParents.push_back(&mNiNode); mNiTriShape2.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -719,7 +722,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -743,7 +746,7 @@ namespace
copy(mTransform, mNiTriShape.mTransform); copy(mTransform, mNiTriShape.mTransform);
mNiTriShape.mTransform.mScale = 3; mNiTriShape.mTransform.mScale = 3;
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiTriShape); file.mRoots.push_back(&mNiTriShape);
file.mHash = mHash; file.mHash = mHash;
@ -769,7 +772,7 @@ namespace
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
mNiNode.mTransform.mScale = 4; mNiNode.mTransform.mScale = 4;
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -801,7 +804,7 @@ namespace
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) };
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -836,7 +839,7 @@ namespace
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
mNiNode.mTransform.mScale = 4; mNiNode.mTransform.mScale = 4;
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -872,7 +875,7 @@ namespace
}; };
mNiNode.mTransform.mScale = 4; mNiNode.mTransform.mScale = 4;
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -903,7 +906,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mRoots.push_back(&mNiTriShape2); file.mRoots.push_back(&mNiTriShape2);
file.mHash = mHash; file.mHash = mHash;
@ -938,7 +941,7 @@ namespace
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
mNiNode.recType = Nif::RC_AvoidNode; mNiNode.recType = Nif::RC_AvoidNode;
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -963,7 +966,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -982,7 +985,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1002,7 +1005,7 @@ namespace
mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData); mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1033,7 +1036,7 @@ namespace
mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData); mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1062,7 +1065,7 @@ namespace
mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData); mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1092,7 +1095,7 @@ namespace
mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData); mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1120,7 +1123,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1155,7 +1158,7 @@ namespace
mNiNode.mChildren mNiNode.mChildren
= Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&niTriShape), Nif::NiAVObjectPtr(&emptyCollisionNode) }; = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&niTriShape), Nif::NiAVObjectPtr(&emptyCollisionNode) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1184,7 +1187,7 @@ namespace
mNiNode.mExtraList.push_back(Nif::ExtraPtr(&mNiIntegerExtraData)); mNiNode.mExtraList.push_back(Nif::ExtraPtr(&mNiIntegerExtraData));
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
file.mVersion = Nif::NIFStream::generateVersion(10, 0, 1, 0); file.mVersion = Nif::NIFStream::generateVersion(10, 0, 1, 0);
@ -1205,7 +1208,7 @@ namespace
mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData); mNiNode.mExtra = Nif::ExtraPtr(&mNiStringExtraData);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1218,7 +1221,7 @@ namespace
TEST_F(TestBulletNifLoader, for_tri_strips_root_node_should_return_static_shape) TEST_F(TestBulletNifLoader, for_tri_strips_root_node_should_return_static_shape)
{ {
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiTriStrips); file.mRoots.push_back(&mNiTriStrips);
file.mHash = mHash; file.mHash = mHash;
@ -1242,7 +1245,7 @@ namespace
{ {
mNiTriStripsData.mStrips.clear(); mNiTriStripsData.mStrips.clear();
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiTriStrips); file.mRoots.push_back(&mNiTriStrips);
file.mHash = mHash; file.mHash = mHash;
@ -1257,7 +1260,7 @@ namespace
{ {
mNiTriStripsData.mStrips.front() = { 0, 1 }; mNiTriStripsData.mStrips.front() = { 0, 1 };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiTriStrips); file.mRoots.push_back(&mNiTriStrips);
file.mHash = mHash; file.mHash = mHash;
@ -1275,7 +1278,7 @@ namespace
mNiNode.recType = Nif::RC_AvoidNode; mNiNode.recType = Nif::RC_AvoidNode;
mNiTriStripsData.mStrips.front() = { 0, 1 }; mNiTriStripsData.mStrips.front() = { 0, 1 };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiTriStrips); file.mRoots.push_back(&mNiTriStrips);
file.mHash = mHash; file.mHash = mHash;
@ -1292,7 +1295,7 @@ namespace
mNiTriStrips.mParents.push_back(&mNiNode); mNiTriStrips.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriStrips) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriStrips) };
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mHash = mHash; file.mHash = mHash;
@ -1309,7 +1312,7 @@ namespace
mNiTriShape.mParents.push_back(&mNiNode); mNiTriShape.mParents.push_back(&mNiNode);
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mRoots.push_back(&mNiTriStrips); file.mRoots.push_back(&mNiTriStrips);
file.mHash = mHash; file.mHash = mHash;
@ -1340,7 +1343,7 @@ namespace
mNiNode2.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) }; mNiNode2.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape) };
mNiNode2.mTransform.mScale = 3; mNiNode2.mTransform.mScale = 3;
Nif::NIFFile file("xtest.nif"); Nif::NIFFile file(xtestNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
file.mRoots.push_back(&mNiNode2); file.mRoots.push_back(&mNiNode2);
file.mHash = mHash; file.mHash = mHash;
@ -1378,7 +1381,7 @@ namespace
mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) }; mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) };
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&mNiNode); file.mRoots.push_back(&mNiNode);
const auto result = mLoader.load(file); const auto result = mLoader.load(file);

@ -26,6 +26,8 @@ namespace
using namespace NifOsg; using namespace NifOsg;
using namespace Nif::Testing; using namespace Nif::Testing;
constexpr VFS::Path::NormalizedView testNif("test.nif");
struct BaseNifOsgLoaderTest struct BaseNifOsgLoaderTest
{ {
VFS::Manager mVfs; VFS::Manager mVfs;
@ -70,7 +72,7 @@ namespace
{ {
Nif::NiAVObject node; Nif::NiAVObject node;
init(node); init(node);
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&node); file.mRoots.push_back(&node);
auto result = Loader::load(file, &mImageManager, &mMaterialManager); auto result = Loader::load(file, &mImageManager, &mMaterialManager);
EXPECT_EQ(serialize(*result), R"( EXPECT_EQ(serialize(*result), R"(
@ -259,7 +261,7 @@ osg::Group {
property.mController = nullptr; property.mController = nullptr;
property.mType = GetParam().mShaderType; property.mType = GetParam().mShaderType;
node.mProperties.push_back(Nif::RecordPtrT<Nif::NiProperty>(&property)); node.mProperties.push_back(Nif::RecordPtrT<Nif::NiProperty>(&property));
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&node); file.mRoots.push_back(&node);
auto result = Loader::load(file, &mImageManager, &mMaterialManager); auto result = Loader::load(file, &mImageManager, &mMaterialManager);
EXPECT_EQ(serialize(*result), formatOsgNodeForBSShaderProperty(GetParam().mExpectedShaderPrefix)); EXPECT_EQ(serialize(*result), formatOsgNodeForBSShaderProperty(GetParam().mExpectedShaderPrefix));
@ -289,7 +291,7 @@ osg::Group {
property.mShaderFlags1 |= Nif::BSShaderFlags1::BSSFlag1_DepthTest; property.mShaderFlags1 |= Nif::BSShaderFlags1::BSSFlag1_DepthTest;
property.mShaderFlags2 |= Nif::BSShaderFlags2::BSSFlag2_DepthWrite; property.mShaderFlags2 |= Nif::BSShaderFlags2::BSSFlag2_DepthWrite;
node.mProperties.push_back(Nif::RecordPtrT<Nif::NiProperty>(&property)); node.mProperties.push_back(Nif::RecordPtrT<Nif::NiProperty>(&property));
Nif::NIFFile file("test.nif"); Nif::NIFFile file(testNif);
file.mRoots.push_back(&node); file.mRoots.push_back(&node);
auto result = Loader::load(file, &mImageManager, &mMaterialManager); auto result = Loader::load(file, &mImageManager, &mMaterialManager);
EXPECT_EQ(serialize(*result), formatOsgNodeForBSLightingShaderProperty(GetParam().mExpectedShaderPrefix)); EXPECT_EQ(serialize(*result), formatOsgNodeForBSLightingShaderProperty(GetParam().mExpectedShaderPrefix));

@ -141,7 +141,7 @@ bool readFile(
{ {
case FileClass::NIF: case FileClass::NIF:
{ {
Nif::NIFFile file(Files::pathToUnicodeString(fullPath)); Nif::NIFFile file(VFS::Path::Normalized(Files::pathToUnicodeString(fullPath)));
Nif::Reader reader(file, nullptr); Nif::Reader reader(file, nullptr);
if (vfs != nullptr) if (vfs != nullptr)
reader.parse(vfs->get(pathStr)); reader.parse(vfs->get(pathStr));

@ -704,7 +704,7 @@ namespace MWRender
return nullptr; return nullptr;
auto animsrc = std::make_shared<AnimSource>(); auto animsrc = std::make_shared<AnimSource>();
animsrc->mKeyframes = mResourceSystem->getKeyframeManager()->get(kfname); animsrc->mKeyframes = mResourceSystem->getKeyframeManager()->get(VFS::Path::toNormalized(kfname));
if (!animsrc->mKeyframes || animsrc->mKeyframes->mTextKeys.empty() if (!animsrc->mKeyframes || animsrc->mKeyframes->mTextKeys.empty()
|| animsrc->mKeyframes->mKeyframeControllers.empty()) || animsrc->mKeyframes->mKeyframeControllers.empty())

@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include <components/files/istreamptr.hpp> #include <components/files/istreamptr.hpp>
#include <components/vfs/pathutil.hpp>
#include "record.hpp" #include "record.hpp"
@ -45,7 +46,7 @@ namespace Nif
std::uint32_t mBethVersion = 0; std::uint32_t mBethVersion = 0;
/// File name, used for error messages and opening the file /// File name, used for error messages and opening the file
std::string mPath; VFS::Path::Normalized mPath;
std::string mHash; std::string mHash;
/// Record list /// Record list
@ -56,7 +57,7 @@ namespace Nif
bool mUseSkinning = false; bool mUseSkinning = false;
explicit NIFFile(std::string_view path) explicit NIFFile(VFS::Path::NormalizedView path)
: mPath(path) : mPath(path)
{ {
} }

@ -206,37 +206,34 @@ namespace Resource
{ {
} }
osg::ref_ptr<const SceneUtil::KeyframeHolder> KeyframeManager::get(const std::string& name) osg::ref_ptr<const SceneUtil::KeyframeHolder> KeyframeManager::get(VFS::Path::NormalizedView name)
{ {
const VFS::Path::Normalized normalized(name); osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(name);
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(normalized); if (obj != nullptr)
if (obj)
return osg::ref_ptr<const SceneUtil::KeyframeHolder>(static_cast<SceneUtil::KeyframeHolder*>(obj.get())); return osg::ref_ptr<const SceneUtil::KeyframeHolder>(static_cast<SceneUtil::KeyframeHolder*>(obj.get()));
osg::ref_ptr<SceneUtil::KeyframeHolder> loaded(new SceneUtil::KeyframeHolder);
if (Misc::getFileExtension(name.value()) == "kf")
{
auto file = std::make_shared<Nif::NIFFile>(name);
Nif::Reader reader(*file, mEncoder);
reader.parse(mVFS->get(name));
NifOsg::Loader::loadKf(*file, *loaded.get());
}
else else
{ {
osg::ref_ptr<SceneUtil::KeyframeHolder> loaded(new SceneUtil::KeyframeHolder); osg::ref_ptr<osg::Node> scene = const_cast<osg::Node*>(mSceneManager->getTemplate(name).get());
if (Misc::getFileExtension(normalized) == "kf") osg::ref_ptr<osgAnimation::BasicAnimationManager> bam
= dynamic_cast<osgAnimation::BasicAnimationManager*>(scene->getUpdateCallback());
if (bam)
{ {
auto file = std::make_shared<Nif::NIFFile>(normalized); Resource::RetrieveAnimationsVisitor rav(*loaded.get(), std::move(bam), name, *mVFS);
Nif::Reader reader(*file, mEncoder); scene->accept(rav);
reader.parse(mVFS->get(normalized));
NifOsg::Loader::loadKf(*file, *loaded.get());
}
else
{
osg::ref_ptr<osg::Node> scene = const_cast<osg::Node*>(mSceneManager->getTemplate(normalized).get());
osg::ref_ptr<osgAnimation::BasicAnimationManager> bam
= dynamic_cast<osgAnimation::BasicAnimationManager*>(scene->getUpdateCallback());
if (bam)
{
Resource::RetrieveAnimationsVisitor rav(*loaded.get(), std::move(bam), normalized, *mVFS);
scene->accept(rav);
}
} }
mCache->addEntryToObjectCache(normalized, loaded);
return loaded;
} }
mCache->addEntryToObjectCache(name.value(), loaded);
return loaded;
} }
void KeyframeManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const void KeyframeManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const

@ -56,7 +56,7 @@ namespace Resource
/// Retrieve a read-only keyframe resource by name (case-insensitive). /// Retrieve a read-only keyframe resource by name (case-insensitive).
/// @note Throws an exception if the resource is not found. /// @note Throws an exception if the resource is not found.
osg::ref_ptr<const SceneUtil::KeyframeHolder> get(const std::string& name); osg::ref_ptr<const SceneUtil::KeyframeHolder> get(VFS::Path::NormalizedView name);
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override; void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;

@ -43,17 +43,15 @@ namespace Resource
Nif::NIFFilePtr NifFileManager::get(VFS::Path::NormalizedView name) Nif::NIFFilePtr NifFileManager::get(VFS::Path::NormalizedView name)
{ {
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(name); osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(name);
if (obj) if (obj != nullptr)
return static_cast<NifFileHolder*>(obj.get())->mNifFile; return static_cast<NifFileHolder*>(obj.get())->mNifFile;
else
{ auto file = std::make_shared<Nif::NIFFile>(name);
auto file = std::make_shared<Nif::NIFFile>(name.value()); Nif::Reader reader(*file, mEncoder);
Nif::Reader reader(*file, mEncoder); reader.parse(mVFS->get(name));
reader.parse(mVFS->get(name)); obj = new NifFileHolder(file);
obj = new NifFileHolder(file); mCache->addEntryToObjectCache(name.value(), obj);
mCache->addEntryToObjectCache(name.value(), obj); return file;
return file;
}
} }
void NifFileManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const void NifFileManager::reportStats(unsigned int frameNumber, osg::Stats* stats) const

Loading…
Cancel
Save