mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +00:00 
			
		
		
		
	Don't let the actor "nowhere" after a teleport but move them in their
place. This solve the problem where after loading, an empty frame was rendered because the player is "nowhere".
This commit is contained in:
		
							parent
							
								
									e2213cbdb1
								
							
						
					
					
						commit
						7843dad35d
					
				
					 4 changed files with 12 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -297,12 +297,19 @@ namespace MWPhysics
 | 
			
		|||
        return mPreviousMovementResults;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const PtrPositionList& PhysicsTaskScheduler::resetSimulation()
 | 
			
		||||
    const PtrPositionList& PhysicsTaskScheduler::resetSimulation(const ActorMap& actors)
 | 
			
		||||
    {
 | 
			
		||||
        std::unique_lock lock(mSimulationMutex);
 | 
			
		||||
        mMovementResults.clear();
 | 
			
		||||
        mPreviousMovementResults.clear();
 | 
			
		||||
        mActorsFrameData.clear();
 | 
			
		||||
 | 
			
		||||
        for (const auto& [_, actor] : actors)
 | 
			
		||||
        {
 | 
			
		||||
            actor->resetPosition();
 | 
			
		||||
            actor->setStandingOnPtr(nullptr);
 | 
			
		||||
            mMovementResults[actor->getPtr()] = actor->getWorldPosition();
 | 
			
		||||
        }
 | 
			
		||||
        return mMovementResults;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,7 @@ namespace MWPhysics
 | 
			
		|||
            /// @return new position of each actor
 | 
			
		||||
            const PtrPositionList& moveActors(int numSteps, float timeAccum, std::vector<ActorFrameData>&& actorsData, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats);
 | 
			
		||||
 | 
			
		||||
            const PtrPositionList& resetSimulation();
 | 
			
		||||
            const PtrPositionList& resetSimulation(const ActorMap& actors);
 | 
			
		||||
 | 
			
		||||
            // Thread safe wrappers
 | 
			
		||||
            void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -677,14 +677,7 @@ namespace MWPhysics
 | 
			
		|||
        mTimeAccum -= numSteps * mPhysicsDt;
 | 
			
		||||
 | 
			
		||||
        if (skipSimulation)
 | 
			
		||||
        {
 | 
			
		||||
            for (auto& [_, actor] : mActors)
 | 
			
		||||
            {
 | 
			
		||||
                actor->resetPosition();
 | 
			
		||||
                actor->setStandingOnPtr(nullptr);
 | 
			
		||||
            }
 | 
			
		||||
            return mTaskScheduler->resetSimulation();
 | 
			
		||||
        }
 | 
			
		||||
            return mTaskScheduler->resetSimulation(mActors);
 | 
			
		||||
 | 
			
		||||
        return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), frameStart, frameNumber, stats);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,6 +57,8 @@ namespace MWPhysics
 | 
			
		|||
    class Actor;
 | 
			
		||||
    class PhysicsTaskScheduler;
 | 
			
		||||
 | 
			
		||||
    using ActorMap = std::map<MWWorld::ConstPtr, std::shared_ptr<Actor>>;
 | 
			
		||||
 | 
			
		||||
    struct ContactPoint
 | 
			
		||||
    {
 | 
			
		||||
        MWWorld::Ptr mObject;
 | 
			
		||||
| 
						 | 
				
			
			@ -265,7 +267,6 @@ namespace MWPhysics
 | 
			
		|||
 | 
			
		||||
            std::set<Object*> mAnimatedObjects; // stores pointers to elements in mObjects
 | 
			
		||||
 | 
			
		||||
            using ActorMap = std::map<MWWorld::ConstPtr, std::shared_ptr<Actor>>;
 | 
			
		||||
            ActorMap mActors;
 | 
			
		||||
 | 
			
		||||
            using HeightFieldMap = std::map<std::pair<int, int>, HeightField *>;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue