[Bf-blender-cvs] [96e9c67] master: Code Cleanup: py script float comparisons

Campbell Barton noreply at git.blender.org
Fri Jan 17 23:14:17 CET 2014


Commit: 96e9c67b472850ca711c710209ac684d40fe7132
Author: Campbell Barton
Date:   Sat Jan 18 09:13:51 2014 +1100
https://developer.blender.org/rB96e9c67b472850ca711c710209ac684d40fe7132

Code Cleanup: py script float comparisons

===================================================================

M	release/scripts/startup/bl_operators/freestyle.py
M	release/scripts/startup/bl_operators/rigidbody.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	release/scripts/startup/bl_ui/properties_material.py

===================================================================

diff --git a/release/scripts/startup/bl_operators/freestyle.py b/release/scripts/startup/bl_operators/freestyle.py
index 7aa6ae1..7323223 100644
--- a/release/scripts/startup/bl_operators/freestyle.py
+++ b/release/scripts/startup/bl_operators/freestyle.py
@@ -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
diff --git a/release/scripts/startup/bl_operators/rigidbody.py b/release/scripts/startup/bl_operators/rigidbody.py
index 109484a..f9461c85 100644
--- a/release/scripts/startup/bl_operators/rigidbody.py
+++ b/release/scripts/startup/bl_operators/rigidbody.py
@@ -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
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index bca613b..441d314 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -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")
 
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index d48c495..9e56c26 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -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")




More information about the Bf-blender-cvs mailing list