aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Fioramonti2017-09-07 05:08:38 -0700
committerDavid Fioramonti2017-09-07 06:25:43 -0700
commitd69404d5de6fded94803c36bd0d5fe012d705c0a (patch)
treee5b574dfeb9fa62fbf71f1ef1e24bba79a5a4324
parent40684e83d33eea7bfc91efb1e89d77d7e6ce8f14 (diff)
downloadscummvm-rg350-d69404d5de6fded94803c36bd0d5fe012d705c0a.tar.gz
scummvm-rg350-d69404d5de6fded94803c36bd0d5fe012d705c0a.tar.bz2
scummvm-rg350-d69404d5de6fded94803c36bd0d5fe012d705c0a.zip
TITANIC: Make use of CCameraAutoMover::setPath() more clear
There was a setPath() adn setPath2() function took in different arguments and were doing the same thing, but not using the different arguments. I made it into one function that only takes in the arguments it uses. Also it was marked virtual, but all the derived classes, CMarkedAutoMover, and CUnmarkedAutoMover were just doing there own thing and then calling this base class implementation. Therefore, I made it be not virtual and the derived classes can do there own thing and then call this, but since they are doing slightly different things it makes sense to differentiate the names and not have them all be called setPath. I.e., the derived classes also change the orientation so that is included in their function names to reflect that.
-rw-r--r--engines/titanic/star_control/camera_auto_mover.cpp29
-rw-r--r--engines/titanic/star_control/camera_auto_mover.h9
-rw-r--r--engines/titanic/star_control/marked_auto_mover.cpp4
-rw-r--r--engines/titanic/star_control/marked_auto_mover.h2
-rw-r--r--engines/titanic/star_control/marked_camera_mover.cpp3
-rw-r--r--engines/titanic/star_control/unmarked_auto_mover.cpp4
-rw-r--r--engines/titanic/star_control/unmarked_auto_mover.h4
-rw-r--r--engines/titanic/star_control/unmarked_camera_mover.cpp2
8 files changed, 17 insertions, 40 deletions
diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
index fcd1e9e0ee..1b016bc549 100644
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ b/engines/titanic/star_control/camera_auto_mover.cpp
@@ -41,25 +41,6 @@ CCameraAutoMover::CCameraAutoMover() : _srcPos(0.0, 1000000.0, 0.0) {
_transitionPercentInc = 0.0;
}
-// TODO: same as setPath also orientations are not used
-void CCameraAutoMover::setPath2(const FVector &oldPos, const FVector &newPos,
- const FMatrix &oldOrientation, const FMatrix &newOrientation) {
- _srcPos = oldPos;
- _destPos = newPos;
- _posDelta = _destPos - _srcPos;
-
- float temp = 0.0;
- _posDelta.normalize(temp); // Do the normalization, put the scale amount in temp
- _distance = temp;
- _active = false;
- _field34 = false;
- _transitionPercent = 1.0;
- _field40 = -1;
- _field44 = -1;
- _field48 = -1;
- _field4C = 0;
-}
-
// TODO: same as proc2 also orientations are not used
void CCameraAutoMover::setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient) {
_srcPos.clear();
@@ -70,18 +51,14 @@ void CCameraAutoMover::setOrientations(const FMatrix &srcOrient, const FMatrix &
_field34 = false;
}
-// TODO: same as setPath2 also orientations are not used
-void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
+void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV) {
_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);
- }
+ _posDelta.normalize(temp); // normalization won't happen if _posDelta is zero vector
+ // and that is okay
_distance = temp;
_active = false;
diff --git a/engines/titanic/star_control/camera_auto_mover.h b/engines/titanic/star_control/camera_auto_mover.h
index 25384632fa..d83f15013c 100644
--- a/engines/titanic/star_control/camera_auto_mover.h
+++ b/engines/titanic/star_control/camera_auto_mover.h
@@ -59,14 +59,15 @@ public:
CCameraAutoMover();
virtual ~CCameraAutoMover() {}
- virtual void setPath2(const FVector &oldPos, const FVector &newPos,
- const FMatrix &oldOrientation, const FMatrix &newOrientation);
-
/**
* Clear src and dest orientation and set some default values for other fields
*/
virtual void setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient);
- virtual void setPath(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
+
+ /**
+ * Setup a transition to from one position to another
+ */
+ void setPath(const FVector &srcV, const FVector &destV);
/**
* Applys speeds to the mover. More than one application is usually done for several transitions
diff --git a/engines/titanic/star_control/marked_auto_mover.cpp b/engines/titanic/star_control/marked_auto_mover.cpp
index 0787c48de3..ae987aa8fc 100644
--- a/engines/titanic/star_control/marked_auto_mover.cpp
+++ b/engines/titanic/star_control/marked_auto_mover.cpp
@@ -26,9 +26,9 @@
namespace Titanic {
-void CMarkedAutoMover::setPath2(const FVector &oldPos, const FVector &newPos,
+void CMarkedAutoMover::setPathOrients(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation) {
- CCameraAutoMover::setPath2(oldPos, newPos, oldOrientation, newOrientation);
+ CCameraAutoMover::setPath(oldPos, newPos);
double distance = _distance;
_active = true;
diff --git a/engines/titanic/star_control/marked_auto_mover.h b/engines/titanic/star_control/marked_auto_mover.h
index 856df99c03..ca7fbf3b7f 100644
--- a/engines/titanic/star_control/marked_auto_mover.h
+++ b/engines/titanic/star_control/marked_auto_mover.h
@@ -41,7 +41,7 @@ private:
public:
virtual ~CMarkedAutoMover() {}
- virtual void setPath2(const FVector &oldPos, const FVector &newPos,
+ void setPathOrients(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation);
/**
diff --git a/engines/titanic/star_control/marked_camera_mover.cpp b/engines/titanic/star_control/marked_camera_mover.cpp
index ff9c055abb..df6edbec5f 100644
--- a/engines/titanic/star_control/marked_camera_mover.cpp
+++ b/engines/titanic/star_control/marked_camera_mover.cpp
@@ -32,13 +32,12 @@ CMarkedCameraMover::CMarkedCameraMover(const CNavigationInfo *src) :
CCameraMover(src) {
}
-
void CMarkedCameraMover::transitionBetweenPosOrients(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation) {
if (isLocked())
decLockCount();
- _autoMover.setPath2(oldPos, newPos, oldOrientation, newOrientation);
+ _autoMover.setPathOrients(oldPos, newPos, oldOrientation, newOrientation);
incLockCount();
}
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
index c84fbbab00..1120690b0e 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ b/engines/titanic/star_control/unmarked_auto_mover.cpp
@@ -36,8 +36,8 @@ void CUnmarkedAutoMover::setOrientations(const FMatrix &srcOrient, const FMatrix
_active = true;
}
-void CUnmarkedAutoMover::setPath(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
- CCameraAutoMover::setPath(srcV, destV, orientation);
+void CUnmarkedAutoMover::setPathOrient(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
+ CCameraAutoMover::setPath(srcV, destV);
if (_distance > 8000.0) {
_active = true;
diff --git a/engines/titanic/star_control/unmarked_auto_mover.h b/engines/titanic/star_control/unmarked_auto_mover.h
index b7fb4e3c66..41c13311e0 100644
--- a/engines/titanic/star_control/unmarked_auto_mover.h
+++ b/engines/titanic/star_control/unmarked_auto_mover.h
@@ -37,9 +37,9 @@ public:
virtual void setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient);
/**
- * Sets the path to animate movement between
+ * Sets the path and starting and ending orientations to animate movement between
*/
- virtual void setPath(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
+ void setPathOrient(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
};
diff --git a/engines/titanic/star_control/unmarked_camera_mover.cpp b/engines/titanic/star_control/unmarked_camera_mover.cpp
index 200d549ce1..c879dc25e8 100644
--- a/engines/titanic/star_control/unmarked_camera_mover.cpp
+++ b/engines/titanic/star_control/unmarked_camera_mover.cpp
@@ -41,7 +41,7 @@ void CUnmarkedCameraMover::moveTo(const FVector &srcV, const FVector &destV, con
debugC(DEBUG_BASIC, kDebugStarfield, "Starfield move %s to %s", srcV.toString().c_str(),
destV.toString().c_str());
- _autoMover.setPath(srcV, destV, orientation);
+ _autoMover.setPathOrient(srcV, destV, orientation);
}
// TODO: v3 is unused