changeset 559:cccff9b04f57

This fixes a problem where objects that leave the scene were not being removed from thee scene. Projectiles and enemies now get removed when they leave the scene. There should no longer be a segfault when you destroy the final boss.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 22 Jun 2010 15:41:36 +0000
parents 4cb5d0ed33a9
children 69d50e751c9a
files demos/shooter/scripts/scene.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/demos/shooter/scripts/scene.py	Fri Jun 18 19:49:13 2010 +0000
+++ b/demos/shooter/scripts/scene.py	Tue Jun 22 15:41:36 2010 +0000
@@ -450,8 +450,21 @@
 					self.queueObjectForRemoval(obj)
 
 			#self._world.renderBoundingBox(obj)			
-
-
+	
+		"""
+		Do some more cleanup.  Objects that leave the scene should be removed.
+		
+		@todo: Objects that leave the scene should be added to the scenes object removal
+		in the objects update function.  The current implementation is much slower.
+		"""
+		
+		worldlist = self.getObjectsInRange(0, self._maxnodes)
+		
+		for obj in worldlist:
+			if obj.scenenodeid < leftnode:
+				self.queueObjectForRemoval(obj)
+			if obj.type == SHTR_PROJECTILE and obj.scenenodeid > rightnode:
+				self.queueObjectForRemoval(obj)
 				
 	def _getPlayer(self):
 		return self._player