mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-29 13:20:35 +00:00
Use distance to position since last normal state in obstacle checker
This commit is contained in:
parent
52945921a7
commit
0c92a567af
@ -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…
x
Reference in New Issue
Block a user