Code Cleanup: py script float comparisons
authorCampbell Barton <ideasman42@gmail.com>
Fri, 17 Jan 2014 22:13:51 +0000 (09:13 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 17 Jan 2014 22:13:51 +0000 (09:13 +1100)
release/scripts/startup/bl_operators/freestyle.py
release/scripts/startup/bl_operators/rigidbody.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_material.py

index 7aa6ae13b56de61a8351837bc93f152d0067503e..73232232e23aaad396347810fe6d628ce7d0aeb7 100644 (file)
@@ -41,7 +41,8 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
         return rl and rl.freestyle_settings.linesets.active
 
     def execute(self, context):
-        rl = context.scene.render.layers.active
+        scene = context.scene
+        rl = scene.render.layers.active
         lineset = rl.freestyle_settings.linesets.active
         linestyle = lineset.linestyle
         # Find the modifier to work on
@@ -53,7 +54,7 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
             m = linestyle.thickness_modifiers[self.name]
         # Find the source object
         if m.type == 'DISTANCE_FROM_CAMERA':
-            source = context.scene.camera
+            source = scene.camera
         elif m.type == 'DISTANCE_FROM_OBJECT':
             if m.target is None:
                 self.report({'ERROR'}, "Target object not specified")
@@ -63,8 +64,8 @@ class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
             self.report({'ERROR'}, "Unexpected modifier type: " + m.type)
             return {'CANCELLED'}
         # Find selected mesh objects
-        selection = [ob for ob in context.scene.objects if ob.select and ob.type == 'MESH' and ob.name != source.name]
-        if len(selection) > 0:
+        selection = [ob for ob in scene.objects if ob.select and ob.type == 'MESH' and ob.name != source.name]
+        if selection:
             # Compute the min/max distance between selected mesh objects and the source
             min_dist = sys.float_info.max
             max_dist = -min_dist
index 109484a6b9b4f2d20bcd4bd27fad96f7f7888cdd..f9461c85341d504e4c42680e11835c094b42e00b 100644 (file)
@@ -151,7 +151,7 @@ class BakeToKeyframes(Operator):
                         q1 = obj.rotation_quaternion
                         q2 = mat.to_quaternion()
                         # make quaternion compatible with the previous one
-                        if (q1.dot(q2) < 0):
+                        if q1.dot(q2) < 0.0:
                             obj.rotation_quaternion = -q2
                         else:
                             obj.rotation_quaternion = q2
index bca613be8662deadefee777fed058aaa6ec433d7..441d314463d024acd4c54cc9807b547485c59469 100644 (file)
@@ -583,7 +583,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.prop(md, "wave_alignment", text="Alignment")
         sub = col.column()
-        sub.active = md.wave_alignment > 0
+        sub.active = (md.wave_alignment > 0.0)
         sub.prop(md, "wave_direction", text="Direction")
         sub.prop(md, "damping")
 
index d48c4957e6e686e213e354f9daacabb6267fe804..9e56c269b2b0b425039670c25bbe9d69d6536a55 100644 (file)
@@ -412,7 +412,7 @@ class MATERIAL_PT_transp(MaterialButtonsPanel, Panel):
         col.active = (not mat.use_shadeless)
         col.prop(rayt, "fresnel")
         sub = col.column()
-        sub.active = rayt.fresnel > 0
+        sub.active = (rayt.fresnel > 0.0)
         sub.prop(rayt, "fresnel_factor", text="Blend")
 
         if base_mat.transparency_method == 'RAYTRACE':
@@ -469,7 +469,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
         col = split.column()
         col.prop(raym, "fresnel")
         sub = col.column()
-        sub.active = raym.fresnel > 0
+        sub.active = (raym.fresnel > 0.0)
         sub.prop(raym, "fresnel_factor", text="Blend")
 
         split = layout.split()
@@ -480,7 +480,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
         col.prop(raym, "distance", text="Max Dist")
         col.separator()
         sub = col.split(percentage=0.4)
-        sub.active = raym.distance > 0.0
+        sub.active = (raym.distance > 0.0)
         sub.label(text="Fade To:")
         sub.prop(raym, "fade_to", text="")
 
@@ -488,7 +488,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
         col.label(text="Gloss:")
         col.prop(raym, "gloss_factor", text="Amount")
         sub = col.column()
-        sub.active = raym.gloss_factor < 1.0
+        sub.active = (raym.gloss_factor < 1.0)
         sub.prop(raym, "gloss_threshold", text="Threshold")
         sub.prop(raym, "gloss_samples", text="Samples")
         sub.prop(raym, "gloss_anisotropic", text="Anisotropic")