Skip to content

Commit

Permalink
Fix T50453: Add option to FBX export to apply render or preview modif…
Browse files Browse the repository at this point in the history
…iers.
  • Loading branch information
Bastien Montagne committed Jan 17, 2017
1 parent e264efb commit 18099be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion io_scene_fbx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
"version": (3, 7, 7),
"version": (3, 7, 8),
"blender": (2, 77, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
Expand Down Expand Up @@ -314,6 +314,11 @@ class ExportFBX(bpy.types.Operator, ExportHelper, IOFBXOrientationHelper):
"WARNING: prevents exporting shape keys",
default=True,
)
use_mesh_modifiers_render = BoolProperty(
name="Use Modifiers Render Setting",
description="Use render settings when applying modifiers to mesh objects",
default=True,
)
mesh_smooth_type = EnumProperty(
name="Smoothing",
items=(('OFF', "Normals Only", "Export only normals instead of writing edge or face smoothing data"),
Expand Down Expand Up @@ -518,6 +523,9 @@ def draw(self, context):
sub.prop(self, "use_batch_own_dir", text="", icon='NEWFOLDER')
elif self.ui_tab == 'GEOMETRY':
layout.prop(self, "use_mesh_modifiers")
sub = layout.row()
sub.enabled = self.use_mesh_modifiers
sub.prop(self, "use_mesh_modifiers_render")
layout.prop(self, "mesh_smooth_type")
layout.prop(self, "use_mesh_edges")
sub = layout.row()
Expand Down
7 changes: 5 additions & 2 deletions io_scene_fbx/export_fbx_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,8 @@ def fbx_data_from_scene(scene, settings):
if mod.show_render:
use_org_data = False
if not use_org_data:
tmp_me = ob.to_mesh(scene, apply_modifiers=True, settings='RENDER')
tmp_me = ob.to_mesh(scene, apply_modifiers=True,
settings='RENDER' if settings.use_mesh_modifiers_render else 'PREVIEW')
data_meshes[ob_obj] = (get_blenderID_key(tmp_me), tmp_me, True)
# Re-enable temporary disabled modifiers.
for mod, show_render in tmp_mods:
Expand Down Expand Up @@ -2871,6 +2872,7 @@ def save_single(operator, scene, filepath="",
context_objects=None,
object_types=None,
use_mesh_modifiers=True,
use_mesh_modifiers_render=True,
mesh_smooth_type='FACE',
use_armature_deform_only=False,
bake_anim=True,
Expand Down Expand Up @@ -2941,7 +2943,7 @@ def save_single(operator, scene, filepath="",
settings = FBXExportSettings(
operator.report, (axis_up, axis_forward), global_matrix, global_scale, apply_unit_scale,
bake_space_transform, global_matrix_inv, global_matrix_inv_transposed,
context_objects, object_types, use_mesh_modifiers,
context_objects, object_types, use_mesh_modifiers, use_mesh_modifiers_render,
mesh_smooth_type, use_mesh_edges, use_tspace,
armature_nodetype, use_armature_deform_only,
add_leaf_bones, bone_correction_matrix, bone_correction_matrix_inv,
Expand Down Expand Up @@ -3012,6 +3014,7 @@ def defaults_unity3d():

"object_types": {'ARMATURE', 'EMPTY', 'MESH', 'OTHER'},
"use_mesh_modifiers": True,
"use_mesh_modifiers_render": True,
"use_mesh_edges": False,
"mesh_smooth_type": 'FACE',
"use_tspace": False, # XXX Why? Unity is expected to support tspace import...
Expand Down
2 changes: 1 addition & 1 deletion io_scene_fbx/fbx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ def fbx_name_class(name, cls):
FBXExportSettings = namedtuple("FBXExportSettings", (
"report", "to_axes", "global_matrix", "global_scale", "apply_unit_scale",
"bake_space_transform", "global_matrix_inv", "global_matrix_inv_transposed",
"context_objects", "object_types", "use_mesh_modifiers",
"context_objects", "object_types", "use_mesh_modifiers", "use_mesh_modifiers_render",
"mesh_smooth_type", "use_mesh_edges", "use_tspace",
"armature_nodetype", "use_armature_deform_only", "add_leaf_bones",
"bone_correction_matrix", "bone_correction_matrix_inv",
Expand Down

0 comments on commit 18099be

Please sign in to comment.