Skip to content

Commit

Permalink
TITANIC: Fix some vector calculations in marker lock-on code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 4, 2017
1 parent 8c31328 commit 44fce15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions engines/titanic/star_control/dvector.cpp
Expand Up @@ -60,18 +60,18 @@ DVector DVector::fn3() const {
DVector vector = *this;
DVector dest;
dest._x = vector.normalize();
dest._z = acos(vector._y);
dest._y = acos(vector._y);

if (ABS(vector._z) < 0.00001) {
if (vector._x < 0.0) {
dest._y = 2 * M_PI - (M_PI / 2.0);
dest._z = 2 * M_PI - (M_PI / 2.0);
} else {
dest._y = M_PI / 2.0;
dest._z = M_PI / 2.0;
}
} else {
dest._y = atan(vector._x / vector._z);
dest._z = atan(vector._x / vector._z);
if (vector._x < 0.0)
dest._y += 2 * M_PI;
dest._z += 2 * M_PI;
}

return dest;
Expand All @@ -80,8 +80,8 @@ DVector DVector::fn3() const {
DMatrix DVector::fn4(const DVector &v) {
const double FACTOR = 180.0 / M_PI;
DMatrix matrix1, matrix2, matrix3, matrix4;
DVector vector1 = fn3();

DVector vector1 = fn3();
matrix1.setRotationMatrix(X_AXIS, vector1._y * FACTOR);
matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * FACTOR));
matrix3 = matrix1.fn4(matrix2);
Expand All @@ -91,7 +91,6 @@ DMatrix DVector::fn4(const DVector &v) {
matrix1.setRotationMatrix(X_AXIS, vector1._y * FACTOR);
matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * FACTOR));
matrix3 = matrix1.fn4(matrix2);
matrix4 = matrix1.fn1();

return matrix4.fn4(matrix3);
}
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/star_control_sub21.cpp
Expand Up @@ -48,7 +48,7 @@ void CStarControlSub21::proc10(const FVector &v1, const FVector &v2, const FVect
DVector vector1 = v1;
DVector vector2 = v2;
DMatrix matrix1 = vector2.fn4(vector1);
FMatrix matrix2 = matrix1.fn4(m);
DMatrix matrix2 = matrix1.fn4(m);

_sub24.proc3(m, matrix2);
incLockCount();
Expand Down

0 comments on commit 44fce15

Please sign in to comment.