mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Remove "Tri Bip*" nodes in creature meshes (meant for debugging)? (Fixes #2148)
This commit is contained in:
parent
c57e72fe03
commit
58cd2b1a84
@ -208,6 +208,38 @@ namespace
|
|||||||
std::vector<osg::Node*> mToRemove;
|
std::vector<osg::Node*> mToRemove;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RemoveTriBipVisitor : public osg::NodeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RemoveTriBipVisitor()
|
||||||
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void apply(osg::Geode &node)
|
||||||
|
{
|
||||||
|
const std::string toFind = "tri bip";
|
||||||
|
if (Misc::StringUtils::ciCompareLen(node.getName(), toFind, toFind.size()) == 0)
|
||||||
|
{
|
||||||
|
// Not safe to remove in apply(), since the visitor is still iterating the child list
|
||||||
|
mToRemove.push_back(&node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove()
|
||||||
|
{
|
||||||
|
for (std::vector<osg::Node*>::iterator it = mToRemove.begin(); it != mToRemove.end(); ++it)
|
||||||
|
{
|
||||||
|
osg::Node* node = *it;
|
||||||
|
if (node->getNumParents())
|
||||||
|
node->getParent(0)->removeChild(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<osg::Node*> mToRemove;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
@ -898,7 +930,7 @@ namespace MWRender
|
|||||||
return movement;
|
return movement;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly)
|
void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
|
||||||
{
|
{
|
||||||
if (mObjectRoot)
|
if (mObjectRoot)
|
||||||
{
|
{
|
||||||
@ -933,6 +965,13 @@ namespace MWRender
|
|||||||
removeDrawableVisitor.remove();
|
removeDrawableVisitor.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCreature)
|
||||||
|
{
|
||||||
|
RemoveTriBipVisitor removeTriBipVisitor;
|
||||||
|
mObjectRoot->accept(removeTriBipVisitor);
|
||||||
|
removeTriBipVisitor.remove();
|
||||||
|
}
|
||||||
|
|
||||||
NodeMapVisitor visitor;
|
NodeMapVisitor visitor;
|
||||||
mObjectRoot->accept(visitor);
|
mObjectRoot->accept(visitor);
|
||||||
mNodeMap = visitor.getNodeMap();
|
mNodeMap = visitor.getNodeMap();
|
||||||
@ -1308,7 +1347,7 @@ namespace MWRender
|
|||||||
{
|
{
|
||||||
if (!model.empty())
|
if (!model.empty())
|
||||||
{
|
{
|
||||||
setObjectRoot(model, false, false);
|
setObjectRoot(model, false, false, false);
|
||||||
if (animated)
|
if (animated)
|
||||||
addAnimSource(model);
|
addAnimSource(model);
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ protected:
|
|||||||
* @param baseonly If true, then any meshes or particle systems in the model are ignored
|
* @param baseonly If true, then any meshes or particle systems in the model are ignored
|
||||||
* (useful for NPCs, where only the skeleton is needed for the root, and the actual NPC parts are then assembled from separate files).
|
* (useful for NPCs, where only the skeleton is needed for the root, and the actual NPC parts are then assembled from separate files).
|
||||||
*/
|
*/
|
||||||
void setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly);
|
void setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly, bool isCreature);
|
||||||
|
|
||||||
/* Adds the keyframe controllers in the specified model as a new animation source. Note that
|
/* Adds the keyframe controllers in the specified model as a new animation source. Note that
|
||||||
* the filename portion of the provided model name will be prepended with 'x', and the .nif
|
* the filename portion of the provided model name will be prepended with 'x', and the .nif
|
||||||
|
@ -24,7 +24,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr,
|
|||||||
|
|
||||||
if(!model.empty())
|
if(!model.empty())
|
||||||
{
|
{
|
||||||
setObjectRoot(model, false, false);
|
setObjectRoot(model, false, false, true);
|
||||||
|
|
||||||
if((ref->mBase->mFlags&ESM::Creature::Bipedal))
|
if((ref->mBase->mFlags&ESM::Creature::Bipedal))
|
||||||
addAnimSource("meshes\\xbase_anim.nif");
|
addAnimSource("meshes\\xbase_anim.nif");
|
||||||
@ -42,7 +42,7 @@ CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const
|
|||||||
|
|
||||||
if(!model.empty())
|
if(!model.empty())
|
||||||
{
|
{
|
||||||
setObjectRoot(model, true, false);
|
setObjectRoot(model, true, false, true);
|
||||||
|
|
||||||
if((ref->mBase->mFlags&ESM::Creature::Bipedal))
|
if((ref->mBase->mFlags&ESM::Creature::Bipedal))
|
||||||
addAnimSource("meshes\\xbase_anim.nif");
|
addAnimSource("meshes\\xbase_anim.nif");
|
||||||
|
@ -378,7 +378,7 @@ void NpcAnimation::updateNpcBase()
|
|||||||
: "meshes\\wolf\\skin.1st.nif");
|
: "meshes\\wolf\\skin.1st.nif");
|
||||||
smodel = Misc::ResourceHelpers::correctActorModelPath(smodel, mResourceSystem->getVFS());
|
smodel = Misc::ResourceHelpers::correctActorModelPath(smodel, mResourceSystem->getVFS());
|
||||||
|
|
||||||
setObjectRoot(smodel, true, true);
|
setObjectRoot(smodel, true, true, false);
|
||||||
|
|
||||||
if(mViewMode != VM_FirstPerson)
|
if(mViewMode != VM_FirstPerson)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user