Skip to content

Commit

Permalink
Merge branch 'bonewalkers-deboned' into 'master'
Browse files Browse the repository at this point in the history
Automatically generate collision boxes if any component is negative (Close #8048)

Closes #8048

See merge request OpenMW/openmw!4227
  • Loading branch information
psi29a committed Jul 11, 2024
2 parents 664a844 + 4cc956f commit 5553b00
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions apps/components_tests/nifloader/testbulletnifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion components/nifbullet/bulletnifloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5553b00

Please sign in to comment.