[Scummvm-git-logs] scummvm master -> ceb329ad0e913288309aef1cfe9696bce4f93e7e

dreammaster dreammaster at scummvm.org
Wed Aug 23 01:53:56 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:
ceb329ad0e TITANIC: Formatting fixes for star control classes


Commit: ceb329ad0e913288309aef1cfe9696bce4f93e7e
    https://github.com/scummvm/scummvm/commit/ceb329ad0e913288309aef1cfe9696bce4f93e7e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-08-22T19:53:47-04:00

Commit Message:
TITANIC: Formatting fixes for star control classes

Changed paths:
    engines/titanic/star_control/camera_auto_mover.cpp
    engines/titanic/star_control/daffine.cpp
    engines/titanic/star_control/daffine.h
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/fmatrix.cpp
    engines/titanic/star_control/fpose.cpp
    engines/titanic/star_control/fpose.h
    engines/titanic/star_control/fvector.cpp
    engines/titanic/star_control/fvector.h
    engines/titanic/star_control/unmarked_auto_mover.cpp


diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
index aa29fa0..0bde472 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -49,9 +49,10 @@ void CCameraAutoMover::proc2(const FVector &oldPos, const FVector &newPos,
 	_srcPos = oldPos;
 	_destPos = newPos;
 	_posDelta = _destPos - _srcPos;
-       float temp = 0.0;
+
+	float temp = 0.0;
 	_posDelta.normalize(temp); // Do the normalization, put the scale amount in temp
-       _distance = temp;
+	_distance = temp;
 	_active = false;
 	_field34 = false;
 	_transitionPercent = 1.0;
@@ -74,12 +75,15 @@ void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV, const
 	_srcPos = srcV;
 	_destPos = destV;
 	_posDelta = _destPos - _srcPos;
-       float temp = 0.0;
-	if (!_posDelta.normalize(temp)) { // Do the normalization, put the scale amount in temp,
-                                         // but if it is unsuccessful, crash
-              assert(temp);
-       }
-       _distance = temp;
+
+	float temp = 0.0;
+	if (!_posDelta.normalize(temp)) {
+		// Do the normalization, put the scale amount in temp,
+		// but if it is unsuccessful, crash
+		assert(temp);
+	}
+
+	_distance = temp;
 	_active = false;
 	_field34 = false;
 	_field40 = -1;
@@ -93,7 +97,7 @@ void CCameraAutoMover::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; // For _nMoverTransitions = 32 this second value was 64, 
-				 		     // should it always be x2 _nMoverTransitions?
+				// should it always be x2 _nMoverTransitions?
 	_field38 = distance / (double)(val1 + val2 * 2);
 	_field40 = nMoverTransitions-1;
 	_field48 = nMoverTransitions-1;
diff --git a/engines/titanic/star_control/daffine.cpp b/engines/titanic/star_control/daffine.cpp
index 261d310..8cfd9ec 100644
--- a/engines/titanic/star_control/daffine.cpp
+++ b/engines/titanic/star_control/daffine.cpp
@@ -80,7 +80,7 @@ void DAffine::clear() {
 
 // Source: https://en.wikipedia.org/wiki/Rotation_matrix
 void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
-        clear();
+	clear();
 
 	double sinVal = sin(angleDeg * Deg2Rad);
 	double cosVal = cos(angleDeg * Deg2Rad);
@@ -117,8 +117,9 @@ void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
 
 //TODO: Check column 4 math
 DAffine DAffine::inverseTransform() const {
-        DAffine m;
-       //Inverse of rotation matrix is the transpose
+	DAffine m;
+
+	// Inverse of rotation matrix is the transpose
 	m._col1._x = _col1._x;
 	m._col2._x = _col1._y;
 	m._col3._x = _col1._z;
@@ -130,14 +131,14 @@ DAffine DAffine::inverseTransform() const {
 	m._col3._z = _col3._z;
 
 	m._col4._x = -(_col4._x * m._col1._x
-                    + _col4._y * m._col2._x
-		     + _col4._z * m._col3._x);
+		+ _col4._y * m._col2._x
+		+ _col4._z * m._col3._x);
 	m._col4._y = -(_col4._x * m._col1._y
-                    + _col4._y * m._col2._y
-                    + _col4._z * m._col3._y);
+		+ _col4._y * m._col2._y
+		+ _col4._z * m._col3._y);
 	m._col4._z = -(_col4._x * m._col1._z
-                    + _col4._y * m._col2._z
-                    + _col4._z * m._col3._z);
+		+ _col4._y * m._col2._z
+		+ _col4._z * m._col3._z);
 	return m;
 }
 
diff --git a/engines/titanic/star_control/daffine.h b/engines/titanic/star_control/daffine.h
index 074c135..6e1eccc 100644
--- a/engines/titanic/star_control/daffine.h
+++ b/engines/titanic/star_control/daffine.h
@@ -47,7 +47,7 @@ public:
 	DVector _col4;
 public:
 	DAffine();
-        //TODO: consider making mode an enum since that is more helpful when it is used in code
+	// TODO: consider making mode an enum since that is more helpful when it is used in code
 	DAffine(int mode, const DVector &src);
 	DAffine(Axis axis, double angleDeg);
 	DAffine(const FMatrix &src);
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 405af4a..d1236ec 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -29,8 +29,8 @@ namespace Titanic {
 bool DVector::normalize(double & hyp) {
 	hyp = sqrt(_x * _x + _y * _y + _z * _z);
 	if (hyp==0) {
-              return false;
-       }
+		return false;
+	}
 
 	_x *= 1.0 / hyp;
 	_y *= 1.0 / hyp;
@@ -44,20 +44,17 @@ double DVector::getDistance(const DVector &src) {
 
 DVector DVector::dAffMatrixProdVec(const DAffine &m) {
 	DVector dest;
-	dest._x = m._col1._x * _x +
-                  m._col2._x * _y +
-                  m._col3._x * _z +
-                  m._col4._x;
+	dest._x = m._col1._x * _x
+		+ m._col2._x * _y + m._col3._x * _z
+		+ m._col4._x;
 
-	dest._y = m._col1._y * _x +
-                  m._col2._y * _y +
-                  m._col3._y * _z +
-                  m._col4._y;
+	dest._y = m._col1._y * _x
+		+ m._col2._y * _y + m._col3._y * _z
+		+ m._col4._y;
 
-	dest._z = m._col1._z * _x +
-                  m._col2._z * _y +
-                  m._col3._z * _z +
-                  m._col4._z;
+	dest._z = m._col1._z * _x
+		+ m._col2._z * _y + m._col3._z * _z
+		+ m._col4._z;
 
 	return dest;
 }
@@ -76,12 +73,14 @@ DVector DVector::getAnglesAsVect() const {
 	DVector vector = *this;
 	DVector dest;
 
-       if (!vector.normalize(dest._x)) {  // Makes this vector have magnitude=1, put the scale amount in dest._x,
-                                          // but if it is unsuccessful, crash
-              assert(dest._x);
-       }
-	dest._y = acos(vector._y);    // radian distance/angle that this vector's y component is from the +y axis,
-                                      // result is restricted to [0,pi]
+	if (!vector.normalize(dest._x)) {
+		// Makes this vector have magnitude=1, put the scale amount in dest._x,
+		// but if it is unsuccessful, crash
+		assert(dest._x);
+	}
+
+	dest._y = acos(vector._y);	// radian distance/angle that this vector's y component is from the +y axis,
+								// result is restricted to [0,pi]
 	dest._z = atan2(vector._x,vector._z); // result is restricted to [-pi,pi]
 
 	return dest;
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index f115abd..4b85c03 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -46,12 +46,12 @@ public:
 
 	/**
 	 * Attempts to normalizes the vector so the length from origin equals 1.0
-        * Return value is whether or not it was successful in normalizing
-        * First argument is scale value that normalizes the vector
-        * TODO: split this function into 2. One that calculates the normalization
-        * and another that does the normalization. The 2nd would assert if a 
-        * normalization of one was requested. This is cleaner than the current 
-        * implementation.
+	 * Return value is whether or not it was successful in normalizing
+	 * First argument is scale value that normalizes the vector
+	 * TODO: split this function into 2. One that calculates the normalization
+	 * and another that does the normalization. The 2nd would assert if a 
+	 * normalization of one was requested. This is cleaner than the current 
+	 * implementation.
 	 */
 	bool normalize(double &);
 
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index e633db5..bb002fa 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -128,17 +128,19 @@ void FMatrix::set(const FVector &v) {
 
 	_row1 = _row3.crossProduct(_row2);
 
-       float unused_scale=0.0;
-       if (!_row1.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
-                                              // but if it is unsuccessful, crash
-              assert(unused_scale);
-       }
+	float unused_scale=0.0;
+	if (!_row1.normalize(unused_scale)) {
+		// Do the normalization, put the scale amount in unused_scale,
+		// but if it is unsuccessful, crash
+		assert(unused_scale);
+	}
 
 	_row2 = _row3.crossProduct(_row1);
-       if (!_row2.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
-                                              // but if it is unsuccessful, crash
-              assert(unused_scale);
-       }
+	if (!_row2.normalize(unused_scale)) {
+		// Do the normalization, put the scale amount in unused_scale,
+		// but if it is unsuccessful, crash
+		assert(unused_scale);
+	}
 }
 
 void FMatrix::matRProd(const FMatrix &m) {
diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp
index a3697ae..e7aafcf 100644
--- a/engines/titanic/star_control/fpose.cpp
+++ b/engines/titanic/star_control/fpose.cpp
@@ -160,14 +160,14 @@ FPose FPose::inverseTransform() const {
 	result._row3._z = _row3._z;
 
 	result._vector._x = -(_vector._x * result._row1._x
-		            + _vector._y * result._row2._x
-		            + _vector._z * result._row3._x);
+		+ _vector._y * result._row2._x
+		+ _vector._z * result._row3._x);
 	result._vector._y = -(_vector._x * result._row1._y
-                           + _vector._y * result._row2._y
-                           + _vector._z * result._row3._y);
+		+ _vector._y * result._row2._y
+		+ _vector._z * result._row3._y);
 	result._vector._z = -(_vector._x * result._row1._z
-                           + _vector._y * result._row2._z
-                           + _vector._z * result._row3._z);
+		+ _vector._y * result._row2._z
+		+ _vector._z * result._row3._z);
 
 	return result;
 }
diff --git a/engines/titanic/star_control/fpose.h b/engines/titanic/star_control/fpose.h
index f1f00ea..c25790f 100644
--- a/engines/titanic/star_control/fpose.h
+++ b/engines/titanic/star_control/fpose.h
@@ -60,9 +60,9 @@ public:
 	 */
 	void copyFrom(const FMatrix &src);
 
-        /**
-         * The inverse of rotation and the position vector
-         */
+	/**
+	 * The inverse of rotation and the position vector
+	 */
 	FPose inverseTransform() const;
 };
 
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index 142d9ea..fee74e6 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -51,8 +51,8 @@ FVector FVector::crossProduct(const FVector &src) const {
 bool FVector::normalize(float & hyp) {
 	hyp = sqrt(_x * _x + _y * _y + _z * _z);
 	if (hyp==0) {
-              return false;
-       }
+		return false;
+	}
 
 	_x *= 1.0 / hyp;
 	_y *= 1.0 / hyp;
@@ -62,11 +62,14 @@ bool FVector::normalize(float & hyp) {
 
 FVector FVector::addAndNormalize(const FVector &v) const {
 	FVector tempV(_x + v._x, _y + v._y, _z + v._z);
-       float unused_scale=0.0;
-       if (!tempV.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
-                                              // but if it is unsuccessful, crash
-              assert(unused_scale);
-       }
+
+	float unusedScale = 0.0;
+	if (!tempV.normalize(unusedScale)) {
+		// Do the normalization, put the scale amount in unusedScale,
+		// but if it is unsuccessful, crash
+		assert(unusedScale);
+	}
+
 	return tempV;
 }
 
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index ed5789a..d4ba754 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -65,12 +65,12 @@ public:
 
 	/**
 	 * Attempts to normalizes the vector so the length from origin equals 1.0
-        * Return value is whether or not it was successful in normalizing
-        * First argument is scale value that normalizes the vector
-        * TODO: split this function into 2. One that calculates the normalization
-        * and another that does the normalization. The 2nd would assert if a 
-        * normalization of one was requested. This is cleaner than the current 
-        * implementation.
+	 * Return value is whether or not it was successful in normalizing
+	 * First argument is scale value that normalizes the vector
+	 * TODO: split this function into 2. One that calculates the normalization
+	 * and another that does the normalization. The 2nd would assert if a
+	 * normalization of one was requested. This is cleaner than the current
+	 * implementation.
 	 */
 	bool normalize(float &);
 
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
index 424e143..429e42d 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ b/engines/titanic/star_control/unmarked_auto_mover.cpp
@@ -99,11 +99,12 @@ int CUnmarkedAutoMover::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orie
 	v2 = orientation._row3;
 	v3 = _destPos - pos;
 
-       float unused_scale=0.0;
-       if (!v3.normalize(unused_scale)) {  // Do the normalization, put the scale amount in unused_scale,
-                                           // but if it is unsuccessful, crash
-              assert(unused_scale);
-       }
+	float unusedScale = 0.0;
+	if (!v3.normalize(unusedScale)) {
+		// Do the normalization, put the scale amount in unusedScale,
+		// but if it is unsuccessful, crash
+		assert(unusedScale);
+	}
 
 	double val = orientation._row3._x * v3._x + orientation._row3._y * v3._y + orientation._row3._z * v3._z;
 	bool flag = false;





More information about the Scummvm-git-logs mailing list