commit:2ffa7d6ac1518a98acc77b4be3c6b5a95e5c5313
author:Chip Black
committer:Chip Black
date:Tue Jul 15 21:38:07 2008 -0500
parents:97b0a22977a4a5d66ca4695345bfa126909b5029
Added drawing to QuadTree
diff --git a/Richter/util.py b/Richter/util.py
line changes: +35/-0
index 52ae449..47bcfbc
--- a/Richter/util.py
+++ b/Richter/util.py
@@ -70,3 +70,38 @@ class QuadTreeR:
 			return o
 		else:
 			return None
+
+
+	def draw(self, rect = None):
+		glColor3f(1.0, 1.0, 1.0)
+		glBegin(GL_LINE_LOOP)
+		glVertex3f(self.bbox.left, self.bbox.top, 0)
+		glVertex3f(self.bbox.right, self.bbox.top, 0)
+		glVertex3f(self.bbox.right, self.bbox.bottom, 0)
+		glVertex3f(self.bbox.left, self.bbox.bottom, 0)
+		glEnd()
+
+		for (r, o) in self.rects:
+			if rect and r.colliderect(rect):
+				glColor3f(1.0, 1.0, 0.0)
+			else:
+				glColor3f(0.0, 0.0, 1.0)
+			glBegin(GL_LINE_LOOP)
+			glVertex3f(r.left, r.top, 0)
+			glVertex3f(r.right, r.top, 0)
+			glVertex3f(r.right, r.bottom, 0)
+			glVertex3f(r.left, r.bottom, 0)
+			glEnd()
+
+		if self.subregions:
+			for s in self.subregions:
+				s.draw(rect)
+
+		if rect:
+			glColor3f(1.0, 0.0, 0.0)
+			glBegin(GL_LINE_LOOP)
+			glVertex3f(rect.left, rect.top, 0)
+			glVertex3f(rect.right, rect.top, 0)
+			glVertex3f(rect.right, rect.bottom, 0)
+			glVertex3f(rect.left, rect.bottom, 0)
+			glEnd()