[Scummvm-git-logs] scummvm master -> 9fa832a2b661a8051606650678f5e39c17682c86

dreammaster dreammaster at scummvm.org
Sun Aug 13 21:16:48 CEST 2017


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

Summary:
a319941436 TITANIC: Star control dvector work, renamed fn1 to DAffMatrixProdVec
18e52ef1ea TITANIC: star control dvector rename fn2 to RotVectAxisY
ba128368e8 TITANIC: star control dvector work, replace fn3 with getAnglesAsVect also replace atan2 implementation
5a770437bd TITANIC: dvect work, replace fn4 with getFrameTransform
d1f9aa8fe3 TITANIC: dvector work, fn5 renamed to RotXY
9fa832a2b6 Merge pull request #989 from dafioram/dvector_refactor


Commit: a3199414369bcdf51f6425b83d00263999285404
    https://github.com/scummvm/scummvm/commit/a3199414369bcdf51f6425b83d00263999285404
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-12T18:32:52-07:00

Commit Message:
TITANIC: Star control dvector work, renamed fn1 to DAffMatrixProdVec

It does a matrix product with a vector and a z translation

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/star_camera.cpp


diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 0a6fa97..1408740 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -40,11 +40,23 @@ double DVector::getDistance(const DVector &src) {
 	return sqrt((src._x - _x) * (src._x - _x) + (src._y - _y) * (src._y - _y) + (src._z - _z) * (src._z - _z));
 }
 
-DVector DVector::fn1(const DAffine &m) {
+DVector DVector::DAffMatrixProdVec(const DAffine &m) {
 	DVector dest;
-	dest._x = m._col3._x * _z + m._col2._x * _y + m._col1._x * _x + m._col4._x;
-	dest._y = m._col2._y * _y + m._col3._y * _z + m._col1._y * _x + m._col4._y;
-	dest._z = m._col3._z * _z + m._col2._z * _y + m._col1._z * _x + m._col4._z;
+	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._z = m._col1._z * _x +
+                  m._col2._z * _y +
+                  m._col3._z * _z +
+                  m._col4._z;
+
 	return dest;
 }
 
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index 94df30e..cd57cbc 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -48,7 +48,13 @@ public:
 	 */
 	double getDistance(const DVector &src);
 
-	DVector fn1(const DAffine &m);
+	/**
+	 * Returns the matrix product with this vector and 
+         * also does a z translations
+	 * Doesn't change this vector
+	 */
+	DVector DAffMatrixProdVec(const DAffine &m);
+
 	void fn2(double angle);
 	DVector fn3() const;
 	DAffine fn4(const DVector &v);
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index 6829194..dcc295a 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -321,15 +321,15 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		tempV7._x = m3._row3._x * 1000000.0 + tempV3._x;
 
 		mrow3 = tempV8 = tempV7;
-		tempV3 = tempV3.fn1(subX);
-		mrow1 = mrow1.fn1(subX);
-		mrow2 = mrow2.fn1(subX);
-		mrow3 = mrow3.fn1(subX);
+		tempV3 = tempV3.DAffMatrixProdVec(subX);
+		mrow1 = mrow1.DAffMatrixProdVec(subX);
+		mrow2 = mrow2.DAffMatrixProdVec(subX);
+		mrow3 = mrow3.DAffMatrixProdVec(subX);
 
-		tempV3 = tempV3.fn1(m1);
-		mrow1 = mrow1.fn1(m1);
-		mrow2 = mrow2.fn1(m1);
-		mrow3 = mrow3.fn1(m1);
+		tempV3 = tempV3.DAffMatrixProdVec(m1);
+		mrow1 = mrow1.DAffMatrixProdVec(m1);
+		mrow2 = mrow2.DAffMatrixProdVec(m1);
+		mrow3 = mrow3.DAffMatrixProdVec(m1);
 
 		mrow1 -= tempV3;
 		mrow2 -= tempV3;
@@ -497,11 +497,11 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	tempV3._z = m5._row3._z * 1000000.0 + m4._col1._z;
 	m4._col4 = tempV3;
 
-	tempV2 = tempV2.fn1(m2);
-	m4._col1 = m4._col1.fn1(m2);
-	m4._col3 = m4._col3.fn1(m2);
-	m4._col2 = m4._col2.fn1(m2);
-	m4._col4 = m4._col4.fn1(m2);
+	tempV2 = tempV2.DAffMatrixProdVec(m2);
+	m4._col1 = m4._col1.DAffMatrixProdVec(m2);
+	m4._col3 = m4._col3.DAffMatrixProdVec(m2);
+	m4._col2 = m4._col2.DAffMatrixProdVec(m2);
+	m4._col4 = m4._col4.DAffMatrixProdVec(m2);
 
 	// Find the angle that gives the minimum distance
 	DVector tempPos;
@@ -522,10 +522,10 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	m4._col2.fn2((double)minDegree);
 	m4._col3.fn2((double)minDegree);
 	m4._col4.fn2((double)minDegree);
-	m4._col1 = m4._col1.fn1(m1);
-	m4._col2 = m4._col2.fn1(m1);
-	m4._col3 = m4._col3.fn1(m1);
-	m4._col4 = m4._col4.fn1(m1);
+	m4._col1 = m4._col1.DAffMatrixProdVec(m1);
+	m4._col2 = m4._col2.DAffMatrixProdVec(m1);
+	m4._col3 = m4._col3.DAffMatrixProdVec(m1);
+	m4._col4 = m4._col4.DAffMatrixProdVec(m1);
 
 	m4._col3 -= m4._col1;
 	m4._col2 -= m4._col1;


Commit: 18e52ef1ea6f2fea5ea311c8d0307a1a65f15ece
    https://github.com/scummvm/scummvm/commit/18e52ef1ea6f2fea5ea311c8d0307a1a65f15ece
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-12T18:38:58-07:00

Commit Message:
TITANIC: star control dvector rename fn2 to RotVectAxisY

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/star_camera.cpp


diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 1408740..728c94e 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -60,10 +60,10 @@ DVector DVector::DAffMatrixProdVec(const DAffine &m) {
 	return dest;
 }
 
-void DVector::fn2(double angle) {
+void DVector::RotVectAxisY(double angle_deg) {
 	const double FACTOR = 2 * M_PI / 360.0;
-	double sinVal = sin(angle * FACTOR);
-	double cosVal = cos(angle * FACTOR);
+	double sinVal = sin(angle_deg * FACTOR);
+	double cosVal = cos(angle_deg * FACTOR);
 	double x = cosVal * _x - sinVal * _z;
 	double z = cosVal * _z + sinVal * _x;
 
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index cd57cbc..7daeda7 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -55,7 +55,11 @@ public:
 	 */
 	DVector DAffMatrixProdVec(const DAffine &m);
 
-	void fn2(double angle);
+	/**
+	 * Rotate this vector about the Y axis
+	 */
+	void RotVectAxisY(double angle_deg);
+
 	DVector fn3() const;
 	DAffine fn4(const DVector &v);
 	DAffine fn5() const;
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index dcc295a..6192fc5 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -509,7 +509,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 	int minDegree = 0;
 	for (int degree = 0; degree < 360; ++degree) {
 		tempPos = m4._col1;
-		tempPos.fn2((double)degree);
+		tempPos.RotVectAxisY((double)degree);
 		double distance = tempV2.getDistance(tempPos);
 
 		if (distance < minDistance) {
@@ -518,10 +518,10 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 		}
 	}
 
-	m4._col1.fn2((double)minDegree);
-	m4._col2.fn2((double)minDegree);
-	m4._col3.fn2((double)minDegree);
-	m4._col4.fn2((double)minDegree);
+	m4._col1.RotVectAxisY((double)minDegree);
+	m4._col2.RotVectAxisY((double)minDegree);
+	m4._col3.RotVectAxisY((double)minDegree);
+	m4._col4.RotVectAxisY((double)minDegree);
 	m4._col1 = m4._col1.DAffMatrixProdVec(m1);
 	m4._col2 = m4._col2.DAffMatrixProdVec(m1);
 	m4._col3 = m4._col3.DAffMatrixProdVec(m1);


Commit: ba128368e8e7c4c4369db48c0f024bd40e8dad80
    https://github.com/scummvm/scummvm/commit/ba128368e8e7c4c4369db48c0f024bd40e8dad80
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-12T20:31:16-07:00

Commit Message:
TITANIC: star control dvector work, replace fn3 with getAnglesAsVect also replace atan2 implementation

fn3 in dvector returns a vector that stores a magnitude, and 2 angles.
The second angle (the z component of the returned vector) was the angle
that the internal vector was between its z and x axis.

This angle was obtained by doing a poor man 4-quadrant atan implementation
and it gave large values for negative x. This has been replaced with the
atan2 standard function.

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h


diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 728c94e..86396c9 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -26,6 +26,9 @@
 
 namespace Titanic {
 
+const double Rad2Deg = 180.0 / M_PI;
+const double Deg2Rad = 1.0 / Rad2Deg;
+
 double DVector::normalize() {
 	double hyp = sqrt(_x * _x + _y * _y + _z * _z);
 	assert(hyp);
@@ -61,9 +64,8 @@ DVector DVector::DAffMatrixProdVec(const DAffine &m) {
 }
 
 void DVector::RotVectAxisY(double angle_deg) {
-	const double FACTOR = 2 * M_PI / 360.0;
-	double sinVal = sin(angle_deg * FACTOR);
-	double cosVal = cos(angle_deg * FACTOR);
+	double sinVal = sin(angle_deg * Deg2Rad);
+	double cosVal = cos(angle_deg * Deg2Rad);
 	double x = cosVal * _x - sinVal * _z;
 	double z = cosVal * _z + sinVal * _x;
 
@@ -71,51 +73,39 @@ void DVector::RotVectAxisY(double angle_deg) {
 	_z = z;
 }
 
-DVector DVector::fn3() const {
+DVector DVector::getAnglesAsVect() const {
 	DVector vector = *this;
 	DVector dest;
-	dest._x = vector.normalize();
-	dest._y = acos(vector._y);
-
-	if (ABS(vector._z) < 0.00001) {
-		if (vector._x < 0.0) {
-			dest._z = 2 * M_PI - (M_PI / 2.0);
-		} else {
-			dest._z = M_PI / 2.0;
-		}
-	} else {
-		dest._z = atan(vector._x / vector._z);
-		if (vector._x < 0.0)
-			dest._z += 2 * M_PI;
-	}
+	dest._x = vector.normalize(); // scale that makes this vector have magnitude=1, also does the scaling
+	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;
 }
 
 DAffine DVector::fn4(const DVector &v) {
-	const double FACTOR = 180.0 / M_PI;
 	DAffine matrix1, matrix2, matrix3, matrix4;
 
-	DVector vector1 = fn3();
-	matrix1.setRotationMatrix(X_AXIS, vector1._y * FACTOR);
-	matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * FACTOR));
+	DVector vector1 = getAnglesAsVect();
+	matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg);
+	matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * Rad2Deg));
 	matrix3 = matrix1.compose(matrix2);
 	matrix4 = matrix3.inverseTransform();
 
-	vector1 = v.fn3();
-	matrix1.setRotationMatrix(X_AXIS, vector1._y * FACTOR);
-	matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * FACTOR));
+	vector1 = v.getAnglesAsVect();
+	matrix1.setRotationMatrix(X_AXIS, vector1._y * Rad2Deg);
+	matrix2.setRotationMatrix(Y_AXIS, -(vector1._z * Rad2Deg));
 	matrix3 = matrix1.compose(matrix2);
 
 	return matrix4.compose(matrix3);
 }
 
 DAffine DVector::fn5() const {
-	const double FACTOR = 180.0 / M_PI;
-	DVector v1 = fn3();
+	DVector v1 = getAnglesAsVect();
 	DAffine m1, m2;
-	m1.setRotationMatrix(X_AXIS, v1._y * FACTOR);
-	m2.setRotationMatrix(Y_AXIS, -(v1._z * FACTOR));
+	m1.setRotationMatrix(X_AXIS, v1._y * Rad2Deg);
+	m2.setRotationMatrix(Y_AXIS, -(v1._z * Rad2Deg));
 	return m1.compose(m2);
 }
 
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index 7daeda7..b37c8bb 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -60,7 +60,13 @@ public:
 	 */
 	void RotVectAxisY(double angle_deg);
 
-	DVector fn3() const;
+	/**
+         * Returns a vector, v, that represents a magnitude, and two angles in radians
+	 * 1. Scale this vector to be unit magnitude and store scale in x component of v
+         * 2. X rotation angle from +y axis of this vector is put in y component of v
+         * 3. z component output of v is the 4-quadrant angle that z makes with x (Y axis rotation)
+	 */
+	DVector getAnglesAsVect() const;
 	DAffine fn4(const DVector &v);
 	DAffine fn5() const;
 


Commit: 5a770437bdd2065aa2a811c7741c29e29ed15b26
    https://github.com/scummvm/scummvm/commit/5a770437bdd2065aa2a811c7741c29e29ed15b26
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-12T21:16:43-07:00

Commit Message:
TITANIC: dvect work, replace fn4 with getFrameTransform

This function was using two vectors one as a frame rotation and
the other as a vector/point rotation.

This function is only used in when you click on a star in starview.

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/unmarked_camera_mover.cpp


diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 86396c9..93e52b3 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -84,7 +84,7 @@ DVector DVector::getAnglesAsVect() const {
 	return dest;
 }
 
-DAffine DVector::fn4(const DVector &v) {
+DAffine DVector::getFrameTransform(const DVector &v) {
 	DAffine matrix1, matrix2, matrix3, matrix4;
 
 	DVector vector1 = getAnglesAsVect();
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index b37c8bb..d0a87be 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -67,7 +67,12 @@ public:
          * 3. z component output of v is the 4-quadrant angle that z makes with x (Y axis rotation)
 	 */
 	DVector getAnglesAsVect() const;
-	DAffine fn4(const DVector &v);
+
+	/**
+         * Returns a matrix that contains the frame rotation based on this vector and 
+	 * a vector rotation based on input vector v
+	 */
+	DAffine getFrameTransform(const DVector &v);
 	DAffine fn5() const;
 
 	/**
diff --git a/engines/titanic/star_control/unmarked_camera_mover.cpp b/engines/titanic/star_control/unmarked_camera_mover.cpp
index c950baa..c92ed2b 100644
--- a/engines/titanic/star_control/unmarked_camera_mover.cpp
+++ b/engines/titanic/star_control/unmarked_camera_mover.cpp
@@ -44,10 +44,10 @@ void CUnmarkedCameraMover::moveTo(const FVector &srcV, const FVector &destV, con
 void CUnmarkedCameraMover::proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {
 	if (isLocked())
 		decLockCount();
-
+	//TODO: v3 is unused
 	DVector vector1 = v1;
 	DVector vector2 = v2;
-	DAffine matrix1 = vector2.fn4(vector1);
+	DAffine matrix1 = vector2.getFrameTransform(vector1);
 	DAffine matrix2 = matrix1.compose(m);
 
 	_autoMover.proc3(m, matrix2);


Commit: d1f9aa8fe300ba9d8f3c24cca2342f4c32da5f13
    https://github.com/scummvm/scummvm/commit/d1f9aa8fe300ba9d8f3c24cca2342f4c32da5f13
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-12T21:32:07-07:00

Commit Message:
TITANIC: dvector work, fn5 renamed to RotXY

It does a rotation around the X axis then Y.

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/star_camera.cpp


diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index 93e52b3..8ea167a 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -101,7 +101,7 @@ DAffine DVector::getFrameTransform(const DVector &v) {
 	return matrix4.compose(matrix3);
 }
 
-DAffine DVector::fn5() const {
+DAffine DVector::RotXY() const {
 	DVector v1 = getAnglesAsVect();
 	DAffine m1, m2;
 	m1.setRotationMatrix(X_AXIS, v1._y * Rad2Deg);
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index d0a87be..7edb37f 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -73,7 +73,12 @@ public:
 	 * a vector rotation based on input vector v
 	 */
 	DAffine getFrameTransform(const DVector &v);
-	DAffine fn5() const;
+
+	/**
+         * Returns a affine matrix that does a x then a y axis frame rotation
+	 * based on the orientation of this vector
+	 */
+	DAffine RotXY() const;
 
 	/**
 	 * Returns true if the passed vector equals this one
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index 6192fc5..f8f6155 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -289,7 +289,7 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 
 		tempV1 = _matrix._row2 - _matrix._row1;
 		diffV = tempV1;
-		m1 = diffV.fn5();
+		m1 = diffV.RotXY();
 		m1 = m1.compose(subX);
 		subX = m1.inverseTransform();
 		subX = subX.compose(subY);
@@ -459,7 +459,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
 
 	DAffine m2(X_AXIS, _matrix._row1);
 	DVector tempV1 = v - _matrix._row1;
-	DAffine m1 = tempV1.fn5();
+	DAffine m1 = tempV1.RotXY();
 	m1 = m1.compose(m2);
 	m2 = m1.inverseTransform();
 	


Commit: 9fa832a2b661a8051606650678f5e39c17682c86
    https://github.com/scummvm/scummvm/commit/9fa832a2b661a8051606650678f5e39c17682c86
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-08-13T15:16:42-04:00

Commit Message:
Merge pull request #989 from dafioram/dvector_refactor

TITANIC: Star control dvector class refactor

Changed paths:
    engines/titanic/star_control/dvector.cpp
    engines/titanic/star_control/dvector.h
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/unmarked_camera_mover.cpp







More information about the Scummvm-git-logs mailing list