aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorDavid Fioramonti2017-08-28 19:28:15 -0700
committerDavid Fioramonti2017-08-30 19:53:13 -0700
commit8f479522c4bf53616c785099d516d350f8fad94c (patch)
treea871507ee1325db2c323f8876d1985eefdfa5bf8 /engines
parentd1325e2d12ec2b7f9e12381f3e62e94897d5b57c (diff)
downloadscummvm-rg350-8f479522c4bf53616c785099d516d350f8fad94c.tar.gz
scummvm-rg350-8f479522c4bf53616c785099d516d350f8fad94c.tar.bz2
scummvm-rg350-8f479522c4bf53616c785099d516d350f8fad94c.zip
TITANIC: CCameraMover and related classes Refactor
1. Removed updatePosition function defintions since UnmarkedCameraMover and MarkedCameraMover, derived classes, are overriddening it. I.e., CCameraMover::updatePosition doesn't get used. This also allowed some header files to removed. 2. Renaming of some functions.
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/star_control/camera_mover.cpp59
-rw-r--r--engines/titanic/star_control/camera_mover.h36
-rw-r--r--engines/titanic/star_control/marked_camera_mover.cpp4
-rw-r--r--engines/titanic/star_control/marked_camera_mover.h9
-rw-r--r--engines/titanic/star_control/star_camera.cpp8
-rw-r--r--engines/titanic/star_control/unmarked_camera_mover.cpp6
-rw-r--r--engines/titanic/star_control/unmarked_camera_mover.h5
7 files changed, 73 insertions, 54 deletions
diff --git a/engines/titanic/star_control/camera_mover.cpp b/engines/titanic/star_control/camera_mover.cpp
index 95981a951c..09e7ed72ba 100644
--- a/engines/titanic/star_control/camera_mover.cpp
+++ b/engines/titanic/star_control/camera_mover.cpp
@@ -23,7 +23,6 @@
#include "titanic/star_control/camera_mover.h"
#include "titanic/star_control/base_stars.h" // includes class CStarVector
#include "titanic/star_control/error_code.h"
-#include "titanic/star_control/fmatrix.h" // Also has class FVector
#include "titanic/support/simple_file.h"
// Not currently being used: #include "common/textconsole.h"
@@ -36,14 +35,7 @@ CCameraMover::CCameraMover(const CNavigationInfo *src) {
if (src) {
copyFrom(src);
} else {
- _speed = 0.0;
- _speedChangeCtr = 0.0;
- _speedChangeInc = 20.0;
- _unused = 0.0;
- _maxSpeed = 50000.0;
- _unusedX = 1.0;
- _unusedY = 1.0;
- _unusedZ = 0.0;
+ reset();
}
}
@@ -51,6 +43,29 @@ CCameraMover::~CCameraMover() {
clear();
}
+void CCameraMover::clear() {
+ if (_starVector) {
+ delete _starVector;
+ _starVector = nullptr;
+ }
+}
+
+void CCameraMover::reset() {
+ _speed = 0.0;
+ _speedChangeCtr = 0.0;
+ _speedChangeInc = 20.0;
+ _unused = 0.0;
+ _maxSpeed = 50000.0;
+ _unusedX = 1.0;
+ _unusedY = 1.0;
+ _unusedZ = 0.0;
+}
+
+void CCameraMover::setVector(CStarVector *sv) {
+ clear();
+ _starVector = sv;
+}
+
void CCameraMover::copyFrom(const CNavigationInfo *src) {
_speed = src->_speed;
_unused = src->_speedChangeCtr;
@@ -99,28 +114,7 @@ void CCameraMover::stop() {
}
}
-void CCameraMover::updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
- if (_speed > 0.0) {
- pos._x += orientation._row3._x * _speed;
- pos._y += orientation._row3._y * _speed;
- pos._z += orientation._row3._z * _speed;
-
- errorCode.set();
- }
-}
-
-void CCameraMover::setVector(CStarVector *sv) {
- clear();
- _starVector = sv;
-}
-
-void CCameraMover::clear() {
- if (_starVector) {
- delete _starVector;
- _starVector = nullptr;
- }
-}
-
+// TODO: this is confusing to negate the val value
void CCameraMover::load(SimpleFile *file, int val) {
if (!val) {
_speed = file->readFloat();
@@ -146,6 +140,7 @@ void CCameraMover::save(SimpleFile *file, int indent) {
}
void CCameraMover::incLockCount() {
+ if (_lockCounter < 3)
++_lockCounter;
}
@@ -154,4 +149,4 @@ void CCameraMover::decLockCount() {
--_lockCounter;
}
-} // End of namespace Titanic
+} // End of namespace Titanic \ No newline at end of file
diff --git a/engines/titanic/star_control/camera_mover.h b/engines/titanic/star_control/camera_mover.h
index 9bd9d48700..3d72e01c8c 100644
--- a/engines/titanic/star_control/camera_mover.h
+++ b/engines/titanic/star_control/camera_mover.h
@@ -23,10 +23,6 @@
#ifndef TITANIC_CAMERA_MOVER_H
#define TITANIC_CAMERA_MOVER_H
-//#include "titanic/support/simple_file.h"
-//#include "titanic/star_control/error_code.h"
-//#include "titanic/star_control/fmatrix.h" // class FVector
-
namespace Titanic {
class CErrorCode;
@@ -58,6 +54,19 @@ public:
virtual void copyTo(CNavigationInfo *dest);
/**
+ * delete _starVector
+ */
+ virtual void clear();
+ /**
+ * Set default values for CNavigationInfo
+ */
+ virtual void reset();
+
+ /**
+ * Sets this CStarVector
+ */
+ virtual void setVector(CStarVector *sv);
+ /**
* Increases movement speed in forward direction
*/
virtual void increaseForwardSpeed();
@@ -77,7 +86,11 @@ public:
*/
virtual void stop();
- virtual void proc8(const FVector &oldPos, const FVector &newPos,
+ /**
+ * Move the mover from an old position and orientation to a new
+ * position and orientation
+ */
+ virtual void transitionBetweenPosOrients(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation) {}
/**
@@ -85,19 +98,16 @@ public:
*/
virtual void moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {}
- virtual void proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {}
-
/**
- * Update the passed position and orientation matrix
+ * First two vectors are used to form a new orientation that gets transitioned to from the old
+ * orientation m.
*/
- virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
-
- virtual void setVector(CStarVector *sv);
+ virtual void transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {}
/**
- * Clear the class
+ * Update the passed position and orientation matrix
*/
- virtual void clear();
+ virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {}
/**
* Load the class
diff --git a/engines/titanic/star_control/marked_camera_mover.cpp b/engines/titanic/star_control/marked_camera_mover.cpp
index 79e74cdd05..66549c5859 100644
--- a/engines/titanic/star_control/marked_camera_mover.cpp
+++ b/engines/titanic/star_control/marked_camera_mover.cpp
@@ -23,6 +23,7 @@
#include "titanic/star_control/marked_camera_mover.h"
#include "titanic/star_control/base_stars.h" // includes class CStarVector
#include "titanic/star_control/error_code.h"
+#include "titanic/star_control/fmatrix.h" // includes class FVector
// Not currently being used: #include "common/textconsole.h"
namespace Titanic {
@@ -31,7 +32,8 @@ CMarkedCameraMover::CMarkedCameraMover(const CNavigationInfo *src) :
CCameraMover(src) {
}
-void CMarkedCameraMover::proc8(const FVector &oldPos, const FVector &newPos,
+
+void CMarkedCameraMover::transitionBetweenPosOrients(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation) {
if (isLocked())
decLockCount();
diff --git a/engines/titanic/star_control/marked_camera_mover.h b/engines/titanic/star_control/marked_camera_mover.h
index 7706db1098..2e971615dc 100644
--- a/engines/titanic/star_control/marked_camera_mover.h
+++ b/engines/titanic/star_control/marked_camera_mover.h
@@ -28,6 +28,9 @@
namespace Titanic {
+class FMatrix;
+class FVector;
+
class CMarkedCameraMover : public CCameraMover {
private:
CMarkedAutoMover _autoMover;
@@ -35,7 +38,11 @@ public:
CMarkedCameraMover(const CNavigationInfo *src);
virtual ~CMarkedCameraMover() {}
- virtual void proc8(const FVector &oldPos, const FVector &newPos,
+ /**
+ * Move the mover from an old position and orientation to a new
+ * position and orientation
+ */
+ virtual void transitionBetweenPosOrients(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation);
/**
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index f7cedf4d22..a5760e9f33 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -498,7 +498,7 @@ bool CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
FMatrix matrix = _viewport.getOrientation();
const FVector &pos = _viewport._position;
- _mover->proc10(v3, tempV, pos, matrix);
+ _mover->transitionBetweenOrientations(v3, tempV, pos, matrix); // TODO: pos does not get used in this function
CStarVector *sv = new CStarVector(this, v2);
_mover->setVector(sv);
@@ -602,13 +602,13 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
if (minDistance > 1.0e8) {
// The transition will do poorly in this case.
//removeLockedStar(); // undo locking 2nd star
- _mover->proc8(_viewport._position, _viewport._position, m6, m6);
+ _mover->transitionBetweenPosOrients(_viewport._position, _viewport._position, m6, m6);
//CStarVector *sv = new CStarVector(this, v);
//_mover->setVector(sv);
return false;
}
else {
- _mover->proc8(_viewport._position, newPos, m6, m5);
+ _mover->transitionBetweenPosOrients(_viewport._position, newPos, m6, m5);
CStarVector *sv = new CStarVector(this, v);
_mover->setVector(sv);
@@ -625,7 +625,7 @@ bool CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
FVector newPos = viewport->_position;
FVector oldPos = _viewport._position;
- _mover->proc8(oldPos, newPos, oldOr, newOr);
+ _mover->transitionBetweenPosOrients(oldPos, newPos, oldOr, newOr);
CStarVector *sv = new CStarVector(this, v);
_mover->setVector(sv);
diff --git a/engines/titanic/star_control/unmarked_camera_mover.cpp b/engines/titanic/star_control/unmarked_camera_mover.cpp
index bba49e925b..aa896710f2 100644
--- a/engines/titanic/star_control/unmarked_camera_mover.cpp
+++ b/engines/titanic/star_control/unmarked_camera_mover.cpp
@@ -26,6 +26,7 @@
#include "titanic/star_control/dvector.h"
#include "titanic/star_control/daffine.h"
#include "titanic/star_control/error_code.h"
+#include "titanic/star_control/fmatrix.h" // includes class FVector
#include "titanic/titanic.h"
// Not currently being used: #include "common/textconsole.h"
@@ -44,10 +45,11 @@ void CUnmarkedCameraMover::moveTo(const FVector &srcV, const FVector &destV, con
_autoMover.setPath(srcV, destV, orientation);
}
-void CUnmarkedCameraMover::proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {
+// TODO: v3 is unused
+void CUnmarkedCameraMover::transitionBetweenOrientations(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.getFrameTransform(vector1);
diff --git a/engines/titanic/star_control/unmarked_camera_mover.h b/engines/titanic/star_control/unmarked_camera_mover.h
index bcf904684f..cb606b96dd 100644
--- a/engines/titanic/star_control/unmarked_camera_mover.h
+++ b/engines/titanic/star_control/unmarked_camera_mover.h
@@ -28,6 +28,9 @@
namespace Titanic {
+class FMatrix;
+class FVector;
+
class CUnmarkedCameraMover : public CCameraMover {
private:
CUnmarkedAutoMover _autoMover;
@@ -40,7 +43,7 @@ public:
*/
virtual void moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
- virtual void proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m);
+ virtual void transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m);
/**
* Update the passed position and orientation matrix