diff options
-rw-r--r-- | engines/titanic/star_control/fmatrix.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/star_control/fvector.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/star_control/fvector.h | 4 |
3 files changed, 19 insertions, 27 deletions
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp index a4cfec8b40..5885658835 100644 --- a/engines/titanic/star_control/fmatrix.cpp +++ b/engines/titanic/star_control/fmatrix.cpp @@ -94,25 +94,13 @@ void FMatrix::set(const DVector &row1, const DVector &row2, const DVector &row3) } void FMatrix::fn1(const FVector &v) { - _row3._x = v._x; + _row3 = v; + _row2 = _row3.fn1(); - FVector tempVector; - _row3.fn1(&tempVector); - - _row2._x = tempVector._x; - _row2._y = tempVector._y; - _row2._z = tempVector._z; - - _row3.crossProduct(tempVector, _row2); - _row1._x = _row2._x; - _row1._y = _row2._y; - _row1._z = _row2._z; + _row1 = _row3.crossProduct(_row2); _row1.normalize(); - _row3.crossProduct(tempVector, _row1); - _row2._x = _row1._x; - _row2._y = _row1._y; - _row2._z = _row1._z; + _row2 = _row3.crossProduct(_row1); _row2.normalize(); } diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp index da7f37cebc..456a57f2cb 100644 --- a/engines/titanic/star_control/fvector.cpp +++ b/engines/titanic/star_control/fvector.cpp @@ -31,17 +31,21 @@ namespace Titanic { FVector::FVector(const DVector &src) : _x(src._x), _y(src._y), _z(src._z) { } -void FVector::fn1(FVector *v) { - v->_x = (ABS(_x - _y) < 0.00001 && ABS(_y - _z) < 0.00001 && - ABS(_x - _z) < 0.00001) ? -_x : _x; - v->_y = _y; - v->_z = _z; +FVector FVector::fn1() const { + return FVector( + (ABS(_x - _y) < 0.00001 && ABS(_y - _z) < 0.00001 && + ABS(_x - _z) < 0.00001) ? -_x : _x, + _z, + _y + ); } -void FVector::crossProduct(FVector &dest, const FVector &src) { - dest._x = (src._z * _y) - (_z * src._y); - dest._y = (src._x * _z) - (_x * src._z); - dest._z = (src._y * _x) - (_y * src._x); +FVector FVector::crossProduct(const FVector &src) const { + return FVector( + src._z * _y - _z * src._y, + src._x * _z - _x * src._z, + src._y * _x - _y * src._x + ); } double FVector::normalize() { diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h index 67eba6b5c9..0dea0c32bb 100644 --- a/engines/titanic/star_control/fvector.h +++ b/engines/titanic/star_control/fvector.h @@ -51,12 +51,12 @@ public: _x = _y = _z = 0.0; } - void fn1(FVector *v); + FVector fn1() const; /** * Calculates the cross-product between this matrix and a passed one */ - void crossProduct(FVector &dest, const FVector &src); + FVector crossProduct(const FVector &src) const; /** * Normalizes the vector so the length from origin equals 1.0 |