mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 05:45:33 +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;
|
return mPreviousMovementResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PtrPositionList& PhysicsTaskScheduler::resetSimulation()
|
const PtrPositionList& PhysicsTaskScheduler::resetSimulation(const ActorMap& actors)
|
||||||
{
|
{
|
||||||
std::unique_lock lock(mSimulationMutex);
|
std::unique_lock lock(mSimulationMutex);
|
||||||
mMovementResults.clear();
|
mMovementResults.clear();
|
||||||
mPreviousMovementResults.clear();
|
mPreviousMovementResults.clear();
|
||||||
mActorsFrameData.clear();
|
mActorsFrameData.clear();
|
||||||
|
|
||||||
|
for (const auto& [_, actor] : actors)
|
||||||
|
{
|
||||||
|
actor->resetPosition();
|
||||||
|
actor->setStandingOnPtr(nullptr);
|
||||||
|
mMovementResults[actor->getPtr()] = actor->getWorldPosition();
|
||||||
|
}
|
||||||
return mMovementResults;
|
return mMovementResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace MWPhysics
|
||||||
/// @return new position of each actor
|
/// @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& 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
|
// Thread safe wrappers
|
||||||
void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const;
|
void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, btCollisionWorld::RayResultCallback& resultCallback) const;
|
||||||
|
|
|
@ -677,14 +677,7 @@ namespace MWPhysics
|
||||||
mTimeAccum -= numSteps * mPhysicsDt;
|
mTimeAccum -= numSteps * mPhysicsDt;
|
||||||
|
|
||||||
if (skipSimulation)
|
if (skipSimulation)
|
||||||
{
|
return mTaskScheduler->resetSimulation(mActors);
|
||||||
for (auto& [_, actor] : mActors)
|
|
||||||
{
|
|
||||||
actor->resetPosition();
|
|
||||||
actor->setStandingOnPtr(nullptr);
|
|
||||||
}
|
|
||||||
return mTaskScheduler->resetSimulation();
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), frameStart, frameNumber, stats);
|
return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), frameStart, frameNumber, stats);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ namespace MWPhysics
|
||||||
class Actor;
|
class Actor;
|
||||||
class PhysicsTaskScheduler;
|
class PhysicsTaskScheduler;
|
||||||
|
|
||||||
|
using ActorMap = std::map<MWWorld::ConstPtr, std::shared_ptr<Actor>>;
|
||||||
|
|
||||||
struct ContactPoint
|
struct ContactPoint
|
||||||
{
|
{
|
||||||
MWWorld::Ptr mObject;
|
MWWorld::Ptr mObject;
|
||||||
|
@ -265,7 +267,6 @@ namespace MWPhysics
|
||||||
|
|
||||||
std::set<Object*> mAnimatedObjects; // stores pointers to elements in mObjects
|
std::set<Object*> mAnimatedObjects; // stores pointers to elements in mObjects
|
||||||
|
|
||||||
using ActorMap = std::map<MWWorld::ConstPtr, std::shared_ptr<Actor>>;
|
|
||||||
ActorMap mActors;
|
ActorMap mActors;
|
||||||
|
|
||||||
using HeightFieldMap = std::map<std::pair<int, int>, HeightField *>;
|
using HeightFieldMap = std::map<std::pair<int, int>, HeightField *>;
|
||||||
|
|
Loading…
Reference in a new issue