godotengine / godot-blender-exporter

Addon for Blender to directly export to a Godot Scene
GNU General Public License v2.0
1.13k stars 120 forks source link

Exporting rigged mesh fails with "ReferenceError: StructRNA of type ExportGodot has been removed" #278

Open mysticfall opened 4 years ago

mysticfall commented 4 years ago

OS: Manjaro Linux 18.04

Godot version: Master (Not relevant)

Blender version: Blender 2.80 (AUR version, blender2.7 branch / 40a8c4908818)

Issue description: When I try to export a rigged mesh using Blender 2.8 with the latest version of Godot Exporter (blender2.80 branch / 8126696f2), it fails with the following output:

Traceback (most recent call last):
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/__init__.py", line 198, in execute
    return export_godot.save(self, context, **keywords)
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/export_godot.py", line 318, in save
    exp.export()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/export_godot.py", line 270, in export
    out_file.write(self.escn_file.to_string())
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 99, in to_string
    '\n\n'.join(e.to_string() for e in self.internal_resources),
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 99, in <genexpr>
    '\n\n'.join(e.to_string() for e in self.internal_resources),
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 145, in to_string
    body = self.generate_body_string()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 138, in generate_body_string
    val = to_string(val)
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 451, in to_string
    val = val.to_string()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/converters/mesh.py", line 513, in to_string
    return self.generate_object().to_string()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 304, in to_string
    for k, v in self.items()]) +
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 304, in <listcomp>
    for k, v in self.items()]) +
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/structures.py", line 451, in to_string
    val = val.to_string()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/converters/mesh.py", line 477, in to_string
    return self.generate_lines().to_string()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/converters/mesh.py", line 416, in generate_lines
    bones, bone_weights = self._get_bone_arrays()
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/converters/mesh.py", line 461, in _get_bone_arrays
    logging.warning("Vertex weights more than maximal")
  File "/usr/lib/python3.7/logging/__init__.py", line 1974, in warning
    root.warning(msg, *args, **kwargs)
  File "/usr/lib/python3.7/logging/__init__.py", line 1390, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.7/logging/__init__.py", line 1514, in _log
    self.handle(record)
  File "/usr/lib/python3.7/logging/__init__.py", line 1524, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.7/logging/__init__.py", line 1586, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.7/logging/__init__.py", line 894, in handle
    self.emit(record)
  File "/home/fender/.config/blender/2.80/scripts/addons/io_scene_godot/export_godot.py", line 74, in emit
    self.blender_op.report({'WARNING'}, record.message)
  File "/usr/share/blender/2.80/scripts/modules/bpy_types.py", line 670, in __getattribute__
    properties = StructRNA.path_resolve(self, "properties")
ReferenceError: StructRNA of type ExportGodot has been removed

location: <unknown location>:-1

It seems exporting only the mesh works as expected, and the functionality was working correctly in an earlier version (several months old) of the exporter.

Minimal reproduction project: godot-exporter-issue.zip

Jason0214 commented 4 years ago

The stack trace looks like an issue in the report of warning message. Haven't touch that part of code for a long time, probably some Blender change make it not workable. I will find some time look into it.

IntricateMachinations commented 4 years ago

I think this line tells you about the actual error

logging.warning("Vertex weights more than maximal")

Meaning you should normalize your bone weights.

Jason0214 commented 4 years ago

FYI, for the vertex weights, looks like there is also an issue in Blender's normalize

249

Jason0214 commented 4 years ago

This issue looks like a Blender problem. I tried to reproduce, sometimes I got it and sometimes I don't. The stack trace is complain about lost the reference to the addon instance in logging a message (which would not happen in the addon's logic), probably some issue in Blender's reference model.

kis3lori commented 4 years ago

If you run into this issue a temporary fix is to just comment line 461 from io_scene_godot/converters/mesh.py It should look like this: logging.warning("Vertex weights more than maximal")

Somewhere along the line trying to log that warning it breaks.