From 85f586e69d4e3386b03acbd07f6ee6a7a33739ee Mon Sep 17 00:00:00 2001 From: Sai Vineet Date: Sat, 21 Dec 2013 09:58:57 +0000 Subject: Fix pen color bug Color problem - Weird color behavior - * Add a box, and a pen to the box. Let some points be plotted. * After a bit of time, remove the box, and the attached pen * Exit using Stop button, and thus save to journal * Restart the above journal project. * Now add a box, and a pen to it. * Notice that the points plotted before change color to the new box's color. Also, fixed the destroy tool's malfuntioning bug, caused by track_indices. Solution: Save tracked_bodies too. --- diff --git a/physics.py b/physics.py index e89e12a..fff69ca 100644 --- a/physics.py +++ b/physics.py @@ -81,7 +81,8 @@ class PhysicsGame: self.world.add.remove_mouseJoint() additional_data = { "trackinfo": self.trackinfo, - "full_pos_list": self.full_pos_list + "full_pos_list": self.full_pos_list, + "tracked_bodies": self.tracked_bodies } self.world.json_save(path, additional_data, serialize=True) @@ -123,6 +124,9 @@ class PhysicsGame: self.world.additional_vars['full_pos_list'] if 'trackinfo' in self.world.additional_vars: self.trackinfo = self.world.additional_vars['trackinfo'] + if 'tracked_bodies' in self.world.additional_vars: + self.tracked_bodies = \ + self.world.additional_vars['tracked_bodies'] while self.loop: while gtk.events_pending(): diff --git a/tools.py b/tools.py index d9c107b..f896e1b 100644 --- a/tools.py +++ b/tools.py @@ -601,12 +601,13 @@ class DestroyTool(Tool): destroyed_body = False for key, info in tracklist: trackdex = info[4] - if trackdex in tokill[0].userData['track_indices'] and \ - info[3] is False: - self.game.world.world.DestroyBody(info[1]) - self.game.trackinfo[key][3] = True - destroyed_body = True - break + if "track_indices" in tokill[0].userData: + if trackdex in tokill[0].userData['track_indices'] and \ + info[3] is False: + self.game.world.world.DestroyBody(info[1]) + self.game.trackinfo[key][3] = True + destroyed_body = True + break jointnode = tokill[0].GetJointList() if jointnode and not destroyed_body: -- cgit v0.9.1