# HG changeset patch # User Neil Muller # Date 1282993855 -7200 # Node ID 0630a37cb371bda5ba10bcb9b123c713445c2948 # Parent 1208bb5eaf6f8623bd607994a27c69443cfc97b7 Print existing intersection in scene on startup diff -r 1208bb5eaf6f -r 0630a37cb371 tools/rect_drawer.py --- a/tools/rect_drawer.py Sat Aug 28 13:05:40 2010 +0200 +++ b/tools/rect_drawer.py Sat Aug 28 13:10:55 2010 +0200 @@ -91,9 +91,39 @@ self.draw_thing_rects = True self.draw_images = True self.draw_toolbar = True + self.find_existing_intersects() - def find_intersecting_things(self): + def find_existing_intersects(self): """Parse the things in the scene for overlaps""" + if self.state.current_detail: + scene = self.state.current_detail + else: + scene = self.state.current_scene + # Pylint hates this function + for thing in scene.things.itervalues(): + for interact_name in thing.interacts: + thing.set_interact(interact_name) + if hasattr(thing.rect, 'collidepoint'): + thing_rects = [thing.rect] + else: + thing_rects = thing.rect + for thing2 in scene.things.itervalues(): + if thing is thing2: + continue + for interact2_name in thing2.interacts: + thing2.set_interact(interact2_name) + if hasattr(thing2.rect, 'collidepoint'): + thing2_rects = [thing2.rect] + else: + thing2_rects = thing2.rect + for my_rect in thing_rects: + for other_rect in thing2_rects: + if my_rect.colliderect(other_rect): + print 'Existing Intersecting rects' + print " Thing1 %s Interact %s" % (thing.name, interact_name) + print " Thing2 %s Interact %s" % (thing2.name, interact2_name) + print " Rects", my_rect, other_rect + print def find_intersecting_rects(self, d): """Find if any rect collections intersect"""