Skip to content

Commit

Permalink
FULLPIPE: Implement MovGraph::calcNodeDistancesAndAngles()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- authored and Kamil Zbróg committed Oct 24, 2013
1 parent 7d8fef7 commit aebe01f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions engines/fullpipe/motion.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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()");

Expand Down
3 changes: 3 additions & 0 deletions engines/fullpipe/motion.h
Expand Up @@ -206,6 +206,8 @@ class MovGraphLink : public CObject {
public:
MovGraphLink();
virtual bool load(MfcArchive &file);

void calcNodeDistanceAndAngle();
};

struct MovGraphItem {
Expand Down Expand Up @@ -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);
};

Expand Down

0 comments on commit aebe01f

Please sign in to comment.