Cleanup body association for ray polys we discard. Add missed call to update_shapes
authorNeil <neil@dip.sun.ac.za>
Tue, 13 Sep 2016 16:13:24 +0000 (18:13 +0200)
committerNeil <neil@dip.sun.ac.za>
Tue, 13 Sep 2016 16:13:24 +0000 (18:13 +0200)
tabakrolletjie/rays.py
tabakrolletjie/scenes/day.py

index ac51802d2d91315aa2eb5ef07be175b62e1ef89c..9db09a2a62ee5b388609ac237c476b813ac0897a 100644 (file)
@@ -109,6 +109,8 @@ class RayPolyManager(object):
     def update_shapes(self):
         if self._old_poly_cache:
             self._space.remove(*self._old_poly_cache)
+            for poly in self._old_poly_cache:
+                poly.body = None
         new_polys = self._old_poly_cache = self.polys()
         self._space.add(*new_polys)
 
index cbe0460c4717a86fb15181a1a9f040e0d49457a2..4176e36774de7dc8544ebd1fd4a4ce6e1e9f2887 100644 (file)
@@ -206,6 +206,7 @@ class DayScene(BaseScene):
         angle = math.atan2(distance[1], distance[0])
         # Set light angle to this position
         self._dragging.ray_manager.direction = math.degrees(angle)
+        self._dragging.ray_manager.update_shapes()
         # Hackily update gamestate with new angle
         for light_cfg in gamestate.station["lights"]:
             light_pos = pymunk.Vec2d(light_cfg["position"])