mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
break wether we *should* be trying to move out of the resolver
This commit is contained in:
parent
eaa6a62b0c
commit
25b3a7c070
1 changed files with 64 additions and 63 deletions
|
|
@ -122,9 +122,23 @@ bool AIController::getAIMove(Move* movePtr)
|
||||||
mControllerData->resolveYaw(this, location, movePtr);
|
mControllerData->resolveYaw(this, location, movePtr);
|
||||||
mControllerData->resolvePitch(this, location, movePtr);
|
mControllerData->resolvePitch(this, location, movePtr);
|
||||||
mControllerData->resolveRoll(this, location, movePtr);
|
mControllerData->resolveRoll(this, location, movePtr);
|
||||||
|
|
||||||
|
if (mMovement.mMoveState != AIController::ModeStop)
|
||||||
|
{
|
||||||
|
F32 xDiff = getNav()->mMoveDestination.x - location.x;
|
||||||
|
F32 yDiff = getNav()->mMoveDestination.y - location.y;
|
||||||
|
if (mFabs(xDiff) < mControllerData->mMoveTolerance && mFabs(yDiff) < mControllerData->mMoveTolerance)
|
||||||
|
{
|
||||||
|
mMovement.mMoveState = AIController::ModeStop;
|
||||||
|
getNav()->onReachDestination();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mControllerData->resolveSpeed(this, location, movePtr);
|
mControllerData->resolveSpeed(this, location, movePtr);
|
||||||
mControllerData->resolveStuck(this);
|
mControllerData->resolveStuck(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test for target location in sight if it's an object. The LOS is
|
// Test for target location in sight if it's an object. The LOS is
|
||||||
// run from the eye position to the center of the object's bounding,
|
// run from the eye position to the center of the object's bounding,
|
||||||
|
|
@ -323,21 +337,10 @@ void AIControllerData::resolveRoll(AIController* obj, Point3F location, Move* mo
|
||||||
|
|
||||||
void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* movePtr)
|
void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* movePtr)
|
||||||
{
|
{
|
||||||
// Move towards the destination
|
|
||||||
if (obj->mMovement.mMoveState != AIController::ModeStop)
|
|
||||||
{
|
|
||||||
F32 xDiff = obj->getNav()->mMoveDestination.x - location.x;
|
F32 xDiff = obj->getNav()->mMoveDestination.x - location.x;
|
||||||
F32 yDiff = obj->getNav()->mMoveDestination.y - location.y;
|
F32 yDiff = obj->getNav()->mMoveDestination.y - location.y;
|
||||||
Point3F rotation = obj->getAIInfo()->mObj->getTransform().toEuler();
|
Point3F rotation = obj->getAIInfo()->mObj->getTransform().toEuler();
|
||||||
|
|
||||||
// Check if we should mMove, or if we are 'close enough'
|
|
||||||
if (mFabs(xDiff) < mMoveTolerance && mFabs(yDiff) < mMoveTolerance)
|
|
||||||
{
|
|
||||||
obj->mMovement.mMoveState = AIController::ModeStop;
|
|
||||||
obj->getNav()->onReachDestination();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Build move direction in world space
|
// Build move direction in world space
|
||||||
if (mIsZero(xDiff))
|
if (mIsZero(xDiff))
|
||||||
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||||
|
|
@ -388,8 +391,6 @@ void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* m
|
||||||
|
|
||||||
obj->mMovement.mMoveState = AIController::ModeMove;
|
obj->mMovement.mMoveState = AIController::ModeMove;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIControllerData::resolveStuck(AIController* obj)
|
void AIControllerData::resolveStuck(AIController* obj)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue