[Scummvm-git-logs] scummvm master -> 3bfc3f77dc7f47a5cc6ee8b615a9e87e8f3db51a

dreammaster dreammaster at scummvm.org
Mon Mar 13 00:56:02 CET 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:
3bfc3f77dc TITANIC: More matrix renamings, thanks to Dark-Star


Commit: 3bfc3f77dc7f47a5cc6ee8b615a9e87e8f3db51a
    https://github.com/scummvm/scummvm/commit/3bfc3f77dc7f47a5cc6ee8b615a9e87e8f3db51a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-12T19:55:56-04:00

Commit Message:
TITANIC: More matrix renamings, thanks to Dark-Star

Changed paths:
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fmatrix.h
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h
    engines/titanic/star_control/star_control_sub13.cpp
    engines/titanic/star_control/star_control_sub23.cpp
    engines/titanic/star_control/star_control_sub6.cpp
    engines/titanic/star_control/star_control_sub6.h
    engines/titanic/star_control/star_view.cpp


diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index f3cf19c..e0c270b 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -67,6 +67,12 @@ void FMatrix::save(SimpleFile *file, int indent) {
 }
 
 void FMatrix::clear() {
+	_row1.clear();
+	_row2.clear();
+	_row3.clear();
+}
+
+void FMatrix::identity() {
 	_row1 = FVector(1.0, 0.0, 0.0);
 	_row2 = FVector(0.0, 1.0, 0.0);
 	_row3 = FVector(0.0, 0.0, 1.0);
@@ -88,17 +94,17 @@ void FMatrix::fn1(const FVector &v) {
 	_row2._y = tempVector._y;
 	_row2._z = tempVector._z;
 
-	_row3.multiply(&tempVector, &_row2);
+	_row3.crossProduct(&tempVector, &_row2);
 	_row1._x = _row2._x;
 	_row1._y = _row2._y;
 	_row1._z = _row2._z;
-	_row1.fn3();
+	_row1.normalize();
 
-	_row3.multiply(&tempVector, &_row1);
+	_row3.crossProduct(&tempVector, &_row1);
 	_row2._x = _row1._x;
 	_row2._y = _row1._y;
 	_row2._z = _row1._z;
-	_row2.fn3();
+	_row2.normalize();
 }
 
 void FMatrix::fn2(const FMatrix &m) {
diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h
index b0dc709..282338c 100644
--- a/engines/titanic/star_control/fmatrix.h
+++ b/engines/titanic/star_control/fmatrix.h
@@ -65,6 +65,11 @@ public:
 	void clear();
 
 	/**
+	 * Sets up an identity matrix
+	 */
+	void identity();
+
+	/**
 	 * Sets the data for the matrix
 	 */
 	void set(FVector *row1, FVector *row2, FVector *row3);
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index de33bcf..b0667c5 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -34,13 +34,13 @@ void FVector::fn1(FVector *v) {
 	v->_z = _z;
 }
 
-void FVector::multiply(FVector *dest, const FVector *src) {
+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);
 }
 
-double FVector::fn3() {
+double FVector::normalize() {
 	double hyp = sqrt(_x * _x + _y * _y + _z * _z);
 	assert(hyp);
 
@@ -50,6 +50,13 @@ double FVector::fn3() {
 	return hyp;
 }
 
+void FVector::addAndNormalize(FVector *dest, const FVector *v1, const FVector *v2) {
+	FVector tempVector(v1->_x + v2->_x, v1->_y + v2->_y, v1->_z + v2->_z);
+	tempVector.normalize();
+
+	*dest = tempVector;
+}
+
 double FVector::getDistance(const FVector *src) const {
 	double xd = src->_x - _x;
 	double yd = src->_y - _y;
@@ -58,13 +65,6 @@ double FVector::getDistance(const FVector *src) const {
 	return sqrt(xd * xd + yd * yd + zd * zd);
 }
 
-void FVector::fn4(FVector *dest, const FVector *v1, const FVector *v2) {
-	FVector tempVector(v1->_x + v2->_x, v1->_y + v2->_y, v1->_z + v2->_z);
-	tempVector.fn3();
-
-	*dest = tempVector;
-}
-
 void FVector::fn5(FVector *dest, const CStarControlSub6 *sub6) const {
 	error("TODO: FVector::fn5");
 }
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index 71336eb..83f0039 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -48,15 +48,27 @@ public:
 	}
 
 	void fn1(FVector *v);
-	void multiply(FVector *dest, const FVector *src);
-	double fn3();
+
+	/**
+	 * Calculates the cross-product between this matrix and a passed one
+	 */
+	void crossProduct(FVector *dest, const FVector *src);
+
+	/**
+	 * Normalizes the vector so the length from origin equals 1.0
+	 */
+	double normalize();
+
+	/**
+	 * Adds two vectors together and then normalizes the result
+	 */
+	static void addAndNormalize(FVector *dest, const FVector *v1, const FVector *v2);
 
 	/**
 	 * Returns the distance between a specified point and this one
 	 */
 	double getDistance(const FVector *src) const;
 
-	static void fn4(FVector *dest, const FVector *v1, const FVector *v2);
 	void fn5(FVector *dest, const CStarControlSub6 *sub6) const;
 
 	/**
diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp
index 5e33eeb..cd7f0bb 100644
--- a/engines/titanic/star_control/star_control_sub13.cpp
+++ b/engines/titanic/star_control/star_control_sub13.cpp
@@ -156,7 +156,7 @@ void CStarControlSub13::set1C(double v) {
 }
 
 void CStarControlSub13::fn12() {
-	_matrix.clear();
+	_matrix.identity();
 
 	CStarControlSub6 m1(0, g_vm->getRandomNumber(359));
 	CStarControlSub6 m2(1, g_vm->getRandomNumber(359));
diff --git a/engines/titanic/star_control/star_control_sub23.cpp b/engines/titanic/star_control/star_control_sub23.cpp
index 40dbb8d..5d09475 100644
--- a/engines/titanic/star_control/star_control_sub23.cpp
+++ b/engines/titanic/star_control/star_control_sub23.cpp
@@ -47,7 +47,7 @@ void CStarControlSub23::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2
 	_row1 = v1;
 	_row2 = v2;
 	_row3 = _row2 - _row1;
-	_field24 = _row3.fn3();
+	_field24 = _row3.normalize();
 
 	_field58 = 0;
 	_field8 = 0;
@@ -74,7 +74,7 @@ void CStarControlSub23::proc4(FVector &v1, FVector &v2, FMatrix &m) {
 	_row2 = v2;
 	FVector vector = _row2 - _row1;
 	_row3 = vector;
-	_field24 = _row3.fn3();
+	_field24 = _row3.normalize();
 
 	_field8 = 0;
 	_field34 = 0;
diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp
index b1dd9e4..f0ec68e 100644
--- a/engines/titanic/star_control/star_control_sub6.cpp
+++ b/engines/titanic/star_control/star_control_sub6.cpp
@@ -47,8 +47,8 @@ void CStarControlSub6::deinit() {
 	_static = nullptr;
 }
 
-void CStarControlSub6::clear() {
-	FMatrix::clear();
+void CStarControlSub6::identity() {
+	FMatrix::identity();
 	_vector.clear();
 }
 
diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/star_control_sub6.h
index 572ac4a..d638680 100644
--- a/engines/titanic/star_control/star_control_sub6.h
+++ b/engines/titanic/star_control/star_control_sub6.h
@@ -41,9 +41,9 @@ public:
 	CStarControlSub6(const CStarControlSub6 *src);
 
 	/**
-	 * Clear the item
+	 * Sets an identity matrix
 	 */
-	void clear();
+	void identity();
 
 	/**
 	 * Sets up a passed instance from the specified two other ones
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index f320bba..540d2c7 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -450,7 +450,7 @@ void CStarView::randomizeVectors1(FVector &v1, FVector &v2) {
 	v2._x = vx;
 	v2._y = vy;
 	v2._z = -v1._z;
-	v2.fn3();
+	v2.normalize();
 }
 
 void CStarView::randomizeVectors2(FVector &v1, FVector &v2) {
@@ -462,7 +462,7 @@ void CStarView::randomizeVectors2(FVector &v1, FVector &v2) {
 	v2._x = -v1._x;
 	v2._y = -v1._y;
 	v2._z = -v1._z;
-	v2.fn3();
+	v2.normalize();
 }
 
 void CStarView::randomizeVectors3(FVector &v1, FVector &v2) {
@@ -474,7 +474,7 @@ void CStarView::randomizeVectors3(FVector &v1, FVector &v2) {
 	v2._x = -v1._x;
 	v2._y = -v1._y;
 	v2._z = -v1._z;
-	v2.fn3();
+	v2.normalize();
 }
 
 void CStarView::randomizeVectors4(FVector &v1, FVector &v2) {
@@ -486,7 +486,7 @@ void CStarView::randomizeVectors4(FVector &v1, FVector &v2) {
 	v2._x = -v1._x;
 	v2._y = -v1._y;
 	v2._z = -v1._z;
-	v2.fn3();
+	v2.normalize();
 }
 void CStarView::resizeSurface(CScreenManager *scrManager, int width, int height,
 		CVideoSurface **surface) {





More information about the Scummvm-git-logs mailing list