Fix T50453: Add option to FBX export to apply render or preview modifiers.

This commit is contained in:
Bastien Montagne 2017-01-17 12:23:24 +01:00
parent e264efb7e8
commit 18099be5f8
Notes: blender-bot 2023-02-14 19:42:07 +01:00
Referenced by issue #50453, fbx exporter "apply modifier" misunderstand
3 changed files with 15 additions and 4 deletions

View File

@ -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",
@ -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"),
@ -518,6 +523,9 @@ class ExportFBX(bpy.types.Operator, ExportHelper, IOFBXOrientationHelper):
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()

View File

@ -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:
@ -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,
@ -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,
@ -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...

View File

@ -1193,7 +1193,7 @@ FBXExportSettingsMedia = namedtuple("FBXExportSettingsMedia", (
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",