Code Cleanup: py script float comparisons

This commit is contained in:
Campbell Barton 2014-01-18 09:13:51 +11:00
parent a025ff407e
commit 96e9c67b47
4 changed files with 11 additions and 10 deletions

@ -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

@ -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

@ -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")

@ -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")