[Scummvm-git-logs] scummvm master -> a8d802f17dfd83f46020f98a914496102c2742c8
dreammaster
paulfgilbert at gmail.com
Fri Jan 17 03:31:35 UTC 2020
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
690b18ac0b TITANIC: Standardized camera mover classes as motion control
0280ca2359 TITANIC: Clarifying auto movers as flight managers
da3c74224d TITANIC: Better naming for CFlightManagerBase fields
e138a455aa TITANIC: Clarify CStarVector as CCallbackHandler
e30c9ad7d9 TITANIC: Cleanup of flight manager code
33f74e3027 TITANIC: Cleanup camera creation of motion controllers
a8d802f17d TITANIC: Cleanup of #include lines
Commit: 690b18ac0bcb626ff181b20879362ca9f8f208dc
https://github.com/scummvm/scummvm/commit/690b18ac0bcb626ff181b20879362ca9f8f208dc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Standardized camera mover classes as motion control
Changed paths:
A engines/titanic/star_control/motion_control.cpp
A engines/titanic/star_control/motion_control.h
A engines/titanic/star_control/motion_control_marked.cpp
A engines/titanic/star_control/motion_control_marked.h
A engines/titanic/star_control/motion_control_unmarked.cpp
A engines/titanic/star_control/motion_control_unmarked.h
R engines/titanic/star_control/camera_mover.cpp
R engines/titanic/star_control/camera_mover.h
R engines/titanic/star_control/marked_camera_mover.cpp
R engines/titanic/star_control/marked_camera_mover.h
R engines/titanic/star_control/unmarked_camera_mover.cpp
R engines/titanic/star_control/unmarked_camera_mover.h
engines/titanic/module.mk
engines/titanic/star_control/camera.cpp
engines/titanic/star_control/camera.h
engines/titanic/star_control/star_control.cpp
engines/titanic/star_control/star_view.cpp
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 73517d7..d64de0a 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -434,7 +434,6 @@ MODULE_OBJS := \
star_control/base_stars.o \
star_control/camera.o \
star_control/camera_auto_mover.o \
- star_control/camera_mover.o \
star_control/const_boundaries.o \
star_control/constellations.o \
star_control/fmatrix.o \
@@ -444,8 +443,10 @@ MODULE_OBJS := \
star_control/frect.o \
star_control/fvector.o \
star_control/marked_auto_mover.o \
- star_control/marked_camera_mover.o \
star_control/matrix_transform.o \
+ star_control/motion_control.o \
+ star_control/motion_control_unmarked.o \
+ star_control/motion_control_marked.o \
star_control/orientation_changer.o \
star_control/star_closeup.o \
star_control/star_crosshairs.o \
@@ -457,7 +458,6 @@ MODULE_OBJS := \
star_control/surface_area.o \
star_control/surface_fader.o \
star_control/unmarked_auto_mover.o \
- star_control/unmarked_camera_mover.o \
star_control/viewport.o \
support/avi_surface.o \
support/direct_draw.o \
diff --git a/engines/titanic/star_control/camera.cpp b/engines/titanic/star_control/camera.cpp
index 069e3ec..febb2e5 100644
--- a/engines/titanic/star_control/camera.cpp
+++ b/engines/titanic/star_control/camera.cpp
@@ -22,11 +22,11 @@
#include "titanic/star_control/camera.h"
#include "titanic/debugger.h"
-#include "titanic/star_control/camera_mover.h"
+#include "titanic/star_control/motion_control.h"
#include "titanic/star_control/fmatrix.h"
#include "titanic/star_control/fpoint.h"
-#include "titanic/star_control/marked_camera_mover.h"
-#include "titanic/star_control/unmarked_camera_mover.h"
+#include "titanic/star_control/motion_control_marked.h"
+#include "titanic/star_control/motion_control_unmarked.h"
#include "titanic/star_control/error_code.h"
#include "titanic/support/simple_file.h"
#include "titanic/titanic.h"
@@ -433,17 +433,17 @@ void CCamera::save(SimpleFile *file, int indent) {
}
bool CCamera::setMoverType(const CNavigationInfo *src) {
- CCameraMover *mover = nullptr;
+ CMotionControl *mover = nullptr;
switch (_starLockState) {
case ZERO_LOCKED:
- mover = new CUnmarkedCameraMover(src);
+ mover = new CMotionControlUnmarked(src);
break;
case ONE_LOCKED:
case TWO_LOCKED:
case THREE_LOCKED:
- mover = new CMarkedCameraMover(src);
+ mover = new CMotionControlMarked(src);
break;
default:
@@ -502,8 +502,8 @@ bool CCamera::lockMarker1(FVector v1, FVector firstStarPosition, FVector v3) {
FMatrix matrix = _viewport.getOrientation();
const FVector &pos = _viewport._position;
_mover->transitionBetweenOrientations(v3, tempV, pos, matrix); // TODO: pos does not get used in this function,
- // i.e., _mover has CUnmarkedCameraMover handle which means
- // CUnmarkedCameraMover::transitionBetweenOrientations gets called
+ // i.e., _mover has CMotionControlUnmarked handle which means
+ // CMotionControlUnmarked::transitionBetweenOrientations gets called
CStarVector *sv = new CStarVector(this, firstStarPosition);
_mover->setVector(sv);
diff --git a/engines/titanic/star_control/camera.h b/engines/titanic/star_control/camera.h
index c130bd2..01cf2a7 100644
--- a/engines/titanic/star_control/camera.h
+++ b/engines/titanic/star_control/camera.h
@@ -29,7 +29,7 @@
namespace Titanic {
-class CCameraMover;
+class CMotionControl;
class CErrorCode;
struct CNavigationInfo;
class FPoint;
@@ -47,7 +47,7 @@ private:
private:
StarLockState _starLockState;
FMatrix _lockedStarsPos; // Each row represents the location of a locked star
- CCameraMover *_mover; // A marked or unmarked camera mover, contains an automover
+ CMotionControl *_mover; // A marked or unmarked camera mover, contains an automover
CViewport _viewport;
bool _isMoved; // Used in CPetStarfield to determine if a star destination can be set
bool _isInLockingProcess; // The mover/view is homing in on a new star
diff --git a/engines/titanic/star_control/camera_mover.cpp b/engines/titanic/star_control/camera_mover.cpp
deleted file mode 100644
index 8669aee..0000000
--- a/engines/titanic/star_control/camera_mover.cpp
+++ /dev/null
@@ -1,152 +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/camera_mover.h"
-#include "titanic/star_control/base_stars.h" // includes class CStarVector
-#include "titanic/star_control/error_code.h"
-#include "titanic/support/simple_file.h"
-// Not currently being used: #include "common/textconsole.h"
-
-namespace Titanic {
-
-CCameraMover::CCameraMover(const CNavigationInfo *src) {
- _lockCounter = 0;
- _starVector = nullptr;
-
- if (src) {
- setMotion(src);
- } else {
- reset();
- }
-}
-
-CCameraMover::~CCameraMover() {
- clear();
-}
-
-void CCameraMover::clear() {
- if (_starVector) {
- delete _starVector;
- _starVector = nullptr;
- }
-}
-
-void CCameraMover::reset() {
- _currVelocity = 0.0;
- _incVelocity = 0.0;
- _incAcceleration = 20.0;
- _minVelocity = 0.0;
- _maxVelocity = 50000.0;
- _rotationX = 1.0;
- _rotationY = 1.0;
- _rotationZ = 0.0;
-}
-
-void CCameraMover::setVector(CStarVector *sv) {
- clear();
- _starVector = sv;
-}
-
-void CCameraMover::setMotion(const CNavigationInfo *src) {
- _currVelocity = src->_initialVelocity;
- _minVelocity = src->_minVelocity;
- _maxVelocity = src->_maxVelocity;
- _incVelocity = src->_velocity;
- _incAcceleration = src->_acceleration;
- _rotationX = src->_rotationX;
- _rotationY = src->_rotationY;
- _rotationZ = src->_rotationZ;
-}
-
-void CCameraMover::getMotion(CNavigationInfo *dest) {
- dest->_initialVelocity = _currVelocity;
- dest->_minVelocity = _minVelocity;
- dest->_maxVelocity = _maxVelocity;
- dest->_velocity = _incVelocity;
- dest->_acceleration = _incAcceleration;
- dest->_rotationX = _rotationX;
- dest->_rotationY = _rotationY;
- dest->_rotationZ = _rotationZ;
-}
-
-void CCameraMover::accelerate() {
- if (!isLocked() && _currVelocity < _maxVelocity) {
- _incVelocity += _incAcceleration;
- _currVelocity += ABS(_incVelocity);
- }
-}
-
-void CCameraMover::deccelerate() {
- if (!isLocked() && _currVelocity > -_maxVelocity) {
- _incVelocity -= _incAcceleration;
- _currVelocity -= ABS(_incVelocity);
- }
-}
-
-void CCameraMover::fullSpeed() {
- if (!isLocked())
- _currVelocity = _maxVelocity;
-}
-
-void CCameraMover::stop() {
- if (!isLocked()) {
- _currVelocity = 0.0;
- _incVelocity = 0.0;
- }
-}
-
-// TODO: this is confusing to negate the val value
-void CCameraMover::load(SimpleFile *file, int val) {
- if (!val) {
- _currVelocity = file->readFloat();
- _incVelocity = file->readFloat();
- _incAcceleration = file->readFloat();
- _minVelocity = file->readFloat();
- _maxVelocity = file->readFloat();
- _rotationX = file->readFloat();
- _rotationY = file->readFloat();
- _rotationZ = file->readFloat();
- }
-}
-
-void CCameraMover::save(SimpleFile *file, int indent) {
- file->writeFloatLine(_currVelocity, indent);
- file->writeFloatLine(_incVelocity, indent);
- file->writeFloatLine(_incAcceleration, indent);
- file->writeFloatLine(_minVelocity, indent);
- file->writeFloatLine(_maxVelocity, indent);
- file->writeFloatLine(_rotationX, indent);
- file->writeFloatLine(_rotationY, indent);
- file->writeFloatLine(_rotationZ, indent);
-}
-
-void CCameraMover::incLockCount() {
- if (_lockCounter < 3)
- ++_lockCounter;
-}
-
-void CCameraMover::decLockCount() {
- if (_lockCounter > 0)
- --_lockCounter;
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/camera_mover.h b/engines/titanic/star_control/camera_mover.h
deleted file mode 100644
index 28800fa..0000000
--- a/engines/titanic/star_control/camera_mover.h
+++ /dev/null
@@ -1,149 +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_CAMERA_MOVER_H
-#define TITANIC_CAMERA_MOVER_H
-
-namespace Titanic {
-
-class CErrorCode;
-class CStarVector;
-class FMatrix;
-class FVector;
-class SimpleFile;
-
-struct CNavigationInfo {
- double _initialVelocity;
- double _minVelocity;
- double _maxVelocity;
- double _velocity;
- double _acceleration;
- double _rotationX;
- double _rotationY;
- double _rotationZ;
-};
-
-class CCameraMover {
-protected:
- double _currVelocity;
- double _incVelocity;
- double _incAcceleration;
- double _minVelocity;
- double _maxVelocity;
- double _rotationX;
- double _rotationY;
- double _rotationZ;
-public:
- int _lockCounter;
- CStarVector *_starVector;
-public:
- CCameraMover(const CNavigationInfo *src);
- virtual ~CCameraMover();
-
- virtual void setMotion(const CNavigationInfo *src);
- virtual void getMotion(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 accelerate();
-
- /**
- * Decreases movement speed in backward direction
- */
- virtual void deccelerate();
-
- /**
- * Increase to full speed
- */
- virtual void fullSpeed();
-
- /**
- * Completely stop
- */
- virtual void stop();
-
- /**
- * 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) {}
-
- /**
- * Start a movement to a given specified destination
- */
- virtual void moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {}
-
- /**
- * First two vectors are used to form a new orientation that gets transitioned to from the old
- * orientation m.
- */
- virtual void transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {}
-
- /**
- * Update the passed position and orientation matrix
- */
- virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {}
-
- /**
- * Load the class
- */
- virtual void load(SimpleFile *file, int val = 0);
-
- /**
- * Save the class
- */
- virtual void save(SimpleFile *file, int indent);
-
- /**
- * Increment tthe lock counter
- */
- void incLockCount();
-
- /**
- * Decrement the lock counter
- */
- void decLockCount();
-
- /**
- * Returns true if the lock counter is non-zero
- */
- bool isLocked() const { return _lockCounter > 0; }
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_CAMERA_MOVER_H */
diff --git a/engines/titanic/star_control/marked_camera_mover.cpp b/engines/titanic/star_control/marked_camera_mover.cpp
deleted file mode 100644
index e22dd8b..0000000
--- a/engines/titanic/star_control/marked_camera_mover.cpp
+++ /dev/null
@@ -1,63 +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/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 {
-
-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.setPathOrients(oldPos, newPos, oldOrientation, newOrientation);
- incLockCount();
-}
-
-void CMarkedCameraMover::updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
- if (_autoMover.isActive()) {
- decLockCount();
- MoverState moveState = _autoMover.move(errorCode, pos, orientation);
- if (moveState == MOVING)
- incLockCount();
- if (moveState == DONE_MOVING) {
- stop();
- if (_starVector)
- _starVector->apply();
- }
- } else if (_currVelocity != 0.0) {
- pos._x += orientation._row3._x * _currVelocity;
- pos._y += orientation._row3._y * _currVelocity;
- pos._z += orientation._row3._z * _currVelocity;
- errorCode.set();
- }
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/marked_camera_mover.h b/engines/titanic/star_control/marked_camera_mover.h
deleted file mode 100644
index 2e97161..0000000
--- a/engines/titanic/star_control/marked_camera_mover.h
+++ /dev/null
@@ -1,56 +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_MARKED_CAMERA_MOVER_H
-#define TITANIC_MARKED_CAMERA_MOVER_H
-
-#include "titanic/star_control/camera_mover.h"
-#include "titanic/star_control/marked_auto_mover.h"
-
-namespace Titanic {
-
-class FMatrix;
-class FVector;
-
-class CMarkedCameraMover : public CCameraMover {
-private:
- CMarkedAutoMover _autoMover;
-public:
- CMarkedCameraMover(const CNavigationInfo *src);
- virtual ~CMarkedCameraMover() {}
-
- /**
- * 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);
-
- /**
- * Update the passed position and orientation matrix
- */
- virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_MARKED_CAMERA_MOVER_H */
diff --git a/engines/titanic/star_control/motion_control.cpp b/engines/titanic/star_control/motion_control.cpp
new file mode 100644
index 0000000..8f25a7d
--- /dev/null
+++ b/engines/titanic/star_control/motion_control.cpp
@@ -0,0 +1,151 @@
+/* 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/motion_control.h"
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/error_code.h"
+#include "titanic/support/simple_file.h"
+
+namespace Titanic {
+
+CMotionControl::CMotionControl(const CNavigationInfo *src) {
+ _lockCounter = 0;
+ _starVector = nullptr;
+
+ if (src) {
+ setMotion(src);
+ } else {
+ reset();
+ }
+}
+
+CMotionControl::~CMotionControl() {
+ clear();
+}
+
+void CMotionControl::clear() {
+ if (_starVector) {
+ delete _starVector;
+ _starVector = nullptr;
+ }
+}
+
+void CMotionControl::reset() {
+ _currVelocity = 0.0;
+ _incVelocity = 0.0;
+ _incAcceleration = 20.0;
+ _minVelocity = 0.0;
+ _maxVelocity = 50000.0;
+ _rotationX = 1.0;
+ _rotationY = 1.0;
+ _rotationZ = 0.0;
+}
+
+void CMotionControl::setVector(CStarVector *sv) {
+ clear();
+ _starVector = sv;
+}
+
+void CMotionControl::setMotion(const CNavigationInfo *src) {
+ _currVelocity = src->_initialVelocity;
+ _minVelocity = src->_minVelocity;
+ _maxVelocity = src->_maxVelocity;
+ _incVelocity = src->_velocity;
+ _incAcceleration = src->_acceleration;
+ _rotationX = src->_rotationX;
+ _rotationY = src->_rotationY;
+ _rotationZ = src->_rotationZ;
+}
+
+void CMotionControl::getMotion(CNavigationInfo *dest) {
+ dest->_initialVelocity = _currVelocity;
+ dest->_minVelocity = _minVelocity;
+ dest->_maxVelocity = _maxVelocity;
+ dest->_velocity = _incVelocity;
+ dest->_acceleration = _incAcceleration;
+ dest->_rotationX = _rotationX;
+ dest->_rotationY = _rotationY;
+ dest->_rotationZ = _rotationZ;
+}
+
+void CMotionControl::accelerate() {
+ if (!isLocked() && _currVelocity < _maxVelocity) {
+ _incVelocity += _incAcceleration;
+ _currVelocity += ABS(_incVelocity);
+ }
+}
+
+void CMotionControl::deccelerate() {
+ if (!isLocked() && _currVelocity > -_maxVelocity) {
+ _incVelocity -= _incAcceleration;
+ _currVelocity -= ABS(_incVelocity);
+ }
+}
+
+void CMotionControl::fullSpeed() {
+ if (!isLocked())
+ _currVelocity = _maxVelocity;
+}
+
+void CMotionControl::stop() {
+ if (!isLocked()) {
+ _currVelocity = 0.0;
+ _incVelocity = 0.0;
+ }
+}
+
+// TODO: this is confusing to negate the val value
+void CMotionControl::load(SimpleFile *file, int val) {
+ if (!val) {
+ _currVelocity = file->readFloat();
+ _incVelocity = file->readFloat();
+ _incAcceleration = file->readFloat();
+ _minVelocity = file->readFloat();
+ _maxVelocity = file->readFloat();
+ _rotationX = file->readFloat();
+ _rotationY = file->readFloat();
+ _rotationZ = file->readFloat();
+ }
+}
+
+void CMotionControl::save(SimpleFile *file, int indent) {
+ file->writeFloatLine(_currVelocity, indent);
+ file->writeFloatLine(_incVelocity, indent);
+ file->writeFloatLine(_incAcceleration, indent);
+ file->writeFloatLine(_minVelocity, indent);
+ file->writeFloatLine(_maxVelocity, indent);
+ file->writeFloatLine(_rotationX, indent);
+ file->writeFloatLine(_rotationY, indent);
+ file->writeFloatLine(_rotationZ, indent);
+}
+
+void CMotionControl::incLockCount() {
+ if (_lockCounter < 3)
+ ++_lockCounter;
+}
+
+void CMotionControl::decLockCount() {
+ if (_lockCounter > 0)
+ --_lockCounter;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/motion_control.h b/engines/titanic/star_control/motion_control.h
new file mode 100644
index 0000000..6fc77f1
--- /dev/null
+++ b/engines/titanic/star_control/motion_control.h
@@ -0,0 +1,149 @@
+/* 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_MOTION_CONTROL_H
+#define TITANIC_MOTION_CONTROL_H
+
+namespace Titanic {
+
+class CErrorCode;
+class CStarVector;
+class FMatrix;
+class FVector;
+class SimpleFile;
+
+struct CNavigationInfo {
+ double _initialVelocity;
+ double _minVelocity;
+ double _maxVelocity;
+ double _velocity;
+ double _acceleration;
+ double _rotationX;
+ double _rotationY;
+ double _rotationZ;
+};
+
+class CMotionControl {
+protected:
+ double _currVelocity;
+ double _incVelocity;
+ double _incAcceleration;
+ double _minVelocity;
+ double _maxVelocity;
+ double _rotationX;
+ double _rotationY;
+ double _rotationZ;
+public:
+ int _lockCounter;
+ CStarVector *_starVector;
+public:
+ CMotionControl(const CNavigationInfo *src);
+ virtual ~CMotionControl();
+
+ virtual void setMotion(const CNavigationInfo *src);
+ virtual void getMotion(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 accelerate();
+
+ /**
+ * Decreases movement speed in backward direction
+ */
+ virtual void deccelerate();
+
+ /**
+ * Increase to full speed
+ */
+ virtual void fullSpeed();
+
+ /**
+ * Completely stop
+ */
+ virtual void stop();
+
+ /**
+ * 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) {}
+
+ /**
+ * Start a movement to a given specified destination
+ */
+ virtual void moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {}
+
+ /**
+ * First two vectors are used to form a new orientation that gets transitioned to from the old
+ * orientation m.
+ */
+ virtual void transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {}
+
+ /**
+ * Update the passed position and orientation matrix
+ */
+ virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {}
+
+ /**
+ * Load the class
+ */
+ virtual void load(SimpleFile *file, int val = 0);
+
+ /**
+ * Save the class
+ */
+ virtual void save(SimpleFile *file, int indent);
+
+ /**
+ * Increment tthe lock counter
+ */
+ void incLockCount();
+
+ /**
+ * Decrement the lock counter
+ */
+ void decLockCount();
+
+ /**
+ * Returns true if the lock counter is non-zero
+ */
+ bool isLocked() const { return _lockCounter > 0; }
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_MOTION_CONTROL_H */
diff --git a/engines/titanic/star_control/motion_control_marked.cpp b/engines/titanic/star_control/motion_control_marked.cpp
new file mode 100644
index 0000000..bea9c18
--- /dev/null
+++ b/engines/titanic/star_control/motion_control_marked.cpp
@@ -0,0 +1,62 @@
+/* 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/motion_control_marked.h"
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/error_code.h"
+#include "titanic/star_control/fmatrix.h"
+
+namespace Titanic {
+
+CMotionControlMarked::CMotionControlMarked(const CNavigationInfo *src) :
+ CMotionControl(src) {
+}
+
+void CMotionControlMarked::transitionBetweenPosOrients(const FVector &oldPos, const FVector &newPos,
+ const FMatrix &oldOrientation, const FMatrix &newOrientation) {
+ if (isLocked())
+ decLockCount();
+
+ _autoMover.setPathOrients(oldPos, newPos, oldOrientation, newOrientation);
+ incLockCount();
+}
+
+void CMotionControlMarked::updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
+ if (_autoMover.isActive()) {
+ decLockCount();
+ MoverState moveState = _autoMover.move(errorCode, pos, orientation);
+ if (moveState == MOVING)
+ incLockCount();
+ if (moveState == DONE_MOVING) {
+ stop();
+ if (_starVector)
+ _starVector->apply();
+ }
+ } else if (_currVelocity != 0.0) {
+ pos._x += orientation._row3._x * _currVelocity;
+ pos._y += orientation._row3._y * _currVelocity;
+ pos._z += orientation._row3._z * _currVelocity;
+ errorCode.set();
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/motion_control_marked.h b/engines/titanic/star_control/motion_control_marked.h
new file mode 100644
index 0000000..6c2c8a7
--- /dev/null
+++ b/engines/titanic/star_control/motion_control_marked.h
@@ -0,0 +1,56 @@
+/* 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_MOTION_CONTROL_MARKED_H
+#define TITANIC_MOTION_CONTROL_MARKED_H
+
+#include "titanic/star_control/motion_control.h"
+#include "titanic/star_control/marked_auto_mover.h"
+
+namespace Titanic {
+
+class FMatrix;
+class FVector;
+
+class CMotionControlMarked : public CMotionControl {
+private:
+ CMarkedAutoMover _autoMover;
+public:
+ CMotionControlMarked(const CNavigationInfo *src);
+ virtual ~CMotionControlMarked() {}
+
+ /**
+ * 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);
+
+ /**
+ * Update the passed position and orientation matrix
+ */
+ virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_MOTION_CONTROL_MARKED_H */
diff --git a/engines/titanic/star_control/motion_control_unmarked.cpp b/engines/titanic/star_control/motion_control_unmarked.cpp
new file mode 100644
index 0000000..d84f0dc
--- /dev/null
+++ b/engines/titanic/star_control/motion_control_unmarked.cpp
@@ -0,0 +1,79 @@
+/* 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/motion_control_unmarked.h"
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/fpose.h"
+#include "titanic/star_control/error_code.h"
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/debugger.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+CMotionControlUnmarked::CMotionControlUnmarked(const CNavigationInfo *src) :
+ CMotionControl(src) {
+}
+
+void CMotionControlUnmarked::moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
+ if (isLocked())
+ decLockCount();
+
+ debugC(DEBUG_BASIC, kDebugStarfield, "Starfield move %s to %s", srcV.toString().c_str(),
+ destV.toString().c_str());
+ _autoMover.setPathOrient(srcV, destV, orientation);
+}
+
+// TODO: v3 is unused
+void CMotionControlUnmarked::transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {
+ if (isLocked())
+ decLockCount();
+
+ FVector vector1 = v1;
+ FVector vector2 = v2;
+ FPose matrix1 = vector2.getFrameTransform(vector1);
+ FPose matrix2 = matrix1.compose(m);
+
+ _autoMover.setOrientations(m, matrix2);
+ incLockCount();
+}
+
+void CMotionControlUnmarked::updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
+ if (_autoMover.isActive()) {
+ decLockCount();
+ MoverState moverState = _autoMover.move(errorCode, pos, orientation);
+ if (moverState == MOVING)
+ incLockCount();
+ if (moverState == DONE_MOVING) {
+ stop();
+ if (_starVector)
+ _starVector->apply();
+ }
+ } else if (_currVelocity != 0.0) {
+ pos._x += orientation._row3._x * _currVelocity;
+ pos._y += orientation._row3._y * _currVelocity;
+ pos._z += orientation._row3._z * _currVelocity;
+ errorCode.set();
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/motion_control_unmarked.h b/engines/titanic/star_control/motion_control_unmarked.h
new file mode 100644
index 0000000..cddfea7
--- /dev/null
+++ b/engines/titanic/star_control/motion_control_unmarked.h
@@ -0,0 +1,56 @@
+/* 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_UNMARKED_CAMERA_MOVER_H
+#define TITANIC_UNMARKED_CAMERA_MOVER_H
+
+#include "titanic/star_control/motion_control.h"
+#include "titanic/star_control/unmarked_auto_mover.h"
+
+namespace Titanic {
+
+class FMatrix;
+class FVector;
+
+class CMotionControlUnmarked : public CMotionControl {
+private:
+ CUnmarkedAutoMover _autoMover;
+public:
+ CMotionControlUnmarked(const CNavigationInfo *src);
+ virtual ~CMotionControlUnmarked() {}
+
+ /**
+ * Start a movement to a given specified destination
+ */
+ virtual void moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
+
+ virtual void transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m);
+
+ /**
+ * Update the passed position and orientation matrix
+ */
+ virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_UNMARKED_CAMERA_MOVER_H */
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp
index fe63936..b53d7e2 100644
--- a/engines/titanic/star_control/star_control.cpp
+++ b/engines/titanic/star_control/star_control.cpp
@@ -25,7 +25,7 @@
#include "titanic/core/project_item.h"
#include "titanic/game_manager.h"
#include "titanic/pet_control/pet_control.h"
-#include "titanic/star_control/camera_mover.h"
+#include "titanic/star_control/motion_control.h"
#include "titanic/star_control/error_code.h" // CErrorCode
#include "titanic/support/screen_manager.h"
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 1fb5b6a..4a76f96 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -21,7 +21,7 @@
*/
#include "titanic/star_control/star_view.h"
-#include "titanic/star_control/camera_mover.h"
+#include "titanic/star_control/motion_control.h"
#include "titanic/star_control/error_code.h"
#include "titanic/star_control/fvector.h"
#include "titanic/star_control/star_control.h"
diff --git a/engines/titanic/star_control/unmarked_camera_mover.cpp b/engines/titanic/star_control/unmarked_camera_mover.cpp
deleted file mode 100644
index 8ecd900..0000000
--- a/engines/titanic/star_control/unmarked_camera_mover.cpp
+++ /dev/null
@@ -1,79 +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/unmarked_camera_mover.h"
-#include "titanic/debugger.h"
-#include "titanic/star_control/base_stars.h"
-#include "titanic/star_control/fpose.h"
-#include "titanic/star_control/error_code.h"
-#include "titanic/star_control/fmatrix.h"
-#include "titanic/titanic.h"
-
-namespace Titanic {
-
-CUnmarkedCameraMover::CUnmarkedCameraMover(const CNavigationInfo *src) :
- CCameraMover(src) {
-}
-
-void CUnmarkedCameraMover::moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
- if (isLocked())
- decLockCount();
-
- debugC(DEBUG_BASIC, kDebugStarfield, "Starfield move %s to %s", srcV.toString().c_str(),
- destV.toString().c_str());
- _autoMover.setPathOrient(srcV, destV, orientation);
-}
-
-// TODO: v3 is unused
-void CUnmarkedCameraMover::transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {
- if (isLocked())
- decLockCount();
-
- FVector vector1 = v1;
- FVector vector2 = v2;
- FPose matrix1 = vector2.getFrameTransform(vector1);
- FPose matrix2 = matrix1.compose(m);
-
- _autoMover.setOrientations(m, matrix2);
- incLockCount();
-}
-
-void CUnmarkedCameraMover::updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
- if (_autoMover.isActive()) {
- decLockCount();
- MoverState moverState = _autoMover.move(errorCode, pos, orientation);
- if (moverState == MOVING)
- incLockCount();
- if (moverState == DONE_MOVING) {
- stop();
- if (_starVector)
- _starVector->apply();
- }
- } else if (_currVelocity != 0.0) {
- pos._x += orientation._row3._x * _currVelocity;
- pos._y += orientation._row3._y * _currVelocity;
- pos._z += orientation._row3._z * _currVelocity;
- errorCode.set();
- }
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/unmarked_camera_mover.h b/engines/titanic/star_control/unmarked_camera_mover.h
deleted file mode 100644
index cb606b9..0000000
--- a/engines/titanic/star_control/unmarked_camera_mover.h
+++ /dev/null
@@ -1,56 +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_UNMARKED_CAMERA_MOVER_H
-#define TITANIC_UNMARKED_CAMERA_MOVER_H
-
-#include "titanic/star_control/camera_mover.h"
-#include "titanic/star_control/unmarked_auto_mover.h"
-
-namespace Titanic {
-
-class FMatrix;
-class FVector;
-
-class CUnmarkedCameraMover : public CCameraMover {
-private:
- CUnmarkedAutoMover _autoMover;
-public:
- CUnmarkedCameraMover(const CNavigationInfo *src);
- virtual ~CUnmarkedCameraMover() {}
-
- /**
- * Start a movement to a given specified destination
- */
- virtual void moveTo(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
-
- virtual void transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m);
-
- /**
- * Update the passed position and orientation matrix
- */
- virtual void updatePosition(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_UNMARKED_CAMERA_MOVER_H */
Commit: 0280ca23597fae3aa2955b03a36bc4e90fe92ba9
https://github.com/scummvm/scummvm/commit/0280ca23597fae3aa2955b03a36bc4e90fe92ba9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Clarifying auto movers as flight managers
Changed paths:
A engines/titanic/star_control/flight_manager_base.cpp
A engines/titanic/star_control/flight_manager_base.h
A engines/titanic/star_control/flight_manager_marked.cpp
A engines/titanic/star_control/flight_manager_marked.h
A engines/titanic/star_control/flight_manager_unmarked.cpp
A engines/titanic/star_control/flight_manager_unmarked.h
R engines/titanic/star_control/camera_auto_mover.cpp
R engines/titanic/star_control/camera_auto_mover.h
R engines/titanic/star_control/marked_auto_mover.cpp
R engines/titanic/star_control/marked_auto_mover.h
R engines/titanic/star_control/unmarked_auto_mover.cpp
R engines/titanic/star_control/unmarked_auto_mover.h
engines/titanic/module.mk
engines/titanic/star_control/motion_control.cpp
engines/titanic/star_control/motion_control.h
engines/titanic/star_control/motion_control_marked.h
engines/titanic/star_control/motion_control_unmarked.h
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index d64de0a..6b41900 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -433,9 +433,11 @@ MODULE_OBJS := \
star_control/star_control.o \
star_control/base_stars.o \
star_control/camera.o \
- star_control/camera_auto_mover.o \
star_control/const_boundaries.o \
star_control/constellations.o \
+ star_control/flight_manager_base.o \
+ star_control/flight_manager_marked.o \
+ star_control/flight_manager_unmarked.o \
star_control/fmatrix.o \
star_control/fpoint.o \
star_control/fpose.o \
diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp
deleted file mode 100644
index d880865..0000000
--- a/engines/titanic/star_control/camera_auto_mover.cpp
+++ /dev/null
@@ -1,95 +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/camera_auto_mover.h"
-#include "titanic/star_control/fmatrix.h"
-
-namespace Titanic {
-
-CCameraAutoMover::CCameraAutoMover() : _srcPos(0.0, 1000000.0, 0.0) {
- _field4 = 0;
- _active = false;
- _distance = 0.0;
- _field34 = false;
- _field38 = 0.0;
- _field3C = 0;
- _field40 = 0;
- _field44 = 0;
- _field48 = 0;
- _field4C = 0;
- _field54 = 0;
- _transitionPercent = 0.0;
- _transitionPercentInc = 0.0;
-}
-
-void CCameraAutoMover::clear() {
- _srcPos.clear();
- _destPos.clear();
- _transitionPercent = 1.0;
- _distance = 0.0;
- _active = false;
- _field34 = false;
-}
-
-void CCameraAutoMover::setPath(const FVector &srcV, const FVector &destV) {
- _srcPos = srcV;
- _destPos = destV;
- _posDelta = _destPos - _srcPos;
-
- float temp = 0.0;
- _posDelta.normalize(temp); // normalization won't happen if _posDelta is zero vector
- // and that is okay
-
- _distance = temp;
- _active = false;
- _field34 = false;
- _field40 = -1;
- _field44 = -1;
- _field48 = -1;
- _field4C = -1;
- _transitionPercent = 1.0;
-}
-
-void CCameraAutoMover::calcSpeeds(int val1, int val2, float distance) {
- // Usually val1 and val2 are small where as distance can be large
- _field44 = val1;
- _field4C = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
- // should it always be x2 (_nMoverTransitions - 1)?
- _field38 = distance / (double)(val1 + val2 * 2);
- _field40 = nMoverTransitions-1;
- _field48 = nMoverTransitions-1;
- _field3C = (double)val2 * _field38;
-
- // Calculate the speeds for a graduated movement between stars
- double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125;
- for (int idx = nMoverTransitions - 1; idx >= 0; --idx) {
- _speeds[idx] = pow(base, power);
- total += _speeds[idx];
- base += baseInc;
- }
-
- for (int idx = 0; idx < nMoverTransitions; ++idx) {
- _speeds[idx] = _speeds[idx] * _field3C / total;
- }
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/camera_auto_mover.h b/engines/titanic/star_control/camera_auto_mover.h
deleted file mode 100644
index d9b2888..0000000
--- a/engines/titanic/star_control/camera_auto_mover.h
+++ /dev/null
@@ -1,88 +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_CAMERA_AUTO_MOVER_H
-#define TITANIC_CAMERA_AUTO_MOVER_H
-
-#include "titanic/star_control/fvector.h"
-#include "titanic/star_control/orientation_changer.h"
-#include "common/array.h"
-
-namespace Titanic {
-
-class CErrorCode;
-class FMatrix;
-const int nMoverTransitions = 32; // The number of vector transitions when doing a mover change is fixed
-enum MoverState { NOT_ACTIVE = 0, MOVING = 1, DONE_MOVING = 2 };
-
-/**
- * Base class for automatic movement of the starview camera
- */
-class CCameraAutoMover {
-protected:
- int _field4;
- bool _active;
- FVector _srcPos, _destPos;
- double _distance;
- FVector _posDelta;
- bool _field34;
- double _field38;
- double _field3C;
- int _field40;
- int _field44;
- int _field48;
- int _field4C;
- double _speeds[nMoverTransitions];
- int _field54;
- double _transitionPercent;
- double _transitionPercentInc;
- COrientationChanger _orientationChanger;
-public:
- CCameraAutoMover();
- virtual ~CCameraAutoMover() {}
-
- /**
- * Clear src and dest orientation and set some default values for other fields
- */
- void clear();
-
- /**
- * 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
- */
- virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) { return DONE_MOVING; }
- /**
- * Given a distance to cover, determines a bunch of speeds for a gradual transition
- * from one position to another (the mover). The speeds go from fast to slow
- */
- virtual void calcSpeeds(int val1, int val2, float distance);
-
- bool isActive() const { return _active; }
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_CAMERA_AUTO_MOVER_H */
diff --git a/engines/titanic/star_control/flight_manager_base.cpp b/engines/titanic/star_control/flight_manager_base.cpp
new file mode 100644
index 0000000..a430dfc
--- /dev/null
+++ b/engines/titanic/star_control/flight_manager_base.cpp
@@ -0,0 +1,95 @@
+/* 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/flight_manager_base.h"
+#include "titanic/star_control/fmatrix.h"
+
+namespace Titanic {
+
+CFlightManagerBase::CFlightManagerBase() : _srcPos(0.0, 1000000.0, 0.0) {
+ _field4 = 0;
+ _active = false;
+ _distance = 0.0;
+ _field34 = false;
+ _field38 = 0.0;
+ _field3C = 0;
+ _field40 = 0;
+ _field44 = 0;
+ _field48 = 0;
+ _field4C = 0;
+ _field54 = 0;
+ _transitionPercent = 0.0;
+ _transitionPercentInc = 0.0;
+}
+
+void CFlightManagerBase::clear() {
+ _srcPos.clear();
+ _destPos.clear();
+ _transitionPercent = 1.0;
+ _distance = 0.0;
+ _active = false;
+ _field34 = false;
+}
+
+void CFlightManagerBase::setPath(const FVector &srcV, const FVector &destV) {
+ _srcPos = srcV;
+ _destPos = destV;
+ _posDelta = _destPos - _srcPos;
+
+ float temp = 0.0;
+ _posDelta.normalize(temp); // normalization won't happen if _posDelta is zero vector
+ // and that is okay
+
+ _distance = temp;
+ _active = false;
+ _field34 = false;
+ _field40 = -1;
+ _field44 = -1;
+ _field48 = -1;
+ _field4C = -1;
+ _transitionPercent = 1.0;
+}
+
+void CFlightManagerBase::calcSpeeds(int val1, int val2, float distance) {
+ // Usually val1 and val2 are small where as distance can be large
+ _field44 = val1;
+ _field4C = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
+ // should it always be x2 (_nMoverTransitions - 1)?
+ _field38 = distance / (double)(val1 + val2 * 2);
+ _field40 = nMoverTransitions-1;
+ _field48 = nMoverTransitions-1;
+ _field3C = (double)val2 * _field38;
+
+ // Calculate the speeds for a graduated movement between stars
+ double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125;
+ for (int idx = nMoverTransitions - 1; idx >= 0; --idx) {
+ _speeds[idx] = pow(base, power);
+ total += _speeds[idx];
+ base += baseInc;
+ }
+
+ for (int idx = 0; idx < nMoverTransitions; ++idx) {
+ _speeds[idx] = _speeds[idx] * _field3C / total;
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/flight_manager_base.h b/engines/titanic/star_control/flight_manager_base.h
new file mode 100644
index 0000000..2a49125
--- /dev/null
+++ b/engines/titanic/star_control/flight_manager_base.h
@@ -0,0 +1,88 @@
+/* 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_FLIGHT_MANAGER_BASE_H
+#define TITANIC_FLIGHT_MANAGER_BASE_H
+
+#include "titanic/star_control/fvector.h"
+#include "titanic/star_control/orientation_changer.h"
+#include "common/array.h"
+
+namespace Titanic {
+
+class CErrorCode;
+class FMatrix;
+const int nMoverTransitions = 32; // The number of vector transitions when doing a mover change is fixed
+enum MoverState { NOT_ACTIVE = 0, MOVING = 1, DONE_MOVING = 2 };
+
+/**
+ * Base class for flight manager handling automated movement
+ */
+class CFlightManagerBase {
+protected:
+ int _field4;
+ bool _active;
+ FVector _srcPos, _destPos;
+ double _distance;
+ FVector _posDelta;
+ bool _field34;
+ double _field38;
+ double _field3C;
+ int _field40;
+ int _field44;
+ int _field48;
+ int _field4C;
+ double _speeds[nMoverTransitions];
+ int _field54;
+ double _transitionPercent;
+ double _transitionPercentInc;
+ COrientationChanger _orientationChanger;
+public:
+ CFlightManagerBase();
+ virtual ~CFlightManagerBase() {}
+
+ /**
+ * Clear src and dest orientation and set some default values for other fields
+ */
+ void clear();
+
+ /**
+ * 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
+ */
+ virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) { return DONE_MOVING; }
+ /**
+ * Given a distance to cover, determines a bunch of speeds for a gradual transition
+ * from one position to another (the mover). The speeds go from fast to slow
+ */
+ virtual void calcSpeeds(int val1, int val2, float distance);
+
+ bool isActive() const { return _active; }
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_FLIGHT_MANAGER_BASE_H */
diff --git a/engines/titanic/star_control/flight_manager_marked.cpp b/engines/titanic/star_control/flight_manager_marked.cpp
new file mode 100644
index 0000000..bd8106d
--- /dev/null
+++ b/engines/titanic/star_control/flight_manager_marked.cpp
@@ -0,0 +1,105 @@
+/* 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/flight_manager_marked.h"
+#include "titanic/star_control/error_code.h"
+
+namespace Titanic {
+
+void CMarkedAutoMover::setPathOrients(const FVector &oldPos, const FVector &newPos,
+ const FMatrix &oldOrientation, const FMatrix &newOrientation) {
+ CFlightManagerBase::setPath(oldPos, newPos);
+
+ double distance = _distance;
+ _active = true;
+ _field34 = true;
+ calcSpeeds(120, 4, distance);
+
+
+ _orientationChanger.load(oldOrientation, newOrientation);
+ _transitionPercent = 0.0;
+
+ if (_field4C == 0) {
+ _transitionPercentInc = 0.1;
+ _active = true;
+ } else {
+ _transitionPercentInc = 1.0 / _field4C;
+ _active = true;
+ }
+
+}
+
+MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
+ if (!_active)
+ return NOT_ACTIVE;
+
+ _transitionPercent += _transitionPercentInc;
+ orientation = _orientationChanger.getOrientation(_transitionPercent);
+ errorCode.set();
+
+ if (_field40 >= 0) {
+ double speedVal = _speeds[_field40];
+ pos += _posDelta * speedVal;
+ getVectorOnPath(pos);
+
+ --_field40;
+ errorCode.set();
+ return MOVING;
+ } else if (_field44 > 0) {
+ pos += _posDelta * _field38;
+ getVectorOnPath(pos);
+
+ --_field44;
+ errorCode.set();
+ return MOVING;
+ } else if (_field48 >= 0) {
+ double speedVal = _speeds[nMoverTransitions - 1 - _field48];
+ pos += _posDelta * speedVal;
+ getVectorOnPath(pos);
+
+ --_field48;
+ errorCode.set();
+ return MOVING;
+ } else {
+ _active = false;
+ return DONE_MOVING;
+ }
+}
+
+void CMarkedAutoMover::getVectorOnPath(FVector &pos) const {
+ double distance = _posDelta.getDistance(pos);
+ distance /= _distance;
+
+ if (distance <= 0.0) {
+ pos = _srcPos;
+ } else if (distance >= 1.0) {
+ pos = _destPos;
+ } else {
+ pos = FVector(
+ (_destPos._x - _srcPos._x) * distance + _srcPos._x,
+ (_destPos._y - _srcPos._y) * distance + _srcPos._y,
+ (_destPos._z - _srcPos._z) * distance + _srcPos._z
+ );
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/flight_manager_marked.h b/engines/titanic/star_control/flight_manager_marked.h
new file mode 100644
index 0000000..de9bc46
--- /dev/null
+++ b/engines/titanic/star_control/flight_manager_marked.h
@@ -0,0 +1,55 @@
+/* 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_FLIGHT_MANAGER_MARKED_H
+#define TITANIC_FLIGHT_MANAGER_MARKED_H
+
+#include "titanic/star_control/flight_manager_base.h"
+
+namespace Titanic {
+
+/**
+ * Automatic camera mover used when one or more markers have been set
+ */
+class CMarkedAutoMover : public CFlightManagerBase {
+private:
+ /**
+ * Given a vector, figures out how far is from the movement source, and
+ * returns a vector on the proper point along the path to the destination
+ * with that same distance from the source.
+ */
+ void getVectorOnPath(FVector &pos) const;
+public:
+ virtual ~CMarkedAutoMover() {}
+
+ void setPathOrients(const FVector &oldPos, const FVector &newPos,
+ const FMatrix &oldOrientation, const FMatrix &newOrientation);
+
+ /**
+ * Applys speeds to the mover. More than one application is usually done for several transitions
+ */
+ virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_FLIGHT_MANAGER_MARKED_H */
diff --git a/engines/titanic/star_control/flight_manager_unmarked.cpp b/engines/titanic/star_control/flight_manager_unmarked.cpp
new file mode 100644
index 0000000..2bbf82a
--- /dev/null
+++ b/engines/titanic/star_control/flight_manager_unmarked.cpp
@@ -0,0 +1,168 @@
+/* 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/flight_manager_unmarked.h"
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/error_code.h"
+
+namespace Titanic {
+
+void CFlightManagerUnmarked::setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient) {
+ CFlightManagerBase::clear();
+ _orientationChanger.load(srcOrient, destOrient);
+ _transitionPercentInc = 0.1;
+ _transitionPercent = 0.0;
+ _field40 = _field44 = _field48 = -1;
+ _active = true;
+}
+
+void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
+ CFlightManagerBase::setPath(srcV, destV);
+
+ if (_distance > 8000.0) {
+ _active = true;
+ _field34 = 1;
+ calcSpeeds(120, 4, _distance - 8000.0);
+ }
+
+ FVector row3 = orientation._row3;
+ double mult = _posDelta._x * row3._x + _posDelta._y * row3._y + _posDelta._z * row3._z;
+ _transitionPercent = 1.0;
+
+ bool flag = false;
+ if (mult < 1.0) {
+ if (mult >= 1.0 - 1.0e-10)
+ flag = true;
+ } else {
+ if (mult <= 1.0 + 1.0e-10)
+ flag = true;
+ }
+
+ if (!flag) {
+ FVector tempV1;
+ tempV1 = row3.addAndNormalize(_posDelta);
+ tempV1 = row3.addAndNormalize(tempV1);
+ tempV1 = row3.addAndNormalize(tempV1);
+ tempV1 = row3.addAndNormalize(tempV1);
+
+ FMatrix newOrient;
+ newOrient.set(tempV1);
+ _orientationChanger.load(orientation, newOrient);
+
+ _transitionPercent = 0.0;
+ _transitionPercentInc = 0.1;
+ _active = true;
+ }
+}
+
+MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
+ FVector v1, v2, v3, v4;
+
+ if (!_active)
+ return NOT_ACTIVE;
+
+ // Firstly we have to do a transition of the camera orientation from
+ // it's current position to one where the destination star is centered
+ if (_transitionPercent < 1.0) {
+ _transitionPercent += _transitionPercentInc;
+ orientation = _orientationChanger.getOrientation(_transitionPercent);
+ errorCode.set();
+ return MOVING;
+ }
+
+ // From here on, we handle the movement to the given destination
+ if (!_field34) {
+ _active = false;
+ return DONE_MOVING;
+ }
+
+ v2 = orientation._row3;
+ v3 = _destPos - pos;
+
+ float unusedScale = 0.0;
+ if (!v3.normalize(unusedScale)) {
+ // Do the normalization, put the scale amount in unusedScale,
+ // but if it is unsuccessful, crash
+ assert(unusedScale);
+ }
+
+ double val = orientation._row3._x * v3._x + orientation._row3._y * v3._y + orientation._row3._z * v3._z;
+ bool flag = false;
+ if (val < 1.0) {
+ if (val >= 1.0 - 1.0e-10)
+ flag = true;
+ } else {
+ if (val <= 1.0 + 1.0e-10)
+ flag = true;
+ }
+
+ if (!flag) {
+ v1 = v2.addAndNormalize(v3);
+ v1 = v2.addAndNormalize(v1);
+ v1 = v2.addAndNormalize(v1);
+ v1 = v2.addAndNormalize(v1);
+
+ orientation.set(v1);
+ v2 = v1;
+ }
+
+ if (_field40 >= 0) {
+ double speedVal = _speeds[_field40];
+ v1 = v2 * speedVal;
+ pos += v1;
+
+ --_field40;
+ errorCode.set();
+ return MOVING;
+ }
+
+ if (_field44 > 0) {
+ v1._z = v2._z * _field38;
+ v1._x = v2._x * _field38;
+ pos._x = v1._x + pos._x;
+ pos._y = v2._y * _field38 + pos._y;
+ pos._z = v1._z + pos._z;
+
+ --_field44;
+ errorCode.set();
+ return MOVING;
+ }
+
+ if (_field48 >= 0) {
+ double speedVal = _speeds[nMoverTransitions - 1 - _field48];
+ v1._y = v2._y * speedVal;
+ v1._z = v2._z * speedVal;
+ v1._x = v2._x * speedVal;
+ pos._y = v1._y + pos._y;
+ pos._z = v1._z + pos._z;
+ pos._x = pos._x + v1._x;
+
+ --_field48;
+ errorCode.set();
+ return MOVING;
+ }
+
+ _active = false;
+ return DONE_MOVING;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/flight_manager_unmarked.h b/engines/titanic/star_control/flight_manager_unmarked.h
new file mode 100644
index 0000000..501e1b0
--- /dev/null
+++ b/engines/titanic/star_control/flight_manager_unmarked.h
@@ -0,0 +1,49 @@
+/* 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_FLIGHT_MANAGER_UNMARKED_H
+#define TITANIC_FLIGHT_MANAGER_UNMARKED_H
+
+#include "titanic/star_control/flight_manager_base.h"
+
+namespace Titanic {
+
+/**
+ * Automatic camera mover used when no markers have been set
+ */
+class CFlightManagerUnmarked : public CFlightManagerBase {
+public:
+ virtual ~CFlightManagerUnmarked() {}
+
+ virtual void setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient);
+
+ /**
+ * Sets the path and starting and ending orientations to animate movement between
+ */
+ void setPathOrient(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
+
+ virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_FLIGHT_MANAGER_UNMARKED_H */
diff --git a/engines/titanic/star_control/marked_auto_mover.cpp b/engines/titanic/star_control/marked_auto_mover.cpp
deleted file mode 100644
index ae987aa..0000000
--- a/engines/titanic/star_control/marked_auto_mover.cpp
+++ /dev/null
@@ -1,106 +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/marked_auto_mover.h"
-#include "titanic/star_control/error_code.h"
-// Not currently being used: #include "common/textconsole.h"
-
-namespace Titanic {
-
-void CMarkedAutoMover::setPathOrients(const FVector &oldPos, const FVector &newPos,
- const FMatrix &oldOrientation, const FMatrix &newOrientation) {
- CCameraAutoMover::setPath(oldPos, newPos);
-
- double distance = _distance;
- _active = true;
- _field34 = true;
- calcSpeeds(120, 4, distance);
-
-
- _orientationChanger.load(oldOrientation, newOrientation);
- _transitionPercent = 0.0;
-
- if (_field4C == 0) {
- _transitionPercentInc = 0.1;
- _active = true;
- } else {
- _transitionPercentInc = 1.0 / _field4C;
- _active = true;
- }
-
-}
-
-MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
- if (!_active)
- return NOT_ACTIVE;
-
- _transitionPercent += _transitionPercentInc;
- orientation = _orientationChanger.getOrientation(_transitionPercent);
- errorCode.set();
-
- if (_field40 >= 0) {
- double speedVal = _speeds[_field40];
- pos += _posDelta * speedVal;
- getVectorOnPath(pos);
-
- --_field40;
- errorCode.set();
- return MOVING;
- } else if (_field44 > 0) {
- pos += _posDelta * _field38;
- getVectorOnPath(pos);
-
- --_field44;
- errorCode.set();
- return MOVING;
- } else if (_field48 >= 0) {
- double speedVal = _speeds[nMoverTransitions - 1 - _field48];
- pos += _posDelta * speedVal;
- getVectorOnPath(pos);
-
- --_field48;
- errorCode.set();
- return MOVING;
- } else {
- _active = false;
- return DONE_MOVING;
- }
-}
-
-void CMarkedAutoMover::getVectorOnPath(FVector &pos) const {
- double distance = _posDelta.getDistance(pos);
- distance /= _distance;
-
- if (distance <= 0.0) {
- pos = _srcPos;
- } else if (distance >= 1.0) {
- pos = _destPos;
- } else {
- pos = FVector(
- (_destPos._x - _srcPos._x) * distance + _srcPos._x,
- (_destPos._y - _srcPos._y) * distance + _srcPos._y,
- (_destPos._z - _srcPos._z) * distance + _srcPos._z
- );
- }
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/marked_auto_mover.h b/engines/titanic/star_control/marked_auto_mover.h
deleted file mode 100644
index d5f714b..0000000
--- a/engines/titanic/star_control/marked_auto_mover.h
+++ /dev/null
@@ -1,55 +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_MARKED_AUTO_MOVER_H
-#define TITANIC_MARKED_AUTO_MOVER_H
-
-#include "titanic/star_control/camera_auto_mover.h"
-
-namespace Titanic {
-
-/**
- * Automatic camera mover used when one or more markers have been set
- */
-class CMarkedAutoMover : public CCameraAutoMover {
-private:
- /**
- * Given a vector, figures out how far is from the movement source, and
- * returns a vector on the proper point along the path to the destination
- * with that same distance from the source.
- */
- void getVectorOnPath(FVector &pos) const;
-public:
- virtual ~CMarkedAutoMover() {}
-
- void setPathOrients(const FVector &oldPos, const FVector &newPos,
- const FMatrix &oldOrientation, const FMatrix &newOrientation);
-
- /**
- * Applys speeds to the mover. More than one application is usually done for several transitions
- */
- virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_MARKED_AUTO_MOVER_H */
diff --git a/engines/titanic/star_control/motion_control.cpp b/engines/titanic/star_control/motion_control.cpp
index 8f25a7d..3b86cc1 100644
--- a/engines/titanic/star_control/motion_control.cpp
+++ b/engines/titanic/star_control/motion_control.cpp
@@ -114,8 +114,8 @@ void CMotionControl::stop() {
}
// TODO: this is confusing to negate the val value
-void CMotionControl::load(SimpleFile *file, int val) {
- if (!val) {
+void CMotionControl::load(SimpleFile *file, int version) {
+ if (version == 0) {
_currVelocity = file->readFloat();
_incVelocity = file->readFloat();
_incAcceleration = file->readFloat();
diff --git a/engines/titanic/star_control/motion_control.h b/engines/titanic/star_control/motion_control.h
index 6fc77f1..60b8776 100644
--- a/engines/titanic/star_control/motion_control.h
+++ b/engines/titanic/star_control/motion_control.h
@@ -121,7 +121,7 @@ public:
/**
* Load the class
*/
- virtual void load(SimpleFile *file, int val = 0);
+ virtual void load(SimpleFile *file, int version = 0);
/**
* Save the class
diff --git a/engines/titanic/star_control/motion_control_marked.h b/engines/titanic/star_control/motion_control_marked.h
index 6c2c8a7..ad04d91 100644
--- a/engines/titanic/star_control/motion_control_marked.h
+++ b/engines/titanic/star_control/motion_control_marked.h
@@ -24,7 +24,7 @@
#define TITANIC_MOTION_CONTROL_MARKED_H
#include "titanic/star_control/motion_control.h"
-#include "titanic/star_control/marked_auto_mover.h"
+#include "titanic/star_control/flight_manager_marked.h"
namespace Titanic {
diff --git a/engines/titanic/star_control/motion_control_unmarked.h b/engines/titanic/star_control/motion_control_unmarked.h
index cddfea7..0d6acb2 100644
--- a/engines/titanic/star_control/motion_control_unmarked.h
+++ b/engines/titanic/star_control/motion_control_unmarked.h
@@ -20,11 +20,11 @@
*
*/
-#ifndef TITANIC_UNMARKED_CAMERA_MOVER_H
-#define TITANIC_UNMARKED_CAMERA_MOVER_H
+#ifndef TITANIC_MOTION_CONTROL_UNMARKED_H
+#define TITANIC_MOTION_CONTROL_UNMARKED_H
#include "titanic/star_control/motion_control.h"
-#include "titanic/star_control/unmarked_auto_mover.h"
+#include "titanic/star_control/flight_manager_unmarked.h"
namespace Titanic {
@@ -33,7 +33,7 @@ class FVector;
class CMotionControlUnmarked : public CMotionControl {
private:
- CUnmarkedAutoMover _autoMover;
+ CFlightManagerUnmarked _autoMover;
public:
CMotionControlUnmarked(const CNavigationInfo *src);
virtual ~CMotionControlUnmarked() {}
@@ -53,4 +53,4 @@ public:
} // End of namespace Titanic
-#endif /* TITANIC_UNMARKED_CAMERA_MOVER_H */
+#endif /* TITANIC_MOTION_CONTROL_UNMARKED_H */
diff --git a/engines/titanic/star_control/unmarked_auto_mover.cpp b/engines/titanic/star_control/unmarked_auto_mover.cpp
deleted file mode 100644
index b8cd042..0000000
--- a/engines/titanic/star_control/unmarked_auto_mover.cpp
+++ /dev/null
@@ -1,169 +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/unmarked_auto_mover.h"
-#include "titanic/star_control/fmatrix.h"
-#include "titanic/star_control/error_code.h"
-// Not currently being used: #include "common/textconsole.h"
-
-namespace Titanic {
-
-void CUnmarkedAutoMover::setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient) {
- CCameraAutoMover::clear();
- _orientationChanger.load(srcOrient, destOrient);
- _transitionPercentInc = 0.1;
- _transitionPercent = 0.0;
- _field40 = _field44 = _field48 = -1;
- _active = true;
-}
-
-void CUnmarkedAutoMover::setPathOrient(const FVector &srcV, const FVector &destV, const FMatrix &orientation) {
- CCameraAutoMover::setPath(srcV, destV);
-
- if (_distance > 8000.0) {
- _active = true;
- _field34 = 1;
- calcSpeeds(120, 4, _distance - 8000.0);
- }
-
- FVector row3 = orientation._row3;
- double mult = _posDelta._x * row3._x + _posDelta._y * row3._y + _posDelta._z * row3._z;
- _transitionPercent = 1.0;
-
- bool flag = false;
- if (mult < 1.0) {
- if (mult >= 1.0 - 1.0e-10)
- flag = true;
- } else {
- if (mult <= 1.0 + 1.0e-10)
- flag = true;
- }
-
- if (!flag) {
- FVector tempV1;
- tempV1 = row3.addAndNormalize(_posDelta);
- tempV1 = row3.addAndNormalize(tempV1);
- tempV1 = row3.addAndNormalize(tempV1);
- tempV1 = row3.addAndNormalize(tempV1);
-
- FMatrix newOrient;
- newOrient.set(tempV1);
- _orientationChanger.load(orientation, newOrient);
-
- _transitionPercent = 0.0;
- _transitionPercentInc = 0.1;
- _active = true;
- }
-}
-
-MoverState CUnmarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
- FVector v1, v2, v3, v4;
-
- if (!_active)
- return NOT_ACTIVE;
-
- // Firstly we have to do a transition of the camera orientation from
- // it's current position to one where the destination star is centered
- if (_transitionPercent < 1.0) {
- _transitionPercent += _transitionPercentInc;
- orientation = _orientationChanger.getOrientation(_transitionPercent);
- errorCode.set();
- return MOVING;
- }
-
- // From here on, we handle the movement to the given destination
- if (!_field34) {
- _active = false;
- return DONE_MOVING;
- }
-
- v2 = orientation._row3;
- v3 = _destPos - pos;
-
- float unusedScale = 0.0;
- if (!v3.normalize(unusedScale)) {
- // Do the normalization, put the scale amount in unusedScale,
- // but if it is unsuccessful, crash
- assert(unusedScale);
- }
-
- double val = orientation._row3._x * v3._x + orientation._row3._y * v3._y + orientation._row3._z * v3._z;
- bool flag = false;
- if (val < 1.0) {
- if (val >= 1.0 - 1.0e-10)
- flag = true;
- } else {
- if (val <= 1.0 + 1.0e-10)
- flag = true;
- }
-
- if (!flag) {
- v1 = v2.addAndNormalize(v3);
- v1 = v2.addAndNormalize(v1);
- v1 = v2.addAndNormalize(v1);
- v1 = v2.addAndNormalize(v1);
-
- orientation.set(v1);
- v2 = v1;
- }
-
- if (_field40 >= 0) {
- double speedVal = _speeds[_field40];
- v1 = v2 * speedVal;
- pos += v1;
-
- --_field40;
- errorCode.set();
- return MOVING;
- }
-
- if (_field44 > 0) {
- v1._z = v2._z * _field38;
- v1._x = v2._x * _field38;
- pos._x = v1._x + pos._x;
- pos._y = v2._y * _field38 + pos._y;
- pos._z = v1._z + pos._z;
-
- --_field44;
- errorCode.set();
- return MOVING;
- }
-
- if (_field48 >= 0) {
- double speedVal = _speeds[nMoverTransitions - 1 - _field48];
- v1._y = v2._y * speedVal;
- v1._z = v2._z * speedVal;
- v1._x = v2._x * speedVal;
- pos._y = v1._y + pos._y;
- pos._z = v1._z + pos._z;
- pos._x = pos._x + v1._x;
-
- --_field48;
- errorCode.set();
- return MOVING;
- }
-
- _active = false;
- return DONE_MOVING;
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/unmarked_auto_mover.h b/engines/titanic/star_control/unmarked_auto_mover.h
deleted file mode 100644
index 41c1331..0000000
--- a/engines/titanic/star_control/unmarked_auto_mover.h
+++ /dev/null
@@ -1,49 +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_UNMARKED_AUTO_MOVER_H
-#define TITANIC_UNMARKED_AUTO_MOVER_H
-
-#include "titanic/star_control/camera_auto_mover.h"
-
-namespace Titanic {
-
-/**
- * Automatic camera mover used when no markers have been set
- */
-class CUnmarkedAutoMover : public CCameraAutoMover {
-public:
- virtual ~CUnmarkedAutoMover() {}
-
- virtual void setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient);
-
- /**
- * Sets the path and starting and ending orientations to animate movement between
- */
- void setPathOrient(const FVector &srcV, const FVector &destV, const FMatrix &orientation);
-
- virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_UNMARKED_AUTO_MOVER_H */
Commit: da3c74224d4dc94518b14c35c687816e6292b008
https://github.com/scummvm/scummvm/commit/da3c74224d4dc94518b14c35c687816e6292b008
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Better naming for CFlightManagerBase fields
Changed paths:
engines/titanic/star_control/flight_manager_base.cpp
engines/titanic/star_control/flight_manager_base.h
engines/titanic/star_control/flight_manager_marked.cpp
engines/titanic/star_control/flight_manager_unmarked.cpp
diff --git a/engines/titanic/star_control/flight_manager_base.cpp b/engines/titanic/star_control/flight_manager_base.cpp
index a430dfc..a9e9177 100644
--- a/engines/titanic/star_control/flight_manager_base.cpp
+++ b/engines/titanic/star_control/flight_manager_base.cpp
@@ -26,17 +26,15 @@
namespace Titanic {
CFlightManagerBase::CFlightManagerBase() : _srcPos(0.0, 1000000.0, 0.0) {
- _field4 = 0;
_active = false;
_distance = 0.0;
- _field34 = false;
- _field38 = 0.0;
- _field3C = 0;
- _field40 = 0;
- _field44 = 0;
- _field48 = 0;
- _field4C = 0;
- _field54 = 0;
+ _flight = false;
+ _step = 0.0;
+ _step1 = 0;
+ _accCount = 0;
+ _traCount = 0;
+ _decCount = 0;
+ _totCount = 0;
_transitionPercent = 0.0;
_transitionPercentInc = 0.0;
}
@@ -47,48 +45,48 @@ void CFlightManagerBase::clear() {
_transitionPercent = 1.0;
_distance = 0.0;
_active = false;
- _field34 = false;
+ _flight = false;
}
-void CFlightManagerBase::setPath(const FVector &srcV, const FVector &destV) {
- _srcPos = srcV;
- _destPos = destV;
- _posDelta = _destPos - _srcPos;
+void CFlightManagerBase::setPath(const FVector &from, const FVector &to) {
+ _srcPos = from;
+ _destPos = to;
+ _direction = _destPos - _srcPos;
+ // normalization won't happen if _direction is zero vector and that is okay
float temp = 0.0;
- _posDelta.normalize(temp); // normalization won't happen if _posDelta is zero vector
- // and that is okay
+ _direction.normalize(temp);
_distance = temp;
_active = false;
- _field34 = false;
- _field40 = -1;
- _field44 = -1;
- _field48 = -1;
- _field4C = -1;
+ _flight = false;
+ _accCount = -1;
+ _traCount = -1;
+ _decCount = -1;
+ _totCount = -1;
_transitionPercent = 1.0;
}
void CFlightManagerBase::calcSpeeds(int val1, int val2, float distance) {
// Usually val1 and val2 are small where as distance can be large
- _field44 = val1;
- _field4C = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
+ _traCount = val1;
+ _totCount = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
// should it always be x2 (_nMoverTransitions - 1)?
- _field38 = distance / (double)(val1 + val2 * 2);
- _field40 = nMoverTransitions-1;
- _field48 = nMoverTransitions-1;
- _field3C = (double)val2 * _field38;
+ _step = distance / (double)(val1 + val2 * 2);
+ _accCount = nMoverTransitions-1;
+ _decCount = nMoverTransitions-1;
+ _step1 = (double)val2 * _step;
// Calculate the speeds for a graduated movement between stars
double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125;
for (int idx = nMoverTransitions - 1; idx >= 0; --idx) {
- _speeds[idx] = pow(base, power);
- total += _speeds[idx];
+ _gammaTable[idx] = pow(base, power);
+ total += _gammaTable[idx];
base += baseInc;
}
for (int idx = 0; idx < nMoverTransitions; ++idx) {
- _speeds[idx] = _speeds[idx] * _field3C / total;
+ _gammaTable[idx] = _gammaTable[idx] * _step1 / total;
}
}
diff --git a/engines/titanic/star_control/flight_manager_base.h b/engines/titanic/star_control/flight_manager_base.h
index 2a49125..f397b3c 100644
--- a/engines/titanic/star_control/flight_manager_base.h
+++ b/engines/titanic/star_control/flight_manager_base.h
@@ -39,20 +39,18 @@ enum MoverState { NOT_ACTIVE = 0, MOVING = 1, DONE_MOVING = 2 };
*/
class CFlightManagerBase {
protected:
- int _field4;
bool _active;
FVector _srcPos, _destPos;
double _distance;
- FVector _posDelta;
- bool _field34;
- double _field38;
- double _field3C;
- int _field40;
- int _field44;
- int _field48;
- int _field4C;
- double _speeds[nMoverTransitions];
- int _field54;
+ FVector _direction;
+ bool _flight;
+ double _step;
+ double _step1;
+ int _accCount;
+ int _traCount;
+ int _decCount;
+ int _totCount;
+ double _gammaTable[nMoverTransitions];
double _transitionPercent;
double _transitionPercentInc;
COrientationChanger _orientationChanger;
@@ -68,7 +66,7 @@ public:
/**
* Setup a transition to from one position to another
*/
- void setPath(const FVector &srcV, const FVector &destV);
+ void setPath(const FVector &from, const FVector &to);
/**
* Applys speeds to the mover. More than one application is usually done for several transitions
diff --git a/engines/titanic/star_control/flight_manager_marked.cpp b/engines/titanic/star_control/flight_manager_marked.cpp
index bd8106d..e7a41fa 100644
--- a/engines/titanic/star_control/flight_manager_marked.cpp
+++ b/engines/titanic/star_control/flight_manager_marked.cpp
@@ -31,18 +31,18 @@ void CMarkedAutoMover::setPathOrients(const FVector &oldPos, const FVector &newP
double distance = _distance;
_active = true;
- _field34 = true;
+ _flight = true;
calcSpeeds(120, 4, distance);
_orientationChanger.load(oldOrientation, newOrientation);
_transitionPercent = 0.0;
- if (_field4C == 0) {
+ if (_totCount == 0) {
_transitionPercentInc = 0.1;
_active = true;
} else {
- _transitionPercentInc = 1.0 / _field4C;
+ _transitionPercentInc = 1.0 / _totCount;
_active = true;
}
@@ -56,27 +56,27 @@ MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &
orientation = _orientationChanger.getOrientation(_transitionPercent);
errorCode.set();
- if (_field40 >= 0) {
- double speedVal = _speeds[_field40];
- pos += _posDelta * speedVal;
+ if (_accCount >= 0) {
+ double speedVal = _gammaTable[_accCount];
+ pos += _direction * speedVal;
getVectorOnPath(pos);
- --_field40;
+ --_accCount;
errorCode.set();
return MOVING;
- } else if (_field44 > 0) {
- pos += _posDelta * _field38;
+ } else if (_traCount > 0) {
+ pos += _direction * _step;
getVectorOnPath(pos);
- --_field44;
+ --_traCount;
errorCode.set();
return MOVING;
- } else if (_field48 >= 0) {
- double speedVal = _speeds[nMoverTransitions - 1 - _field48];
- pos += _posDelta * speedVal;
+ } else if (_decCount >= 0) {
+ double speedVal = _gammaTable[nMoverTransitions - 1 - _decCount];
+ pos += _direction * speedVal;
getVectorOnPath(pos);
- --_field48;
+ --_decCount;
errorCode.set();
return MOVING;
} else {
@@ -86,7 +86,7 @@ MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &
}
void CMarkedAutoMover::getVectorOnPath(FVector &pos) const {
- double distance = _posDelta.getDistance(pos);
+ double distance = _direction.getDistance(pos);
distance /= _distance;
if (distance <= 0.0) {
diff --git a/engines/titanic/star_control/flight_manager_unmarked.cpp b/engines/titanic/star_control/flight_manager_unmarked.cpp
index 2bbf82a..4f226c0 100644
--- a/engines/titanic/star_control/flight_manager_unmarked.cpp
+++ b/engines/titanic/star_control/flight_manager_unmarked.cpp
@@ -31,7 +31,7 @@ void CFlightManagerUnmarked::setOrientations(const FMatrix &srcOrient, const FMa
_orientationChanger.load(srcOrient, destOrient);
_transitionPercentInc = 0.1;
_transitionPercent = 0.0;
- _field40 = _field44 = _field48 = -1;
+ _accCount = _traCount = _decCount = -1;
_active = true;
}
@@ -40,12 +40,12 @@ void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &d
if (_distance > 8000.0) {
_active = true;
- _field34 = 1;
+ _flight = true;
calcSpeeds(120, 4, _distance - 8000.0);
}
FVector row3 = orientation._row3;
- double mult = _posDelta._x * row3._x + _posDelta._y * row3._y + _posDelta._z * row3._z;
+ double mult = _direction._x * row3._x + _direction._y * row3._y + _direction._z * row3._z;
_transitionPercent = 1.0;
bool flag = false;
@@ -59,7 +59,7 @@ void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &d
if (!flag) {
FVector tempV1;
- tempV1 = row3.addAndNormalize(_posDelta);
+ tempV1 = row3.addAndNormalize(_direction);
tempV1 = row3.addAndNormalize(tempV1);
tempV1 = row3.addAndNormalize(tempV1);
tempV1 = row3.addAndNormalize(tempV1);
@@ -90,7 +90,7 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
}
// From here on, we handle the movement to the given destination
- if (!_field34) {
+ if (!_flight) {
_active = false;
return DONE_MOVING;
}
@@ -125,30 +125,30 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
v2 = v1;
}
- if (_field40 >= 0) {
- double speedVal = _speeds[_field40];
+ if (_accCount >= 0) {
+ double speedVal = _gammaTable[_accCount];
v1 = v2 * speedVal;
pos += v1;
- --_field40;
+ --_accCount;
errorCode.set();
return MOVING;
}
- if (_field44 > 0) {
- v1._z = v2._z * _field38;
- v1._x = v2._x * _field38;
+ if (_traCount > 0) {
+ v1._z = v2._z * _step;
+ v1._x = v2._x * _step;
pos._x = v1._x + pos._x;
- pos._y = v2._y * _field38 + pos._y;
+ pos._y = v2._y * _step + pos._y;
pos._z = v1._z + pos._z;
- --_field44;
+ --_traCount;
errorCode.set();
return MOVING;
}
- if (_field48 >= 0) {
- double speedVal = _speeds[nMoverTransitions - 1 - _field48];
+ if (_decCount >= 0) {
+ double speedVal = _gammaTable[nMoverTransitions - 1 - _decCount];
v1._y = v2._y * speedVal;
v1._z = v2._z * speedVal;
v1._x = v2._x * speedVal;
@@ -156,7 +156,7 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
pos._z = v1._z + pos._z;
pos._x = pos._x + v1._x;
- --_field48;
+ --_decCount;
errorCode.set();
return MOVING;
}
Commit: e138a455aa0ccec012a0ac6f13c4acdd2c50f2be
https://github.com/scummvm/scummvm/commit/e138a455aa0ccec012a0ac6f13c4acdd2c50f2be
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Clarify CStarVector as CCallbackHandler
Changed paths:
engines/titanic/star_control/base_stars.cpp
engines/titanic/star_control/base_stars.h
engines/titanic/star_control/camera.cpp
engines/titanic/star_control/motion_control.cpp
engines/titanic/star_control/motion_control.h
engines/titanic/star_control/motion_control_marked.cpp
engines/titanic/star_control/motion_control_unmarked.cpp
diff --git a/engines/titanic/star_control/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp
index 4f9373f..80c8ae97 100644
--- a/engines/titanic/star_control/base_stars.cpp
+++ b/engines/titanic/star_control/base_stars.cpp
@@ -560,10 +560,4 @@ int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CCamera *camera) {
return ref._index;
}
-/*------------------------------------------------------------------------*/
-
-void CStarVector::apply() {
- _owner->addLockedStar(_vector);
-}
-
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/base_stars.h b/engines/titanic/star_control/base_stars.h
index 1bf9c71..cc7652b 100644
--- a/engines/titanic/star_control/base_stars.h
+++ b/engines/titanic/star_control/base_stars.h
@@ -160,19 +160,6 @@ public:
int baseFn2(CSurfaceArea *surfaceArea, CCamera *camera);
};
-class CStarVector {
-private:
- CCamera *_owner;
- FVector _vector;
-public:
- CStarVector(CCamera *owner, const FVector &v) : _owner(owner), _vector(v) {}
-
- /**
- * Applies the saved vector
- */
- void apply();
-};
-
} // End of namespace Titanic
#endif /* TITANIC_BASE_STARS_H */
diff --git a/engines/titanic/star_control/camera.cpp b/engines/titanic/star_control/camera.cpp
index febb2e5..4129f46 100644
--- a/engines/titanic/star_control/camera.cpp
+++ b/engines/titanic/star_control/camera.cpp
@@ -505,8 +505,8 @@ bool CCamera::lockMarker1(FVector v1, FVector firstStarPosition, FVector v3) {
// i.e., _mover has CMotionControlUnmarked handle which means
// CMotionControlUnmarked::transitionBetweenOrientations gets called
- CStarVector *sv = new CStarVector(this, firstStarPosition);
- _mover->setVector(sv);
+ CCallbackHandler *callback = new CCallbackHandler(this, firstStarPosition);
+ _mover->setCallback(callback);
return true;
}
@@ -597,8 +597,8 @@ bool CCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosition
// WORKAROUND: set old position to new position (1st argument), this prevents
// locking issues when locking the 2nd star. Fixes #9961.
_mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
- CStarVector *sv = new CStarVector(this, secondStarPosition);
- _mover->setVector(sv);
+ CCallbackHandler *callback = new CCallbackHandler(this, secondStarPosition);
+ _mover->setCallback(callback);
return true;
}
@@ -617,8 +617,8 @@ bool CCamera::lockMarker3(CViewport *viewport, const FVector &thirdStarPosition)
// locking issues when locking the 3rd star. Fixes #9961.
_mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
- CStarVector *sv = new CStarVector(this, thirdStarPosition);
- _mover->setVector(sv);
+ CCallbackHandler *callback = new CCallbackHandler(this, thirdStarPosition);
+ _mover->setCallback(callback);
return true;
}
diff --git a/engines/titanic/star_control/motion_control.cpp b/engines/titanic/star_control/motion_control.cpp
index 3b86cc1..48e7b39 100644
--- a/engines/titanic/star_control/motion_control.cpp
+++ b/engines/titanic/star_control/motion_control.cpp
@@ -23,13 +23,20 @@
#include "titanic/star_control/motion_control.h"
#include "titanic/star_control/base_stars.h"
#include "titanic/star_control/error_code.h"
+#include "titanic/star_control/camera.h"
#include "titanic/support/simple_file.h"
namespace Titanic {
+void CCallbackHandler::apply() {
+ _owner->addLockedStar(_vector);
+}
+
+/*------------------------------------------------------------------------*/
+
CMotionControl::CMotionControl(const CNavigationInfo *src) {
_lockCounter = 0;
- _starVector = nullptr;
+ _callback = nullptr;
if (src) {
setMotion(src);
@@ -43,9 +50,9 @@ CMotionControl::~CMotionControl() {
}
void CMotionControl::clear() {
- if (_starVector) {
- delete _starVector;
- _starVector = nullptr;
+ if (_callback) {
+ delete _callback;
+ _callback = nullptr;
}
}
@@ -60,9 +67,9 @@ void CMotionControl::reset() {
_rotationZ = 0.0;
}
-void CMotionControl::setVector(CStarVector *sv) {
+void CMotionControl::setCallback(CCallbackHandler *callback) {
clear();
- _starVector = sv;
+ _callback = callback;
}
void CMotionControl::setMotion(const CNavigationInfo *src) {
diff --git a/engines/titanic/star_control/motion_control.h b/engines/titanic/star_control/motion_control.h
index 60b8776..c140b1e 100644
--- a/engines/titanic/star_control/motion_control.h
+++ b/engines/titanic/star_control/motion_control.h
@@ -23,10 +23,12 @@
#ifndef TITANIC_MOTION_CONTROL_H
#define TITANIC_MOTION_CONTROL_H
+#include "titanic/star_control/fmatrix.h"
+
namespace Titanic {
+class CCamera;
class CErrorCode;
-class CStarVector;
class FMatrix;
class FVector;
class SimpleFile;
@@ -42,6 +44,23 @@ struct CNavigationInfo {
double _rotationZ;
};
+/**
+ * Handles doing a callback to the starfield to lock in a star after movement finishes
+ */
+class CCallbackHandler {
+private:
+ CCamera *_owner;
+ FVector _vector;
+public:
+ CCallbackHandler(CCamera *owner, const FVector &v) : _owner(owner), _vector(v) {
+ }
+
+ /**
+ * Locks in the star at the given position
+ */
+ void apply();
+};
+
class CMotionControl {
protected:
double _currVelocity;
@@ -54,7 +73,7 @@ protected:
double _rotationZ;
public:
int _lockCounter;
- CStarVector *_starVector;
+ CCallbackHandler *_callback;
public:
CMotionControl(const CNavigationInfo *src);
virtual ~CMotionControl();
@@ -72,9 +91,9 @@ public:
virtual void reset();
/**
- * Sets this CStarVector
+ * Sets this CCallbackHandler
*/
- virtual void setVector(CStarVector *sv);
+ virtual void setCallback(CCallbackHandler *callback);
/**
* Increases movement speed in forward direction
*/
diff --git a/engines/titanic/star_control/motion_control_marked.cpp b/engines/titanic/star_control/motion_control_marked.cpp
index bea9c18..7d33e32 100644
--- a/engines/titanic/star_control/motion_control_marked.cpp
+++ b/engines/titanic/star_control/motion_control_marked.cpp
@@ -48,8 +48,8 @@ void CMotionControlMarked::updatePosition(CErrorCode &errorCode, FVector &pos, F
incLockCount();
if (moveState == DONE_MOVING) {
stop();
- if (_starVector)
- _starVector->apply();
+ if (_callback)
+ _callback->apply();
}
} else if (_currVelocity != 0.0) {
pos._x += orientation._row3._x * _currVelocity;
diff --git a/engines/titanic/star_control/motion_control_unmarked.cpp b/engines/titanic/star_control/motion_control_unmarked.cpp
index d84f0dc..b9af83f 100644
--- a/engines/titanic/star_control/motion_control_unmarked.cpp
+++ b/engines/titanic/star_control/motion_control_unmarked.cpp
@@ -65,8 +65,8 @@ void CMotionControlUnmarked::updatePosition(CErrorCode &errorCode, FVector &pos,
incLockCount();
if (moverState == DONE_MOVING) {
stop();
- if (_starVector)
- _starVector->apply();
+ if (_callback)
+ _callback->apply();
}
} else if (_currVelocity != 0.0) {
pos._x += orientation._row3._x * _currVelocity;
Commit: e30c9ad7d987ba737b91cb9299b6746e548182f5
https://github.com/scummvm/scummvm/commit/e30c9ad7d987ba737b91cb9299b6746e548182f5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Cleanup of flight manager code
Changed paths:
engines/titanic/star_control/flight_manager_base.cpp
engines/titanic/star_control/flight_manager_base.h
engines/titanic/star_control/flight_manager_marked.cpp
engines/titanic/star_control/flight_manager_marked.h
engines/titanic/star_control/flight_manager_unmarked.cpp
engines/titanic/star_control/fvector.cpp
engines/titanic/star_control/fvector.h
engines/titanic/star_control/motion_control_marked.cpp
diff --git a/engines/titanic/star_control/flight_manager_base.cpp b/engines/titanic/star_control/flight_manager_base.cpp
index a9e9177..39814f3 100644
--- a/engines/titanic/star_control/flight_manager_base.cpp
+++ b/engines/titanic/star_control/flight_manager_base.cpp
@@ -35,14 +35,14 @@ CFlightManagerBase::CFlightManagerBase() : _srcPos(0.0, 1000000.0, 0.0) {
_traCount = 0;
_decCount = 0;
_totCount = 0;
- _transitionPercent = 0.0;
- _transitionPercentInc = 0.0;
+ _currentSpin = 0.0;
+ _spinStep = 0.0;
}
void CFlightManagerBase::clear() {
_srcPos.clear();
_destPos.clear();
- _transitionPercent = 1.0;
+ _currentSpin = 1.0;
_distance = 0.0;
_active = false;
_flight = false;
@@ -64,30 +64,33 @@ void CFlightManagerBase::setPath(const FVector &from, const FVector &to) {
_traCount = -1;
_decCount = -1;
_totCount = -1;
- _transitionPercent = 1.0;
+ _currentSpin = 1.0;
}
-void CFlightManagerBase::calcSpeeds(int val1, int val2, float distance) {
- // Usually val1 and val2 are small where as distance can be large
- _traCount = val1;
- _totCount = val1 + 2 * (nMoverTransitions - 1); // For _nMoverTransitions = 32 this second value was 62,
- // should it always be x2 (_nMoverTransitions - 1)?
- _step = distance / (double)(val1 + val2 * 2);
- _accCount = nMoverTransitions-1;
- _decCount = nMoverTransitions-1;
- _step1 = (double)val2 * _step;
+void CFlightManagerBase::buildMotionTable(int sustain, int decay, float distance) {
+ _step = distance / (sustain + 2 * decay);
+ _step1 = decay * _step;
- // Calculate the speeds for a graduated movement between stars
- double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125;
- for (int idx = nMoverTransitions - 1; idx >= 0; --idx) {
- _gammaTable[idx] = pow(base, power);
- total += _gammaTable[idx];
- base += baseInc;
- }
+ _accCount = GAMMA_TABLE_SIZE - 1;
+ _traCount = sustain;
+ _decCount = GAMMA_TABLE_SIZE - 1;
+ _totCount = _accCount + _traCount + _decCount;
+
+ // Main calculation loop
+ double radix = 4.0;
+ double index = 0.0;
+ double step = 1.0 / (double)(GAMMA_TABLE_SIZE);
+ double total = 0.0;
- for (int idx = 0; idx < nMoverTransitions; ++idx) {
- _gammaTable[idx] = _gammaTable[idx] * _step1 / total;
+ for (int i = 0; i < GAMMA_TABLE_SIZE; ++i) {
+ _gammaTable[GAMMA_TABLE_SIZE - i - 1] = pow(index, radix);
+ index += step;
+ total += _gammaTable[GAMMA_TABLE_SIZE - i - 1];
}
+
+ // normalise them
+ for (int i = 0; i < GAMMA_TABLE_SIZE; ++i)
+ _gammaTable[i] = _step1 * _gammaTable[i] / total;
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/flight_manager_base.h b/engines/titanic/star_control/flight_manager_base.h
index f397b3c..cf80f29 100644
--- a/engines/titanic/star_control/flight_manager_base.h
+++ b/engines/titanic/star_control/flight_manager_base.h
@@ -29,9 +29,10 @@
namespace Titanic {
+#define GAMMA_TABLE_SIZE 32
+
class CErrorCode;
class FMatrix;
-const int nMoverTransitions = 32; // The number of vector transitions when doing a mover change is fixed
enum MoverState { NOT_ACTIVE = 0, MOVING = 1, DONE_MOVING = 2 };
/**
@@ -50,9 +51,9 @@ protected:
int _traCount;
int _decCount;
int _totCount;
- double _gammaTable[nMoverTransitions];
- double _transitionPercent;
- double _transitionPercentInc;
+ double _gammaTable[GAMMA_TABLE_SIZE];
+ double _currentSpin;
+ double _spinStep;
COrientationChanger _orientationChanger;
public:
CFlightManagerBase();
@@ -72,11 +73,11 @@ public:
* Applys speeds to the mover. More than one application is usually done for several transitions
*/
virtual MoverState move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) { return DONE_MOVING; }
+
/**
- * Given a distance to cover, determines a bunch of speeds for a gradual transition
- * from one position to another (the mover). The speeds go from fast to slow
+ * Given a distance to cover, builds an acceleration table for the journey
*/
- virtual void calcSpeeds(int val1, int val2, float distance);
+ virtual void buildMotionTable(int sustain, int decay, float distance);
bool isActive() const { return _active; }
};
diff --git a/engines/titanic/star_control/flight_manager_marked.cpp b/engines/titanic/star_control/flight_manager_marked.cpp
index e7a41fa..6585c66 100644
--- a/engines/titanic/star_control/flight_manager_marked.cpp
+++ b/engines/titanic/star_control/flight_manager_marked.cpp
@@ -25,35 +25,33 @@
namespace Titanic {
-void CMarkedAutoMover::setPathOrients(const FVector &oldPos, const FVector &newPos,
+void CMarkedAutoMover::setFlight(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation) {
CFlightManagerBase::setPath(oldPos, newPos);
double distance = _distance;
_active = true;
_flight = true;
- calcSpeeds(120, 4, distance);
-
+ buildMotionTable(120, 4, distance);
_orientationChanger.load(oldOrientation, newOrientation);
- _transitionPercent = 0.0;
+ _currentSpin = 0.0;
if (_totCount == 0) {
- _transitionPercentInc = 0.1;
+ _spinStep = 0.1;
_active = true;
} else {
- _transitionPercentInc = 1.0 / _totCount;
+ _spinStep = 1.0 / _totCount;
_active = true;
}
-
}
MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
if (!_active)
return NOT_ACTIVE;
- _transitionPercent += _transitionPercentInc;
- orientation = _orientationChanger.getOrientation(_transitionPercent);
+ _currentSpin += _spinStep;
+ orientation = _orientationChanger.getOrientation(_currentSpin);
errorCode.set();
if (_accCount >= 0) {
@@ -72,7 +70,7 @@ MoverState CMarkedAutoMover::move(CErrorCode &errorCode, FVector &pos, FMatrix &
errorCode.set();
return MOVING;
} else if (_decCount >= 0) {
- double speedVal = _gammaTable[nMoverTransitions - 1 - _decCount];
+ double speedVal = _gammaTable[GAMMA_TABLE_SIZE - 1 - _decCount];
pos += _direction * speedVal;
getVectorOnPath(pos);
diff --git a/engines/titanic/star_control/flight_manager_marked.h b/engines/titanic/star_control/flight_manager_marked.h
index de9bc46..fa860fb 100644
--- a/engines/titanic/star_control/flight_manager_marked.h
+++ b/engines/titanic/star_control/flight_manager_marked.h
@@ -41,7 +41,7 @@ private:
public:
virtual ~CMarkedAutoMover() {}
- void setPathOrients(const FVector &oldPos, const FVector &newPos,
+ void setFlight(const FVector &oldPos, const FVector &newPos,
const FMatrix &oldOrientation, const FMatrix &newOrientation);
/**
diff --git a/engines/titanic/star_control/flight_manager_unmarked.cpp b/engines/titanic/star_control/flight_manager_unmarked.cpp
index 4f226c0..78a70c7 100644
--- a/engines/titanic/star_control/flight_manager_unmarked.cpp
+++ b/engines/titanic/star_control/flight_manager_unmarked.cpp
@@ -29,8 +29,8 @@ namespace Titanic {
void CFlightManagerUnmarked::setOrientations(const FMatrix &srcOrient, const FMatrix &destOrient) {
CFlightManagerBase::clear();
_orientationChanger.load(srcOrient, destOrient);
- _transitionPercentInc = 0.1;
- _transitionPercent = 0.0;
+ _spinStep = 0.1;
+ _currentSpin = 0.0;
_accCount = _traCount = _decCount = -1;
_active = true;
}
@@ -41,12 +41,12 @@ void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &d
if (_distance > 8000.0) {
_active = true;
_flight = true;
- calcSpeeds(120, 4, _distance - 8000.0);
+ buildMotionTable(120, 4, _distance - 8000.0);
}
FVector row3 = orientation._row3;
double mult = _direction._x * row3._x + _direction._y * row3._y + _direction._z * row3._z;
- _transitionPercent = 1.0;
+ _currentSpin = 1.0;
bool flag = false;
if (mult < 1.0) {
@@ -59,17 +59,17 @@ void CFlightManagerUnmarked::setPathOrient(const FVector &srcV, const FVector &d
if (!flag) {
FVector tempV1;
- tempV1 = row3.addAndNormalize(_direction);
- tempV1 = row3.addAndNormalize(tempV1);
- tempV1 = row3.addAndNormalize(tempV1);
- tempV1 = row3.addAndNormalize(tempV1);
+ tempV1 = row3.half(_direction);
+ tempV1 = row3.half(tempV1);
+ tempV1 = row3.half(tempV1);
+ tempV1 = row3.half(tempV1);
FMatrix newOrient;
newOrient.set(tempV1);
_orientationChanger.load(orientation, newOrient);
- _transitionPercent = 0.0;
- _transitionPercentInc = 0.1;
+ _currentSpin = 0.0;
+ _spinStep = 0.1;
_active = true;
}
}
@@ -82,9 +82,9 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
// Firstly we have to do a transition of the camera orientation from
// it's current position to one where the destination star is centered
- if (_transitionPercent < 1.0) {
- _transitionPercent += _transitionPercentInc;
- orientation = _orientationChanger.getOrientation(_transitionPercent);
+ if (_currentSpin < 1.0) {
+ _currentSpin += _spinStep;
+ orientation = _orientationChanger.getOrientation(_currentSpin);
errorCode.set();
return MOVING;
}
@@ -116,10 +116,10 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
}
if (!flag) {
- v1 = v2.addAndNormalize(v3);
- v1 = v2.addAndNormalize(v1);
- v1 = v2.addAndNormalize(v1);
- v1 = v2.addAndNormalize(v1);
+ v1 = v2.half(v3);
+ v1 = v2.half(v1);
+ v1 = v2.half(v1);
+ v1 = v2.half(v1);
orientation.set(v1);
v2 = v1;
@@ -148,7 +148,7 @@ MoverState CFlightManagerUnmarked::move(CErrorCode &errorCode, FVector &pos, FMa
}
if (_decCount >= 0) {
- double speedVal = _gammaTable[nMoverTransitions - 1 - _decCount];
+ double speedVal = _gammaTable[GAMMA_TABLE_SIZE - 1 - _decCount];
v1._y = v2._y * speedVal;
v1._z = v2._z * speedVal;
v1._x = v2._x * speedVal;
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index 6ebd297..9651117 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -66,20 +66,13 @@ bool FVector::normalize(float & hyp) {
return true;
}
-FVector FVector::addAndNormalize(const FVector &v) const {
- FVector tempV(_x + v._x, _y + v._y, _z + v._z);
-
- float unusedScale = 0.0;
- if (!tempV.normalize(unusedScale)) {
- // Do the normalization, put the scale amount in unusedScale,
- // but if it is unsuccessful, crash
- assert(unusedScale);
- }
-
+FVector FVector::half(const FVector &v) const {
+ FVector tempV = *this + v;
+ tempV.normalize();
return tempV;
}
-FVector FVector::getAnglesAsVect() const {
+FVector FVector::getPolarCoord() const {
FVector vector = *this;
FVector dest;
@@ -115,13 +108,13 @@ FVector FVector::matProdRowVect(const FPose &pose) const {
FPose FVector::getFrameTransform(const FVector &v) {
FPose matrix1, matrix2, matrix3, matrix4;
- FVector vector1 = getAnglesAsVect();
+ FVector vector1 = getPolarCoord();
matrix1.setRotationMatrix(X_AXIS, Common::rad2deg<double>(vector1._y));
matrix2.setRotationMatrix(Y_AXIS, Common::rad2deg<double>(vector1._z));
fposeProd(matrix1, matrix2, matrix3);
matrix4 = matrix3.inverseTransform();
- vector1 = v.getAnglesAsVect();
+ vector1 = v.getPolarCoord();
matrix1.setRotationMatrix(X_AXIS, Common::rad2deg<double>(vector1._y));
matrix2.setRotationMatrix(Y_AXIS, Common::rad2deg<double>(vector1._z));
fposeProd(matrix1, matrix2, matrix3);
@@ -131,7 +124,7 @@ FPose FVector::getFrameTransform(const FVector &v) {
}
FPose FVector::formRotXY() const {
- FVector v1 = getAnglesAsVect();
+ FVector v1 = getPolarCoord();
FPose m1, m2;
m1.setRotationMatrix(X_AXIS, Common::rad2deg<double>(v1._y));
m2.setRotationMatrix(Y_AXIS, Common::rad2deg<double>(v1._z));
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index 6b562bc..f266dcb 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -79,10 +79,9 @@ public:
}
/**
- * Adds the current vector and a passed one together, normalizes them,
- * and then returns the resulting vector
+ * Calculates a vector halfway between two given vectors
*/
- FVector addAndNormalize(const FVector &v) const;
+ FVector half(const FVector &v) const;
/**
* Returns a vector, v, that represents a magnitude, and two angles in radians
@@ -90,7 +89,7 @@ public:
* 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)
*/
- FVector getAnglesAsVect() const;
+ FVector getPolarCoord() const;
/**
* Returns the distance between a specified point and this one
diff --git a/engines/titanic/star_control/motion_control_marked.cpp b/engines/titanic/star_control/motion_control_marked.cpp
index 7d33e32..e86d1bd 100644
--- a/engines/titanic/star_control/motion_control_marked.cpp
+++ b/engines/titanic/star_control/motion_control_marked.cpp
@@ -36,7 +36,7 @@ void CMotionControlMarked::transitionBetweenPosOrients(const FVector &oldPos, co
if (isLocked())
decLockCount();
- _autoMover.setPathOrients(oldPos, newPos, oldOrientation, newOrientation);
+ _autoMover.setFlight(oldPos, newPos, oldOrientation, newOrientation);
incLockCount();
}
Commit: 33f74e30273b38b0a9175348ef95619481921075
https://github.com/scummvm/scummvm/commit/33f74e30273b38b0a9175348ef95619481921075
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Cleanup camera creation of motion controllers
Changed paths:
engines/titanic/star_control/camera.cpp
engines/titanic/star_control/camera.h
diff --git a/engines/titanic/star_control/camera.cpp b/engines/titanic/star_control/camera.cpp
index 4129f46..7110fe5 100644
--- a/engines/titanic/star_control/camera.cpp
+++ b/engines/titanic/star_control/camera.cpp
@@ -40,12 +40,12 @@ FMatrix *CCamera::_priorOrientation;
FMatrix *CCamera::_newOrientation;
CCamera::CCamera(const CNavigationInfo *data) :
- _starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false) {
- setMoverType(data);
+ _lockLevel(ZERO_LOCKED), _motion(nullptr), _isMoved(false), _isInLockingProcess(false) {
+ createMotionControl(data);
}
CCamera::CCamera(CViewport *src) :
- _starLockState(ZERO_LOCKED), _mover(nullptr), _isMoved(false), _isInLockingProcess(false), _viewport(src) {
+ _lockLevel(ZERO_LOCKED), _motion(nullptr), _isMoved(false), _isInLockingProcess(false), _viewport(src) {
}
void CCamera::init() {
@@ -61,7 +61,7 @@ void CCamera::deinit() {
}
bool CCamera::isLocked() {
- return _mover->isLocked();
+ return _motion->isLocked();
}
bool CCamera::isNotInLockingProcess() {
@@ -69,7 +69,7 @@ bool CCamera::isNotInLockingProcess() {
}
CCamera::~CCamera() {
- removeMover();
+ deleteMotionController();
}
void CCamera::setViewport(const CViewport *src) {
@@ -77,7 +77,7 @@ void CCamera::setViewport(const CViewport *src) {
}
void CCamera::setMotion(const CNavigationInfo *src) {
- _mover->setMotion(src);
+ _motion->setMotion(src);
}
void CCamera::setPosition(const FVector &v) {
@@ -136,7 +136,7 @@ void CCamera::setDestination(const FVector &v) {
FMatrix orientation = _viewport.getOrientation();
FVector oldPos = _viewport._position;
- _mover->moveTo(oldPos, v, orientation);
+ _motion->moveTo(oldPos, v, orientation);
}
void CCamera::updatePosition(CErrorCode *errorCode) {
@@ -150,7 +150,7 @@ void CCamera::updatePosition(CErrorCode *errorCode) {
FVector priorPos = _viewport._position;
FVector newPos = _viewport._position;
- _mover->updatePosition(*errorCode, newPos, *_newOrientation);
+ _motion->updatePosition(*errorCode, newPos, *_newOrientation);
if (newPos != priorPos) {
_viewport.setPosition(newPos);
@@ -163,19 +163,19 @@ void CCamera::updatePosition(CErrorCode *errorCode) {
}
void CCamera::accelerate() {
- _mover->accelerate();
+ _motion->accelerate();
}
void CCamera::deccelerate() {
- _mover->deccelerate();
+ _motion->deccelerate();
}
void CCamera::fullSpeed() {
- _mover->fullSpeed();
+ _motion->fullSpeed();
}
void CCamera::stop() {
- _mover->stop();
+ _motion->stop();
}
void CCamera::reposition(double factor) {
@@ -250,7 +250,7 @@ void CCamera::setViewportAngle(const FPoint &angles) {
if (isLocked())
return;
- switch(_starLockState) {
+ switch(_lockLevel) {
case ZERO_LOCKED: {
FPose subX(X_AXIS, angles._y);
FPose subY(Y_AXIS, -angles._x); // needs to be negative or looking left will cause the view to go right
@@ -393,30 +393,30 @@ void CCamera::setViewportAngle(const FPoint &angles) {
}
bool CCamera::addLockedStar(const FVector v) {
- if (_starLockState == THREE_LOCKED)
+ if (_lockLevel == THREE_LOCKED)
return false;
CNavigationInfo data;
- _mover->getMotion(&data);
- removeMover();
+ _motion->getMotion(&data);
+ deleteMotionController();
- FVector &row = _lockedStarsPos[(int)_starLockState];
- _starLockState = StarLockState((int)_starLockState + 1);
+ FVector &row = _lockedStarsPos[(int)_lockLevel];
+ _lockLevel = (StarLockLevel)((int)_lockLevel + 1);
row = v;
- setMoverType(&data);
+ createMotionControl(&data);
return true;
}
bool CCamera::removeLockedStar() {
- if (_starLockState == ZERO_LOCKED)
+ if (_lockLevel == ZERO_LOCKED)
return false;
CNavigationInfo data;
- _mover->getMotion(&data);
- removeMover();
+ _motion->getMotion(&data);
+ deleteMotionController();
- _starLockState = StarLockState((int)_starLockState - 1);
- setMoverType(&data);
+ _lockLevel = (StarLockLevel)((int)_lockLevel - 1);
+ createMotionControl(&data);
return true;
}
@@ -432,43 +432,43 @@ void CCamera::save(SimpleFile *file, int indent) {
_viewport.save(file, indent);
}
-bool CCamera::setMoverType(const CNavigationInfo *src) {
- CMotionControl *mover = nullptr;
+bool CCamera::createMotionControl(const CNavigationInfo *src) {
+ CMotionControl *motion = nullptr;
- switch (_starLockState) {
+ switch (_lockLevel) {
case ZERO_LOCKED:
- mover = new CMotionControlUnmarked(src);
+ motion = new CMotionControlUnmarked(src);
break;
case ONE_LOCKED:
case TWO_LOCKED:
case THREE_LOCKED:
- mover = new CMotionControlMarked(src);
+ motion = new CMotionControlMarked(src);
break;
default:
break;
}
- if (mover) {
- assert(!_mover); // removeMover() is usually called before this function so _mover is null
- _mover = mover;
+ if (motion) {
+ assert(!_motion);
+ _motion = motion;
return true;
} else {
return false;
}
}
-void CCamera::removeMover() {
- if (_mover) {
- delete _mover;
- _mover = nullptr;
+void CCamera::deleteMotionController() {
+ if (_motion) {
+ delete _motion;
+ _motion = nullptr;
_isInLockingProcess = false;
}
}
bool CCamera::lockMarker1(FVector v1, FVector firstStarPosition, FVector v3) {
- if (_starLockState != ZERO_LOCKED)
+ if (_lockLevel != ZERO_LOCKED)
return true;
_isInLockingProcess = true;
@@ -501,18 +501,16 @@ bool CCamera::lockMarker1(FVector v1, FVector firstStarPosition, FVector v3) {
FMatrix matrix = _viewport.getOrientation();
const FVector &pos = _viewport._position;
- _mover->transitionBetweenOrientations(v3, tempV, pos, matrix); // TODO: pos does not get used in this function,
- // i.e., _mover has CMotionControlUnmarked handle which means
- // CMotionControlUnmarked::transitionBetweenOrientations gets called
+ _motion->transitionBetweenOrientations(v3, tempV, pos, matrix);
CCallbackHandler *callback = new CCallbackHandler(this, firstStarPosition);
- _mover->setCallback(callback);
+ _motion->setCallback(callback);
return true;
}
bool CCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosition) {
- if (_starLockState != ONE_LOCKED)
+ if (_lockLevel != ONE_LOCKED)
return true;
_isInLockingProcess = true;
@@ -596,15 +594,15 @@ bool CCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosition
// WORKAROUND: set old position to new position (1st argument), this prevents
// locking issues when locking the 2nd star. Fixes #9961.
- _mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
+ _motion->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
CCallbackHandler *callback = new CCallbackHandler(this, secondStarPosition);
- _mover->setCallback(callback);
+ _motion->setCallback(callback);
return true;
}
bool CCamera::lockMarker3(CViewport *viewport, const FVector &thirdStarPosition) {
- if (_starLockState != TWO_LOCKED)
+ if (_lockLevel != TWO_LOCKED)
return true;
_isInLockingProcess = true;
@@ -615,10 +613,10 @@ bool CCamera::lockMarker3(CViewport *viewport, const FVector &thirdStarPosition)
// WORKAROUND: set old position to new position (1st argument), this prevents
// locking issues when locking the 3rd star. Fixes #9961.
- _mover->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
+ _motion->transitionBetweenPosOrients(newPos, newPos, oldOr, newOr);
CCallbackHandler *callback = new CCallbackHandler(this, thirdStarPosition);
- _mover->setCallback(callback);
+ _motion->setCallback(callback);
return true;
}
diff --git a/engines/titanic/star_control/camera.h b/engines/titanic/star_control/camera.h
index 01cf2a7..5b2d503 100644
--- a/engines/titanic/star_control/camera.h
+++ b/engines/titanic/star_control/camera.h
@@ -35,7 +35,7 @@ struct CNavigationInfo;
class FPoint;
class SimpleFile;
-enum StarLockState { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 };
+enum StarLockLevel { ZERO_LOCKED=0, ONE_LOCKED=1, TWO_LOCKED=2, THREE_LOCKED=3 };
/**
* Implements a reference point from which the starmap can be viewed
@@ -45,24 +45,24 @@ private:
static FMatrix *_priorOrientation;
static FMatrix *_newOrientation;
private:
- StarLockState _starLockState;
+ StarLockLevel _lockLevel;
FMatrix _lockedStarsPos; // Each row represents the location of a locked star
- CMotionControl *_mover; // A marked or unmarked camera mover, contains an automover
+ CMotionControl *_motion; // A marked or unmarked camera mover, contains an automover
CViewport _viewport;
bool _isMoved; // Used in CPetStarfield to determine if a star destination can be set
bool _isInLockingProcess; // The mover/view is homing in on a new star
private:
/**
- * Set Mover type to be unmarked or marked camera mover based on
- * the number of stars currently locked (_starLockState)
- * The CNavigationInfo data is used to initialize the mover
+ * Creates a motion controller for the camera. This needs to be recreated
+ * when the number of locked stars changes.
+ * @param src Contains characteristics to set for the motion
*/
- bool setMoverType(const CNavigationInfo *src);
+ bool createMotionControl(const CNavigationInfo *src);
/**
* Deletes the previous mover handle
*/
- void removeMover();
+ void deleteMotionController();
/**
* Return whether the handler is locked
@@ -199,7 +199,7 @@ public:
/**
* How many stars are currently locked onto
*/
- virtual StarLockState getStarLockState() const { return _starLockState; }
+ virtual StarLockLevel getLockLevel() const { return _lockLevel; }
/**
* Adds the row for a locked in marker/star
Commit: a8d802f17dfd83f46020f98a914496102c2742c8
https://github.com/scummvm/scummvm/commit/a8d802f17dfd83f46020f98a914496102c2742c8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-01-16T19:27:49-08:00
Commit Message:
TITANIC: Cleanup of #include lines
Changed paths:
engines/titanic/game_manager.h
engines/titanic/input_handler.h
engines/titanic/star_control/base_stars.h
engines/titanic/star_control/star_control.cpp
engines/titanic/star_control/star_control.h
engines/titanic/star_control/surface_fader.h
engines/titanic/star_control/viewport.h
engines/titanic/titanic.h
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index c319e18..e778101 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -27,8 +27,8 @@
#include "titanic/game_state.h"
#include "titanic/input_handler.h"
#include "titanic/input_translator.h"
-#include "titanic/support/time_event_info.h" // class CTimeEventInfo
-#include "titanic/true_talk/true_talk_manager.h" // class CTrueTalkManager
+#include "titanic/support/time_event_info.h"
+#include "titanic/true_talk/true_talk_manager.h"
#include "titanic/sound/music_room.h"
#include "titanic/sound/sound.h"
diff --git a/engines/titanic/input_handler.h b/engines/titanic/input_handler.h
index 53b11f8..d9df834 100644
--- a/engines/titanic/input_handler.h
+++ b/engines/titanic/input_handler.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_INPUT_HANDLER_H
#define TITANIC_INPUT_HANDLER_H
-#include "titanic/support/rect.h" // Point
+#include "titanic/support/rect.h"
namespace Titanic {
diff --git a/engines/titanic/star_control/base_stars.h b/engines/titanic/star_control/base_stars.h
index cc7652b..abd0c0b 100644
--- a/engines/titanic/star_control/base_stars.h
+++ b/engines/titanic/star_control/base_stars.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_BASE_STARS_H
#define TITANIC_BASE_STARS_H
-#include "titanic/star_control/frange.h" // class Fvector
+#include "titanic/star_control/frange.h"
#include "common/array.h"
namespace Common {
diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp
index b53d7e2..51c8204 100644
--- a/engines/titanic/star_control/star_control.cpp
+++ b/engines/titanic/star_control/star_control.cpp
@@ -26,7 +26,7 @@
#include "titanic/game_manager.h"
#include "titanic/pet_control/pet_control.h"
#include "titanic/star_control/motion_control.h"
-#include "titanic/star_control/error_code.h" // CErrorCode
+#include "titanic/star_control/error_code.h"
#include "titanic/support/screen_manager.h"
namespace Titanic {
diff --git a/engines/titanic/star_control/star_control.h b/engines/titanic/star_control/star_control.h
index 7efd386..6bbd45b 100644
--- a/engines/titanic/star_control/star_control.h
+++ b/engines/titanic/star_control/star_control.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_STAR_CONTROL_H
#define TITANIC_STAR_CONTROL_H
-#include "titanic/core/game_object.h" // class SimpleFile
+#include "titanic/core/game_object.h"
#include "titanic/star_control/star_field.h"
#include "titanic/star_control/star_view.h"
diff --git a/engines/titanic/star_control/surface_fader.h b/engines/titanic/star_control/surface_fader.h
index d209e83..3a2a9f0 100644
--- a/engines/titanic/star_control/surface_fader.h
+++ b/engines/titanic/star_control/surface_fader.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_SURFACE_FADER_H
#define TITANIC_SURFACE_FADER_H
-#include "common/scummsys.h" // typedef for byte
+#include "common/scummsys.h"
namespace Titanic {
diff --git a/engines/titanic/star_control/viewport.h b/engines/titanic/star_control/viewport.h
index 9a2be8d..cc37a67 100644
--- a/engines/titanic/star_control/viewport.h
+++ b/engines/titanic/star_control/viewport.h
@@ -23,8 +23,8 @@
#ifndef TITANIC_VIEWPORT_H
#define TITANIC_VIEWPORT_H
-#include "titanic/star_control/base_stars.h" // Includes StarMode enum
-#include "titanic/star_control/fpose.h" // Includes FMatrix and FVector
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/fpose.h"
class SimpleFile;
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index ce2188e..b879d49 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -23,13 +23,13 @@
#ifndef TITANIC_TITANIC_H
#define TITANIC_TITANIC_H
-#include "common/random.h" // getRandomNumber and getRandomFloat
-#include "engines/engine.h" // class Engine
-#include "titanic/support/exe_resources.h" // class CExeResources
-#include "titanic/support/movie_manager.h" // class CMovieManager
-#include "titanic/support/string.h" // class StringArray;
-#include "titanic/support/strings.h" // class Strings;
-#include "common/language.h" // Language enum
+#include "common/random.h"
+#include "engines/engine.h"
+#include "titanic/support/exe_resources.h"
+#include "titanic/support/movie_manager.h"
+#include "titanic/support/string.h"
+#include "titanic/support/strings.h"
+#include "common/language.h"
/**
* This is the namespace of the Titanic engine.
More information about the Scummvm-git-logs
mailing list