Tweak API to support adding evaluated meshes to main database
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 16 May 2019 11:49:21 +0000 (13:49 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 16 May 2019 14:42:16 +0000 (16:42 +0200)
commit32d5d127cb49743578e8e1e9882d8a707a4e848e
tree72c18410ca6f3d503d8790bd936bc73273efb658
parent22a91bb0bd6ac76142f832e0e07df0b5f9e8ead2
Tweak API to support adding evaluated meshes to main database

One of the usecases is to create mesh from an object is a manner similar to
how Apply Modifiers does it, and have it in the bmain so it can be referenced
by other objects.

This usecase is something what went unnoticed in the previous API changes, so
here is a followup.

Summary of changes:

* bpy.meshes.new_from_object() behaves almost the same as before this change.
  The difference now is that it now ensures all referenced data-blocks are
original (for example, materials referenced by the mesh).

* object.to_mesh() now creates free-standing Mesh data-block which is outside
  of any bmain. The object owns it, which guarantees the memory never leaks.

  It is possible to force free memory by calling object.to_mesh_clear().

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D4875
15 files changed:
doc/python_api/examples/bpy.types.Depsgraph.4.py
doc/python_api/examples/bpy.types.Depsgraph.5.py
doc/python_api/examples/bpy.types.Depsgraph.6.py [new file with mode: 0644]
intern/cycles/blender/blender_util.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/mesh_convert.c
source/blender/blenkernel/intern/object.c
source/blender/editors/object/object_bake_api.c
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
source/blender/makesdna/DNA_object_types.h
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_object_api.c
tests/python/bl_alembic_import_test.py