mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
GRIM: Use the right turn rate, and increase it only when necessary.
This commit is contained in:
parent
3b9a59dc93
commit
eb5c89a880
@ -473,7 +473,7 @@ Math::Vector3d Actor::actorUp() const {
|
||||
return Math::Vector3d(0.f, 1.f, 0.f);
|
||||
}
|
||||
|
||||
void Actor::turnTo(const Math::Vector3d &pos) {
|
||||
void Actor::turnTo(const Math::Vector3d &pos, bool snap) {
|
||||
Math::Vector3d lookVector = pos - _pos;
|
||||
lookVector.normalize();
|
||||
|
||||
@ -490,16 +490,17 @@ void Actor::turnTo(const Math::Vector3d &pos) {
|
||||
m.buildFromTargetDir(actorForward(), lookVector, actorUp(), up);
|
||||
|
||||
if (_puckOrient) {
|
||||
turnTo(m.getPitch(), m.getYaw(), m.getRoll());
|
||||
turnTo(m.getPitch(), m.getYaw(), m.getRoll(), snap);
|
||||
} else {
|
||||
turnTo(_pitch, m.getYaw(), _roll);
|
||||
turnTo(_pitch, m.getYaw(), _roll, snap);
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::turnTo(const Math::Angle &pitchParam, const Math::Angle &yawParam, const Math::Angle &rollParam) {
|
||||
void Actor::turnTo(const Math::Angle &pitchParam, const Math::Angle &yawParam, const Math::Angle &rollParam, bool snap) {
|
||||
_movePitch = pitchParam;
|
||||
_moveRoll = rollParam;
|
||||
_moveYaw = yawParam;
|
||||
_turnRateMultiplier = (snap ? 5.f : 1.f);
|
||||
if (_yaw != yawParam || _pitch != pitchParam || _roll != rollParam) {
|
||||
_turning = true;
|
||||
} else
|
||||
@ -802,7 +803,7 @@ void Actor::walkForward() {
|
||||
return;
|
||||
|
||||
ei.angleWithEdge += (float)1.0f;
|
||||
turnTo(0, _moveYaw + ei.angleWithEdge * turnDir, 0);
|
||||
turnTo(0, _moveYaw + ei.angleWithEdge * turnDir, 0, true);
|
||||
|
||||
if (oldDist <= dist + 0.001f) {
|
||||
// If we didn't move at all, keep trying a couple more times
|
||||
@ -953,6 +954,7 @@ void Actor::turn(int dir) {
|
||||
float delta = g_grim->getPerSecond(_turnRate) * dir;
|
||||
_moveYaw = _moveYaw + delta;
|
||||
_turning = true;
|
||||
_turnRateMultiplier = 5.f;
|
||||
_currTurnDir = dir;
|
||||
}
|
||||
|
||||
@ -1253,7 +1255,7 @@ void Actor::updateWalk() {
|
||||
}
|
||||
}
|
||||
|
||||
turnTo(destPos);
|
||||
turnTo(destPos, true);
|
||||
|
||||
dir = destPos - _pos;
|
||||
dir.normalize();
|
||||
@ -1289,12 +1291,13 @@ void Actor::update(uint frameTime) {
|
||||
}
|
||||
|
||||
if (_turning) {
|
||||
float turnAmt = g_grim->getPerSecond(_turnRate)*5;
|
||||
float turnAmt = g_grim->getPerSecond(_turnRate) * _turnRateMultiplier;
|
||||
_currTurnDir = animTurn(turnAmt, _moveYaw, &_yaw);
|
||||
int p = animTurn(turnAmt, _movePitch, &_pitch);
|
||||
int r = animTurn(turnAmt, _moveRoll, &_roll);
|
||||
if (_currTurnDir == 0 && p == 0 && r == 0) {
|
||||
_turning = false;
|
||||
_turnRateMultiplier = 1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,6 +175,7 @@ public:
|
||||
* @param pitch The rotation of the x axis
|
||||
* @param yaw The rotation of the z axis
|
||||
* @param roll The rotation of the y axis
|
||||
* @param snap If true tells the actor to increate its turn speed.
|
||||
* @see getPitch
|
||||
* @see getYaw
|
||||
* @see getRoll
|
||||
@ -182,17 +183,18 @@ public:
|
||||
* @see turn
|
||||
* @see isTurning
|
||||
*/
|
||||
void turnTo(const Math::Angle &pitch, const Math::Angle &yaw, const Math::Angle &roll);
|
||||
void turnTo(const Math::Angle &pitch, const Math::Angle &yaw, const Math::Angle &roll, bool snap = false);
|
||||
/**
|
||||
* Turn the actor towards a point in space.
|
||||
* The effect is not immediate, the actor will slowly rotate
|
||||
* to the destination orientation.
|
||||
*
|
||||
* @param pos The position the actor should turn to.
|
||||
* @param snap If true tells the actor to increate its turn speed.
|
||||
* @see turnTo
|
||||
* @see setRot
|
||||
*/
|
||||
void turnTo(const Math::Vector3d &pos);
|
||||
void turnTo(const Math::Vector3d &pos, bool snap = false);
|
||||
/**
|
||||
* Returns true if the actor is turning.
|
||||
*
|
||||
@ -558,6 +560,8 @@ private:
|
||||
Math::Angle _moveYaw;
|
||||
Math::Angle _movePitch;
|
||||
Math::Angle _moveRoll;
|
||||
// This is used to increase momentarily the turn rate when needed
|
||||
float _turnRateMultiplier;
|
||||
|
||||
// Variables for walking to a point
|
||||
bool _walking;
|
||||
|
@ -341,10 +341,7 @@ void Lua_V1::SetActorRot() {
|
||||
float pitch = lua_getnumber(p);
|
||||
float yaw = lua_getnumber(y);
|
||||
float roll = lua_getnumber(r);
|
||||
if (getbool(5))
|
||||
actor->turnTo(pitch, yaw, roll);
|
||||
else
|
||||
actor->setRot(pitch, yaw, roll);
|
||||
actor->turnTo(pitch, yaw, roll, getbool(5));
|
||||
}
|
||||
|
||||
void Lua_V1::GetActorRot() {
|
||||
@ -1174,7 +1171,7 @@ void Lua_V1::TurnActorTo() {
|
||||
}
|
||||
|
||||
Math::Vector3d turnToVector(x, y, z);
|
||||
actor->turnTo(turnToVector);
|
||||
actor->turnTo(turnToVector, false);
|
||||
|
||||
// Return true if the actor is still turning
|
||||
// This allows manny to have the right yaw when he exits the elevator in the garage
|
||||
|
Loading…
Reference in New Issue
Block a user