aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2013-10-23 00:49:55 +0300
committerEugene Sandulenko2013-10-23 00:49:55 +0300
commit18d2bbc2289feff265c12026aae7093b24aee959 (patch)
treeaf609dd8c733d6945749fbe7c8888537bdf2244b
parent1dd90e4ea9a01df9f2ccca8779c4fb3bec86cb34 (diff)
downloadscummvm-rg350-18d2bbc2289feff265c12026aae7093b24aee959.tar.gz
scummvm-rg350-18d2bbc2289feff265c12026aae7093b24aee959.tar.bz2
scummvm-rg350-18d2bbc2289feff265c12026aae7093b24aee959.zip
FULLPIPE: Implement MovGraph::calcNodeDistancesAndAngles()
-rw-r--r--engines/fullpipe/motion.cpp22
-rw-r--r--engines/fullpipe/motion.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index ebf896cf1e..750c2de5ea 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -357,6 +357,18 @@ double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzz
return res;
}
+void MovGraph::calcNodeDistancesAndAngles() {
+ for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
+
+ MovGraphLink *lnk = (MovGraphLink *)*i;
+
+ lnk->_flags &= 0x7FFFFFFF;
+
+ lnk->calcNodeDistanceAndAngle();
+ }
+}
+
int MovGraph2::getItemIndexByGameObjectId(int objectId) {
for (uint i = 0; i < _items.size(); i++)
if (_items[i]->_objectId == objectId)
@@ -1248,6 +1260,16 @@ bool MovGraphLink::load(MfcArchive &file) {
return true;
}
+void MovGraphLink::calcNodeDistanceAndAngle() {
+ if (_movGraphNode1) {
+ double dx = _movGraphNode2->_x - _movGraphNode1->_x;
+ double dy = _movGraphNode2->_y - _movGraphNode1->_y;
+
+ _distance = sqrt(dy * dy + dx * dx);
+ _angle = atan2(dx, dy);
+ }
+}
+
bool MovGraphNode::load(MfcArchive &file) {
debug(5, "MovGraphNode::load()");
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index 85ad084f60..7da0c47fb2 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -206,6 +206,8 @@ class MovGraphLink : public CObject {
public:
MovGraphLink();
virtual bool load(MfcArchive &file);
+
+ void calcNodeDistanceAndAngle();
};
struct MovGraphItem {
@@ -255,6 +257,7 @@ class MovGraph : public MotionController {
virtual int method50();
double calcDistance(Common::Point *point, MovGraphLink *link, int fuzzyMatch);
+ void calcNodeDistancesAndAngles();
MovGraphNode *calcOffset(int ox, int oy);
};