[Scummvm-git-logs] scummvm master -> 5e4feaf86a4209323cccf5629a7c2921ee9d4499

dreammaster dreammaster at scummvm.org
Wed Mar 29 03:12:12 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5e4feaf86a TITANIC: Cleanup for FMatrix fn1 and called methods


Commit: 5e4feaf86a4209323cccf5629a7c2921ee9d4499
    https://github.com/scummvm/scummvm/commit/5e4feaf86a4209323cccf5629a7c2921ee9d4499
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-28T21:11:58-04:00

Commit Message:
TITANIC: Cleanup for FMatrix fn1 and called methods

Changed paths:
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h


diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index a4cfec8..5885658 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 da7f37c..456a57f 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 67eba6b..0dea0c3 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





More information about the Scummvm-git-logs mailing list