Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 11 Jun 2018 09:06:43 +0000 (11:06 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 11 Jun 2018 09:06:43 +0000 (11:06 +0200)
1  2 
release/scripts/startup/bl_operators/uvcalc_lightmap.py
source/blender/blenkernel/intern/text.c

index 61ceb3c04c473a2f920523649d777ffc422aace3,3757a466382b61ecf83027ea30cea52497a42bb4..ff7bab4102aee4529c6eb621327a25e70d8f489b
@@@ -275,12 -275,12 +275,12 @@@ def lightmap_uvpack(meshes
              face_groups.append(faces)
  
          if PREF_NEW_UVLAYER:
 -            me.uv_textures.new()
 +            me.uv_layers.new()
  
          # Add face UV if it does not exist.
          # All new faces are selected.
 -        if not me.uv_textures:
 -            me.uv_textures.new()
 +        if not me.uv_layers:
 +            me.uv_layers.new()
  
      for face_sel in face_groups:
          print("\nStarting unwrap")
          print("done")
  
          if PREF_APPLY_IMAGE:
 +            pass
 +            # removed with texface
 +            '''
              if not PREF_PACK_IN_ONE:
                  image = bpy.data.images.new(name="lightmap",
                                              width=PREF_IMG_PX_SIZE,
                                              )
  
              for f in face_sel:
 -                f.image = image
 -                f.id_data.uv_textures.active.data[f.index].image = image  # XXX25
 +                f.image = image
 +            '''
  
      for me in meshes:
          me.update()
  
  def unwrap(operator, context, **kwargs):
  
-     is_editmode = (context.object.mode == 'EDIT')
+     # only unwrap active object if True
+     PREF_ACT_ONLY = kwargs.pop("PREF_ACT_ONLY")
+     # ensure object(s) are selected if necessary and active object is set
+     if context.object is None:
+         if PREF_ACT_ONLY:
+             operator.report({'WARNING'}, "Active object not set")
+             return {'CANCELLED'}
+         elif len(context.selected_objects) == 0:
+             operator.report({'WARNING'}, "No selected objects")
+             return {'CANCELLED'}
+      # switch to object mode
+     is_editmode = context.object and context.object.mode == 'EDIT'
      if is_editmode:
          bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
  
-     PREF_ACT_ONLY = kwargs.pop("PREF_ACT_ONLY")
+     # define list of meshes
      meshes = []
      if PREF_ACT_ONLY:
          obj = context.scene.objects.active
  
      lightmap_uvpack(meshes, **kwargs)
  
+     # switch back to edit mode
      if is_editmode:
          bpy.ops.object.mode_set(mode='EDIT', toggle=False)
  
index a24020d7764e6473611ac58b91722c3d5701186d,eed3138ec1be0f18a11caef64ba851e56e0c3592..226ab33e45e973dbdea22eb6d96bc931c2775d4d
@@@ -47,6 -47,8 +47,6 @@@
  #include "BLI_fileops.h"
  
  #include "DNA_constraint_types.h"
 -#include "DNA_controller_types.h"
 -#include "DNA_actuator_types.h"
  #include "DNA_scene_types.h"
  #include "DNA_screen_types.h"
  #include "DNA_space_types.h"
@@@ -56,6 -58,7 +56,6 @@@
  #include "DNA_node_types.h"
  #include "DNA_material_types.h"
  
 -#include "BKE_depsgraph.h"
  #include "BKE_global.h"
  #include "BKE_library.h"
  #include "BKE_main.h"
@@@ -1702,7 -1705,7 +1702,7 @@@ static void txt_undo_add_blockop(Text *
        /* 4 bytes */
        txt_undo_store_uint32(utxt->buf, &utxt->pos, length);
        /* 'length' bytes */
-       strncpy(utxt->buf + utxt->pos, buf, length);
+       BLI_strncpy(utxt->buf + utxt->pos, buf, length);
        utxt->pos += length;
        /* 4 bytes */
        txt_undo_store_uint32(utxt->buf, &utxt->pos, length);