Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-10-15 00:53:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-10-15 00:53:28 +0400
commitef30f9e98f3241b4568ffe410ed3cadb90714ffe (patch)
tree11a08926a39718ad260bb3d072754287ceb93959
parentd57fa9e144659689ae0ca6b1f104f191be4b0bf6 (diff)
parent44a0755b3cc537ef490ed2bfb5cc87f146006700 (diff)
svn merge ^/trunk/py/scripts/addons -c4789 -c4790 -c4791v2.69
-rw-r--r--io_scene_fbx/export_fbx.py60
-rw-r--r--io_scene_fbx/import_fbx.py10
-rw-r--r--object_edit_linked.py29
3 files changed, 63 insertions, 36 deletions
diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py
index e477d77f..edc21692 100644
--- a/io_scene_fbx/export_fbx.py
+++ b/io_scene_fbx/export_fbx.py
@@ -1370,9 +1370,10 @@ def save_single(operator, scene, filepath="",
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 @@ def save_single(operator, scene, filepath="",
'\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 @@ def save_single(operator, scene, filepath="",
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 @@ def save_single(operator, scene, filepath="",
mats = me.materials
else:
me = ob.data
- me.update(calc_tessface=True)
+ me.update()
mats = me.materials
# # Support object colors
@@ -1857,27 +1858,33 @@ def save_single(operator, scene, filepath="",
# 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()
@@ -1904,9 +1911,9 @@ def save_single(operator, scene, filepath="",
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 @@ def save_single(operator, scene, filepath="",
# == 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 @@ def save_single(operator, scene, filepath="",
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)))
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index ab21ca77..f38b0499 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -497,6 +497,11 @@ def blen_read_geom_layer_uv(fbx_obj, mesh):
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 @@ def blen_read_geom_layer_color(fbx_obj, mesh):
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",
diff --git a/object_edit_linked.py b/object_edit_linked.py
index 3fb66beb..e880b9fd 100644
--- a/object_edit_linked.py
+++ b/object_edit_linked.py
@@ -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 @@ class EditLinked(bpy.types.Operator):
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 @@ class EditLinked(bpy.types.Operator):
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 @@ class EditLinked(bpy.types.Operator):
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 @@ class PanelLinkedEdit(bpy.types.Panel):
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)
+ text="Edit Library: %s" % target.name)
else:
props = layout.operator("object.edit_linked", icon="LINK_BLEND",
text="Edit Library: %s" % context.active_object.name)
@@ -181,9 +192,9 @@ class PanelLinkedEdit(bpy.types.Panel):
layout.prop(scene, "use_autosave")
layout.prop(scene, "use_instance")
- if (context.active_object.dupli_group is not None):
+ if (target is not None):
layout.label(text="Path: %s" %
- context.active_object.dupli_group.library.filepath)
+ target.library.filepath)
else:
layout.label(text="Path: %s" %
context.active_object.library.filepath)