Skip to content
Permalink
Browse files

TITANIC: Fixes to CStarView class

  • Loading branch information
dreammaster committed Mar 26, 2017
1 parent 843540b commit 538e6ffc8f418e736d235221ae7f31bc832611da
Showing with 7 additions and 39 deletions.
  1. +7 −37 engines/titanic/star_control/star_view.cpp
  2. +0 −2 engines/titanic/star_control/star_view.h
@@ -282,7 +282,7 @@ void CStarView::fn3(bool fadeIn) {

void CStarView::fn4() {
FVector v1, v2;
randomizeVectors2(v1, v2);
randomizeVectors1(v1, v2);
_sub12.setPosition(v1);
_sub12.proc5(v2);
}
@@ -299,7 +299,7 @@ void CStarView::fn7() {
const CBaseStarEntry *star = _starField->getRandomStar();
if (star) {
FVector v1, v2;
randomizeVectors3(v1, v2);
randomizeVectors1(v1, v2);
v2 += star->_position;
_sub12.setPosition(v2);
_sub12.proc5(v1);
@@ -310,7 +310,7 @@ void CStarView::fn19(int index) {
const CBaseStarEntry *star = _starField->getStar(index);
if (star) {
FVector v1, v2;
randomizeVectors3(v1, v2);
randomizeVectors1(v1, v2);
v1 += star->_position;
_sub12.setPosition(v1);
_sub12.proc5(v2);
@@ -362,7 +362,7 @@ void CStarView::fn14() {

void CStarView::setHasReference() {
FVector v1, v2;
randomizeVectors1(v1, v2);
randomizeVectors2(v1, v2);

_sub13.setPosition(v1);
_sub13.fn11(v2);
@@ -438,53 +438,23 @@ void CStarView::fn18(CStarControlSub12 *sub12) {
}

void CStarView::randomizeVectors1(FVector &v1, FVector &v2) {
v1._x = g_vm->getRandomFloat() * -4096.0 - 3072.0;
v1._y = g_vm->getRandomFloat() * -4096.0 - 3072.0;
v1._z = g_vm->getRandomFloat() * -4096.0 - 3072.0;

double vx = g_vm->getRandomFloat() * 8192.0;
double vy = g_vm->getRandomFloat() * 1024.0;
vx -= v1._x;
vy -= v1._y;

v2._x = vx;
v2._y = vy;
v2._z = -v1._z;
v2.normalize();
}

void CStarView::randomizeVectors2(FVector &v1, FVector &v2) {
v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0;

// TODO: Doublecheck
v2._x = -v1._x;
v2._y = -v1._y;
v2._z = -v1._z;
v2.normalize();
}

void CStarView::randomizeVectors3(FVector &v1, FVector &v2) {
v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0;

// TODO: Doublecheck
v2._x = -v1._x;
v2._y = -v1._y;
v2._z = -v1._z;
v2.normalize();
}

void CStarView::randomizeVectors4(FVector &v1, FVector &v2) {
void CStarView::randomizeVectors2(FVector &v1, FVector &v2) {
v1._x = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._y = 3072.0 - g_vm->getRandomFloat() * -4096.0;
v1._z = 3072.0 - g_vm->getRandomFloat() * -4096.0;

// TODO: Doublecheck
v2._x = -v1._x;
v2._y = -v1._y;
v2._x = g_vm->getRandomFloat() * 8192.0 - v1._x;
v2._y = g_vm->getRandomFloat() * 1024.0 - v1._y;
v2._z = -v1._z;
v2.normalize();
}
@@ -59,8 +59,6 @@ class CStarView {

void randomizeVectors1(FVector &v1, FVector &v2);
void randomizeVectors2(FVector &v1, FVector &v2);
void randomizeVectors3(FVector &v1, FVector &v2);
void randomizeVectors4(FVector &v1, FVector &v2);

/**
* Handles resizing the surface

0 comments on commit 538e6ff

Please sign in to comment.
You can’t perform that action at this time.