mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 13:26:44 +00:00 
			
		
		
		
	1. Skip smooth camera transition after changing cell; 2. Fix 'zoom out when move' for extremely high speed;
This commit is contained in:
		
							parent
							
								
									a890c951bc
								
							
						
					
					
						commit
						68148f5ec7
					
				
					 3 changed files with 14 additions and 0 deletions
				
			
		| 
						 | 
					@ -65,6 +65,7 @@ namespace MWRender
 | 
				
			||||||
      mFocalPointCurrentOffset(osg::Vec2d()),
 | 
					      mFocalPointCurrentOffset(osg::Vec2d()),
 | 
				
			||||||
      mFocalPointTargetOffset(osg::Vec2d()),
 | 
					      mFocalPointTargetOffset(osg::Vec2d()),
 | 
				
			||||||
      mFocalPointTransitionSpeedCoef(1.f),
 | 
					      mFocalPointTransitionSpeedCoef(1.f),
 | 
				
			||||||
 | 
					      mSkipFocalPointTransition(true),
 | 
				
			||||||
      mPreviousTransitionInfluence(0.f),
 | 
					      mPreviousTransitionInfluence(0.f),
 | 
				
			||||||
      mSmoothedSpeed(0.f),
 | 
					      mSmoothedSpeed(0.f),
 | 
				
			||||||
      mZoomOutWhenMoveCoef(Settings::Manager::getFloat("zoom out when move coef", "Camera")),
 | 
					      mZoomOutWhenMoveCoef(Settings::Manager::getFloat("zoom out when move coef", "Camera")),
 | 
				
			||||||
| 
						 | 
					@ -219,6 +220,7 @@ namespace MWRender
 | 
				
			||||||
        updateFocalPointOffset(duration);
 | 
					        updateFocalPointOffset(duration);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        float speed = mTrackingPtr.getClass().getSpeed(mTrackingPtr);
 | 
					        float speed = mTrackingPtr.getClass().getSpeed(mTrackingPtr);
 | 
				
			||||||
 | 
					        speed /= (1.f + speed / 500.f);
 | 
				
			||||||
        float maxDelta = 300.f * duration;
 | 
					        float maxDelta = 300.f * duration;
 | 
				
			||||||
        mSmoothedSpeed += osg::clampBetween(speed - mSmoothedSpeed, -maxDelta, maxDelta);
 | 
					        mSmoothedSpeed += osg::clampBetween(speed - mSmoothedSpeed, -maxDelta, maxDelta);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -235,6 +237,14 @@ namespace MWRender
 | 
				
			||||||
        if (duration <= 0)
 | 
					        if (duration <= 0)
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (mSkipFocalPointTransition)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mSkipFocalPointTransition = false;
 | 
				
			||||||
 | 
					            mPreviousExtraOffset = osg::Vec2d();
 | 
				
			||||||
 | 
					            mPreviousTransitionInfluence = 0.f;
 | 
				
			||||||
 | 
					            mFocalPointCurrentOffset = mFocalPointTargetOffset;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        osg::Vec2d oldOffset = mFocalPointCurrentOffset;
 | 
					        osg::Vec2d oldOffset = mFocalPointCurrentOffset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (mPreviousTransitionInfluence > 0)
 | 
					        if (mPreviousTransitionInfluence > 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,6 +59,7 @@ namespace MWRender
 | 
				
			||||||
        osg::Vec2d mFocalPointCurrentOffset;
 | 
					        osg::Vec2d mFocalPointCurrentOffset;
 | 
				
			||||||
        osg::Vec2d mFocalPointTargetOffset;
 | 
					        osg::Vec2d mFocalPointTargetOffset;
 | 
				
			||||||
        float mFocalPointTransitionSpeedCoef;
 | 
					        float mFocalPointTransitionSpeedCoef;
 | 
				
			||||||
 | 
					        bool mSkipFocalPointTransition;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // This fields are used to make focal point transition smooth if previous transition was not finished.
 | 
					        // This fields are used to make focal point transition smooth if previous transition was not finished.
 | 
				
			||||||
        float mPreviousTransitionInfluence;
 | 
					        float mPreviousTransitionInfluence;
 | 
				
			||||||
| 
						 | 
					@ -84,6 +85,7 @@ namespace MWRender
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void setFocalPointTransitionSpeed(float v) { mFocalPointTransitionSpeedCoef = v; }
 | 
					        void setFocalPointTransitionSpeed(float v) { mFocalPointTransitionSpeedCoef = v; }
 | 
				
			||||||
        void setFocalPointTargetOffset(osg::Vec2d v);
 | 
					        void setFocalPointTargetOffset(osg::Vec2d v);
 | 
				
			||||||
 | 
					        void skipFocalPointTransition() { mSkipFocalPointTransition = true; }
 | 
				
			||||||
        void enableDynamicCameraDistance(bool v) { mDynamicCameraDistanceEnabled = v; }
 | 
					        void enableDynamicCameraDistance(bool v) { mDynamicCameraDistanceEnabled = v; }
 | 
				
			||||||
        void enableCrosshairInThirdPersonMode(bool v) { mShowCrosshairInThirdPersonMode = v; }
 | 
					        void enableCrosshairInThirdPersonMode(bool v) { mShowCrosshairInThirdPersonMode = v; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -945,6 +945,7 @@ namespace MWWorld
 | 
				
			||||||
        removeContainerScripts(getPlayerPtr());
 | 
					        removeContainerScripts(getPlayerPtr());
 | 
				
			||||||
        mWorldScene->changeToInteriorCell(cellName, position, adjustPlayerPos, changeEvent);
 | 
					        mWorldScene->changeToInteriorCell(cellName, position, adjustPlayerPos, changeEvent);
 | 
				
			||||||
        addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
 | 
					        addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
 | 
				
			||||||
 | 
					        mRendering->getCamera()->skipFocalPointTransition();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void World::changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
 | 
					    void World::changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
 | 
				
			||||||
| 
						 | 
					@ -960,6 +961,7 @@ namespace MWWorld
 | 
				
			||||||
        removeContainerScripts(getPlayerPtr());
 | 
					        removeContainerScripts(getPlayerPtr());
 | 
				
			||||||
        mWorldScene->changeToExteriorCell(position, adjustPlayerPos, changeEvent);
 | 
					        mWorldScene->changeToExteriorCell(position, adjustPlayerPos, changeEvent);
 | 
				
			||||||
        addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
 | 
					        addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
 | 
				
			||||||
 | 
					        mRendering->getCamera()->skipFocalPointTransition();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void World::changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
 | 
					    void World::changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue