mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
setaicontroller: use Ids
get rid of duplicated mMoveDestination
This commit is contained in:
parent
201b7bf695
commit
2fe36a571b
5 changed files with 13 additions and 13 deletions
|
|
@ -117,7 +117,7 @@ bool AIController::getAIMove(Move* movePtr)
|
||||||
if (getAim()->mObj || getAim()->mPosSet)
|
if (getAim()->mObj || getAim()->mPosSet)
|
||||||
mMovement.mAimLocation = getAim()->getPosition();
|
mMovement.mAimLocation = getAim()->getPosition();
|
||||||
else
|
else
|
||||||
mMovement.mAimLocation = mMovement.mMoveDestination;
|
mMovement.mAimLocation = getNav()->mMoveDestination;
|
||||||
|
|
||||||
mControllerData->resolveYaw(this, location, movePtr);
|
mControllerData->resolveYaw(this, location, movePtr);
|
||||||
mControllerData->resolvePitch(this, location, movePtr);
|
mControllerData->resolvePitch(this, location, movePtr);
|
||||||
|
|
@ -232,8 +232,8 @@ void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* m
|
||||||
// Move towards the destination
|
// Move towards the destination
|
||||||
if (obj->mMovement.mMoveState != AIController::ModeStop)
|
if (obj->mMovement.mMoveState != AIController::ModeStop)
|
||||||
{
|
{
|
||||||
F32 xDiff = obj->mMovement.mMoveDestination.x - location.x;
|
F32 xDiff = obj->getNav()->mMoveDestination.x - location.x;
|
||||||
F32 yDiff = obj->mMovement.mMoveDestination.y - location.y;
|
F32 yDiff = obj->getNav()->mMoveDestination.y - location.y;
|
||||||
Point3F rotation = obj->getAIInfo()->mObj->getTransform().getForwardVector();
|
Point3F rotation = obj->getAIInfo()->mObj->getTransform().getForwardVector();
|
||||||
|
|
||||||
// Check if we should mMove, or if we are 'close enough'
|
// Check if we should mMove, or if we are 'close enough'
|
||||||
|
|
@ -246,22 +246,22 @@ void AIControllerData::resolveSpeed(AIController* obj, Point3F location, Move* m
|
||||||
{
|
{
|
||||||
// Build move direction in world space
|
// Build move direction in world space
|
||||||
if (mIsZero(xDiff))
|
if (mIsZero(xDiff))
|
||||||
movePtr->y = (location.y > obj->mMovement.mMoveDestination.y) ? -1.0f : 1.0f;
|
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||||
else
|
else
|
||||||
if (mIsZero(yDiff))
|
if (mIsZero(yDiff))
|
||||||
movePtr->x = (location.x > obj->mMovement.mMoveDestination.x) ? -1.0f : 1.0f;
|
movePtr->x = (location.x > obj->getNav()->mMoveDestination.x) ? -1.0f : 1.0f;
|
||||||
else
|
else
|
||||||
if (mFabs(xDiff) > mFabs(yDiff))
|
if (mFabs(xDiff) > mFabs(yDiff))
|
||||||
{
|
{
|
||||||
F32 value = mFabs(yDiff / xDiff);
|
F32 value = mFabs(yDiff / xDiff);
|
||||||
movePtr->y = (location.y > obj->mMovement.mMoveDestination.y) ? -value : value;
|
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -value : value;
|
||||||
movePtr->x = (location.x > obj->mMovement.mMoveDestination.x) ? -1.0f : 1.0f;
|
movePtr->x = (location.x > obj->getNav()->mMoveDestination.x) ? -1.0f : 1.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
F32 value = mFabs(xDiff / yDiff);
|
F32 value = mFabs(xDiff / yDiff);
|
||||||
movePtr->x = (location.x > obj->mMovement.mMoveDestination.x) ? -value : value;
|
movePtr->x = (location.x > obj->getNav()->mMoveDestination.x) ? -value : value;
|
||||||
movePtr->y = (location.y > obj->mMovement.mMoveDestination.y) ? -1.0f : 1.0f;
|
movePtr->y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotate the move into object space (this really only needs
|
// Rotate the move into object space (this really only needs
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ public:
|
||||||
Point3F mLastLocation; // For stuck check
|
Point3F mLastLocation; // For stuck check
|
||||||
S32 mMoveStuckTestCountdown; // The current countdown until at AI starts to check if it is stuck
|
S32 mMoveStuckTestCountdown; // The current countdown until at AI starts to check if it is stuck
|
||||||
Point3F mAimLocation;
|
Point3F mAimLocation;
|
||||||
Point3F mMoveDestination;
|
|
||||||
// move triggers
|
// move triggers
|
||||||
bool mMoveTriggers[MaxTriggerKeys];
|
bool mMoveTriggers[MaxTriggerKeys];
|
||||||
void stopMove();
|
void stopMove();
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
AINavigation::AINavigation(AIController* controller)
|
AINavigation::AINavigation(AIController* controller)
|
||||||
{
|
{
|
||||||
mControllerRef = controller;
|
mControllerRef = controller;
|
||||||
|
mJump = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavMesh* AINavigation::findNavMesh() const
|
NavMesh* AINavigation::findNavMesh() const
|
||||||
|
|
|
||||||
|
|
@ -2259,7 +2259,7 @@ void Player::advanceTime(F32 dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::setAIController(const char* controller)
|
bool Player::setAIController(S32 controller)
|
||||||
{
|
{
|
||||||
if (Sim::findObject(controller, mAIController))
|
if (Sim::findObject(controller, mAIController))
|
||||||
{
|
{
|
||||||
|
|
@ -2271,7 +2271,7 @@ bool Player::setAIController(const char* controller)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(Player, setAIController, bool, (const char* controller), , "")
|
DefineEngineMethod(Player, setAIController, bool, (S32 controller), , "")
|
||||||
{
|
{
|
||||||
return object->setAIController(controller);
|
return object->setAIController(controller);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -763,7 +763,7 @@ public:
|
||||||
void setMomentum(const Point3F &momentum) override;
|
void setMomentum(const Point3F &momentum) override;
|
||||||
bool displaceObject(const Point3F& displaceVector) override;
|
bool displaceObject(const Point3F& displaceVector) override;
|
||||||
virtual bool getAIMove(Move*);
|
virtual bool getAIMove(Move*);
|
||||||
bool setAIController(const char* controller);
|
bool setAIController(S32 controller);
|
||||||
AIController* getAIController() { return mAIController; };
|
AIController* getAIController() { return mAIController; };
|
||||||
|
|
||||||
bool checkDismountPosition(const MatrixF& oldPos, const MatrixF& newPos); ///< Is it safe to dismount here?
|
bool checkDismountPosition(const MatrixF& oldPos, const MatrixF& newPos); ///< Is it safe to dismount here?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue