add Apply Modifiers export property
This commit is contained in:
parent
a3a824fe9c
commit
f3cbc90651
|
@ -82,11 +82,19 @@ class ExportMSH(Operator, ExportHelper):
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
apply_modifiers: BoolProperty(
|
||||||
|
name="Apply Modifiers",
|
||||||
|
description="Whether to apply Modifiers during export or not.",
|
||||||
|
default=True
|
||||||
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
with open(self.filepath, 'wb') as output_file:
|
with open(self.filepath, 'wb') as output_file:
|
||||||
save_scene(
|
save_scene(
|
||||||
output_file=output_file,
|
output_file=output_file,
|
||||||
scene=create_scene(generate_triangle_strips=self.generate_triangle_strips))
|
scene=create_scene(
|
||||||
|
generate_triangle_strips=self.generate_triangle_strips,
|
||||||
|
apply_modifiers=self.apply_modifiers))
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ SKIPPED_OBJECT_TYPES = {"LATTICE", "CAMERA", "LIGHT", "SPEAKER", "LIGHT_PROBE"}
|
||||||
MESH_OBJECT_TYPES = {"MESH", "CURVE", "SURFACE", "META", "FONT", "GPENCIL"}
|
MESH_OBJECT_TYPES = {"MESH", "CURVE", "SURFACE", "META", "FONT", "GPENCIL"}
|
||||||
MAX_MSH_VERTEX_COUNT = 32767
|
MAX_MSH_VERTEX_COUNT = 32767
|
||||||
|
|
||||||
def gather_models() -> List[Model]:
|
def gather_models(apply_modifiers: bool) -> List[Model]:
|
||||||
""" Gathers the Blender objects from the current scene and returns them as a list of
|
""" Gathers the Blender objects from the current scene and returns them as a list of
|
||||||
Model objects. """
|
Model objects. """
|
||||||
|
|
||||||
|
@ -26,7 +26,10 @@ def gather_models() -> List[Model]:
|
||||||
if uneval_obj.type in SKIPPED_OBJECT_TYPES and uneval_obj.name not in parents:
|
if uneval_obj.type in SKIPPED_OBJECT_TYPES and uneval_obj.name not in parents:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
obj = uneval_obj.evaluated_get(depsgraph)
|
if apply_modifiers:
|
||||||
|
obj = uneval_obj.evaluated_get(depsgraph)
|
||||||
|
else:
|
||||||
|
obj = uneval_obj
|
||||||
|
|
||||||
local_translation, local_rotation, _ = obj.matrix_local.decompose()
|
local_translation, local_rotation, _ = obj.matrix_local.decompose()
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Scene:
|
||||||
materials: Dict[str, Material] = field(default_factory=dict)
|
materials: Dict[str, Material] = field(default_factory=dict)
|
||||||
models: List[Model] = field(default_factory=list)
|
models: List[Model] = field(default_factory=list)
|
||||||
|
|
||||||
def create_scene(generate_triangle_strips: bool) -> Scene:
|
def create_scene(generate_triangle_strips: bool, apply_modifiers: bool) -> Scene:
|
||||||
""" Create a msh Scene from the active Blender scene. """
|
""" Create a msh Scene from the active Blender scene. """
|
||||||
|
|
||||||
scene = Scene()
|
scene = Scene()
|
||||||
|
@ -53,7 +53,7 @@ def create_scene(generate_triangle_strips: bool) -> Scene:
|
||||||
|
|
||||||
scene.materials = gather_materials()
|
scene.materials = gather_materials()
|
||||||
|
|
||||||
scene.models = gather_models()
|
scene.models = gather_models(apply_modifiers=apply_modifiers)
|
||||||
scene.models = sort_by_parent(scene.models)
|
scene.models = sort_by_parent(scene.models)
|
||||||
|
|
||||||
if generate_triangle_strips:
|
if generate_triangle_strips:
|
||||||
|
|
|
@ -14,6 +14,9 @@ In order to improve runtime performance and reduce munged model size you are **s
|
||||||
|
|
||||||
For very complex scenes with meshes that have tens of thousands (or more) faces Blender may freeze up for a couple minutes while triangle strips are generated. Either minimize it and do something else on your PC while you wait and it'll eventually finish.
|
For very complex scenes with meshes that have tens of thousands (or more) faces Blender may freeze up for a couple minutes while triangle strips are generated. Either minimize it and do something else on your PC while you wait and it'll eventually finish.
|
||||||
|
|
||||||
|
#### Apply Modifiers
|
||||||
|
Whether to apply [Modifiers](https://docs.blender.org/manual/en/latest/modeling/modifiers/index.html) during export or not.
|
||||||
|
|
||||||
### Export Failures
|
### Export Failures
|
||||||
There should be few things that can cause an export to fail. Should you encounter one you can consult the list below for how to remedy the situation. If you're error isn't on the list then feel free to [Open an issue](https://github.com/SleepKiller/SWBF-msh-Blender-Export/issues/new), remember to attach a .blend file that reproduces the issue.
|
There should be few things that can cause an export to fail. Should you encounter one you can consult the list below for how to remedy the situation. If you're error isn't on the list then feel free to [Open an issue](https://github.com/SleepKiller/SWBF-msh-Blender-Export/issues/new), remember to attach a .blend file that reproduces the issue.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue