mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-28 20:06:41 +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;
|
mWalkState = WalkState::Norm;
|
||||||
mStateDuration = 0;
|
mStateDuration = 0;
|
||||||
mPrev = position;
|
mPrev = position;
|
||||||
|
mInitialDistance = (destination - position).length();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,10 +130,11 @@ namespace MWMechanics
|
||||||
const float prevDistance = (destination - mPrev).length();
|
const float prevDistance = (destination - mPrev).length();
|
||||||
const float currentDistance = (destination - position).length();
|
const float currentDistance = (destination - position).length();
|
||||||
const float movedDistance = prevDistance - currentDistance;
|
const float movedDistance = prevDistance - currentDistance;
|
||||||
|
const float movedFromInitialDistance = mInitialDistance - currentDistance;
|
||||||
|
|
||||||
mPrev = position;
|
mPrev = position;
|
||||||
|
|
||||||
if (movedDistance >= distSameSpot)
|
if (movedDistance >= distSameSpot && movedFromInitialDistance >= distSameSpot)
|
||||||
{
|
{
|
||||||
mWalkState = WalkState::Norm;
|
mWalkState = WalkState::Norm;
|
||||||
mStateDuration = 0;
|
mStateDuration = 0;
|
||||||
|
@ -143,6 +145,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
mWalkState = WalkState::CheckStuck;
|
mWalkState = WalkState::CheckStuck;
|
||||||
mStateDuration = duration;
|
mStateDuration = duration;
|
||||||
|
mInitialDistance = (destination - position).length();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
float mStateDuration;
|
float mStateDuration;
|
||||||
int mEvadeDirectionIndex;
|
int mEvadeDirectionIndex;
|
||||||
|
float mInitialDistance = 0;
|
||||||
|
|
||||||
void chooseEvasionDirection();
|
void chooseEvasionDirection();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue