From 6e7661ca879661bbabc6333fd376e4b1cb49f621 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 3 Dec 2023 17:44:49 +0300 Subject: [PATCH] BulletNifLoader: Handle only the first child of NiSwitchNode and NiFltAnimationNode To prevent duplicated collisions in general cases when the node states are similar or only one child is ever active. For NiLODNode this is definitely not going to work --- components/nifbullet/bulletnifloader.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 96dff80004..2c7dd1b1c4 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -250,11 +250,16 @@ namespace NifBullet const Nif::Parent currentParent{ *ninode, parent }; for (const auto& child : ninode->mChildren) { - if (child.empty()) - continue; - - assert(std::find(child->mParents.begin(), child->mParents.end(), ninode) != child->mParents.end()); - handleNode(child.get(), ¤tParent, args); + if (!child.empty()) + { + assert(std::find(child->mParents.begin(), child->mParents.end(), ninode) != child->mParents.end()); + handleNode(child.get(), ¤tParent, args); + } + // For NiSwitchNodes and NiFltAnimationNodes, only use the first child + // TODO: must synchronize with the rendering scene graph somehow + // Doing this for NiLODNodes is unsafe (the first level might not be the closest) + if (node.recType == Nif::RC_NiSwitchNode || node.recType == Nif::RC_NiFltAnimationNode) + break; } } }