aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe
diff options
context:
space:
mode:
authorEugene Sandulenko2014-05-05 08:02:26 +0300
committerEugene Sandulenko2014-05-05 08:02:44 +0300
commitc6d36044c5343b6cbc476d3e06be06963c35a9ba (patch)
treee6e6b56535b9d3cda96c046e6535fdd1cb22a0ba /engines/fullpipe
parent9f4c221a2222d33323549b137767c0bbd68df29d (diff)
downloadscummvm-rg350-c6d36044c5343b6cbc476d3e06be06963c35a9ba.tar.gz
scummvm-rg350-c6d36044c5343b6cbc476d3e06be06963c35a9ba.tar.bz2
scummvm-rg350-c6d36044c5343b6cbc476d3e06be06963c35a9ba.zip
FULLPIPE: Started MovGraph::findClosestLink() implementation
Diffstat (limited to 'engines/fullpipe')
-rw-r--r--engines/fullpipe/motion.cpp58
-rw-r--r--engines/fullpipe/motion.h1
2 files changed, 59 insertions, 0 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index df0e8d8e35..00e4d856ba 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -687,6 +687,64 @@ void MovGraph::calcNodeDistancesAndAngles() {
}
}
+bool MovGraph::findClosestLink(int unusedArg, Common::Point *p, MovArr *movarr) {
+#if 0
+ v4 = (double)p->x;
+ v5 = (double)(signed int)p->y;
+ link = 0;
+ v28 = 1.0e20;
+
+ for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
+ MovGraphLink *lnk = (MovGraphLink *)*i;
+
+ v8 = v6->data;
+
+ if ((lnk->_flags & 0x10000000) && !(lnk->_flags & 0x20000000) ) {
+ v12 = lnk->_movGraphNode1->_x;
+ v13 = lnk->_movGraphNode1->_y;
+ v23 = v12;
+ v14 = lnk->_movGraphNode2->_x;
+ v15 = (double)v12;
+ v27 = v14;
+ v16 = v14 - v12;
+ v17 = lnk->_movGraphNode2->_y;
+ v29 = v15;
+ v18 = v4 - v15;
+ v32 = (double)v13 - v5;
+ v33 = (double)v16;
+ v19 = sqrt(v32 * v32 + v18 * v18);
+ v20 = ((double)(v13 - v17) * v32 + v33 * v18) / lnk->_distance / v19;
+ v21 = v20 * v19;
+ v26 = sqrt(1.0 - v20 * v20) * v19;
+ if ( v20 * v19 < 0.0 ) {
+ v21 = 0.0;
+ v26 = sqrt((v29 - v4) * (v29 - v4) + v32 * v32);
+ }
+ if (v21 > lnk->_distance) {
+ v21 = lnk->_distance;
+ v26 = sqrt(((double)v27 - v4) * ((double)v27 - v4) + ((double)lnk->_movGraphNode2->_y - v5) * ((double)lnk->_movGraphNode2->_y - v5));
+ }
+ if ( v21 >= 0.0 && v21 <= lnk->_distance && v26 < v28 ) {
+ v30 = v23 + (unsigned __int64)(signed __int64)(v33 * v21 / lnk->_distance);
+ v7 = v13 + (unsigned __int64)(signed __int64)((double)(v17 - v13) * v21 / lnk->_distance);
+ v28 = v26;
+ link = lnk;
+ }
+ }
+ }
+
+ if (v28 < 1.0e20) {
+ if (movarr)
+ movarr->_link = link;
+ p->x = v30;
+ p->y = v7;
+
+ return true;
+ }
+#endif
+ return false;
+}
+
int MovGraph::getItemIndexByStaticAni(StaticANIObject *ani) {
for (uint i = 0; i < _items.size(); i++)
if (_items[i]->ani == ani)
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index 396fc6578f..13d96ae551 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -359,6 +359,7 @@ public:
double calcDistance(Common::Point *point, MovGraphLink *link, int fuzzyMatch);
void calcNodeDistancesAndAngles();
+ bool findClosestLink(int unusedArg, Common::Point *p, MovArr *movarr);
MovGraphNode *calcOffset(int ox, int oy);
int getItemIndexByStaticAni(StaticANIObject *ani);
Common::Array<MovArr *> *genMovArr(int x, int y, int *arrSize, int flag1, int flag2);