mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-09 12:22:51 +00:00
TITANIC: Rewrite of lockMarker2
This commit is contained in:
parent
13048f2af0
commit
cb3f8f35db
@ -72,8 +72,8 @@ public:
|
||||
*/
|
||||
virtual void stop();
|
||||
|
||||
virtual void proc8(FVector &oldPos, FVector &newPos,
|
||||
FMatrix &oldOrientation, FMatrix &newOrientation) {}
|
||||
virtual void proc8(const FVector &oldPos, const FVector &newPos,
|
||||
const FMatrix &oldOrientation, const FMatrix &newOrientation) {}
|
||||
|
||||
/**
|
||||
* Start a movement to a given specified destination
|
||||
|
@ -457,16 +457,13 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
|
||||
if (_matrixRow != 0)
|
||||
return;
|
||||
|
||||
DMatrix m1;
|
||||
DVector tempV1 = _matrix._row1;
|
||||
DMatrix m2(X_AXIS, tempV1);
|
||||
|
||||
tempV1 = v - _matrix._row1;
|
||||
m1 = tempV1.fn5();
|
||||
DMatrix m2(X_AXIS, _matrix._row1);
|
||||
DVector tempV1 = v - _matrix._row1;
|
||||
DMatrix m1 = tempV1.fn5();
|
||||
m1 = m1.fn4(m2);
|
||||
m2 = m1.fn1();
|
||||
|
||||
DVector tempV2 = _viewport._position;
|
||||
|
||||
FVector tempV2 = _viewport._position;
|
||||
DMatrix m4;
|
||||
m4._row1 = viewport->_position;
|
||||
m4._row2 = DVector(0.0, 0.0, 0.0);
|
||||
@ -474,31 +471,46 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
|
||||
m4._row4 = DVector(0.0, 0.0, 0.0);
|
||||
|
||||
FMatrix m5 = viewport->getOrientation();
|
||||
DVector tempV3, tempV4;
|
||||
m4._row3 = tempV4 = m5._row1 * 1000000.0 + m4._row1;
|
||||
m4._row2 = tempV3 = m5._row2 * 1000000.0 + m4._row1;
|
||||
double yVal1 = m5._row1._y * 1000000.0;
|
||||
double zVal1 = m5._row1._z * 1000000.0;
|
||||
double xVal1 = m5._row2._x * 1000000.0;
|
||||
double yVal2 = m5._row2._y * 1000000.0;
|
||||
double zVal2 = m5._row2._z * 1000000.0;
|
||||
double zVal3 = zVal1 + m4._row1._z;
|
||||
double yVal3 = yVal1 + m4._row1._y;
|
||||
double xVal2 = m5._row1._x * 1000000.0 + m4._row1._x;
|
||||
double zVal4 = zVal2 + m4._row1._z;
|
||||
double yVal4 = yVal2 + m4._row1._y;
|
||||
double xVal3 = xVal1 + m4._row1._x;
|
||||
|
||||
tempV4._x = m5._row3._x * 1000000.0;
|
||||
tempV4._y = m5._row3._y * 1000000.0;
|
||||
tempV3._x = tempV4._x + m4._row1._x;
|
||||
tempV3._y = tempV4._y + m4._row1._y;
|
||||
DVector tempV4(xVal2, yVal3, zVal3);
|
||||
DVector tempV3(xVal3, yVal4, zVal4);
|
||||
m4._row3 = tempV4;
|
||||
|
||||
FVector tempV5;
|
||||
tempV5._x = m5._row3._x * 1000000.0;
|
||||
tempV5._y = m5._row3._y * 1000000.0;
|
||||
m4._row2 = tempV3;
|
||||
|
||||
tempV3._x = tempV5._x + m4._row1._x;
|
||||
tempV3._y = tempV5._y + m4._row1._y;
|
||||
tempV3._z = m5._row3._z * 1000000.0 + m4._row1._z;
|
||||
m4._row4 = tempV3;
|
||||
|
||||
tempV3 = tempV2.fn1(m2);
|
||||
tempV2 = tempV2.fn1();
|
||||
m4._row1 = m4._row1.fn1(m2);
|
||||
m4._row2 = m4._row2.fn1(m2);
|
||||
m4._row3 = m4._row3.fn1(m2);
|
||||
m4._row2 = m4._row2.fn1(m2);
|
||||
m4._row4 = m4._row4.fn1(m2);
|
||||
|
||||
// Find the angle that gives the minimum distance
|
||||
DVector tempV5;
|
||||
DVector tempPos;
|
||||
double minDistance = 1.0e20;
|
||||
int minDegree = 0;
|
||||
for (int degree = 0; degree < 360; ++degree) {
|
||||
tempV5 = m4._row1;
|
||||
tempV5.fn2((double)degree);
|
||||
double distance = tempV2.getDistance(tempV5);
|
||||
tempPos = m4._row1;
|
||||
tempPos.fn2((double)degree);
|
||||
double distance = tempV2.getDistance(tempPos);
|
||||
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
@ -516,9 +528,7 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
|
||||
m4._row4 = m4._row4.fn1(m1);
|
||||
|
||||
m4._row3 -= m4._row1;
|
||||
m4._row2._x -= m4._row1._x;
|
||||
m4._row2._y -= m4._row1._y;
|
||||
m4._row2._z = m4._row2._z - m4._row1._z;
|
||||
m4._row2 -= m4._row1;
|
||||
m4._row4 -= m4._row1;
|
||||
|
||||
m4._row3.normalize();
|
||||
@ -526,9 +536,9 @@ void CStarCamera::lockMarker2(CViewport *viewport, const FVector &v) {
|
||||
m4._row4.normalize();
|
||||
m5.set(m4._row3, m4._row2, m4._row4);
|
||||
|
||||
FVector tempV6 = m4._row1;
|
||||
FVector newPos = m4._row1;
|
||||
FMatrix m6 = _viewport.getOrientation();
|
||||
_mover->proc8(_viewport._position, tempV6, m6, m5);
|
||||
_mover->proc8(_viewport._position, newPos, m6, m5);
|
||||
|
||||
CStarVector *sv = new CStarVector(this, v);
|
||||
_mover->setVector(sv);
|
||||
|
@ -29,8 +29,8 @@ CStarControlSub22::CStarControlSub22(const CNavigationInfo *src) :
|
||||
CCameraMover(src) {
|
||||
}
|
||||
|
||||
void CStarControlSub22::proc8(FVector &oldPos, FVector &newPos,
|
||||
FMatrix &oldOrientation, FMatrix &newOrientation) {
|
||||
void CStarControlSub22::proc8(const FVector &oldPos, const FVector &newPos,
|
||||
const FMatrix &oldOrientation, const FMatrix &newOrientation) {
|
||||
if (isLocked())
|
||||
decLockCount();
|
||||
|
||||
|
@ -35,8 +35,8 @@ public:
|
||||
CStarControlSub22(const CNavigationInfo *src);
|
||||
virtual ~CStarControlSub22() {}
|
||||
|
||||
virtual void proc8(FVector &oldPos, FVector &newPos,
|
||||
FMatrix &oldOrientation, FMatrix &newOrientation);
|
||||
virtual void proc8(const FVector &oldPos, const FVector &newPos,
|
||||
const FMatrix &oldOrientation, const FMatrix &newOrientation);
|
||||
|
||||
/**
|
||||
* Update the passed position and orientation matrix
|
||||
|
Loading…
x
Reference in New Issue
Block a user