Skip to content

Commit

Permalink
TITANIC: Renaming of camera setting position & orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Apr 16, 2017
1 parent 0774501 commit 4fae7c8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 34 deletions.
48 changes: 24 additions & 24 deletions engines/titanic/star_control/star_camera.cpp
Expand Up @@ -29,8 +29,8 @@

namespace Titanic {

FMatrix *CStarCamera::_matrix1;
FMatrix *CStarCamera::_matrix2;
FMatrix *CStarCamera::_priorOrientation;
FMatrix *CStarCamera::_newOrientation;

CStarCamera::CStarCamera(const CNavigationInfo *data) :
_matrixRow(-1), _mover(nullptr), _field108(0) {
Expand All @@ -42,15 +42,15 @@ CStarCamera::CStarCamera(CViewport *src) :
}

void CStarCamera::init() {
_matrix1 = nullptr;
_matrix2 = nullptr;
_priorOrientation = nullptr;
_newOrientation = nullptr;
}

void CStarCamera::deinit() {
delete _matrix1;
delete _matrix2;
_matrix1 = nullptr;
_matrix2 = nullptr;
delete _priorOrientation;
delete _newOrientation;
_priorOrientation = nullptr;
_newOrientation = nullptr;
}

CStarCamera::~CStarCamera() {
Expand Down Expand Up @@ -123,26 +123,26 @@ void CStarCamera::setDestination(const FVector &v) {
_mover->moveTo(vector, v, matrix);
}

void CStarCamera::proc15(CErrorCode *errorCode) {
if (!_matrix1)
_matrix1 = new FMatrix();
if (!_matrix2)
_matrix2 = new FMatrix();
void CStarCamera::updatePosition(CErrorCode *errorCode) {
if (!_priorOrientation)
_priorOrientation = new FMatrix();
if (!_newOrientation)
_newOrientation = new FMatrix();

*_matrix1 = _viewport.getMatrix();
*_matrix2 = *_matrix1;
*_priorOrientation = _viewport.getMatrix();
*_newOrientation = *_priorOrientation;

FVector v1 = _viewport._position;
FVector v2 = _viewport._position;
_mover->proc11(*errorCode, v2, *_matrix2);
FVector priorPos = _viewport._position;
FVector newPos = _viewport._position;
_mover->proc11(*errorCode, newPos, *_newOrientation);

if (v1 != v2) {
_viewport.setPosition(v2);
if (newPos != priorPos) {
_viewport.setPosition(newPos);
set108();
}

if (*_matrix1 != *_matrix2) {
_viewport.setMatrix(*_matrix2);
if (*_priorOrientation != *_newOrientation) {
_viewport.setOrientation(*_newOrientation);
}
}

Expand Down Expand Up @@ -312,7 +312,7 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
tempV1 += row1;

m1.set(tempV4, tempV5, tempV6);
_viewport.setMatrix(m1);
_viewport.setOrientation(m1);
_viewport.setPosition(tempV1);
} else if (_matrixRow == 1) {
FVector tempV2;
Expand Down Expand Up @@ -386,7 +386,7 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
tempV16 = tempV3;

m3.set(mrow1, mrow2, mrow3);
_viewport.setMatrix(m3);
_viewport.setOrientation(m3);
_viewport.setPosition(tempV16);
}
}
Expand Down
10 changes: 7 additions & 3 deletions engines/titanic/star_control/star_camera.h
Expand Up @@ -38,8 +38,8 @@ namespace Titanic {
*/
class CStarCamera {
private:
static FMatrix *_matrix1;
static FMatrix *_matrix2;
static FMatrix *_priorOrientation;
static FMatrix *_newOrientation;
private:
int _matrixRow;
FMatrix _matrix;
Expand Down Expand Up @@ -87,7 +87,11 @@ class CStarCamera {
*/
virtual void setDestination(const FVector &v);

virtual void proc15(CErrorCode *errorCode);
/**
* Updates the camera position
*/
virtual void updatePosition(CErrorCode *errorCode);

virtual void proc16();
virtual void proc17();
virtual void proc18();
Expand Down
2 changes: 2 additions & 0 deletions engines/titanic/star_control/star_control_sub2.cpp
Expand Up @@ -22,6 +22,7 @@

#include "titanic/star_control/star_control_sub2.h"
#include "titanic/star_control/star_camera.h"
#include "titanic/titanic.h"

namespace Titanic {

Expand All @@ -42,6 +43,7 @@ bool CStarControlSub2::selectStar(CSurfaceArea *surfaceArea,
if (index == -1) {
return false;
} else if (!handler) {
debugC(DEBUG_BASIC, kDebugStarfield, "Select star %d", index);
camera->setDestination(_data[index]._position);
return true;
} else {
Expand Down
8 changes: 4 additions & 4 deletions engines/titanic/star_control/star_view.cpp
Expand Up @@ -179,7 +179,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
if (v == -1) {
pose.setRotationMatrix(key == Common::KEYCODE_z ? Y_AXIS : X_AXIS, 1.0);
_camera.proc22(pose);
_camera.proc15(errorCode);
_camera.updatePosition(errorCode);
return true;
}
break;
Expand Down Expand Up @@ -212,7 +212,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
if (v == -1) {
pose.setRotationMatrix(Y_AXIS, -1.0);
_camera.proc22(pose);
_camera.proc15(errorCode);
_camera.updatePosition(errorCode);
return true;
}
break;
Expand All @@ -221,7 +221,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
if (v == -1) {
pose.setRotationMatrix(X_AXIS, -1.0);
_camera.proc22(pose);
_camera.proc15(errorCode);
_camera.updatePosition(errorCode);
return true;
}
break;
Expand All @@ -248,7 +248,7 @@ void CStarView::resetPosition() {
bool CStarView::fn1() {
if (_videoSurface) {
CErrorCode errorCode;
_camera.proc15(&errorCode);
_camera.updatePosition(&errorCode);

if (_fader._index < 0 || _fader._index >= _fader._count)
_starField->fn1(&errorCode);
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/viewport.cpp
Expand Up @@ -111,7 +111,7 @@ void CViewport::setPosition(const FPose &pose) {
_flag = false;
}

void CViewport::setMatrix(const FMatrix &m) {
void CViewport::setOrientation(const FMatrix &m) {
_matrix = m;
_flag = false;
}
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/star_control/viewport.h
Expand Up @@ -85,9 +85,9 @@ class CViewport {
void setPosition(const FPose &pose);

/**
* Sets the matrix
* Sets the orientation
*/
void setMatrix(const FMatrix &m);
void setOrientation(const FMatrix &m);

void fn11(const FVector &v);
void fn12();
Expand Down

0 comments on commit 4fae7c8

Please sign in to comment.