mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 22:56:40 +00:00 
			
		
		
		
	Remove "Tri Bip*" nodes in creature meshes (meant for debugging)? (Fixes #2148)
This commit is contained in:
		
							parent
							
								
									c57e72fe03
								
							
						
					
					
						commit
						58cd2b1a84
					
				
					 4 changed files with 45 additions and 6 deletions
				
			
		|  | @ -208,6 +208,38 @@ namespace | |||
|         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 | ||||
|  | @ -898,7 +930,7 @@ namespace MWRender | |||
|         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) | ||||
|         { | ||||
|  | @ -933,6 +965,13 @@ namespace MWRender | |||
|             removeDrawableVisitor.remove(); | ||||
|         } | ||||
| 
 | ||||
|         if (isCreature) | ||||
|         { | ||||
|             RemoveTriBipVisitor removeTriBipVisitor; | ||||
|             mObjectRoot->accept(removeTriBipVisitor); | ||||
|             removeTriBipVisitor.remove(); | ||||
|         } | ||||
| 
 | ||||
|         NodeMapVisitor visitor; | ||||
|         mObjectRoot->accept(visitor); | ||||
|         mNodeMap = visitor.getNodeMap(); | ||||
|  | @ -1308,7 +1347,7 @@ namespace MWRender | |||
|     { | ||||
|         if (!model.empty()) | ||||
|         { | ||||
|             setObjectRoot(model, false, false); | ||||
|             setObjectRoot(model, false, false, false); | ||||
|             if (animated) | ||||
|                 addAnimSource(model); | ||||
| 
 | ||||
|  |  | |||
|  | @ -273,7 +273,7 @@ protected: | |||
|      * @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). | ||||
|      */ | ||||
|     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
 | ||||
|      * 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()) | ||||
|     { | ||||
|         setObjectRoot(model, false, false); | ||||
|         setObjectRoot(model, false, false, true); | ||||
| 
 | ||||
|         if((ref->mBase->mFlags&ESM::Creature::Bipedal)) | ||||
|             addAnimSource("meshes\\xbase_anim.nif"); | ||||
|  | @ -42,7 +42,7 @@ CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const | |||
| 
 | ||||
|     if(!model.empty()) | ||||
|     { | ||||
|         setObjectRoot(model, true, false); | ||||
|         setObjectRoot(model, true, false, true); | ||||
| 
 | ||||
|         if((ref->mBase->mFlags&ESM::Creature::Bipedal)) | ||||
|             addAnimSource("meshes\\xbase_anim.nif"); | ||||
|  |  | |||
|  | @ -378,7 +378,7 @@ void NpcAnimation::updateNpcBase() | |||
|                                       : "meshes\\wolf\\skin.1st.nif"); | ||||
|     smodel = Misc::ResourceHelpers::correctActorModelPath(smodel, mResourceSystem->getVFS()); | ||||
| 
 | ||||
|     setObjectRoot(smodel, true, true); | ||||
|     setObjectRoot(smodel, true, true, false); | ||||
| 
 | ||||
|     if(mViewMode != VM_FirstPerson) | ||||
|     { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue