mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 16:06:44 +00:00
Use distance to position since last normal state in obstacle checker
This commit is contained in:
parent
52945921a7
commit
0c92a567af
2 changed files with 5 additions and 1 deletions
|
@ -120,6 +120,7 @@ namespace MWMechanics
|
|||
mWalkState = WalkState::Norm;
|
||||
mStateDuration = 0;
|
||||
mPrev = position;
|
||||
mInitialDistance = (destination - position).length();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -129,10 +130,11 @@ namespace MWMechanics
|
|||
const float prevDistance = (destination - mPrev).length();
|
||||
const float currentDistance = (destination - position).length();
|
||||
const float movedDistance = prevDistance - currentDistance;
|
||||
const float movedFromInitialDistance = mInitialDistance - currentDistance;
|
||||
|
||||
mPrev = position;
|
||||
|
||||
if (movedDistance >= distSameSpot)
|
||||
if (movedDistance >= distSameSpot && movedFromInitialDistance >= distSameSpot)
|
||||
{
|
||||
mWalkState = WalkState::Norm;
|
||||
mStateDuration = 0;
|
||||
|
@ -143,6 +145,7 @@ namespace MWMechanics
|
|||
{
|
||||
mWalkState = WalkState::CheckStuck;
|
||||
mStateDuration = duration;
|
||||
mInitialDistance = (destination - position).length();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace MWMechanics
|
|||
|
||||
float mStateDuration;
|
||||
int mEvadeDirectionIndex;
|
||||
float mInitialDistance = 0;
|
||||
|
||||
void chooseEvasionDirection();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue