Object.to_mesh(preserve_all_data_layers=True,...) causes strange stateful-behavior in exporters #72581

Closed
opened 2019-12-19 18:43:11 +01:00 by Ted Greene · 9 comments

System Information
Operating system: Tested Windows 10, x64, various Mac OS versions
Graphics card:

Blender Version
Tested: Blender 2.80-2.82a2

Short description of error
I am not sure if this is a bug or me not understanding this API. I am the maintainer of XPlane2Blender, an exporter for our flight sim's own 3D format. My users noticed that exported geometry can sometimes shift or rotate (and other weird side-effects, such as the Blender Object itself having moved after export) after each time hitting export. The common theme we found was that things with Scale transformations and modifiers on the objects seemed to trigger it. The fix is to either restart Blender or Apply All Transformations to all objects and bones.

I tracked this issue down to one parameter of in my call to Object.to_mesh: if preserve_all_data_layers is set to False these problems (as far as I've seen) go away.

I am very confused by this. I thought this API (depsgraph_get, evaluated_get, to_mesh, to_mesh_clear) was all read only and any side effects would only be applied to the temporary mesh from to_mesh.

  1. Is this a bug then or does "preserving_all_data_layers" also mean making some stateful-ness.
  2. I would also like to know what exact data layers get dropped when preserving_all_data_layers is set to False.

Exact steps for others to reproduce the error

  1. Unless you really want to install and use the addon, I've provided the outputted files (look at how the VT entries change) and a screenshot

export_multiple_times_result.png

export_multiple_times_result.blend

test_multiple_export_works3.obj

test_multiple_export_works6.obj

test_multiple_export_works9.obj

  1. The relevant code is in a file called xplane_mesh.py, lines 60-63 and 136. See on github (https://github.com/X-Plane/XPlane2Blender/blob/399-blender-28-support/io_xplane2blender/xplane_types/xplane_mesh.py)
**System Information** Operating system: Tested Windows 10, x64, various Mac OS versions Graphics card: **Blender Version** Tested: Blender 2.80-2.82a2 **Short description of error** I am not sure if this is a bug or me not understanding this API. I am the maintainer of XPlane2Blender, an exporter for our flight sim's own 3D format. My users noticed that exported geometry can sometimes shift or rotate (and other weird side-effects, such as the Blender Object itself having moved after export) after each time hitting export. The common theme we found was that things with Scale transformations and modifiers on the objects seemed to trigger it. The fix is to either restart Blender or Apply All Transformations to all objects and bones. I tracked this issue down to one parameter of in my call to Object.to_mesh: if preserve_all_data_layers is set to False these problems (as far as I've seen) go away. I am very confused by this. I thought this API (depsgraph_get, evaluated_get, to_mesh, to_mesh_clear) was all read only and any side effects would only be applied to the temporary mesh from to_mesh. 1. Is this a bug then or does "preserving_all_data_layers" also mean making some stateful-ness. 2. I would also like to know what exact data layers get dropped when preserving_all_data_layers is set to False. **Exact steps for others to reproduce the error** 1. Unless you really want to install and use the addon, I've provided the outputted files (look at how the VT entries change) and a screenshot ![export_multiple_times_result.png](https://archive.blender.org/developer/F8234793/export_multiple_times_result.png) [export_multiple_times_result.blend](https://archive.blender.org/developer/F8234791/export_multiple_times_result.blend) [test_multiple_export_works3.obj](https://archive.blender.org/developer/F8234788/test_multiple_export_works3.obj) [test_multiple_export_works6.obj](https://archive.blender.org/developer/F8234789/test_multiple_export_works6.obj) [test_multiple_export_works9.obj](https://archive.blender.org/developer/F8234790/test_multiple_export_works9.obj) 2. The relevant code is in a file called xplane_mesh.py, lines 60-63 and 136. See on github (https://github.com/X-Plane/XPlane2Blender/blob/399-blender-28-support/io_xplane2blender/xplane_types/xplane_mesh.py)
Author

Added subscriber: @tngreene

Added subscriber: @tngreene
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Are you able to reproduce this issue outside of your addon in a simple standalone script? That would make debugging the issue much easier.

Are you able to reproduce this issue outside of your addon in a simple standalone script? That would make debugging the issue much easier.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs User Info' to: 'Archived'

Changed status from 'Needs User Info' to: 'Archived'
Philipp Oeser self-assigned this 2020-01-07 10:09:34 +01:00
Member

More than a week without reply or activity. Due to the policy of the tracker closing for until required info/data are provided.

More than a week without reply or activity. Due to the policy of the tracker closing for until required info/data are provided.

Added subscriber: @skatbude

Added subscriber: @skatbude

System Information
Operating system: Linux-5.7.2-sparky-amd64-x86_64-with-glibc2.29 64 Bits
Graphics card: Mesa DRI Intel(R) HD Graphics 3000 (SNB GT2) Intel Open Source Technology Center 3.3 (Core Profile) Mesa 20.1.2

Blender Version
Broken: version: 2.83.2
Worked: -

Short description of error
I stumbled across the same issue while modifying the .obj-exporter.
The issue seems to be related to both
object.evaluated_get(depsgraph)
and
obj.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph)

The attached file contains a cube that is scaled by factor 2.
A custom Operator uses above code to retrieve the cube's mesh and then transform it by the cubes world matrix.
Next the coordinate of one Vertex is reported to Info.
Expected Result: (2, 2, 2) (modulo sign)
Actual Result: Coordinates double every time the Operator is executed.

Exact steps for others to reproduce the error
Open the attached .blend file and follow the instruction on screen (Readme file is included).
statefulBehaviour.blend

**System Information** Operating system: Linux-5.7.2-sparky-amd64-x86_64-with-glibc2.29 64 Bits Graphics card: Mesa DRI Intel(R) HD Graphics 3000 (SNB GT2) Intel Open Source Technology Center 3.3 (Core Profile) Mesa 20.1.2 **Blender Version** Broken: version: 2.83.2 Worked: - **Short description of error** I stumbled across the same issue while modifying the .obj-exporter. The issue seems to be related to both ```object.evaluated_get(depsgraph)``` and ```obj.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph)``` The attached file contains a cube that is scaled by factor 2. A custom Operator uses above code to retrieve the cube's mesh and then transform it by the cubes world matrix. Next the coordinate of one Vertex is reported to Info. __Expected Result:__ (2, 2, 2) (modulo sign) __Actual Result:__ Coordinates double every time the Operator is executed. **Exact steps for others to reproduce the error** Open the attached .blend file and follow the instruction on screen (Readme file is included). [statefulBehaviour.blend](https://archive.blender.org/developer/F8723611/statefulBehaviour.blend)
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#72581
No description provided.