]> Shamusworld >> Repos - architektonas/blobdiff - src/container.cpp
Fix for missing ampersand in QApplication.
[architektonas] / src / container.cpp
index e125672eac63c6690d4d1cbc4da044e08a9e6ee7..c867eaf80224c59609925d49eed1ec35683d3103 100644 (file)
@@ -16,6 +16,7 @@
 #include "container.h"
 
 #include <QtGui>
+#include "dimension.h"
 
 
 Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p),
@@ -117,8 +118,34 @@ Like so:
                {
                        if (objects[i]->Collided(point))
                        {
+Dimension * dimension = objects[i]->GetAttachedDimension();
+
                                objects.erase(objects.begin() + i);     // Calls the destructor, (deletes the object, I presume... O_o)
+
+// If this object had an attached dimension, reattach it to another object, if any...
+// The only problem with that approach is if the object it gets attached to is deleted,
+// it will call the dimension to use a NULL pointer and BLAMMO
+if (dimension)
+{
+       Vector p1 = dimension->GetPoint1();
+       Vector p2 = dimension->GetPoint2();
+       for(int j=0; j<(int)objects.size(); j++)
+       {
+               Vector * objectP1 = objects[i]->GetPointAt(p1);
+               Vector * objectP2 = objects[i]->GetPointAt(p2);
+
+               if (objectP1)
+                       dimension->SetPoint1(objectP1);
+
+               if (objectP2)
+                       dimension->SetPoint2(objectP2);
+       }
+}
+
+                               // This only allows deleting objects one at a time...
                                break;
+                               // however, this way of doing things could be problematic if we don't
+                               // delete one at a time... Need to come up with a better approach.
                        }
                }
        }