aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/star_control/star_camera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic/star_control/star_camera.cpp')
-rw-r--r--engines/titanic/star_control/star_camera.cpp60
1 files changed, 31 insertions, 29 deletions
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index c9cffd481f..a763f85770 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -522,33 +522,33 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi
_isInLockingProcess = true;
FVector firstStarPosition = _lockedStarsPos._row1;
DAffine m2(0, firstStarPosition); // Identity matrix and col4 as the 1st stars position
- DVector starDelta = secondStarPosition - firstStarPosition;
+ FVector starDelta = secondStarPosition - firstStarPosition;
DAffine m1 = starDelta.formRotXY();
m1 = m1.compose(m2);
m2 = m1.inverseTransform();
- DVector oldPos = _viewport._position;
+ FVector oldPos = _viewport._position;
DAffine m4;
m4._col1 = viewport->_position;
- m4._col2 = DVector(0.0, 0.0, 0.0);
- m4._col3 = DVector(0.0, 0.0, 0.0);
- m4._col4 = DVector(0.0, 0.0, 0.0);
+ m4._col2 = FVector(0.0, 0.0, 0.0);
+ m4._col3 = FVector(0.0, 0.0, 0.0);
+ m4._col4 = FVector(0.0, 0.0, 0.0);
FMatrix newOr = viewport->getOrientation();
- double yVal1 = newOr._row1._y * rowScale2;
- double zVal1 = newOr._row1._z * rowScale2;
- double xVal1 = newOr._row2._x * rowScale2;
- double yVal2 = newOr._row2._y * rowScale2;
- double zVal2 = newOr._row2._z * rowScale2;
- double zVal3 = zVal1 + m4._col1._z;
- double yVal3 = yVal1 + m4._col1._y;
- double xVal2 = newOr._row1._x * rowScale2 + m4._col1._x;
- double zVal4 = zVal2 + m4._col1._z;
- double yVal4 = yVal2 + m4._col1._y;
- double xVal3 = xVal1 + m4._col1._x;
-
- DVector tempV4(xVal2, yVal3, zVal3);
- DVector tempV3(xVal3, yVal4, zVal4);
+ float yVal1 = newOr._row1._y * rowScale2;
+ float zVal1 = newOr._row1._z * rowScale2;
+ float xVal1 = newOr._row2._x * rowScale2;
+ float yVal2 = newOr._row2._y * rowScale2;
+ float zVal2 = newOr._row2._z * rowScale2;
+ float zVal3 = zVal1 + m4._col1._z;
+ float yVal3 = yVal1 + m4._col1._y;
+ float xVal2 = newOr._row1._x * rowScale2 + m4._col1._x;
+ float zVal4 = zVal2 + m4._col1._z;
+ float yVal4 = yVal2 + m4._col1._y;
+ float xVal3 = xVal1 + m4._col1._x;
+
+ FVector tempV4(xVal2, yVal3, zVal3);
+ FVector tempV3(xVal3, yVal4, zVal4);
m4._col3 = tempV4;
FVector tempV5;
@@ -561,15 +561,17 @@ bool CStarCamera::lockMarker2(CViewport *viewport, const FVector &secondStarPosi
tempV3._z = newOr._row3._z * rowScale2 + m4._col1._z;
m4._col4 = tempV3;
- DVector viewPosition = oldPos.dAffMatrixProdVec(m2);
+ FVector viewPosition = oldPos.MatProdColVect(m2);
m4._col1 = m4._col1.dAffMatrixProdVec(m2);
m4._col3 = m4._col3.dAffMatrixProdVec(m2);
m4._col2 = m4._col2.dAffMatrixProdVec(m2);
m4._col4 = m4._col4.dAffMatrixProdVec(m2);
- double minDistance;
+ float minDistance;
+ FVector x1(viewPosition);
+ FVector x2(m4._col1);
// Find the angle of rotation for m4._col1 that gives the minimum distance to viewPosition
- double minDegree = calcAngleForMinDist(viewPosition,m4._col1,minDistance);
+ float minDegree = calcAngleForMinDist(x1,x2,minDistance);
m4._col1.rotVectAxisY((double)minDegree);
m4._col2.rotVectAxisY((double)minDegree);
@@ -627,20 +629,20 @@ bool CStarCamera::lockMarker3(CViewport *viewport, const FVector &thirdStarPosit
return true;
}
-double CStarCamera::calcAngleForMinDist(DVector &x, DVector &y, double &minDistance) {
- DVector tempPos;
+float CStarCamera::calcAngleForMinDist(FVector &x, FVector &y, float &minDistance) {
+ FVector tempPos;
minDistance = 1.0e20;
- double minDegree = 0.0;
- double degInc = 1.0; // one degree steps
+ float minDegree = 0.0;
+ float degInc = 1.0; // one degree steps
int nDegrees = floor(360.0/degInc);
for (int i = 0; i < nDegrees; ++i) {
tempPos = y;
- tempPos.rotVectAxisY((double)degInc*i);
- double distance = x.getDistance(tempPos);
+ tempPos.rotVectAxisY((float)degInc*i);
+ float distance = x.getDistance(tempPos);
if (distance < minDistance) {
minDistance = distance;
- minDegree = (double) degInc*i;
+ minDegree = (float) degInc*i;
}
}
return minDegree;