diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-24 15:37:47 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-27 12:00:42 +0300 |
commit | 5dbda33462349a4ac78f08e8ed4ec7922ca7394f (patch) | |
tree | b73b67873cd42dc1a9a927227fd85e9bfb52285e /source/blender/makesrna/intern/rna_object_api.c | |
parent | 07d3d8c2fd75d633a7d6ba6aab47308860af676c (diff) |
Depsgraph API: Allow preserving custom data layers
This commit extends dependency graph API with an argument which
denotes that all custom data layers are to be preserved. This
forces modifier stack re-evaluation with more inclusive mask.
Far from ideal, since this might fail in certain configurations
with indirectly used objects which might be missing layers needed
for the current object evaluation. But this is how it worked for
a long time, so should be good enough for until more sophisticated
solution is found.
In order to use this new behavior two things are to be passed:
- Pass keep_all_data_layers=True
- Pass a valid dependency graph.
The dependency graph is only needed if keep_all_data_layers=True
and is NOT to be passed if keep_all_data_layers=False.
If keep_all_data_layers=True the dependency graph MUST be passed.
Reviewers: mont29, brecht
Reviewed By: mont29
Maniphest Tasks: T64994, T64794
Differential Revision: https://developer.blender.org/D4940
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 7362f6ba610..b5f515277ca 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -375,7 +375,10 @@ static void rna_Object_camera_fit_coords( } /* copied from Mesh_getFromObject and adapted to RNA interface */ -static Mesh *rna_Object_to_mesh(Object *object, ReportList *reports) +static Mesh *rna_Object_to_mesh(Object *object, + ReportList *reports, + bool preserve_all_data_layers, + Depsgraph *depsgraph) { /* TODO(sergey): Make it more re-usable function, de-duplicate with * rna_Main_meshes_new_from_object. */ @@ -391,7 +394,7 @@ static Mesh *rna_Object_to_mesh(Object *object, ReportList *reports) return NULL; } - return BKE_object_to_mesh(object); + return BKE_object_to_mesh(depsgraph, object, preserve_all_data_layers); } static void rna_Object_to_mesh_clear(Object *object) @@ -898,6 +901,19 @@ void RNA_api_object(StructRNA *srna) "data-block. To force free it use to_mesh_clear(). " "The result is temporary and can not be used by objects from the main database"); RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_boolean(func, + "preserve_all_data_layers", + false, + "", + "Preserve all data layers in the mesh, like UV maps and vertex groups. " + "By default Blender only computes the subset of data layers needed for viewport " + "display and rendering, for better performance"); + RNA_def_pointer( + func, + "depsgraph", + "Depsgraph", + "Dependency Graph", + "Evaluated dependency graph which is required when preserve_all_data_layers is true"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object"); RNA_def_function_return(func, parm); |