Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rough update to work with Blender 3.0 #411

Merged
merged 1 commit into from
Dec 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions io_scene_godot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
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",
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion io_scene_godot/converters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down