[fix] fix various issues

- add edit mode switch before bm export to prevent potential error
- let the default value of ZBuffer in Virtools Material become True
- fix the issue that duplicated elements adder do not understand enable option.
This commit is contained in:
yyc12345 2023-01-10 19:35:15 +08:00
parent e7376a3e9c
commit 7680d11c0e
5 changed files with 15 additions and 4 deletions

View File

@ -26,6 +26,12 @@ class BALLANCE_OT_export_bm(bpy.types.Operator, bpy_extras.io_utils.ExportHelper
) )
def execute(self, context): def execute(self, context):
# detect edit mode
in_edit_mode = False
if bpy.context.object and bpy.context.object.mode == "EDIT":
in_edit_mode = True
bpy.ops.object.editmode_toggle()
if ((self.export_mode == 'COLLECTION' and context.scene.BallanceBlenderPluginProperty.collection_picker is None) or if ((self.export_mode == 'COLLECTION' and context.scene.BallanceBlenderPluginProperty.collection_picker is None) or
(self.export_mode == 'OBJECT' and context.scene.BallanceBlenderPluginProperty.object_picker is None)): (self.export_mode == 'OBJECT' and context.scene.BallanceBlenderPluginProperty.object_picker is None)):
UTILS_functions.show_message_box(("No specific target", ), "Lost parameter", 'ERROR') UTILS_functions.show_message_box(("No specific target", ), "Lost parameter", 'ERROR')
@ -40,6 +46,11 @@ class BALLANCE_OT_export_bm(bpy.types.Operator, bpy_extras.io_utils.ExportHelper
export_bm(context, self.filepath, export_bm(context, self.filepath,
prefs.no_component_collection, prefs.no_component_collection,
self.export_mode, context.scene.BallanceBlenderPluginProperty.object_picker) self.export_mode, context.scene.BallanceBlenderPluginProperty.object_picker)
# restore edit mode
if in_edit_mode:
bpy.ops.object.editmode_toggle()
return {'FINISHED'} return {'FINISHED'}
def draw(self, context): def draw(self, context):

View File

@ -55,7 +55,7 @@ class BALLANCE_OT_add_components(bpy.types.Operator):
UTILS_functions.add_into_scene_and_move_to_cursor(obj) UTILS_functions.add_into_scene_and_move_to_cursor(obj)
# extra duplication # extra duplication
if self.elements_type in self.canDuplicatedElements: if (self.elements_type in self.canDuplicatedElements) and self.elements_duplicated:
for i in range(self.elements_dup_times - 1): for i in range(self.elements_dup_times - 1):
obj = bpy.data.objects.new(finalObjectName, loadedMesh) obj = bpy.data.objects.new(finalObjectName, loadedMesh)
UTILS_functions.add_into_scene_and_move_to_cursor(obj) UTILS_functions.add_into_scene_and_move_to_cursor(obj)

View File

@ -221,7 +221,7 @@ def _create_or_get_material(material_name, prefs_externalTexture):
try_item['data']['ambient'], try_item['data']['diffuse'], try_item['data']['ambient'], try_item['data']['diffuse'],
try_item['data']['specular'], try_item['data']['emissive'], try_item['data']['specular'], try_item['data']['emissive'],
try_item['data']['power'], try_item['data']['power'],
False, False, False, False, False, False, True, False,
texture) texture)
) )
break break

View File

@ -105,7 +105,7 @@ def parse_material_nodes(mtl):
# return value # return value
return (True, return (True,
mtl_ambient, mtl_diffuse, mtl_specular, mtl_emissive, mtl_specularPower, mtl_ambient, mtl_diffuse, mtl_specular, mtl_emissive, mtl_specularPower,
False, False, False, False, False, False, True, False,
mtl_texture mtl_texture
) )

View File

@ -53,7 +53,7 @@ class BALLANCE_PG_virtools_material(bpy.types.PropertyGroup):
z_buffer: bpy.props.BoolProperty( z_buffer: bpy.props.BoolProperty(
name="Z Buffer", name="Z Buffer",
description="ZFunc: VXCMP_LESSEQUAL.", description="ZFunc: VXCMP_LESSEQUAL.",
default=False, default=True,
) )
two_sided: bpy.props.BoolProperty( two_sided: bpy.props.BoolProperty(