[Scummvm-git-logs] scummvm master -> 1ed01c2f7f2b9691f913148565b4f9c14a5e0f32

dreammaster dreammaster at scummvm.org
Mon May 22 04:58:43 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:
1ed01c2f7f TITANIC: Rename Sub25 class to COrientationChanger, fixes & cleanup


Commit: 1ed01c2f7f2b9691f913148565b4f9c14a5e0f32
    https://github.com/scummvm/scummvm/commit/1ed01c2f7f2b9691f913148565b4f9c14a5e0f32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-05-21T22:58:31-04:00

Commit Message:
TITANIC: Rename Sub25 class to COrientationChanger, fixes & cleanup

Changed paths:
  A engines/titanic/star_control/orientation_changer.cpp
  A engines/titanic/star_control/orientation_changer.h
  R engines/titanic/star_control/star_control_sub25.cpp
  R engines/titanic/star_control/star_control_sub25.h
    engines/titanic/module.mk
    engines/titanic/star_control/star_control_sub23.h
    engines/titanic/star_control/star_control_sub24.cpp
    engines/titanic/star_control/star_control_sub26.cpp
    engines/titanic/star_control/star_control_sub26.h
    engines/titanic/star_control/star_control_sub27.cpp


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 1228d73..e003d48 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -441,6 +441,7 @@ MODULE_OBJS := \
 	star_control/frange.o \
 	star_control/frect.o \
 	star_control/fvector.o \
+	star_control/orientation_changer.o \
 	star_control/star_camera.o \
 	star_control/star_closeup.o \
 	star_control/star_control_sub2.o \
@@ -450,7 +451,6 @@ MODULE_OBJS := \
 	star_control/star_control_sub22.o \
 	star_control/star_control_sub23.o \
 	star_control/star_control_sub24.o \
-	star_control/star_control_sub25.o \
 	star_control/star_control_sub26.o \
 	star_control/star_control_sub27.o \
 	star_control/star_field.o \
diff --git a/engines/titanic/star_control/orientation_changer.cpp b/engines/titanic/star_control/orientation_changer.cpp
new file mode 100644
index 0000000..decbd6b
--- /dev/null
+++ b/engines/titanic/star_control/orientation_changer.cpp
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/star_control/orientation_changer.h"
+#include "titanic/star_control/dmatrix.h"
+
+namespace Titanic {
+
+void COrientationChanger::load(const FMatrix &minOrient, const FMatrix &maxOrient) {
+	_minOrient = minOrient;
+	_maxOrient = maxOrient;
+
+	_sub1.fn4(_minOrient);
+	_sub2.fn4(_maxOrient);
+}
+
+FMatrix COrientationChanger::getOrientation(double percent) {
+	if (percent <= 0.0) {
+		return _minOrient;
+	} else if (percent > 1.0) {
+		return _maxOrient;
+	} else {
+		CStarControlSub26 sub26 = _sub1.fn5(percent, &_sub2);
+
+		DMatrix m1;
+		m1.fn3(&sub26);
+		return m1;
+	}
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/orientation_changer.h b/engines/titanic/star_control/orientation_changer.h
new file mode 100644
index 0000000..fc1a132
--- /dev/null
+++ b/engines/titanic/star_control/orientation_changer.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_ORIENTATION_CHANGER_H
+#define TITANIC_ORIENTATION_CHANGER_H
+
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/star_control_sub26.h"
+
+namespace Titanic {
+
+class COrientationChanger {
+public:
+	FMatrix _minOrient;
+	FMatrix _maxOrient;
+	CStarControlSub26 _sub1;
+	CStarControlSub26 _sub2;
+public:
+	/**
+	 * Loads the constraints for the minimum and maximum orientation
+	 */
+	void load(const FMatrix &minOrient, const FMatrix &maxOrient);
+
+	/**
+	 * Returns the orientation for a given percentage between the two
+	 * extremes
+	 * @param percent	Percentage transition 0.0 to 1.0
+	 * @returns		New orientation for the given percentage between the two
+	 */
+	FMatrix getOrientation(double percent);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_ORIENTATION_CHANGER_H */
diff --git a/engines/titanic/star_control/star_control_sub23.h b/engines/titanic/star_control/star_control_sub23.h
index e1e1ba0..d747f35 100644
--- a/engines/titanic/star_control/star_control_sub23.h
+++ b/engines/titanic/star_control/star_control_sub23.h
@@ -26,7 +26,7 @@
 #include "titanic/star_control/error_code.h"
 #include "titanic/star_control/fmatrix.h"
 #include "titanic/star_control/fvector.h"
-#include "titanic/star_control/star_control_sub25.h"
+#include "titanic/star_control/orientation_changer.h"
 
 namespace Titanic {
 
@@ -48,7 +48,7 @@ protected:
 	int _field54;
 	double _moveDelayCtr;
 	double _moveDelayInc;
-	CStarControlSub25 _sub25;
+	COrientationChanger _sub25;
 public:
 	CStarControlSub23();
 	virtual ~CStarControlSub23() {}
diff --git a/engines/titanic/star_control/star_control_sub24.cpp b/engines/titanic/star_control/star_control_sub24.cpp
index 4873753..b3f873f 100644
--- a/engines/titanic/star_control/star_control_sub24.cpp
+++ b/engines/titanic/star_control/star_control_sub24.cpp
@@ -27,7 +27,7 @@ namespace Titanic {
 
 void CStarControlSub24::proc3(const FMatrix &m1, const FMatrix &m2) {
 	CStarControlSub23::proc3(m1, m2);
-	_sub25.fn1(m1, m2);
+	_sub25.load(m1, m2);
 	_moveDelayInc = 0.1;
 	_moveDelayCtr = 0.0;
 	_field40 = _field44 = _field48 = -1;
@@ -71,7 +71,7 @@ void CStarControlSub24::setPath(const FVector &srcV, const FVector &destV, const
 
 		FMatrix m1;
 		m1.fn1(tempV1);
-		_sub25.fn1(orientation, m1);
+		_sub25.load(orientation, m1);
 
 		_moveDelayCtr = 0.0;
 		_moveDelayInc = 0.1;
@@ -88,7 +88,7 @@ int CStarControlSub24::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orien
 
 	if (_moveDelayCtr < 1.0) {
 		_moveDelayCtr += _moveDelayInc;
-		_sub25.fn2(_moveDelayCtr, orientation);
+		orientation = _sub25.getOrientation(_moveDelayCtr);
 		errorCode.set();
 		return 1;
 	}
diff --git a/engines/titanic/star_control/star_control_sub25.cpp b/engines/titanic/star_control/star_control_sub25.cpp
deleted file mode 100644
index 3958872..0000000
--- a/engines/titanic/star_control/star_control_sub25.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "titanic/star_control/star_control_sub25.h"
-#include "titanic/star_control/dmatrix.h"
-
-namespace Titanic {
-
-void CStarControlSub25::fn1(const FMatrix &m1, const FMatrix &m2) {
-	_matrix1 = m1;
-	_matrix2 = m2;
-
-	DMatrix matrix = _matrix2;
-	_sub1.fn4(matrix);
-	matrix = _matrix2;
-	_sub2.fn4(matrix);
-}
-
-void CStarControlSub25::fn2(double val, FMatrix &orientation) {
-	if (val <= 0.0) {
-		orientation = _matrix1;
-	} else if (val > 1.0) {
-		orientation = _matrix2;
-	} else {
-		CStarControlSub26 sub26 = _sub1.fn5(val, &_sub2);
-
-		DMatrix m1;
-		m1.fn3(&sub26);
-		orientation = m1;
-	}
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub25.h b/engines/titanic/star_control/star_control_sub25.h
deleted file mode 100644
index e6a3034..0000000
--- a/engines/titanic/star_control/star_control_sub25.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TITANIC_STAR_CONTROL_SUB25_H
-#define TITANIC_STAR_CONTROL_SUB25_H
-
-#include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/star_control_sub26.h"
-
-namespace Titanic {
-
-class CStarControlSub25 {
-public:
-	FMatrix _matrix1;
-	FMatrix _matrix2;
-	CStarControlSub26 _sub1;
-	CStarControlSub26 _sub2;
-public:
-	void fn1(const FMatrix &m1, const FMatrix &m2);
-	void fn2(double val, FMatrix &orientation);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_STAR_CONTROL_SUB25_H */
diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp
index ce23d51..5625457 100644
--- a/engines/titanic/star_control/star_control_sub26.cpp
+++ b/engines/titanic/star_control/star_control_sub26.cpp
@@ -96,7 +96,7 @@ void CStarControlSub26::fn4(const DMatrix &m) {
 	}
 }
 
-CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) {
+CStarControlSub26 CStarControlSub26::fn5(double percent, CStarControlSub26 *src) {
 	CStarControlSub26 sub1 = *this;
 	CStarControlSub26 sub2, sub3, sub4;
 	CStarControlSub26 dest;
@@ -114,8 +114,8 @@ CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) {
 		dest._sub._v3 = -sub1._field0;
 		dest._field0 = sub1._sub._v3;
 
-		double sin1 = sin(val * M_PI);
-		double sin2 = sin((0.5 - val) * M_PI);
+		double sin1 = sin(percent * M_PI);
+		double sin2 = sin((0.5 - percent) * M_PI);
 		dest._sub._v1 = sin1 * dest._sub._v1 + sub1._sub._v1 * sin2;
 		dest._sub._v2 = sub1._sub._v2 * sin2 + sub1._sub._v1 * sin1;
 		dest._sub._v3 = sin1 * -sub1._field0 + sub1._sub._v3 * sin2;
@@ -125,13 +125,13 @@ CStarControlSub26 CStarControlSub26::fn5(double val, CStarControlSub26 *src) {
 		double val2;
 
 		if (1.0 - val1 <= 0.00001) {
-			val2 = 1.0 - val;
-			sp = src->fn3(&sub3, val);
+			val2 = 1.0 - percent;
+			sp = src->fn3(&sub3, percent);
 		} else {
 			double cosVal = acos(val1);
 			double sinVal = sin(cosVal);
-			val2 = sin((1.0 - val) * cosVal) / sinVal;
-			sp = src->fn3(&sub3, sin(cosVal * val) / sinVal);
+			val2 = sin((1.0 - percent) * cosVal) / sinVal;
+			sp = src->fn3(&sub3, sin(cosVal * percent) / sinVal);
 		}
 
 		const CStarControlSub26 *sp2 = sub1.fn3(&sub4, val2);
diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/star_control_sub26.h
index 577e769..690a274 100644
--- a/engines/titanic/star_control/star_control_sub26.h
+++ b/engines/titanic/star_control/star_control_sub26.h
@@ -56,7 +56,7 @@ public:
 
 	double fn1() const;
 	void fn4(const DMatrix &m);
-	CStarControlSub26 fn5(double val, CStarControlSub26 *src);
+	CStarControlSub26 fn5(double percent, CStarControlSub26 *src);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub27.cpp b/engines/titanic/star_control/star_control_sub27.cpp
index 3c56b7d..01b8f2e 100644
--- a/engines/titanic/star_control/star_control_sub27.cpp
+++ b/engines/titanic/star_control/star_control_sub27.cpp
@@ -37,7 +37,7 @@ void CStarControlSub27::proc2(FVector &oldPos, FVector &newPos,
 	}
 
 	if (newPos != oldPos) {
-		_sub25.fn1(oldOrientation, newOrientation);
+		_sub25.load(oldOrientation, newOrientation);
 		_moveDelayCtr = 0.0;
 
 		if (_field4C == 0) {
@@ -55,7 +55,7 @@ int CStarControlSub27::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orien
 		return 0;
 
 	_moveDelayCtr += _moveDelayInc;
-	_sub25.fn2(_moveDelayCtr, orientation);
+	orientation = _sub25.getOrientation(_moveDelayCtr);
 	errorCode.set();
 
 	if (_field40 >= 0) {





More information about the Scummvm-git-logs mailing list