[Scummvm-git-logs] scummvm master -> 38c02017f5a9da17d3c06dbcc1acf23b80c1cac4

dreammaster dreammaster at scummvm.org
Fri Aug 18 04:08:15 CEST 2017


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

Summary:
5ebc972c25 TITANIC: Change fpose Yaxis rotation to be same as wikipedia
fb1e9453fb TITANIC: Unmarked starviewer, fix, key directions
09eb399c07 TITANIC: daffine simpler inverse
24354ac6a8 TITANIC: fpose, simplify inverse
38c02017f5 Merge pull request #992 from dafioram/daffine_fmatrix_work


Commit: 5ebc972c25cd40cb7aec86904bfc2ecfd2aa1ab7
    https://github.com/scummvm/scummvm/commit/5ebc972c25cd40cb7aec86904bfc2ecfd2aa1ab7
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-16T05:13:08-07:00

Commit Message:
TITANIC: Change fpose Yaxis rotation to be same as wikipedia

Add negatives to star camera turning rotations so view turns correctly
when no stars are marked and 1 star is marked.

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


diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp
index 3f7b03d..98de447 100644
--- a/engines/titanic/star_control/fpose.cpp
+++ b/engines/titanic/star_control/fpose.cpp
@@ -83,6 +83,7 @@ void FPose::identity() {
 	_vector.clear();
 }
 
+// Source: https://en.wikipedia.org/wiki/Rotation_matrix
 void FPose::setRotationMatrix(Axis axis, float amount) {
 	const float ROTATION = 2 * M_PI / 360.0;
 	float sinVal = sin(amount * ROTATION);
@@ -104,11 +105,11 @@ void FPose::setRotationMatrix(Axis axis, float amount) {
 	case Y_AXIS:
 		_row1._x = cosVal;
 		_row1._y = 0.0;
-		_row1._z = sinVal;
+		_row1._z = -sinVal;
 		_row2._x = 0.0;
 		_row2._y = 1.0;
 		_row2._z = 0.0;
-		_row3._x = -sinVal;
+		_row3._x = sinVal;
 		_row3._y = 0.0;
 		_row3._z = cosVal;
 		break;
@@ -145,6 +146,7 @@ void FPose::copyFrom(const FMatrix &src) {
 	_row3 = src._row3;
 }
 
+// This looks like DAffine DAffine::inverseTransform()
 FPose FPose::fn4() const {
 	float v2, v3, v6, v7, v8, v9, v10, v11;
 	float v12, v13, v14, v15, v16, v17, v18;
diff --git a/engines/titanic/star_control/fpose.h b/engines/titanic/star_control/fpose.h
index dbdd832..02e00c9 100644
--- a/engines/titanic/star_control/fpose.h
+++ b/engines/titanic/star_control/fpose.h
@@ -29,6 +29,7 @@ namespace Titanic {
 
 /*
  * This class combines a position and orientation in 3D space
+ * TODO: consider merging with DAffine
  */
 class FPose : public FMatrix {
 public:
@@ -59,6 +60,9 @@ public:
 	 */
 	void copyFrom(const FMatrix &src);
 
+        /**
+         * Probably the inverse of the this 3x4
+         */
 	FPose fn4() const;
 };
 
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index f172385..9c1c598 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -230,14 +230,14 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 	if (_matrixRow == -1) {
 		// No locked markers
 		FPose subX(X_AXIS, angles._y);
-		FPose subY(Y_AXIS, angles._x);
+		FPose subY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
 		FPose sub(subX, subY);
 		proc22(sub);
 	} else if (_matrixRow == 0) {
 		// 1 marker is locked in
 		FVector row1 = _matrix._row1;
 		FPose poseX(X_AXIS, angles._y);
-		FPose poseY(Y_AXIS, angles._x);
+		FPose poseY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
 		FPose pose(poseX, poseY);
 
 		FMatrix m1 = _viewport.getOrientation();


Commit: fb1e9453fb63e9533ef70c616118c3b49238ac20
    https://github.com/scummvm/scummvm/commit/fb1e9453fb63e9533ef70c616118c3b49238ac20
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-16T19:11:50-07:00

Commit Message:
TITANIC: Unmarked starviewer, fix, key directions

Changing the fpose Y axis rotations flipped some of the keys (z,x)
so I added in negatives to fix that.

Also before slash was looking up and comma was looking down.
This is the same as the original, but I think thats less
intuitive so I have reversed that. It also makes those keys
now correct in the readme.

Changed paths:
    engines/titanic/star_control/star_view.cpp


diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 465e974..9b27fa4 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -176,9 +176,8 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
 	}
 
 	case Common::KEYCODE_z:
-	case Common::KEYCODE_c:
 		if (matchedIndex == -1) {
-			pose.setRotationMatrix(key == Common::KEYCODE_z ? Y_AXIS : X_AXIS, 1.0);
+			pose.setRotationMatrix(Y_AXIS, -1.0);
 			_camera.proc22(pose);
 			_camera.updatePosition(errorCode);
 			return true;
@@ -211,7 +210,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
 
 	case Common::KEYCODE_x:
 		if (matchedIndex == -1) {
-			pose.setRotationMatrix(Y_AXIS, -1.0);
+			pose.setRotationMatrix(Y_AXIS, 1.0);
 			_camera.proc22(pose);
 			_camera.updatePosition(errorCode);
 			return true;
@@ -220,7 +219,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
 
 	case Common::KEYCODE_QUOTE:
 		if (matchedIndex == -1) {
-			pose.setRotationMatrix(X_AXIS, -1.0);
+			pose.setRotationMatrix(X_AXIS, 1.0);
 			_camera.proc22(pose);
 			_camera.updatePosition(errorCode);
 			return true;
@@ -229,7 +228,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
 
 	case Common::KEYCODE_SLASH:
 		if (matchedIndex == -1) {
-			pose.setRotationMatrix(X_AXIS, 1.0);
+			pose.setRotationMatrix(X_AXIS, -1.0);
 			_camera.proc22(pose);
 			_camera.updatePosition(errorCode);
 			return true;


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

Commit Message:
TITANIC: daffine simpler inverse

Replace rotation inverse with transpose.
inv(R)=tranpose(R) for rotation matrices.

Changed paths:
    engines/titanic/star_control/daffine.cpp


diff --git a/engines/titanic/star_control/daffine.cpp b/engines/titanic/star_control/daffine.cpp
index 8fb0827..261d310 100644
--- a/engines/titanic/star_control/daffine.cpp
+++ b/engines/titanic/star_control/daffine.cpp
@@ -115,69 +115,29 @@ void DAffine::setRotationMatrix(Axis axis, double angleDeg) {
 	}
 }
 
-//TODO: Check math and provide source
+//TODO: Check column 4 math
 DAffine DAffine::inverseTransform() const {
-	double val1 = _col1._x * _col3._z * _col2._y;
-	double val2 = 0.0;
-	double val3 = val1;
-
-	if (val1 < 0.0) {
-		val2 = val3;
-		val1 = 0.0;
-	}
-
-	double val4 = _col3._x * _col1._y * _col2._z;
-	if (val4 < 0.0)
-		val2 = val2 + val4;
-	else
-		val1 = val1 + val4;
-
-	double val5 = _col3._y * _col1._z * _col2._x;
-	if (val5 < 0.0)
-		val2 = val2 + val5;
-	else
-		val1 = val1 + val5;
-
-	if (-(_col3._x * _col2._y * _col1._z) < 0.0)
-		val2 = val2 - _col3._x * _col2._y * _col1._z;
-	else
-		val1 = val1 - _col3._x * _col2._y * _col1._z;
-	if (-(_col1._y * _col3._z * _col2._x) < 0.0)
-		val2 = val2 - _col1._y * _col3._z * _col2._x;
-	else
-		val1 = val1 - _col1._y * _col3._z * _col2._x;
-
-	val3 = _col3._y * _col2._z;
-	double val6 = -(_col1._x * val3);
-	if (val6 < 0.0)
-		val2 = val2 + val6;
-	else
-		val1 = val1 + val6;
-
-	double val7 = val2 + val1;
-	assert(!(val7 == 0.0 || fabs(val7 / (val1 - val2)) < 1.0e-10));
-
-	double val8 = _col3._z * _col2._y;
-	double val9 = 1.0 / val7;
-
-	DAffine m;
-	m._col1._x = (val8 - val3) * val9;
-	m._col2._x = -((_col3._z * _col2._x - _col3._x * _col2._z) * val9);
-	m._col3._x = (_col3._y * _col2._x - _col3._x * _col2._y) * val9;
-	m._col1._y = -((_col1._y * _col3._z - _col3._y * _col1._z) * val9);
-	m._col2._y = (_col1._x * _col3._z - _col3._x * _col1._z) * val9;
-	m._col3._y = -((_col1._x * _col3._y - _col3._x * _col1._y) * val9);
-	m._col1._z = (_col1._y * _col2._z - _col2._y * _col1._z) * val9;
-	m._col2._z = -((_col1._x * _col2._z - _col1._z * _col2._x) * val9);
-	m._col3._z = (_col1._x * _col2._y - _col1._y * _col2._x) * val9;
-
-	m._col4._x = -(m._col1._x * _col4._x + _col4._y * m._col2._x
-		+ _col4._z * m._col3._x);
-	m._col4._y = -(_col4._z * m._col3._y + _col4._y * m._col2._y
-		+ _col4._x * m._col1._y);
-	m._col4._z = -(_col4._z * m._col3._z + _col4._x * m._col1._z
-		+ _col4._y * m._col2._z);
-
+        DAffine m;
+       //Inverse of rotation matrix is the transpose
+	m._col1._x = _col1._x;
+	m._col2._x = _col1._y;
+	m._col3._x = _col1._z;
+	m._col1._y = _col2._x;
+	m._col2._y = _col2._y;
+	m._col3._y = _col2._z;
+	m._col1._z = _col3._x;
+	m._col2._z = _col3._y;
+	m._col3._z = _col3._z;
+
+	m._col4._x = -(_col4._x * m._col1._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);
+	m._col4._z = -(_col4._x * m._col1._z
+                    + _col4._y * m._col2._z
+                    + _col4._z * m._col3._z);
 	return m;
 }
 


Commit: 24354ac6a8425133e3b39caa1e55b4b63dc41665
    https://github.com/scummvm/scummvm/commit/24354ac6a8425133e3b39caa1e55b4b63dc41665
Author: David Fioramonti (dafioram at gmail.com)
Date: 2017-08-16T20:42:09-07:00

Commit Message:
TITANIC: fpose, simplify inverse

Was doing 3x3 inverse now it is doing a transpose.
Also named the function.

Changed paths:
    engines/titanic/star_control/fpose.cpp
    engines/titanic/star_control/fpose.h
    engines/titanic/star_control/viewport.cpp


diff --git a/engines/titanic/star_control/fpose.cpp b/engines/titanic/star_control/fpose.cpp
index 98de447..a3697ae 100644
--- a/engines/titanic/star_control/fpose.cpp
+++ b/engines/titanic/star_control/fpose.cpp
@@ -146,69 +146,28 @@ void FPose::copyFrom(const FMatrix &src) {
 	_row3 = src._row3;
 }
 
-// This looks like DAffine DAffine::inverseTransform()
-FPose FPose::fn4() const {
-	float v2, v3, v6, v7, v8, v9, v10, v11;
-	float v12, v13, v14, v15, v16, v17, v18;
+FPose FPose::inverseTransform() const {
 	FPose result;
 
-	v16 = _row3._z * _row2._y;
-	v2 = _row1._x * v16;
-	v3 = 0.0;
-	v18 = v2;
-	if (v2 < 0.0) {
-		v3 = v18;
-		v2 = 0.0;
-	}
-	v6 = _row3._x * _row1._y * _row2._z;
-	if (v6 < 0.0)
-		v3 = v3 + v6;
-	else
-		v2 = v2 + v6;
-	v7 = _row3._y * _row1._z * _row2._x;
-	if (v7 < 0.0)
-		v3 = v3 + v7;
-	else
-		v2 = v2 + v7;
-	if (-(_row3._x * _row1._z * _row2._y) < 0.0)
-		v3 = v3 - _row3._x * _row1._z * _row2._y;
-	else
-		v2 = v2 - _row3._x * _row1._z * _row2._y;
-	if (-(_row1._y * _row2._x * _row3._z) < 0.0)
-		v3 = v3 - _row1._y * _row2._x * _row3._z;
-	else
-		v2 = v2 - _row1._y * _row2._x * _row3._z;
-	v17 = _row2._z * _row3._y;
-	if (-(_row1._x * v17) < 0.0)
-		v3 = v3 - _row1._x * v17;
-	else
-		v2 = v2 - _row1._x * v17;
-	v18 = v3 + v2;
-	assert(!(v18 == 0.0 || fabs(v18 / (v2 - v3)) < 1.0e-10));
-
-	v8 = 1.0 / v18;
-	v18 = v8;
-	result._row1._x = (v16 - v17) * v8;
-	result._row2._x = -(_row2._x * _row3._z - _row3._x * _row2._z) * v8;
-	result._row3._x = (_row3._y * _row2._x - _row3._x * _row2._y) * v8;
-	result._row1._y = -(_row1._y * _row3._z - _row3._y * _row1._z) * v8;
-	result._row2._y = (_row1._x * _row3._z - _row3._x * _row1._z) * v8;
-	result._row3._y = -(_row1._x * _row3._y - _row3._x * _row1._y) * v8;
-	result._row1._z = (_row1._y * _row2._z - _row1._z * _row2._y) * v8;
-	result._row2._z = -(_row1._x * _row2._z - _row1._z * _row2._x) * v8;
-	v9 = result._row1._x;
-	v10 = result._row2._y;
-	v11 = result._row3._y;
-	v12 = result._row1._z;
-	v13 = result._row2._z;
-	result._row3._z = (_row1._x * _row2._y - _row1._y * _row2._x) * v18;
-	v14 = v9;
-	v15 = result._row3._z;
-	result._vector._x = -(v14 * _vector._x
-		+ _vector._y * result._row2._x
-		+ _vector._z * result._row3._x);
-	result._vector._y = -(_vector._x * result._row1._y + v10 * _vector._y + v11 * _vector._z);
-	result._vector._z = -(v12 * _vector._x + v13 * _vector._y + v15 * _vector._z);
+	result._row1._x = _row1._x;
+	result._row2._x = _row1._y;
+	result._row3._x = _row1._z;
+	result._row1._y = _row2._x;
+	result._row2._y = _row2._y;
+	result._row3._y = _row2._z;
+	result._row1._z = _row3._x;
+	result._row2._z = _row3._y;
+	result._row3._z = _row3._z;
+
+	result._vector._x = -(_vector._x * result._row1._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);
+	result._vector._z = -(_vector._x * result._row1._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 02e00c9..f1f00ea 100644
--- a/engines/titanic/star_control/fpose.h
+++ b/engines/titanic/star_control/fpose.h
@@ -29,7 +29,7 @@ namespace Titanic {
 
 /*
  * This class combines a position and orientation in 3D space
- * TODO: consider merging with DAffine
+ * TODO: Merge with DAffine
  */
 class FPose : public FMatrix {
 public:
@@ -61,9 +61,9 @@ public:
 	void copyFrom(const FMatrix &src);
 
         /**
-         * Probably the inverse of the this 3x4
+         * The inverse of rotation and the position vector
          */
-	FPose fn4() const;
+	FPose inverseTransform() const;
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp
index 39d2c5f..130d59d 100644
--- a/engines/titanic/star_control/viewport.cpp
+++ b/engines/titanic/star_control/viewport.cpp
@@ -248,7 +248,7 @@ void CViewport::reset() {
 
 	_rawPose.copyFrom(_orientation);
 	_rawPose._vector = _position;
-	_currentPose = _rawPose.fn4();
+	_currentPose = _rawPose.inverseTransform();
 
 	_center = FPoint((double)_width * 0.5, (double)_height * 0.5);
 	_centerVector._x = MIN(_center._x, _center._y);


Commit: 38c02017f5a9da17d3c06dbcc1acf23b80c1cac4
    https://github.com/scummvm/scummvm/commit/38c02017f5a9da17d3c06dbcc1acf23b80c1cac4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-08-17T22:08:10-04:00

Commit Message:
Merge pull request #992 from dafioram/daffine_fmatrix_work

TITANIC: Daffine and FMatrix work

Changed paths:
    engines/titanic/star_control/daffine.cpp
    engines/titanic/star_control/fpose.cpp
    engines/titanic/star_control/fpose.h
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/star_view.cpp
    engines/titanic/star_control/viewport.cpp







More information about the Scummvm-git-logs mailing list