aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/star_control/star_camera.cpp36
-rw-r--r--engines/titanic/star_control/star_camera.h6
-rw-r--r--engines/titanic/star_control/star_view.cpp12
3 files changed, 36 insertions, 18 deletions
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index fa19b95ee6..af671ebbac 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -450,9 +450,9 @@ void CStarCamera::deleteHandler() {
}
}
-void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
+bool CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
if (_starLockState != ZERO_LOCKED)
- return;
+ return true;
FVector tempV;
double val1, val2, val3, val4, val5;
@@ -487,11 +487,12 @@ void CStarCamera::lockMarker1(FVector v1, FVector v2, FVector v3) {
CStarVector *sv = new CStarVector(this, v2);
_mover->setVector(sv);
+ return true;
}
-void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
+bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
if (_starLockState != ONE_LOCKED)
- return;
+ return true;
DAffine m2(X_AXIS, _matrix._row1);
DVector tempV1 = v - _matrix._row1;
@@ -567,7 +568,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
m4._col2 -= m4._col1;
m4._col4 -= m4._col1;
- FMatrix m6 = _viewport.getOrientation();
+
double unusedScale=0.0;
if (!m4._col2.normalize(unusedScale) ||
@@ -581,16 +582,28 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
m5.set(m4._col3, m4._col2, m4._col4);
FVector newPos = m4._col1;
-
- _mover->proc8(_viewport._position, newPos, m6, m5);
+ FMatrix m6 = _viewport.getOrientation();
- CStarVector *sv = new CStarVector(this, v);
- _mover->setVector(sv);
+ if (minDistance > 1.0e8) {
+ // The transition will do poorly in this case.
+ //removeLockedStar(); // undo locking 2nd star
+ _mover->proc8(_viewport._position, _viewport._position, m6, m6);
+ //CStarVector *sv = new CStarVector(this, v);
+ //_mover->setVector(sv);
+ return false;
+ }
+ else {
+ _mover->proc8(_viewport._position, newPos, m6, m5);
+ CStarVector *sv = new CStarVector(this, v);
+ _mover->setVector(sv);
+
+ }
+ return true;
}
-void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
+bool CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
if (_starLockState != TWO_LOCKED)
- return;
+ return true;
FMatrix newOr = viewport->getOrientation();
FMatrix oldOr = _viewport.getOrientation();
@@ -601,6 +614,7 @@ void CStarCamera::lockMarker3(CViewport *viewport, const FVector &v) {
CStarVector *sv = new CStarVector(this, v);
_mover->setVector(sv);
+ return true;
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
index 2d4ce57699..572995fc1b 100644
--- a/engines/titanic/star_control/star_camera.h
+++ b/engines/titanic/star_control/star_camera.h
@@ -207,17 +207,17 @@ public:
/**
* Lock in the first matched star marker
*/
- void lockMarker1(FVector v1, FVector v2, FVector v3);
+ bool lockMarker1(FVector v1, FVector v2, FVector v3);
/**
* Lock in the second matched star marker
*/
- void lockMarker2(CViewport *viewport, const FVector &v);
+ bool lockMarker2(CViewport *viewport, const FVector &v);
/**
* Lock in the third and final matched star marker
*/
- void lockMarker3(CViewport *viewport, const FVector &v);
+ bool lockMarker3(CViewport *viewport, const FVector &v);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 578cc00898..ec972d12b5 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -397,6 +397,7 @@ void CStarView::lockStar() {
CSurfaceArea surfaceArea(_videoSurface);
FVector v1, v2, v3;
double val = _starField->fn5(&surfaceArea, &_camera, v1, v2, v3);
+ bool lockSuccess = false;
if (val > -1.0) {
v1 -= surfaceArea._centroid;
@@ -405,19 +406,22 @@ void CStarView::lockStar() {
switch (_starField->getMatchedIndex()) {
case -1:
// First star match
- _camera.lockMarker1(v1, v2, v3);
+ lockSuccess = _camera.lockMarker1(v1, v2, v3);
+ assert(lockSuccess); // lockMarker1 should always succeed
_starField->incMatches();
break;
case 0:
// Second star match
- _camera.lockMarker2(&_photoViewport, v2);
- _starField->incMatches();
+ lockSuccess = _camera.lockMarker2(&_photoViewport, v2);
+ if (lockSuccess) // lockMarker2 may have issues
+ _starField->incMatches();
break;
case 1:
// Third star match
- _camera.lockMarker3(&_photoViewport, v2);
+ lockSuccess = _camera.lockMarker3(&_photoViewport, v2);
+ assert(lockSuccess); // lockMarker3 should always succeed
_starField->incMatches();
break;