From b3cee84787b035cf5e2145bb406e175ce1975270 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Mon, 1 Jul 2024 12:59:10 -0500 Subject: [PATCH 1/3] c h a n g e l o g --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a7e49d37b..0558186b3d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -184,6 +184,7 @@ Bug #8005: F3 stats bars are sorted not according to their place in the timeline Bug #8018: Potion effects should never explode and always apply on self Bug #8021: Player's scale doesn't reset when starting a new game + Bug #8048: Actors can generate negative collision extents and have no collision Bug #8064: Lua move360 script doesn't respect the enableZoom/disableZoom Camera interface setting Feature #1415: Infinite fall failsafe Feature #2566: Handle NAM9 records for manual cell references From 5bca2919c25eb7193b2d68a8d47f2202f0a22c55 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 4 Jul 2024 21:16:52 -0500 Subject: [PATCH 2/3] CLEANUP: Don't assign invalid extents when loading bounding boxes --- components/nifbullet/bulletnifloader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index a57e8b3c06b..bcda7efe70e 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -85,7 +85,8 @@ namespace NifBullet { if (Misc::StringUtils::ciEqual(node.mName, "Bounding Box")) { - if (node.mBounds.mType == Nif::BoundingVolume::Type::BOX_BV) + if (node.mBounds.mType == Nif::BoundingVolume::Type::BOX_BV + && std::ranges::all_of(node.mBounds.mBox.mExtents._v, [](float extent) { return extent > 0.f; })) { mShape->mCollisionBox.mExtents = node.mBounds.mBox.mExtents; mShape->mCollisionBox.mCenter = node.mBounds.mBox.mCenter; From 4cc956fdd7011bba7867abcf6282e813ba028284 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 4 Jul 2024 21:31:25 -0500 Subject: [PATCH 3/3] TEST: Add a test to ensure invalid box extents are not assigned --- .../nifloader/testbulletnifloader.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/components_tests/nifloader/testbulletnifloader.cpp b/apps/components_tests/nifloader/testbulletnifloader.cpp index d44561a68bc..f7ee559578f 100644 --- a/apps/components_tests/nifloader/testbulletnifloader.cpp +++ b/apps/components_tests/nifloader/testbulletnifloader.cpp @@ -1364,4 +1364,28 @@ namespace EXPECT_EQ(*result, expected); } + + TEST_F(TestBulletNifLoader, dont_assign_invalid_bounding_box_extents) + { + copy(mTransform, mNiTriShape.mTransform); + mNiTriShape.mTransform.mScale = 10; + mNiTriShape.mParents.push_back(&mNiNode); + + mNiTriShape2.mName = "Bounding Box"; + mNiTriShape2.mBounds.mType = Nif::BoundingVolume::Type::BOX_BV; + mNiTriShape2.mBounds.mBox.mExtents = osg::Vec3f(-1, -2, -3); + mNiTriShape2.mParents.push_back(&mNiNode); + + mNiNode.mChildren = Nif::NiAVObjectList{ Nif::NiAVObjectPtr(&mNiTriShape), Nif::NiAVObjectPtr(&mNiTriShape2) }; + + Nif::NIFFile file("test.nif"); + file.mRoots.push_back(&mNiNode); + + const auto result = mLoader.load(file); + + const bool extentsUnassigned + = std::ranges::all_of(result->mCollisionBox.mExtents._v, [](float extent) { return extent == 0.f; }); + + EXPECT_EQ(extentsUnassigned, true); + } }