mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-27 23:41:34 +00:00
Introduce helper function to write back updated values inside parent Actor class
This commit is contained in:
parent
b04c958410
commit
9e911cc8b5
1 changed files with 14 additions and 18 deletions
|
@ -83,6 +83,18 @@ namespace
|
||||||
return actorData.mPosition * interpolationFactor + actorData.mActorRaw->getPreviousPosition() * (1.f - interpolationFactor);
|
return actorData.mPosition * interpolationFactor + actorData.mActorRaw->getPreviousPosition() * (1.f - interpolationFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateActor(MWPhysics::ActorFrameData& actorData, bool simulationPerformed, float timeAccum, float dt)
|
||||||
|
{
|
||||||
|
actorData.mActorRaw->setSimulationPosition(interpolateMovements(actorData, timeAccum, dt));
|
||||||
|
if (simulationPerformed)
|
||||||
|
{
|
||||||
|
actorData.mActorRaw->setStandingOnPtr(actorData.mStandingOn);
|
||||||
|
actorData.mActorRaw->setOnGround(actorData.mIsOnGround);
|
||||||
|
actorData.mActorRaw->setOnSlope(actorData.mIsOnSlope);
|
||||||
|
actorData.mActorRaw->setWalkingOnWater(actorData.mWalkingOnWater);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
/// @return either the number of thread as configured by the user, or 1 if Bullet doesn't support multithreading
|
/// @return either the number of thread as configured by the user, or 1 if Bullet doesn't support multithreading
|
||||||
|
@ -230,16 +242,7 @@ namespace MWPhysics
|
||||||
if (std::any_of(actorsData.begin(), actorsData.end(), actorActive))
|
if (std::any_of(actorsData.begin(), actorsData.end(), actorActive))
|
||||||
{
|
{
|
||||||
updateMechanics(data);
|
updateMechanics(data);
|
||||||
|
updateActor(data, mAdvanceSimulation, mTimeAccum, mPhysicsDt);
|
||||||
// these variables are accessed directly from the main thread, update them here to prevent accessing "too new" values
|
|
||||||
if (mAdvanceSimulation)
|
|
||||||
{
|
|
||||||
data.mActorRaw->setStandingOnPtr(data.mStandingOn);
|
|
||||||
data.mActorRaw->setOnGround(data.mIsOnGround);
|
|
||||||
data.mActorRaw->setOnSlope(data.mIsOnSlope);
|
|
||||||
data.mActorRaw->setWalkingOnWater(data.mWalkingOnWater);
|
|
||||||
}
|
|
||||||
data.mActorRaw->setSimulationPosition(interpolateMovements(data, mTimeAccum, mPhysicsDt));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(mAdvanceSimulation)
|
if(mAdvanceSimulation)
|
||||||
|
@ -534,15 +537,8 @@ namespace MWPhysics
|
||||||
for (auto& actorData : mActorsFrameData)
|
for (auto& actorData : mActorsFrameData)
|
||||||
{
|
{
|
||||||
handleFall(actorData, mAdvanceSimulation);
|
handleFall(actorData, mAdvanceSimulation);
|
||||||
actorData.mActorRaw->setSimulationPosition(interpolateMovements(actorData, mTimeAccum, mPhysicsDt));
|
|
||||||
updateMechanics(actorData);
|
updateMechanics(actorData);
|
||||||
if (mAdvanceSimulation)
|
updateActor(actorData, mAdvanceSimulation, mTimeAccum, mPhysicsDt);
|
||||||
{
|
|
||||||
actorData.mActorRaw->setStandingOnPtr(actorData.mStandingOn);
|
|
||||||
actorData.mActorRaw->setOnGround(actorData.mIsOnGround);
|
|
||||||
actorData.mActorRaw->setOnSlope(actorData.mIsOnSlope);
|
|
||||||
actorData.mActorRaw->setWalkingOnWater(actorData.mWalkingOnWater);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
refreshLOSCache();
|
refreshLOSCache();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue