[Scummvm-git-logs] scummvm master -> 50a6100d27803a070f019aafb816151cb775dfe9
dreammaster
dreammaster at scummvm.org
Sat May 27 03:21:38 CEST 2017
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
50a6100d27 TITANIC: Simplify FVector addAndNormalize
Commit: 50a6100d27803a070f019aafb816151cb775dfe9
https://github.com/scummvm/scummvm/commit/50a6100d27803a070f019aafb816151cb775dfe9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-05-26T21:21:29-04:00
Commit Message:
TITANIC: Simplify FVector addAndNormalize
Changed paths:
engines/titanic/star_control/fvector.cpp
engines/titanic/star_control/fvector.h
engines/titanic/star_control/star_control_sub24.cpp
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index ff07b9b..a107ad1 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -58,12 +58,11 @@ float FVector::normalize() {
return hyp;
}
-const FVector *FVector::addAndNormalize(FVector &dest, const FVector &v1, const FVector &v2) {
- FVector tempVector(v1._x + v2._x, v1._y + v2._y, v1._z + v2._z);
- tempVector.normalize();
+FVector FVector::addAndNormalize(const FVector &v) const {
+ FVector tempV(_x + v._x, _y + v._y, _z + v._z);
+ tempV.normalize();
- dest = tempVector;
- return &dest;
+ return tempV;
}
float FVector::getDistance(const FVector &src) const {
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index a9cb44a..fa24fe5 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -64,9 +64,10 @@ public:
float normalize();
/**
- * Adds two vectors together and then normalizes the result
+ * Adds the current vector and a passed one together, normalizes them,
+ * and then returns the resulting vector
*/
- static const FVector *addAndNormalize(FVector &dest, const FVector &v1, const FVector &v2);
+ FVector addAndNormalize(const FVector &v) const;
/**
* Returns the distance between a specified point and this one
diff --git a/engines/titanic/star_control/star_control_sub24.cpp b/engines/titanic/star_control/star_control_sub24.cpp
index 4ceb82f..cac8850 100644
--- a/engines/titanic/star_control/star_control_sub24.cpp
+++ b/engines/titanic/star_control/star_control_sub24.cpp
@@ -57,17 +57,11 @@ void CStarControlSub24::setPath(const FVector &srcV, const FVector &destV, const
}
if (!flag) {
- const FVector *tv;
- FVector tempV1, tempV2;
- FVector::addAndNormalize(tempV1, row3, _posDelta);
- tv = FVector::addAndNormalize(tempV2, row3, tempV1);
- tempV1 = *tv;
-
- tv = FVector::addAndNormalize(tempV2, row3, tempV1);
- tempV1 = *tv;
-
- tv = FVector::addAndNormalize(tempV2, row3, tempV1);
- tempV1 = *tv;
+ FVector tempV1;
+ tempV1 = row3.addAndNormalize(_posDelta);
+ tempV1 = row3.addAndNormalize(tempV1);
+ tempV1 = row3.addAndNormalize(tempV1);
+ tempV1 = row3.addAndNormalize(tempV1);
FMatrix newOrient;
newOrient.fn1(tempV1);
@@ -81,7 +75,6 @@ void CStarControlSub24::setPath(const FVector &srcV, const FVector &destV, const
int CStarControlSub24::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orientation) {
FVector v1, v2, v3, v4;
- const FVector *tv;
if (!_active)
return 0;
@@ -116,13 +109,10 @@ int CStarControlSub24::proc5(CErrorCode &errorCode, FVector &pos, FMatrix &orien
}
if (!flag) {
- v2.addAndNormalize(v1, v2, v3);
- tv = v2.addAndNormalize(v4, v2, v1);
- v1 = *tv;
- tv = v2.addAndNormalize(v4, v2, v1);
- v1 = *tv;
- tv = v2.addAndNormalize(v4, v2, v1);
- v1 = *tv;
+ v1 = v2.addAndNormalize(v3);
+ v1 = v2.addAndNormalize(v1);
+ v1 = v2.addAndNormalize(v1);
+ v1 = v2.addAndNormalize(v1);
orientation.fn1(v1);
v2 = v1;
More information about the Scummvm-git-logs
mailing list