[-] Fix version check for mesh update to work with blender 3.0

- Also, add alternative property introspection for io_scene_godot.export
  that will work with Blender 3.0
This commit is contained in:
Tim Klein
2021-12-23 14:34:30 -05:00
parent c1136facd9
commit 1e0d104df5
2 changed files with 19 additions and 3 deletions

View File

@@ -26,6 +26,15 @@ from bpy_extras.io_utils import ExportHelper
from .structures import ValidationError
from . import export_godot
try:
# Seems to work for Blender 3.0 (instead of old `tuple` check for
# operator properties)
from bpy.props import _PropertyDeferred
except (ImportError, ):
pass
bl_info = { # pylint: disable=invalid-name
"name": "Godot Engine Exporter",
"author": "Lu Jiacheng, Geoffrey Irons, Juan Linietsky",
@@ -267,12 +276,18 @@ def export(filename, overrides=None):
default_settings = dict()
for attr_name in ExportGodot.__annotations__:
attr = ExportGodot.__annotations__[attr_name]
# This introspection is not very robust and may break in future blende
# versions. This is becase for some reason you can't compare against
# This introspection is not very robust and may break in future blender
# versions. This is because for some reason you can't compare against
# bpy.types.Property because. well, they end up not being subclasses
# of that!!!
if issubclass(type(attr), tuple):
default_settings[attr_name] = attr[1]['default']
# Alternate check (for Blender 3.0)
if bpy.app.version[0] > 2:
if isinstance(attr, _PropertyDeferred):
default_settings[attr_name] = attr.keywords['default']
if overrides is not None:
default_settings.update(overrides)

View File

@@ -40,7 +40,8 @@ def triangulate_ngons(mesh):
bmesh.ops.triangulate(tri_mesh, faces=ngons, quad_method="ALTERNATE")
tri_mesh.to_mesh(mesh)
tri_mesh.free()
if bpy.app.version[1] > 80:
if bpy.app.version[0] > 2 or bpy.app.version[1] > 80:
mesh.update()
else:
mesh.update(calc_loop_triangles=True)