Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 17 Feb 2019 14:57:34 +0000 (15:57 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 17 Feb 2019 14:57:34 +0000 (15:57 +0100)
1  2 
intern/cycles/blender/addon/version_update.py
source/blender/blenlib/intern/system.c
source/blender/makesrna/intern/rna_ID.c

@@@ -22,50 -22,39 +22,39 @@@ import mat
  from bpy.app.handlers import persistent
  
  
- def foreach_notree_node(nodetree, callback, traversed):
-     if nodetree in traversed:
-         return
-     traversed.add(nodetree)
+ def foreach_cycles_nodetree_group(nodetree, traversed):
      for node in nodetree.nodes:
-         callback(node)
          if node.bl_idname == 'ShaderNodeGroup':
-             foreach_notree_node(node.node_tree, callback, traversed)
+             group = node.node_tree
+             if group and group not in traversed:
+                 traversed.add(group)
+                 yield group, group.library
+                 yield from foreach_cycles_nodetree_group(group, traversed)
  
  
- def foreach_cycles_node(callback):
+ def foreach_cycles_nodetree():
      traversed = set()
      for material in bpy.data.materials:
-         if material.node_tree:
-             foreach_notree_node(
-                 material.node_tree,
-                 callback,
-                 traversed,
-             )
+         nodetree = material.node_tree
+         if nodetree:
+             yield nodetree, material.library
+             yield from foreach_cycles_nodetree_group(nodetree, traversed)
      for world in bpy.data.worlds:
-         if world.node_tree:
-             foreach_notree_node(
-                 world.node_tree,
-                 callback,
-                 traversed,
-             )
-     for light in bpy.data.lights:
-         if light.node_tree:
-             foreach_notree_node(
-                 light.node_tree,
-                 callback,
-                 traversed,
-             )
+         nodetree = world.node_tree
+         if nodetree:
+             yield nodetree, world.library
+             foreach_cycles_nodetree_group(nodetree, traversed)
  
 -    for lamp in bpy.data.lamps:
 -        nodetree = lamp.node_tree
++    for light in bpy.data.lights:
++        nodetree = light.node_tree
+         if nodetree:
 -            yield nodetree, lamp.library
++            yield nodetree, light.library
+             foreach_cycles_nodetree_group(nodetree, traversed)
  
- def displacement_node_insert(material, nodetree, traversed):
-     if nodetree in traversed:
-         return
-     traversed.add(nodetree)
-     for node in nodetree.nodes:
-         if node.bl_idname == 'ShaderNodeGroup':
-             displacement_node_insert(material, node.node_tree, traversed)
  
+ def displacement_node_insert(nodetree):
      # Gather links to replace
      displacement_links = []
      for link in nodetree.links:
          nodetree.links.new(node.outputs['Displacement'], to_socket)
  
  
- def displacement_nodes_insert():
-     traversed = set()
-     for material in bpy.data.materials:
-         if material.node_tree:
-             displacement_node_insert(material, material.node_tree, traversed)
--
  def displacement_principled_nodes(node):
      if node.bl_idname == 'ShaderNodeDisplacement':
          if node.space != 'WORLD':
@@@ -272,18 -236,11 +235,11 @@@ def ambient_occlusion_node_relink(nodet
          nodetree.links.new(from_node.outputs['Color'], to_socket)
  
  
- def ambient_occlusion_nodes_relink():
-     traversed = set()
-     for material in bpy.data.materials:
-         if material.node_tree:
-             ambient_occlusion_node_relink(material, material.node_tree, traversed)
  @persistent
  def do_versions(self):
 -    if bpy.context.user_preferences.version <= (2, 78, 1):
 -        prop = bpy.context.user_preferences.addons[__package__].preferences
 -        system = bpy.context.user_preferences.system
 +    if bpy.context.preferences.version <= (2, 78, 1):
 +        prop = bpy.context.preferences.addons[__package__].preferences
 +        system = bpy.context.preferences.system
          if not prop.is_property_set("compute_device_type"):
              # Device might not currently be available so this can fail
              try:
      if not bpy.data.is_saved:
          return
  
-     # Clamp Direct/Indirect separation in 270
-     if bpy.data.version <= (2, 70, 0):
-         for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             sample_clamp = cscene.get("sample_clamp", False)
-             if (sample_clamp and
-                 not cscene.is_property_set("sample_clamp_direct") and
-                     not cscene.is_property_set("sample_clamp_indirect")):
-                 cscene.sample_clamp_direct = sample_clamp
-                 cscene.sample_clamp_indirect = sample_clamp
+     # Map of versions used by libraries.
+     library_versions = {}
+     library_versions[bpy.data.version] = [None]
+     for library in bpy.data.libraries:
+         library_versions.setdefault(library.version, []).append(library)
  
-     # Change of Volume Bounces in 271
-     if bpy.data.version <= (2, 71, 0):
-         for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             if not cscene.is_property_set("volume_bounces"):
-                 cscene.volume_bounces = 1
+     # Do versioning per library, since they might have different versions.
+     max_need_versioning = (2, 79, 6)
+     for version, libraries in library_versions.items():
+         if version > max_need_versioning:
+             continue
  
-     # Caustics Reflective/Refractive separation in 272
-     if bpy.data.version <= (2, 72, 0):
+         # Scenes
          for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             if (cscene.get("no_caustics", False) and
-                 not cscene.is_property_set("caustics_reflective") and
+             if scene.library not in libraries:
+                 continue
+             # Clamp Direct/Indirect separation in 270
+             if version <= (2, 70, 0):
+                 cscene = scene.cycles
+                 sample_clamp = cscene.get("sample_clamp", False)
 -                if (
 -                    sample_clamp and
++                if (sample_clamp and
+                     not cscene.is_property_set("sample_clamp_direct") and
 -                        not cscene.is_property_set("sample_clamp_indirect")
 -                ):
 -
++                        not cscene.is_property_set("sample_clamp_indirect")):
+                     cscene.sample_clamp_direct = sample_clamp
+                     cscene.sample_clamp_indirect = sample_clamp
+             # Change of Volume Bounces in 271
+             if version <= (2, 71, 0):
+                 cscene = scene.cycles
+                 if not cscene.is_property_set("volume_bounces"):
+                     cscene.volume_bounces = 1
+             # Caustics Reflective/Refractive separation in 272
+             if version <= (2, 72, 0):
+                 cscene = scene.cycles
 -                if (
 -                    cscene.get("no_caustics", False) and
++                if (cscene.get("no_caustics", False) and
+                     not cscene.is_property_set("caustics_reflective") and
 -                    not cscene.is_property_set("caustics_refractive")
 -                ):
 +                    not cscene.is_property_set("caustics_refractive")):
-                 cscene.caustics_reflective = False
-                 cscene.caustics_refractive = False
-     # Euler order was ZYX in previous versions.
-     if bpy.data.version <= (2, 73, 4):
-         foreach_cycles_node(mapping_node_order_flip)
-     if bpy.data.version <= (2, 76, 5):
-         foreach_cycles_node(vector_curve_node_remap)
-     # Baking types changed
-     if bpy.data.version <= (2, 76, 6):
-         for scene in bpy.data.scenes:
-             custom_bake_remap(scene)
-     # Several default changes for 2.77
-     if bpy.data.version <= (2, 76, 8):
-         for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             # Samples
-             if not cscene.is_property_set("samples"):
-                 cscene.samples = 10
-             # Preview Samples
-             if not cscene.is_property_set("preview_samples"):
-                 cscene.preview_samples = 10
-             # Filter
-             if not cscene.is_property_set("filter_type"):
-                 cscene.pixel_filter_type = 'GAUSSIAN'
-             # Tile Order
-             if not cscene.is_property_set("tile_order"):
-                 cscene.tile_order = 'CENTER'
+                     cscene.caustics_reflective = False
+                     cscene.caustics_refractive = False
+             # Baking types changed
+             if version <= (2, 76, 6):
+                 custom_bake_remap(scene)
+             # Several default changes for 2.77
+             if version <= (2, 76, 8):
+                 cscene = scene.cycles
+                 # Samples
+                 if not cscene.is_property_set("samples"):
+                     cscene.samples = 10
+                 # Preview Samples
+                 if not cscene.is_property_set("preview_samples"):
+                     cscene.preview_samples = 10
+                 # Filter
+                 if not cscene.is_property_set("filter_type"):
+                     cscene.pixel_filter_type = 'GAUSSIAN'
+                 # Tile Order
+                 if not cscene.is_property_set("tile_order"):
+                     cscene.tile_order = 'CENTER'
+             if version <= (2, 76, 10):
+                 cscene = scene.cycles
+                 if cscene.is_property_set("filter_type"):
+                     if not cscene.is_property_set("pixel_filter_type"):
+                         cscene.pixel_filter_type = cscene.filter_type
+                     if cscene.filter_type == 'BLACKMAN_HARRIS':
+                         cscene.filter_type = 'GAUSSIAN'
+             if version <= (2, 78, 2):
+                 cscene = scene.cycles
+                 if not cscene.is_property_set("light_sampling_threshold"):
+                     cscene.light_sampling_threshold = 0.0
+             if version <= (2, 79, 0):
+                 cscene = scene.cycles
+                 # Default changes
+                 if not cscene.is_property_set("aa_samples"):
+                     cscene.aa_samples = 4
+                 if not cscene.is_property_set("preview_aa_samples"):
+                     cscene.preview_aa_samples = 4
+                 if not cscene.is_property_set("blur_glossy"):
+                     cscene.blur_glossy = 0.0
+                 if not cscene.is_property_set("sample_clamp_indirect"):
+                     cscene.sample_clamp_indirect = 0.0
+         # Lamps
 -        for lamp in bpy.data.lamps:
 -            if lamp.library not in libraries:
 +        for light in bpy.data.lights:
-             clight = light.cycles
++            if light.library not in libraries:
+                 continue
  
-             # MIS
-             if not clight.is_property_set("use_multiple_importance_sampling"):
-                 clight.use_multiple_importance_sampling = False
+             if version <= (2, 76, 5):
 -                clamp = lamp.cycles
++                clight = light.cycles
  
-         for mat in bpy.data.materials:
-             cmat = mat.cycles
-             # Volume Sampling
-             if not cmat.is_property_set("volume_sampling"):
-                 cmat.volume_sampling = 'DISTANCE'
+                 # MIS
 -                if not clamp.is_property_set("use_multiple_importance_sampling"):
 -                    clamp.use_multiple_importance_sampling = False
++                if not clight.is_property_set("use_multiple_importance_sampling"):
++                    clight.use_multiple_importance_sampling = False
  
-     if bpy.data.version <= (2, 76, 9):
+         # Worlds
          for world in bpy.data.worlds:
-             cworld = world.cycles
-             # World MIS Samples
-             if not cworld.is_property_set("samples"):
-                 cworld.samples = 4
-             # World MIS Resolution
-             if not cworld.is_property_set("sample_map_resolution"):
-                 cworld.sample_map_resolution = 256
-     if bpy.data.version <= (2, 76, 10):
-         for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             if cscene.is_property_set("filter_type"):
-                 if not cscene.is_property_set("pixel_filter_type"):
-                     cscene.pixel_filter_type = cscene.filter_type
-                 if cscene.filter_type == 'BLACKMAN_HARRIS':
-                     cscene.filter_type = 'GAUSSIAN'
-     if bpy.data.version <= (2, 78, 2):
-         for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             if not cscene.is_property_set("light_sampling_threshold"):
-                 cscene.light_sampling_threshold = 0.0
-     if bpy.data.version <= (2, 79, 0):
-         for scene in bpy.data.scenes:
-             cscene = scene.cycles
-             # Default changes
-             if not cscene.is_property_set("aa_samples"):
-                 cscene.aa_samples = 4
-             if not cscene.is_property_set("preview_aa_samples"):
-                 cscene.preview_aa_samples = 4
-             if not cscene.is_property_set("blur_glossy"):
-                 cscene.blur_glossy = 0.0
-             if not cscene.is_property_set("sample_clamp_indirect"):
-                 cscene.sample_clamp_indirect = 0.0
-     if bpy.data.version <= (2, 79, 1) or \
-        (bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 3)):
-         displacement_nodes_insert()
-     if bpy.data.version <= (2, 79, 2):
+             if world.library not in libraries:
+                 continue
+             if version <= (2, 76, 9):
+                 cworld = world.cycles
+                 # World MIS Samples
+                 if not cworld.is_property_set("samples"):
+                     cworld.samples = 4
+                 # World MIS Resolution
+                 if not cworld.is_property_set("sample_map_resolution"):
+                     cworld.sample_map_resolution = 256
 -            if version <= (2, 79, 4):
++            if version <= (2, 79, 4) or \
++               (version >= (2, 80, 0) and version <= (2, 80, 18)):
+                 cworld = world.cycles
+                 # World MIS
+                 if not cworld.is_property_set("sampling_method"):
+                     if cworld.get("sample_as_light", True):
+                         cworld.sampling_method = 'MANUAL'
+                     else:
+                         cworld.sampling_method = 'NONE'
+         # Materials
          for mat in bpy.data.materials:
-             cmat = mat.cycles
-             if not cmat.is_property_set("displacement_method"):
-                 cmat.displacement_method = 'BUMP'
-         foreach_cycles_node(displacement_principled_nodes)
-     if bpy.data.version <= (2, 79, 3) or \
-        (bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 4)):
-         # Switch to squared roughness convention
-         square_roughness_nodes_insert()
-     if bpy.data.version <= (2, 80, 15):
-         # Copy cycles hair settings to internal settings
+             if mat.library not in libraries:
+                 continue
+             if version <= (2, 76, 5):
+                 cmat = mat.cycles
+                 # Volume Sampling
+                 if not cmat.is_property_set("volume_sampling"):
+                     cmat.volume_sampling = 'DISTANCE'
+             if version <= (2, 79, 2):
+                 cmat = mat.cycles
+                 if not cmat.is_property_set("displacement_method"):
+                     cmat.displacement_method = 'BUMP'
+             # Change default to bump again.
 -            if version <= (2, 79, 6):
++            if version <= (2, 79, 6) or \
++               (version >= (2, 80, 0) and version <= (2, 80, 41)):
+                 cmat = mat.cycles
+                 if not cmat.is_property_set("displacement_method"):
+                     cmat.displacement_method = 'DISPLACEMENT'
+         # Nodes
+         for nodetree, library in foreach_cycles_nodetree():
+             if library not in libraries:
+                 continue
+             # Euler order was ZYX in previous versions.
+             if version <= (2, 73, 4):
+                 for node in nodetree.nodes:
+                     mapping_node_order_flip(node)
+             if version <= (2, 76, 5):
+                 for node in nodetree.nodes:
+                     vector_curve_node_remap(node)
 -            if version <= (2, 79, 1):
++            if version <= (2, 79, 1) or \
++               (version >= (2, 80, 0) and version <= (2, 80, 3)):
+                 displacement_node_insert(nodetree)
+             if version <= (2, 79, 2):
+                 for node in nodetree.nodes:
+                     displacement_principled_nodes(node)
 -            if version <= (2, 79, 3):
++            if version <= (2, 79, 3) or \
++               (version >= (2, 80, 0) and version <= (2, 80, 4)):
+                 # Switch to squared roughness convention
+                 square_roughness_node_insert(nodetree)
+             if version <= (2, 79, 4):
+                 ambient_occlusion_node_relink(nodetree)
++        # Particles
 +        for part in bpy.data.particles:
-             cpart = part.get("cycles", None)
-             if cpart:
-                 part.shape = cpart.get("shape", 0.0)
-                 part.root_radius = cpart.get("root_width", 1.0)
-                 part.tip_radius = cpart.get("tip_width", 0.0)
-                 part.radius_scale = cpart.get("radius_scale", 0.01)
-                 part.use_close_tip = cpart.get("use_closetip", True)
-     if bpy.data.version <= (2, 79, 4) or \
-        (bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 18)):
-         for world in bpy.data.worlds:
-             cworld = world.cycles
-             # World MIS
-             if not cworld.is_property_set("sampling_method"):
-                 if cworld.get("sample_as_light", True):
-                     cworld.sampling_method = 'MANUAL'
-                 else:
-                     cworld.sampling_method = 'NONE'
-         ambient_occlusion_nodes_relink()
-     if bpy.data.version <= (2, 79, 6) or \
-        (bpy.data.version >= (2, 80, 0) and bpy.data.version <= (2, 80, 41)):
-         # Change default to bump again.
-         for mat in bpy.data.materials:
-             cmat = mat.cycles
-             if not cmat.is_property_set("displacement_method"):
-                 cmat.displacement_method = 'DISPLACEMENT'
++            if part.library not in libraries:
++                continue
++
++            # Copy cycles hair settings to internal settings
++            if version <= (2, 80, 15):
++                cpart = part.get("cycles", None)
++                if cpart:
++                    part.shape = cpart.get("shape", 0.0)
++                    part.root_radius = cpart.get("root_width", 1.0)
++                    part.tip_radius = cpart.get("tip_width", 0.0)
++                    part.radius_scale = cpart.get("radius_scale", 0.01)
++                    part.use_close_tip = cpart.get("use_closetip", True)
  
  #include "MEM_guardedalloc.h"
  
 -/* for backtrace */
 -#if defined(__linux__) || defined(__APPLE__)
 -#  include <execinfo.h>
 -#elif defined(WIN32)
 +/* for backtrace and gethostname/GetComputerName */
 +#if defined(WIN32)
+ #  include <intrin.h>
  #  include <windows.h>
  #  include <dbghelp.h>
 +#else
 +#  include <execinfo.h>
 +#  include <unistd.h>
  #endif
  
  int BLI_cpu_support_sse2(void)