mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
expose a getThrottle for vehicles. save some calcs in AIWheeledVehicleControllerData
deletion cleanups
This commit is contained in:
parent
2d5e8c1560
commit
78a26b0108
6 changed files with 22 additions and 38 deletions
|
|
@ -695,42 +695,10 @@ F32 AIWheeledVehicleControllerData::getSteeringAngle(AIController* obj, Point3F
|
|||
steerState = Left;
|
||||
}
|
||||
|
||||
|
||||
F32 xDiff = obj->getNav()->mMoveDestination.x - location.x;
|
||||
F32 yDiff = obj->getNav()->mMoveDestination.y - location.y;
|
||||
Point3F rotation = wvo->getTransform().toEuler();
|
||||
Point2F mov;
|
||||
// Build move direction in world space
|
||||
if (mIsZero(xDiff))
|
||||
mov.y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||
else
|
||||
{
|
||||
if (mIsZero(yDiff))
|
||||
mov.x = (location.x > obj->getNav()->mMoveDestination.x) ? -1.0f : 1.0f;
|
||||
else
|
||||
if (mFabs(xDiff) > mFabs(yDiff))
|
||||
{
|
||||
F32 value = mFabs(yDiff / xDiff);
|
||||
mov.y = (location.y > obj->getNav()->mMoveDestination.y) ? -value : value;
|
||||
mov.x = (location.x > obj->getNav()->mMoveDestination.x) ? -1.0f : 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
F32 value = mFabs(xDiff / yDiff);
|
||||
mov.x = (location.x > obj->getNav()->mMoveDestination.x) ? -value : value;
|
||||
mov.y = (location.y > obj->getNav()->mMoveDestination.y) ? -1.0f : 1.0f;
|
||||
}
|
||||
}
|
||||
// Rotate the move into object space (this really only needs
|
||||
// a 2D matrix)
|
||||
Point3F throttle;
|
||||
MatrixF moveMatrix;
|
||||
moveMatrix.set(EulerF(0.0f, 0.0f, -(rotation.z + steering.x)));
|
||||
moveMatrix.mulV(Point3F(mov.x, mov.y, 0.0f), &throttle);
|
||||
|
||||
F32 turnAdjust = myAngle - steering.x;
|
||||
|
||||
if (throttle.y < 0.0f)
|
||||
F32 throttle = wvo->getThrottle();
|
||||
if (throttle < 0.0f)
|
||||
{
|
||||
F32 reverseReduction = 0.25f;
|
||||
if (steerState == Left)
|
||||
|
|
@ -757,7 +725,6 @@ F32 AIWheeledVehicleControllerData::getSteeringAngle(AIController* obj, Point3F
|
|||
break;
|
||||
};
|
||||
|
||||
|
||||
// Con::printf("AI Steering : %f", steer);
|
||||
return steer;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue