TITANIC: Prevent 2 star locking for large distances

I have added a conditional to the code so that if the player
tries to lock onto the 2nd star and they are very far away, >1e8,
then the game will not allow the star to be locked.

This is a temporary workaround since if a distance of farther
then this is attempted then the view will be throw way off
and the stars will not be shown locking onto correctly.

I've also made the locking functions return booleans so I can
determine the success of the lockings.

This is a partial fix for #9961.
This commit is contained in:
David Fioramonti 2017-08-20 19:43:40 -07:00
parent ffbfdac87e
commit 2a96a6fc72
3 changed files with 36 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -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;