Преглед изворни кода

Merge pull request #6524 from rkusa/apply_modifiers_option

Blender: add option to disable modifier application
Ricardo Cabello пре 10 година
родитељ
комит
01d7957276

+ 14 - 0
utils/exporters/blender/addons/io_three/__init__.py

@@ -301,6 +301,10 @@ def restore_export_settings(properties, settings):
         constants.INFLUENCES_PER_VERTEX,
         constants.EXPORT_OPTIONS[constants.INFLUENCES_PER_VERTEX])
 
+    properties.option_apply_modifiers = settings.get(
+        constants.APPLY_MODIFIERS,
+        constants.EXPORT_OPTIONS[constants.APPLY_MODIFIERS])
+
     properties.option_geometry_type = settings.get(
         constants.GEOMETRY_TYPE,
         constants.EXPORT_OPTIONS[constants.GEOMETRY_TYPE])
@@ -424,6 +428,7 @@ def set_settings(properties):
         constants.NORMALS: properties.option_normals,
         constants.SKINNING: properties.option_skinning,
         constants.BONES: properties.option_bones,
+        constants.APPLY_MODIFIERS: properties.option_apply_modifiers,
         constants.GEOMETRY_TYPE: properties.option_geometry_type,
 
         constants.MATERIALS: properties.option_materials,
@@ -555,6 +560,12 @@ class ExportThree(bpy.types.Operator, ExportHelper):
         description="Export bones",
         default=constants.EXPORT_OPTIONS[constants.BONES])
 
+    option_apply_modifiers = BoolProperty(
+        name="Apply Modifiers",
+        description="Apply Modifiers to mesh objects",
+        default=constants.EXPORT_OPTIONS[constants.APPLY_MODIFIERS]
+    )
+
     option_scale = FloatProperty(
         name="Scale",
         description="Scale vertices",
@@ -751,6 +762,9 @@ class ExportThree(bpy.types.Operator, ExportHelper):
         row.prop(self.properties, 'option_bones')
         row.prop(self.properties, 'option_skinning')
 
+        row = layout.row()
+        row.prop(self.properties, 'option_apply_modifiers')
+
         row = layout.row()
         row.prop(self.properties, 'option_geometry_type')
 

+ 2 - 0
utils/exporters/blender/addons/io_three/constants.py

@@ -44,6 +44,7 @@ FACES = 'faces'
 NORMALS = 'normals'
 BONES = 'bones'
 UVS = 'uvs'
+APPLY_MODIFIERS = 'applyModifiers'
 COLORS = 'colors'
 MIX_COLORS = 'mixColors'
 SCALE = 'scale'
@@ -95,6 +96,7 @@ EXPORT_OPTIONS = {
     VERTICES: True,
     NORMALS: True,
     UVS: True,
+    APPLY_MODIFIERS: True,
     COLORS: False,
     MATERIALS: False,
     FACE_MATERIALS: False,

+ 2 - 1
utils/exporters/blender/addons/io_three/exporter/api/object.py

@@ -329,7 +329,8 @@ def extract_mesh(obj, options, recalculate=False):
 
     """
     logger.debug('object.extract_mesh(%s, %s)', obj, options)
-    mesh_node = obj.to_mesh(context.scene, True, RENDER)
+    apply_modifiers = options.get(constants.APPLY_MODIFIERS, True)
+    mesh_node = obj.to_mesh(context.scene, apply_modifiers, RENDER)
 
     # transfer the geometry type to the extracted mesh
     mesh_node.THREE_geometry_type = obj.data.THREE_geometry_type