mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-11-03 23:56:47 +00:00 
			
		
		
		
	Bug #840, First Person Sneaking Camera Height
Also, added comments to existing code in the area.
This commit is contained in:
		
							parent
							
								
									4496244b14
								
							
						
					
					
						commit
						296abfd48f
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -443,11 +443,31 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
 | 
			
		|||
    Ogre::Vector3 ret = Animation::runAnimation(timepassed);
 | 
			
		||||
 | 
			
		||||
    Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
 | 
			
		||||
 | 
			
		||||
    // We have to make a few adjustments to the first person animation, since the armature
 | 
			
		||||
    // is partly driven by code.
 | 
			
		||||
    if(mViewMode == VM_FirstPerson && mCamera)
 | 
			
		||||
    {
 | 
			
		||||
        // Bend his neck and shoulders so his eyes don't go into his torso.
 | 
			
		||||
        float pitch = mCamera->getPitch();
 | 
			
		||||
        Ogre::Node *node = baseinst->getBone("Bip01 Neck");
 | 
			
		||||
        node->pitch(Ogre::Radian(pitch*0.75f), Ogre::Node::TS_WORLD);
 | 
			
		||||
 | 
			
		||||
        // If NPC is sneaking, his head and shoulders must lower to adjust his camera.
 | 
			
		||||
        const MWWorld::Class *npcClass = &MWWorld::Class::get(mPtr);
 | 
			
		||||
        const MWBase::World *world = MWBase::Environment::get().getWorld();
 | 
			
		||||
 | 
			
		||||
        bool isSneaking = npcClass->getStance(mPtr, MWWorld::Class::Sneak);
 | 
			
		||||
        bool isInAir = !world->isOnGround(mPtr);
 | 
			
		||||
        bool isSwimming = world->isSwimming(mPtr);
 | 
			
		||||
 | 
			
		||||
        if(isSneaking && !(isSwimming || isInAir))
 | 
			
		||||
        {
 | 
			
		||||
            Ogre::Node *headNode = baseinst->getBone("Bip01 Neck");
 | 
			
		||||
            Ogre::Vector3 position = headNode->getPosition();
 | 
			
		||||
            position.x -= 9.5f;
 | 
			
		||||
            headNode->setPosition(position);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for(size_t i = 0;i < ESM::PRT_Count;i++)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue