Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Skip the current overlay and move overlays via the manager so that we…

… never overlap overlays
  • Loading branch information...
commit 32b89e1d1866996a7213c0d433f0da07be7ddff6 1 parent 7d6aac7
@arvind authored
Showing with 5 additions and 20 deletions.
  1. +5 −20 overlay_manager.cpp
View
25 overlay_manager.cpp
@@ -99,26 +99,18 @@ void OverlayManager::checkSpheresOfInfluence(Overlay * overlay) {
GLfloat boundingBoxWithSOI[4];
overlay->getBoundingBoxWithSOI(boundingBoxWithSOI);
-// printf("hello\n");
-
for(overlay_iter it = this->overlays.begin(); it != this->overlays.end(); it++) {
Overlay * o = (Overlay *) it->second;
GLfloat intersectBox[4];
o->getBoundingBoxWithSOI(intersectBox);
+ if(o->getID() == overlay->getID())
+ continue;
+
if(o->getFingers().size() > 0) // If someone's working in their overlay,
continue; // don't move it. That's just rude!
-// printf("bb[0]: %f\t bb[1]: %f\t bb[2]: %f\t bb[3]: %f\n", boundingBoxWithSOI[0],
-// boundingBoxWithSOI[1],
-// boundingBoxWithSOI[2],
-// boundingBoxWithSOI[3]);
-// printf("ob[0]: %f\t ob[1]: %f\t ob[2]: %f\t ob[3]: %f\n", intersectBox[0],
-// intersectBox[1],
-// intersectBox[2],
-// intersectBox[3]);
-
// First check intersection - to intersect they must intersect on both x and y axes
if(((boundingBoxWithSOI[0] > intersectBox[0] && boundingBoxWithSOI[0] < intersectBox[2]) ||
(boundingBoxWithSOI[2] > intersectBox[0] && boundingBoxWithSOI[2] < intersectBox[2])) &&
@@ -131,11 +123,6 @@ void OverlayManager::checkSpheresOfInfluence(Overlay * overlay) {
intersecting_values[2] = intersectBox[3] - boundingBoxWithSOI[1]; // iMaxY - minY
intersecting_values[3] = boundingBoxWithSOI[3] - intersectBox[1]; // maxY - iMinY
-// printf("0: %f\t1: %f\t2: %f\t3: %f\n", intersecting_values[0],
-// intersecting_values[1],
-// intersecting_values[2],
-// intersecting_values[3]);
-
// The direction to move o will be based on which of the four sides the smallest
// intersecting area (> 0) is. We check the smallest intersecting area as this will
// give us an indication of how overlay is moving in relation to o.
@@ -150,8 +137,6 @@ void OverlayManager::checkSpheresOfInfluence(Overlay * overlay) {
}
}
-// printf("min_intersection: %f\tmin_index: %d\n", min_intersection, min_index);
-
if(min_index == 0 || min_index == 1) { // Smallest intersection along x-axis
GLfloat new_y = o->getY();
if(o->getY() < overlay->getY()) {
@@ -160,7 +145,7 @@ void OverlayManager::checkSpheresOfInfluence(Overlay * overlay) {
new_y = boundingBoxWithSOI[3] + (2 * o->getSphereSize()) + (o->getHeight() / 2);
}
- o->setOverlayPos(o->getX(), new_y);
+ this->setOverlayPos(o->getID(), o->getX(), new_y);
} else { // Smallest intersection along y-axis
GLfloat new_x = o->getY();
if(o->getX() < overlay->getX()) {
@@ -169,7 +154,7 @@ void OverlayManager::checkSpheresOfInfluence(Overlay * overlay) {
new_x = boundingBoxWithSOI[2] + (2 * o->getSphereSize()) + (o->getWidth() / 2);
}
- o->setOverlayPos(new_x, o->getY());
+ this->setOverlayPos(o->getID(), new_x, o->getY());
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.