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:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-05-15 15:11:13 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-05-16 11:34:11 +0300
commite5c3ae31189b3acb54d33061da2bd27c3d0abad5 (patch)
treea53fe430313980bc37f98966d35d2c390cdbfb62 /io_scene_fbx/export_fbx_bin.py
parent05baedacbfdb15b74a2c89a790e8b3f196ef1417 (diff)
Addons: Adopt for Dependency Graph API changes
Mainly search-and-replace approach. Tested the enabled-by-default export/import addons. Seems to work with an exception of X3D which is still referencing Blender Internal material properties. Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D4866
Diffstat (limited to 'io_scene_fbx/export_fbx_bin.py')
-rw-r--r--io_scene_fbx/export_fbx_bin.py38
1 files changed, 25 insertions, 13 deletions
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index af3bc005..e399c807 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1130,7 +1130,9 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
# Face's materials.
me_fbxmaterials_idx = scene_data.mesh_material_indices.get(me)
if me_fbxmaterials_idx is not None:
- me_blmaterials = me.materials
+ # Mapping to indices is done using original material pointers, so need to go from evaluated
+ # to original (this is for the case mesh is a result of evaluated modifier stack).
+ me_blmaterials = [material.original for material in me.materials]
if me_fbxmaterials_idx and me_blmaterials:
lay_ma = elem_data_single_int32(geom, b"LayerElementMaterial", 0)
elem_data_single_int32(lay_ma, b"Version", FBX_GEOMETRY_MATERIAL_VERSION)
@@ -2204,27 +2206,36 @@ def fbx_data_from_scene(scene, depsgraph, settings):
if settings.use_mesh_modifiers or ob.type in BLENDER_OTHER_OBJECT_TYPES or is_ob_material:
# We cannot use default mesh in that case, or material would not be the right ones...
use_org_data = not (is_ob_material or ob.type in BLENDER_OTHER_OBJECT_TYPES)
- tmp_mods = []
+ backup_pose_positions = []
if use_org_data and ob.type == 'MESH':
# No need to create a new mesh in this case, if no modifier is active!
for mod in ob.modifiers:
# For meshes, when armature export is enabled, disable Armature modifiers here!
# XXX Temp hacks here since currently we only have access to a viewport depsgraph...
+ #
+ # NOTE: We put armature to the rest pose instead of disabling it so we still
+ # have vertex groups in the evaluated mesh.
if mod.type == 'ARMATURE' and 'ARMATURE' in settings.object_types:
- tmp_mods.append((mod, mod.show_render, mod.show_viewport))
- mod.show_render = False
- mod.show_viewport = False
+ object = mod.object
+ if object and object.type == 'ARMATURE':
+ armature = object.data
+ backup_pose_positions.append((armature, armature.pose_position))
+ armature.pose_position = 'REST'
if mod.show_render or mod.show_viewport:
use_org_data = False
if not use_org_data:
- tmp_me = ob.to_mesh(
- depsgraph,
- apply_modifiers=settings.use_mesh_modifiers)
+ # If modifiers has been altered need to update dependency graph.
+ if backup_pose_positions:
+ depsgraph.update()
+ ob_to_convert = ob.evaluated_get(depsgraph) if settings.use_mesh_modifiers else ob
+ tmp_me = ob_to_convert.to_mesh()
data_meshes[ob_obj] = (get_blenderID_key(tmp_me), tmp_me, True)
- # Re-enable temporary disabled modifiers.
- for mod, show_render, show_viewport in tmp_mods:
- mod.show_render = show_render
- mod.show_viewport = show_viewport
+ # Change armatures back.
+ for armature, pose_position in backup_pose_positions:
+ print((armature, pose_position))
+ armature.pose_position = pose_position
+ # Update now, so we don't leave modified state after last object was exported.
+ depsgraph.update()
if use_org_data:
data_meshes[ob_obj] = (get_blenderID_key(ob.data), ob.data, False)
@@ -3100,7 +3111,8 @@ def save(operator, context,
ctx_objects = context.view_layer.objects
kwargs_mod["context_objects"] = ctx_objects
- ret = save_single(operator, context.scene, context.depsgraph, filepath, **kwargs_mod)
+ depsgraph = context.evaluated_depsgraph_get()
+ ret = save_single(operator, context.scene, depsgraph, filepath, **kwargs_mod)
else:
# XXX We need a way to generate a depsgraph for inactive view_layers first...
# XXX Also, what to do in case of batch-exporting scenes, when there is more than one view layer?