[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4800] tags/2_69_release/py/scripts/ addons: svn merge ^/trunk/py/scripts/addons -c4789 -c4790 -c4791

Campbell Barton ideasman42 at gmail.com
Mon Oct 14 22:53:28 CEST 2013


Revision: 4800
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4800
Author:   campbellbarton
Date:     2013-10-14 20:53:28 +0000 (Mon, 14 Oct 2013)
Log Message:
-----------
svn merge ^/trunk/py/scripts/addons -c4789 -c4790 -c4791

Modified Paths:
--------------
    tags/2_69_release/py/scripts/addons/io_scene_fbx/export_fbx.py
    tags/2_69_release/py/scripts/addons/io_scene_fbx/import_fbx.py
    tags/2_69_release/py/scripts/addons/object_edit_linked.py

Property Changed:
----------------
    tags/2_69_release/py/scripts/addons/


Property changes on: tags/2_69_release/py/scripts/addons
___________________________________________________________________
Added: svn:mergeinfo
   + /trunk/py/scripts/addons:4789-4791

Modified: tags/2_69_release/py/scripts/addons/io_scene_fbx/export_fbx.py
===================================================================
--- tags/2_69_release/py/scripts/addons/io_scene_fbx/export_fbx.py	2013-10-14 18:06:12 UTC (rev 4799)
+++ tags/2_69_release/py/scripts/addons/io_scene_fbx/export_fbx.py	2013-10-14 20:53:28 UTC (rev 4800)
@@ -1370,9 +1370,10 @@
     def write_mesh(my_mesh):
         me = my_mesh.blenData
 
-        # if there are non NULL materials on this mesh
-        do_materials = bool(my_mesh.blenMaterials)
-        do_textures = bool(my_mesh.blenTextures)
+        # if there are non None materials on this mesh
+        print(my_mesh.blenMaterials)
+        do_materials = bool([m for m in my_mesh.blenMaterials if m is not None])
+        do_textures = bool([t for t in my_mesh.blenTextures if t is not None])
         do_uvs = bool(me.uv_layers)
         do_shapekeys = (my_mesh.blenObject.type == 'MESH' and
                         my_mesh.blenObject.data.shape_keys and
@@ -1638,7 +1639,7 @@
                '\n\t\t\t\tTypedIndex: 0'
                '\n\t\t\t}')
 
-        if me.tessface_vertex_colors:
+        if me.vertex_colors:
             fw('\n\t\t\tLayerElement:  {'
                '\n\t\t\t\tType: "LayerElementColor"'
                '\n\t\t\t\tTypedIndex: 0'
@@ -1762,8 +1763,8 @@
     ob_all_typegroups = [ob_meshes, ob_lights, ob_cameras, ob_arms, ob_null]
 
     groups = []  # blender groups, only add ones that have objects in the selections
-    materials = {}  # (mat, image) keys, should be a set()
-    textures = {}  # should be a set()
+    materials = set()  # (mat, image) items
+    textures = set()
 
     tmp_ob_type = None  # in case no objects are exported, so as not to raise an error
 
@@ -1837,7 +1838,7 @@
                         mats = me.materials
                     else:
                         me = ob.data
-                        me.update(calc_tessface=True)
+                        me.update()
                         mats = me.materials
 
 # 						# Support object colors
@@ -1857,28 +1858,34 @@
 # 					if EXP_MESH_HQ_NORMALS:
 # 						BPyMesh.meshCalcNormals(me) # high quality normals nice for realtime engines.
 
-                    texture_mapping_local = {}
-                    material_mapping_local = {}
-                    if me.tessface_uv_textures:
-                        for uvlayer in me.tessface_uv_textures:
-                            for f, uf in zip(me.tessfaces, uvlayer.data):
-                                tex = uf.image
-                                textures[tex] = texture_mapping_local[tex] = None
+                    if not mats:
+                        mats = [None]
 
-                                try:
-                                    mat = mats[f.material_index]
-                                except:
-                                    mat = None
+                    texture_set_local = set()
+                    material_set_local = set()
+                    if me.uv_textures:
+                        for uvlayer in me.uv_textures:
+                            for p, p_uv in zip(me.polygons, uvlayer.data):
+                                tex = p_uv.image
+                                texture_set_local.add(tex)
+                                mat = mats[p.material_index]
 
-                                materials[mat, tex] = material_mapping_local[mat, tex] = None  # should use sets, wait for blender 2.5
+                                # Should not be needed anymore.
+                                #try:
+                                    #mat = mats[p.material_index]
+                                #except:
+                                    #mat = None
 
+                                material_set_local.add((mat, tex))
+
                     else:
                         for mat in mats:
                             # 2.44 use mat.lib too for uniqueness
-                            materials[mat, None] = material_mapping_local[mat, None] = None
-                        else:
-                            materials[None, None] = None
+                            material_set_local.add((mat, None))
 
+                    textures |= texture_set_local
+                    materials |= material_set_local
+
                     if 'ARMATURE' in object_types:
                         armob = ob.find_armature()
                         blenParentBoneName = None
@@ -1904,9 +1911,9 @@
                     my_mesh = my_object_generic(ob, mtx)
                     my_mesh.blenData = me
                     my_mesh.origData = origData
-                    my_mesh.blenMaterials = list(material_mapping_local.keys())
+                    my_mesh.blenMaterials = list(material_set_local)
                     my_mesh.blenMaterialList = mats
-                    my_mesh.blenTextures = list(texture_mapping_local.keys())
+                    my_mesh.blenTextures = list(texture_set_local)
 
                     # sort the name so we get predictable output, some items may be NULL
                     my_mesh.blenMaterials.sort(key=lambda m: (getattr(m[0], "name", ""), getattr(m[1], "name", "")))
@@ -2058,8 +2065,8 @@
     # == WRITE OBJECTS TO THE FILE ==
     # == From now on we are building the FBX file from the information collected above (JCB)
 
-    materials = [(sane_matname(mat_tex_pair), mat_tex_pair) for mat_tex_pair in materials.keys()]
-    textures = [(sane_texname(tex), tex) for tex in textures.keys()  if tex]
+    materials = [(sane_matname(mat_tex_pair), mat_tex_pair) for mat_tex_pair in materials]
+    textures = [(sane_texname(tex), tex) for tex in textures if tex]
     materials.sort(key=lambda m: m[0])  # sort by name
     textures.sort(key=lambda m: m[0])
 
@@ -2070,7 +2077,6 @@
         assert(not (ob_meshes and ('MESH' not in object_types)))
         assert(not (materials and ('MESH' not in object_types)))
         assert(not (textures and ('MESH' not in object_types)))
-        assert(not (textures and ('MESH' not in object_types)))
 
         assert(not (ob_lights and ('LAMP' not in object_types)))
 

Modified: tags/2_69_release/py/scripts/addons/io_scene_fbx/import_fbx.py
===================================================================
--- tags/2_69_release/py/scripts/addons/io_scene_fbx/import_fbx.py	2013-10-14 18:06:12 UTC (rev 4799)
+++ tags/2_69_release/py/scripts/addons/io_scene_fbx/import_fbx.py	2013-10-14 20:53:28 UTC (rev 4800)
@@ -497,6 +497,11 @@
             uv_lay = mesh.uv_layers[-1]
             blen_data = uv_lay.data[:]
 
+            # some valid files omit this data
+            if fbx_layer_data is None or fbx_layer_index is None:
+                print("%r %r missing data" % (layer_id, fbx_layer_name))
+                continue
+
             blen_read_geom_array_mapped_polyloop(
                 mesh, blen_data, "uv",
                 fbx_layer_data, fbx_layer_index,
@@ -521,6 +526,11 @@
             color_lay = mesh.vertex_colors.new(name=fbx_layer_name)
             blen_data = color_lay.data[:]
 
+            # some valid files omit this data
+            if fbx_layer_data is None or fbx_layer_index is None:
+                print("%r %r missing data" % (layer_id, fbx_layer_name))
+                continue
+
             # ignore alpha layer (read 4 items into 3)
             blen_read_geom_array_mapped_polyloop(
                 mesh, blen_data, "color",

Modified: tags/2_69_release/py/scripts/addons/object_edit_linked.py
===================================================================
--- tags/2_69_release/py/scripts/addons/object_edit_linked.py	2013-10-14 18:06:12 UTC (rev 4799)
+++ tags/2_69_release/py/scripts/addons/object_edit_linked.py	2013-10-14 20:53:28 UTC (rev 4800)
@@ -20,7 +20,7 @@
 bl_info = {
     "name": "Edit Linked Library",
     "author": "Jason van Gumster (Fweeb), Bassam Kurdali, Pablo Vazquez",
-    "version": (0, 7, 4),
+    "version": (0, 8, 0),
     "blender": (2, 65, 0),
     "location": "View3D > Toolshelf > Edit Linked Library",
     "description": "Allows editing of objects linked from a .blend library.",
@@ -77,6 +77,8 @@
         return settings["original_file"] == "" and context.active_object is not None and (
                 (context.active_object.dupli_group and
                  context.active_object.dupli_group.library is not None) or
+                (context.active_object.proxy and
+                 context.active_object.proxy.library is not None) or
                  context.active_object.library is not None)
         #return context.active_object is not None
 
@@ -90,6 +92,10 @@
         elif target.library:
             targetpath = target.library.filepath
             settings["linked_objects"].append(target.name)
+        elif target.proxy:
+            target = target.proxy
+            targetpath = target.library.filepath
+            settings["linked_objects"].append(target.name)
 
         if targetpath:
             print(target.name + " is linked to " + targetpath)
@@ -98,8 +104,6 @@
                 bpy.ops.wm.save_mainfile()
 
             settings["original_file"] = bpy.data.filepath
-
-            # XXX: need to test for proxied rigs
             settings["linked_file"] = bpy.path.abspath(targetpath)
 
             if self.use_instance:
@@ -164,14 +168,21 @@
         scene = context.scene
         icon = "OUTLINER_DATA_" + context.active_object.type
 
+        target = None
+
+        if context.active_object.proxy:
+            target = context.active_object.proxy
+        else:
+            target = context.active_object.dupli_group
+
         if settings["original_file"] == "" and (
-                (context.active_object.dupli_group and
-                 context.active_object.dupli_group.library is not None) or
+                (target and
+                 target.library is not None) or
                 context.active_object.library is not None):
 
-            if (context.active_object.dupli_group is not None):
+            if (target is not None):
                 props = layout.operator("object.edit_linked", icon="LINK_BLEND",
-                                        text="Edit Library: %s" % context.active_object.dupli_group.name)

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list