Mercurial > pyntnclick
comparison tools/rect_drawer.py @ 323:0630a37cb371
Print existing intersection in scene on startup
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sat, 28 Aug 2010 13:10:55 +0200 |
parents | e5f3a97ee812 |
children | 2bef605a0ef2 |
comparison
equal
deleted
inserted
replaced
322:1208bb5eaf6f | 323:0630a37cb371 |
---|---|
89 self.draw_rects = True | 89 self.draw_rects = True |
90 self.draw_things = True | 90 self.draw_things = True |
91 self.draw_thing_rects = True | 91 self.draw_thing_rects = True |
92 self.draw_images = True | 92 self.draw_images = True |
93 self.draw_toolbar = True | 93 self.draw_toolbar = True |
94 | 94 self.find_existing_intersects() |
95 def find_intersecting_things(self): | 95 |
96 def find_existing_intersects(self): | |
96 """Parse the things in the scene for overlaps""" | 97 """Parse the things in the scene for overlaps""" |
98 if self.state.current_detail: | |
99 scene = self.state.current_detail | |
100 else: | |
101 scene = self.state.current_scene | |
102 # Pylint hates this function | |
103 for thing in scene.things.itervalues(): | |
104 for interact_name in thing.interacts: | |
105 thing.set_interact(interact_name) | |
106 if hasattr(thing.rect, 'collidepoint'): | |
107 thing_rects = [thing.rect] | |
108 else: | |
109 thing_rects = thing.rect | |
110 for thing2 in scene.things.itervalues(): | |
111 if thing is thing2: | |
112 continue | |
113 for interact2_name in thing2.interacts: | |
114 thing2.set_interact(interact2_name) | |
115 if hasattr(thing2.rect, 'collidepoint'): | |
116 thing2_rects = [thing2.rect] | |
117 else: | |
118 thing2_rects = thing2.rect | |
119 for my_rect in thing_rects: | |
120 for other_rect in thing2_rects: | |
121 if my_rect.colliderect(other_rect): | |
122 print 'Existing Intersecting rects' | |
123 print " Thing1 %s Interact %s" % (thing.name, interact_name) | |
124 print " Thing2 %s Interact %s" % (thing2.name, interact2_name) | |
125 print " Rects", my_rect, other_rect | |
126 print | |
97 | 127 |
98 def find_intersecting_rects(self, d): | 128 def find_intersecting_rects(self, d): |
99 """Find if any rect collections intersect""" | 129 """Find if any rect collections intersect""" |
100 # I loath N^X brute search algorithm's, but whatever, hey | 130 # I loath N^X brute search algorithm's, but whatever, hey |
101 if self.state.current_detail: | 131 if self.state.current_detail: |