mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-29 03:26:38 +00:00 
			
		
		
		
	Readded baseonly parameter to Animation::setObjectRoot
Fixes the first person view.
This commit is contained in:
		
							parent
							
								
									6031db7882
								
							
						
					
					
						commit
						0fb97bd2e7
					
				
					 4 changed files with 48 additions and 6 deletions
				
			
		|  | @ -9,6 +9,7 @@ | |||
| #include <osg/ComputeBoundsVisitor> | ||||
| #include <osg/MatrixTransform> | ||||
| #include <osg/io_utils> | ||||
| #include <osg/Geode> | ||||
| 
 | ||||
| #include <components/nifosg/nifloader.hpp> | ||||
| 
 | ||||
|  | @ -167,6 +168,38 @@ namespace | |||
| 
 | ||||
|         return 0.0f; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     // Removes all drawables from a graph.
 | ||||
|     class RemoveDrawableVisitor : public osg::NodeVisitor | ||||
|     { | ||||
|     public: | ||||
|         RemoveDrawableVisitor() | ||||
|             : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) | ||||
|         { | ||||
|         } | ||||
| 
 | ||||
|         virtual void apply(osg::Geode &node) | ||||
|         { | ||||
|             // Not safe to remove in apply(), since the visitor is still iterating the child list
 | ||||
|             mToRemove.push_back(&node); | ||||
|             traverse(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 | ||||
|  | @ -836,7 +869,7 @@ namespace MWRender | |||
|         return movement; | ||||
|     } | ||||
| 
 | ||||
|     void Animation::setObjectRoot(const std::string &model, bool forceskeleton) | ||||
|     void Animation::setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly) | ||||
|     { | ||||
|         if (mObjectRoot) | ||||
|         { | ||||
|  | @ -864,6 +897,13 @@ namespace MWRender | |||
|             mObjectRoot = newObjectRoot; | ||||
|         } | ||||
| 
 | ||||
|         if (baseonly) | ||||
|         { | ||||
|             RemoveDrawableVisitor removeDrawableVisitor; | ||||
|             mObjectRoot->accept(removeDrawableVisitor); | ||||
|             removeDrawableVisitor.remove(); | ||||
|         } | ||||
| 
 | ||||
|         NodeMapVisitor visitor; | ||||
|         mObjectRoot->accept(visitor); | ||||
|         mNodeMap = visitor.getNodeMap(); | ||||
|  | @ -1130,7 +1170,7 @@ namespace MWRender | |||
|     { | ||||
|         if (!model.empty()) | ||||
|         { | ||||
|             setObjectRoot(model, false); | ||||
|             setObjectRoot(model, false, false); | ||||
| 
 | ||||
|             if (!ptr.getClass().getEnchantment(ptr).empty()) | ||||
|                 addGlow(mObjectRoot, getEnchantmentColor(ptr)); | ||||
|  |  | |||
|  | @ -230,8 +230,10 @@ protected: | |||
|      * Note that you must make sure all animation sources are cleared before reseting the object | ||||
|      * root. All nodes previously retrieved with getNode will also become invalidated. | ||||
|      * @param forceskeleton Wrap the object root in a Skeleton, even if it contains no skinned parts. Use this if you intend to add skinned parts manually. | ||||
|      * @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); | ||||
|     void setObjectRoot(const std::string &model, bool forceskeleton, bool baseonly); | ||||
| 
 | ||||
|     /* 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 | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr, | |||
| 
 | ||||
|     if(!model.empty()) | ||||
|     { | ||||
|         setObjectRoot(model, false /* , baseonly = false */); | ||||
|         setObjectRoot(model, false, false); | ||||
|         //setRenderProperties(mObjectRoot, RV_Actors, RQG_Main, RQG_Alpha);
 | ||||
| 
 | ||||
|         if((ref->mBase->mFlags&ESM::Creature::Bipedal)) | ||||
|  | @ -42,7 +42,7 @@ CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const | |||
| 
 | ||||
|     if(!model.empty()) | ||||
|     { | ||||
|         setObjectRoot(model, true /* , baseonly = false*/); | ||||
|         setObjectRoot(model, true, false); | ||||
|         //setRenderProperties(mObjectRoot, RV_Actors, RQG_Main, RQG_Alpha);
 | ||||
| 
 | ||||
|         if((ref->mBase->mFlags&ESM::Creature::Bipedal)) | ||||
|  |  | |||
|  | @ -299,7 +299,7 @@ void NpcAnimation::updateNpcBase() | |||
|                                       : "meshes\\wolf\\skin.1st.nif"); | ||||
|     smodel = Misc::ResourceHelpers::correctActorModelPath(smodel, mResourceSystem->getVFS()); | ||||
| 
 | ||||
|     setObjectRoot(smodel, true /*, baseonly = true*/); | ||||
|     setObjectRoot(smodel, true, true); | ||||
| 
 | ||||
|     if(mViewMode != VM_FirstPerson) | ||||
|     { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue