[Bf-blender-cvs] [79e51d9e5fb] master: Cleanup: replace verbose checks with read-only attributes

Campbell Barton noreply at git.blender.org
Tue Dec 17 04:08:20 CET 2019


Commit: 79e51d9e5fba95fc9569e75412b27b08bef7a7d5
Author: Campbell Barton
Date:   Tue Dec 17 12:58:32 2019 +1100
Branches: master
https://developer.blender.org/rB79e51d9e5fba95fc9569e75412b27b08bef7a7d5

Cleanup: replace verbose checks with read-only attributes

These attributes checked for any baked / baking
since this is a common test that was performed in layout code.

Also follow our naming convention - using an 'is_/has_' prefix
in this case since "cache_baked_data" reads as if it's used to access
the baked data.

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

M	release/scripts/startup/bl_ui/properties_physics_fluid.py
M	source/blender/makesdna/DNA_fluid_types.h
M	source/blender/makesrna/intern/rna_fluid.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 1eec2ac0ce7..3327d6b979f 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -134,17 +134,17 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
             domain = md.domain_settings
 
             # Deactivate UI if guiding is enabled but not baked yet
-            layout.active = not (domain.use_guiding and not domain.cache_baked_guiding and (domain.guiding_source == 'EFFECTOR' or (domain.guiding_source == 'DOMAIN' and not domain.guiding_parent)))
+            layout.active = not (domain.use_guiding and not domain.has_cache_baked_guiding and (domain.guiding_source == 'EFFECTOR' or (domain.guiding_source == 'DOMAIN' and not domain.guiding_parent)))
 
-            baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-            baked_data = domain.cache_baked_data
+            is_baking_any = domain.is_cache_baking_any
+            has_baked_data = domain.has_cache_baked_data
 
             row = layout.row()
-            row.enabled = not baking_any and not baked_data
+            row.enabled = not is_baking_any and not has_baked_data
             row.prop(domain, "domain_type", expand=False)
 
             flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
-            flow.enabled = not baking_any and not baked_data
+            flow.enabled = not is_baking_any and not has_baked_data
 
             col = flow.column()
             col.prop(domain, "resolution_max", text="Resolution Divisions")
@@ -175,15 +175,15 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
                 split = layout.split()
 
                 bake_incomplete = (domain.cache_frame_pause_data < domain.cache_frame_end)
-                if domain.cache_baked_data and not domain.cache_baking_data and bake_incomplete:
+                if domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
                     col = split.column()
                     col.operator("fluid.bake_data", text="Resume")
                     col = split.column()
                     col.operator("fluid.free_data", text="Free")
-                elif domain.cache_baking_data and not domain.cache_baked_data:
+                elif domain.is_cache_baking_data and not domain.has_cache_baked_data:
                     split.enabled = False
                     split.operator("fluid.pause_bake", text="Baking Data - ESC to pause")
-                elif not domain.cache_baked_data and not domain.cache_baking_data:
+                elif not domain.has_cache_baked_data and not domain.is_cache_baking_data:
                     split.operator("fluid.bake_data", text="Bake Data")
                 else:
                     split.operator("fluid.free_data", text="Free Data")
@@ -259,11 +259,11 @@ class PHYSICS_PT_borders(PhysicButtonsPanel, Panel):
         md = context.fluid
         domain = md.domain_settings
 
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_data = domain.cache_baked_data
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_data = domain.has_cache_baked_data
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
-        flow.enabled = not baking_any and not baked_data
+        flow.enabled = not is_baking_any and not has_baked_data
 
         col = flow.column()
         col.prop(domain, "use_collision_border_front", text="Front")
@@ -298,11 +298,11 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
         md = context.fluid
         domain = md.domain_settings
 
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_data = domain.cache_baked_data
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_data = domain.has_cache_baked_data
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
-        flow.enabled = not baking_any and not baked_data
+        flow.enabled = not is_baking_any and not has_baked_data
 
         col = flow.column()
         col.prop(domain, "alpha")
@@ -337,11 +337,11 @@ class PHYSICS_PT_smoke_dissolve(PhysicButtonsPanel, Panel):
         md = context.fluid
         domain = md.domain_settings
 
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_data = domain.cache_baked_data
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_data = domain.has_cache_baked_data
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
-        flow.enabled = not baking_any and not baked_data
+        flow.enabled = not is_baking_any and not has_baked_data
 
         layout.active = domain.use_dissolve_smoke
 
@@ -372,11 +372,11 @@ class PHYSICS_PT_fire(PhysicButtonsPanel, Panel):
         md = context.fluid
         domain = md.domain_settings
 
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_data = domain.cache_baked_data
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_data = domain.has_cache_baked_data
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
-        flow.enabled = not baking_any and not baked_data
+        flow.enabled = not is_baking_any and not has_baked_data
 
         col = flow.column()
         col.prop(domain, "burning_rate", text="Reaction Speed")
@@ -415,31 +415,31 @@ class PHYSICS_PT_liquid(PhysicButtonsPanel, Panel):
         md = context.fluid
         domain = md.domain_settings
 
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_data = domain.cache_baked_data
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_data = domain.has_cache_baked_data
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
 
         col = flow.column()
         col0 = col.column()
-        col0.enabled = not baking_any and not baked_data
+        col0.enabled = not is_baking_any and not has_baked_data
         col0.prop(domain, "simulation_method", expand=False)
         col0.prop(domain, "flip_ratio", text="FLIP Ratio")
         col0.prop(domain, "particle_radius", text="Particle Radius")
 
         col1 = flow.column(align=True)
-        col1.enabled = not baking_any and not baked_data
+        col1.enabled = not is_baking_any and not has_baked_data
         col1.prop(domain, "particle_maximum", text="Particles Maximum")
         col1.prop(domain, "particle_minimum", text="Minimum")
 
         col1 = flow.column()
-        col1.enabled = not baking_any and not baked_data
+        col1.enabled = not is_baking_any and not has_baked_data
         col1.prop(domain, "particle_number", text="Particle Sampling")
         col1.prop(domain, "particle_band_width", text="Narrow Band Width")
         col1.prop(domain, "particle_randomness", text="Particle Randomness")
 
         col2 = flow.column()
-        col2.enabled = not baking_any and not baked_data
+        col2.enabled = not is_baking_any and not has_baked_data
         col2.prop(domain, "use_fractions", text="Fractional Obstacles")
         col3 = col2.column()
         col3.enabled = domain.use_fractions and col2.enabled
@@ -587,9 +587,11 @@ class PHYSICS_PT_adaptive_domain(PhysicButtonsPanel, Panel):
     def draw_header(self, context):
         md = context.fluid.domain_settings
         domain = context.fluid.domain_settings
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_any = domain.cache_baked_data or domain.cache_baked_mesh or domain.cache_baked_particles or domain.cache_baked_noise or domain.cache_baked_guiding
-        self.layout.enabled = not baking_any and not baked_any
+
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_any = domain.has_cache_baked_any
+
+        self.layout.enabled = not is_baking_any and not has_baked_any
         self.layout.prop(md, "use_adaptive_domain", text="")
 
     def draw(self, context):
@@ -599,11 +601,11 @@ class PHYSICS_PT_adaptive_domain(PhysicButtonsPanel, Panel):
         domain = context.fluid.domain_settings
         layout.active = domain.use_adaptive_domain
 
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or domain.cache_baking_particles or domain.cache_baking_noise or domain.cache_baking_guiding
-        baked_any = domain.cache_baked_data or domain.cache_baked_mesh or domain.cache_baked_particles or domain.cache_baked_noise or domain.cache_baked_guiding
+        is_baking_any = domain.is_cache_baking_any
+        has_baked_any = domain.has_cache_baked_any
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
-        flow.enabled = not baking_any and not baked_any
+        flow.enabled = not is_baking_any and not has_baked_any
 
         col = flow.column()
         col.prop(domain, "additional_res", text="Add Resolution")
@@ -631,8 +633,8 @@ class PHYSICS_PT_noise(PhysicButtonsPanel, Panel):
     def draw_header(self, context):
         md = context.fluid.domain_settings
         domain = context.fluid.domain_settings
-        baking_any = domain.cache_baking_data or domain.cache_baking_mesh or 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list