diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 9f55241ff5..7bf01fdb32 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -182,8 +182,8 @@ namespace NifBullet if (hasCollisionNode && !hasCollisionShape) mShape->mVisualCollisionType = Resource::VisualCollisionType::Camera; bool generateCollisionShape = !hasCollisionShape; - handleNode(filename, *node, nullptr, 0, generateCollisionShape, isAnimated, generateCollisionShape, false, - mShape->mVisualCollisionType); + handleNode(filename, nif.getVersion(), *node, nullptr, 0, generateCollisionShape, isAnimated, + generateCollisionShape, false, mShape->mVisualCollisionType); } if (mCompoundShape) @@ -268,8 +268,8 @@ namespace NifBullet return true; } - void BulletNifLoader::handleNode(const std::string& fileName, const Nif::Node& node, const Nif::Parent* parent, - int flags, bool isCollisionNode, bool isAnimated, bool autogenerated, bool avoid, + void BulletNifLoader::handleNode(const std::string& fileName, unsigned int nifVersion, const Nif::Node& node, + const Nif::Parent* parent, int flags, bool isCollisionNode, bool isAnimated, bool autogenerated, bool avoid, Resource::VisualCollisionType& visualCollisionType) { // TODO: allow on-the fly collision switching via toggling this flag @@ -328,6 +328,9 @@ namespace NifBullet } } + if (nifVersion > Nif::NIFFile::NIFVersion::VER_MW && Misc::StringUtils::ciEqual(node.name, "EditorMarker")) + return; + if (isCollisionNode) { // NOTE: a trishape with hasBounds=true, but no BBoxCollision flag should NOT go through handleNiTriShape! @@ -352,8 +355,8 @@ namespace NifBullet continue; assert(std::find(child->parents.begin(), child->parents.end(), ninode) != child->parents.end()); - handleNode(fileName, child.get(), ¤tParent, flags, isCollisionNode, isAnimated, autogenerated, - avoid, visualCollisionType); + handleNode(fileName, nifVersion, child.get(), ¤tParent, flags, isCollisionNode, isAnimated, + autogenerated, avoid, visualCollisionType); } } } diff --git a/components/nifbullet/bulletnifloader.hpp b/components/nifbullet/bulletnifloader.hpp index 6128857cb8..5866412de4 100644 --- a/components/nifbullet/bulletnifloader.hpp +++ b/components/nifbullet/bulletnifloader.hpp @@ -52,8 +52,8 @@ namespace NifBullet private: bool findBoundingBox(const Nif::Node& node, const std::string& filename); - void handleNode(const std::string& fileName, const Nif::Node& node, const Nif::Parent* parent, int flags, - bool isCollisionNode, bool isAnimated, bool autogenerated, bool avoid, + void handleNode(const std::string& fileName, unsigned int nifVersion, const Nif::Node& node, + const Nif::Parent* parent, int flags, bool isCollisionNode, bool isAnimated, bool autogenerated, bool avoid, Resource::VisualCollisionType& visualCollisionType); bool hasRootCollisionNode(const Nif::Node& rootNode) const; diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 2b245dcee0..c158055d40 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -340,8 +341,8 @@ namespace NifOsg created->setDataVariance(osg::Object::STATIC); for (const Nif::Node* root : roots) { - auto node = handleNode(root, nullptr, nullptr, imageManager, std::vector(), 0, false, - false, false, &textkeys->mTextKeys); + auto node = handleNode(nif.getVersion(), root, nullptr, nullptr, imageManager, + std::vector(), 0, false, false, false, &textkeys->mTextKeys); created->addChild(node); } if (mHasNightDayLabel) @@ -597,13 +598,19 @@ namespace NifOsg return node; } - osg::ref_ptr handleNode(const Nif::Node* nifNode, const Nif::Parent* parent, osg::Group* parentNode, - Resource::ImageManager* imageManager, std::vector boundTextures, int animflags, - bool skipMeshes, bool hasMarkers, bool hasAnimatedParents, SceneUtil::TextKeyMap* textKeys, + osg::ref_ptr handleNode(unsigned int nifVersion, const Nif::Node* nifNode, const Nif::Parent* parent, + osg::Group* parentNode, Resource::ImageManager* imageManager, std::vector boundTextures, + int animflags, bool skipMeshes, bool hasMarkers, bool hasAnimatedParents, SceneUtil::TextKeyMap* textKeys, osg::Node* rootNode = nullptr) { - if (rootNode != nullptr && Misc::StringUtils::ciEqual(nifNode->name, "Bounding Box")) - return nullptr; + if (rootNode) + { + if (Misc::StringUtils::ciEqual(nifNode->name, "Bounding Box")) + return nullptr; + if (nifVersion > Nif::NIFFile::NIFVersion::VER_MW && !Loader::getShowMarkers() + && Misc::StringUtils::ciEqual(nifNode->name, "EditorMarker")) + return nullptr; + } osg::ref_ptr node = createNode(nifNode); @@ -802,8 +809,8 @@ namespace NifOsg const Nif::Parent currentParent{ *ninode, parent }; for (const auto& child : children) if (!child.empty()) - handleNode(child.getPtr(), ¤tParent, currentNode, imageManager, boundTextures, animflags, - skipMeshes, hasMarkers, hasAnimatedParents, textKeys, rootNode); + handleNode(nifVersion, child.getPtr(), ¤tParent, currentNode, imageManager, boundTextures, + animflags, skipMeshes, hasMarkers, hasAnimatedParents, textKeys, rootNode); // Propagate effects to the the direct subgraph instead of the node itself // This simulates their "affected node list" which Morrowind appears to replace with the subgraph (?)