mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-01 08:23:15 +00:00
TITANIC: Better naming for CFlightManagerBase fields
This commit is contained in:
parent
0280ca2359
commit
da3c74224d
@ -26,17 +26,15 @@
|
||||
namespace Titanic {
|
||||
|
||||
CFlightManagerBase::CFlightManagerBase() : _srcPos(0.0, 1000000.0, 0.0) {
|
||||
_field4 = 0;
|
||||
_active = false;
|
||||
_distance = 0.0;
|
||||
_field34 = false;
|
||||
_field38 = 0.0;
|
||||
_field3C = 0;
|
||||
_field40 = 0;
|
||||
_field44 = 0;
|
||||
_field48 = 0;
|
||||
_field4C = 0;
|
||||
_field54 = 0;
|
||||
_flight = false;
|
||||
_step = 0.0;
|
||||
_step1 = 0;
|
||||
_accCount = 0;
|
||||
_traCount = 0;
|
||||
_decCount = 0;
|
||||
_totCount = 0;
|
||||
_transitionPercent = 0.0;
|
||||
_transitionPercentInc = 0.0;
|
||||
}
|
||||
@ -47,48 +45,48 @@ void CFlightManagerBase::clear() {
|
||||
_transitionPercent = 1.0;
|
||||
_distance = 0.0;
|
||||
_active = false;
|
||||
_field34 = false;
|
||||
_flight = false;
|
||||
}
|
||||
|
||||
void CFlightManagerBase::setPath(const FVector &srcV, const FVector &destV) {
|
||||
_srcPos = srcV;
|
||||
_destPos = destV;
|
||||
_posDelta = _destPos - _srcPos;
|
||||
void CFlightManagerBase::setPath(const FVector &from, const FVector &to) {
|
||||
_srcPos = from;
|
||||
_destPos = to;
|
||||
_direction = _destPos - _srcPos;
|
||||
|
||||
// normalization won't happen if _direction is zero vector and that is okay
|
||||
float temp = 0.0;
|
||||
_posDelta.normalize(temp); // normalization won't happen if _posDelta is zero vector
|
||||
// and that is okay
|
||||
_direction.normalize(temp);
|
||||
|
||||
_distance = temp;
|
||||
_active = false;
|
||||
_field34 = false;
|
||||
_field40 = -1;
|
||||
_field44 = -1;
|
||||
_field48 = -1;
|
||||
_field4C = -1;
|
||||
_flight = false;
|
||||
_accCount = -1;
|
||||
_traCount = -1;
|
||||
_decCount = -1;
|
||||
_totCount = -1;
|
||||
_transitionPercent = 1.0;
|
||||
}
|
||||
|
||||
void CFlightManagerBase::calcSpeeds(int val1, int val2, float distance) {
|
||||
// Usually val1 and val2 are small where as distance can be large
|
||||
_field44 = val1;
|
||||
_field4C = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
|
||||
_traCount = val1;
|
||||
_totCount = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
|
||||
// should it always be x2 (_nMoverTransitions - 1)?
|
||||
_field38 = distance / (double)(val1 + val2 * 2);
|
||||
_field40 = nMoverTransitions-1;
|
||||
_field48 = nMoverTransitions-1;
|
||||
_field3C = (double)val2 * _field38;
|
||||
_step = distance / (double)(val1 + val2 * 2);
|
||||
_accCount = nMoverTransitions-1;
|
||||
_decCount = nMoverTransitions-1;
|
||||
_step1 = (double)val2 * _step;
|
||||
|
||||
// Calculate the speeds for a graduated movement between stars
|
||||
double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125;
|
||||
for (int idx = nMoverTransitions - 1; idx >= 0; --idx) {
|
||||
_speeds[idx] = pow(base, power);
|
||||
total += _speeds[idx];
|
||||
_gammaTable[idx] = pow(base, power);
|
||||
total += _gammaTable[idx];
|
||||
base += baseInc;
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < nMoverTransitions; ++idx) {
|
||||
_speeds[idx] = _speeds[idx] * _field3C / total;
|
||||
_gammaTable[idx] = _gammaTable[idx] * _step1 / total;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,20 +39,18 @@ enum MoverState { NOT_ACTIVE = 0, MOVING = 1, DONE_MOVING = 2 };
|
||||
*/
|
||||
class CFlightManagerBase {
|
||||
protected:
|
||||
int _field4;
|
||||
bool _active;
|
||||
FVector _srcPos, _destPos;
|
||||
double _distance;
|
||||
FVector _posDelta;
|
||||
bool _field34;
|
||||
double _field38;
|
||||
double _field3C;
|
||||
int _field40;
|
||||
int _field44;
|
||||
int _field48;
|
||||
int _field4C;
|
||||
double _speeds[nMoverTransitions];
|
||||
int _field54;
|
||||
FVector _direction;
|
||||
bool _flight;
|
||||
double _step;
|
||||
double _step1;
|
||||
int _accCount;
|
||||
int _traCount;
|
||||
int _decCount;
|
||||
int _totCount;
|
||||
double _gammaTable[nMoverTransitions];
|
||||
double _transitionPercent;
|
||||
double _transitionPercentInc;
|
||||
COrientationChanger _orientationChanger;
|
||||
@ -68,7 +66,7 @@ public:
|
||||
/**
|
||||
* Setup a transition to from one position to another
|
||||
*/
|
||||
void setPath(const FVector &srcV, const FVector &destV);
|
||||
void setPath(const FVector &from, const FVector &to);
|
||||
|
||||
/**
|
||||
* Applys speeds to the mover. More than one application is usually done for several transitions
|
||||
|
@ -31,18 +31,18 @@ void CMarkedAutoMover::setPathOrients(const FVector &oldPos, const FVector &newP
|
||||
|
||||
double distance = _distance;
|
||||
_active = true;
|
||||
_field34 = true;
|
||||
_flight = true;
|
||||
calcSpeeds(120, 4, distance);
|
||||
|
||||
|
||||
_orientationChanger.load(oldOrientation, newOrientation);
|
||||
_transitionPercent = 0.0;
|
||||
|
||||
if (_field4C == 0) {
|
||||
if (_totCount == 0) {
|
||||
_transitionPercentInc = 0.1;
|
||||
_active = true;
|
||||
} else {
|
||||
_transitionPercentInc = 1.0 / _field4C;
|
||||
_transitionPercentInc = 1.0 / _totCount;
|
||||
_active = true;
|
||||
}
|
||||
|
||||
@ -56,27 +56,27 @@ MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &
|
||||
orientation = _orientationChanger.getOrientation(_transitionPercent);
|
||||
errorCode.set();
|
||||
|
||||
if (_field40 >= 0) {
|
||||
double speedVal = _speeds[_field40];
|
||||
pos += _posDelta * speedVal;
|
||||
if (_accCount >= 0) {
|
||||
double speedVal = _gammaTable[_accCount];
|
||||
pos += _direction * speedVal;
|
||||
getVectorOnPath(pos);
|
||||
|
||||
--_field40;
|
||||
--_accCount;
|
||||
errorCode.set();
|
||||
return MOVING;
|
||||
} else if (_field44 > 0) {
|
||||
pos += _posDelta * _field38;
|
||||
} else if (_traCount > 0) {
|
||||
pos += _direction * _step;
|
||||
getVectorOnPath(pos);
|
||||
|
||||
--_field44;
|
||||
--_traCount;
|
||||
errorCode.set();
|
||||
return MOVING;
|
||||
} else if (_field48 >= 0) {
|
||||
double speedVal = _speeds[nMoverTransitions - 1 - _field48];
|
||||
pos += _posDelta * speedVal;
|
||||
} else if (_decCount >= 0) {
|
||||
double speedVal = _gammaTable[nMoverTransitions - 1 - _decCount];
|
||||
pos += _direction * speedVal;
|
||||
getVectorOnPath(pos);
|
||||
|
||||
--_field48;
|
||||
--_decCount;
|
||||
errorCode.set();
|
||||
return MOVING;
|
||||
} else {
|
||||
@ -86,7 +86,7 @@ MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &
|
||||
}
|
||||
|
||||
void CMarkedAutoMover::getVectorOnPath(FVector &pos) const {
|
||||
double distance = _posDelta.getDistance(pos);
|
||||
double distance = _direction.getDistance(pos);
|
||||
distance /= _distance;
|
||||
|
||||
if (distance <= 0.0) {
|
||||
|
@ -31,7 +31,7 @@ void CFlightManagerUnmarked::setOrientations(const FMatrix &srcOrient, const FMa
|
||||
_orientationChanger.load(srcOrient, destOrient);
|
||||
_transitionPercentInc = 0.1;
|
||||
_transitionPercent = 0.0;
|
||||
_field40 = _field44 = _field48 = -1;
|
||||
_accCount = _traCount = _decCount = -1;
|
||||
_active = true;
|
||||
}
|
||||
|
||||
@ -40,12 +40,12 @@ void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &d
|
||||
|
||||
if (_distance > 8000.0) {
|
||||
_active = true;
|
||||
_field34 = 1;
|
||||
_flight = true;
|
||||
calcSpeeds(120, 4, _distance - 8000.0);
|
||||
}
|
||||
|
||||
FVector row3 = orientation._row3;
|
||||
double mult = _posDelta._x * row3._x + _posDelta._y * row3._y + _posDelta._z * row3._z;
|
||||
double mult = _direction._x * row3._x + _direction._y * row3._y + _direction._z * row3._z;
|
||||
_transitionPercent = 1.0;
|
||||
|
||||
bool flag = false;
|
||||
@ -59,7 +59,7 @@ void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &d
|
||||
|
||||
if (!flag) {
|
||||
FVector tempV1;
|
||||
tempV1 = row3.addAndNormalize(_posDelta);
|
||||
tempV1 = row3.addAndNormalize(_direction);
|
||||
tempV1 = row3.addAndNormalize(tempV1);
|
||||
tempV1 = row3.addAndNormalize(tempV1);
|
||||
tempV1 = row3.addAndNormalize(tempV1);
|
||||
@ -90,7 +90,7 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
|
||||
}
|
||||
|
||||
// From here on, we handle the movement to the given destination
|
||||
if (!_field34) {
|
||||
if (!_flight) {
|
||||
_active = false;
|
||||
return DONE_MOVING;
|
||||
}
|
||||
@ -125,30 +125,30 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
|
||||
v2 = v1;
|
||||
}
|
||||
|
||||
if (_field40 >= 0) {
|
||||
double speedVal = _speeds[_field40];
|
||||
if (_accCount >= 0) {
|
||||
double speedVal = _gammaTable[_accCount];
|
||||
v1 = v2 * speedVal;
|
||||
pos += v1;
|
||||
|
||||
--_field40;
|
||||
--_accCount;
|
||||
errorCode.set();
|
||||
return MOVING;
|
||||
}
|
||||
|
||||
if (_field44 > 0) {
|
||||
v1._z = v2._z * _field38;
|
||||
v1._x = v2._x * _field38;
|
||||
if (_traCount > 0) {
|
||||
v1._z = v2._z * _step;
|
||||
v1._x = v2._x * _step;
|
||||
pos._x = v1._x + pos._x;
|
||||
pos._y = v2._y * _field38 + pos._y;
|
||||
pos._y = v2._y * _step + pos._y;
|
||||
pos._z = v1._z + pos._z;
|
||||
|
||||
--_field44;
|
||||
--_traCount;
|
||||
errorCode.set();
|
||||
return MOVING;
|
||||
}
|
||||
|
||||
if (_field48 >= 0) {
|
||||
double speedVal = _speeds[nMoverTransitions - 1 - _field48];
|
||||
if (_decCount >= 0) {
|
||||
double speedVal = _gammaTable[nMoverTransitions - 1 - _decCount];
|
||||
v1._y = v2._y * speedVal;
|
||||
v1._z = v2._z * speedVal;
|
||||
v1._x = v2._x * speedVal;
|
||||
@ -156,7 +156,7 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
|
||||
pos._z = v1._z + pos._z;
|
||||
pos._x = pos._x + v1._x;
|
||||
|
||||
--_field48;
|
||||
--_decCount;
|
||||
errorCode.set();
|
||||
return MOVING;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user