diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-18 15:35:34 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-10-18 15:35:34 +0300 |
commit | 3e8abc0535aaeb736310a1b7a5447df1721ff349 (patch) | |
tree | de35daa1ec122c33b2e6803cb7cb61bb20406882 /source/blender/blenkernel/intern | |
parent | 46f0b97d208c21d3ce192b71b65e1fa0776f7825 (diff) |
Depsgraph: Make Copy-on-Write a command line option
Before it was a compile time option which was not very easy to use or test. Now
the project is getting more mature, so very soon we will be able to call for a
public tests of limited features.
The copy-on-write (which includes animation, modifiers) is enabled using
--enable-copy-on-write command line argument.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index c5d267ace9d..3495804f743 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -349,55 +349,55 @@ void BKE_object_eval_uber_data(const EvaluationContext *eval_ctx, break; } -#ifdef WITH_COPY_ON_WRITE - if (ob->type == OB_MESH) { - /* Quick hack to convert evaluated derivedMesh to Mesh. */ - DerivedMesh *dm = ob->derivedFinal; - if (dm != NULL) { - Mesh *mesh = (Mesh *)ob->data; - Mesh *new_mesh = BKE_libblock_alloc_notest(ID_ME); - BKE_mesh_init(new_mesh); - /* Copy ID name so GS(new_mesh->id) works correct later on. */ - BLI_strncpy(new_mesh->id.name, mesh->id.name, sizeof(new_mesh->id.name)); - /* Copy materials so render engines can access them. */ - new_mesh->mat = MEM_dupallocN(mesh->mat); - new_mesh->totcol = mesh->totcol; - DM_to_mesh(dm, new_mesh, ob, CD_MASK_MESH, true); - new_mesh->edit_btmesh = mesh->edit_btmesh; - /* Store result mesh as derived_mesh of object. This way we have - * explicit way to query final object evaluated data and know for sure - * who owns the newly created mesh datablock. - */ - ob->mesh_evaluated = new_mesh; - /* TODO(sergey): This is kind of compatibility thing, so all render - * engines can use object->data for mesh data for display. This is - * something what we might want to change in the future. - */ - ob->data = new_mesh; - /* Save some memory by throwing DerivedMesh away. */ - /* NOTE: Watch out, some tools might need it! - * So keep around for now.. - */ - /* Store original ID as a pointer in evaluated ID. - * This way we can restore original object data when we are freeing - * evaluated mesh. - */ - new_mesh->id.newid = &mesh->id; - } + if (DEG_depsgraph_use_copy_on_write()) { + if (ob->type == OB_MESH) { + /* Quick hack to convert evaluated derivedMesh to Mesh. */ + DerivedMesh *dm = ob->derivedFinal; + if (dm != NULL) { + Mesh *mesh = (Mesh *)ob->data; + Mesh *new_mesh = BKE_libblock_alloc_notest(ID_ME); + BKE_mesh_init(new_mesh); + /* Copy ID name so GS(new_mesh->id) works correct later on. */ + BLI_strncpy(new_mesh->id.name, mesh->id.name, sizeof(new_mesh->id.name)); + /* Copy materials so render engines can access them. */ + new_mesh->mat = MEM_dupallocN(mesh->mat); + new_mesh->totcol = mesh->totcol; + DM_to_mesh(dm, new_mesh, ob, CD_MASK_MESH, true); + new_mesh->edit_btmesh = mesh->edit_btmesh; + /* Store result mesh as derived_mesh of object. This way we have + * explicit way to query final object evaluated data and know for sure + * who owns the newly created mesh datablock. + */ + ob->mesh_evaluated = new_mesh; + /* TODO(sergey): This is kind of compatibility thing, so all render + * engines can use object->data for mesh data for display. This is + * something what we might want to change in the future. + */ + ob->data = new_mesh; + /* Save some memory by throwing DerivedMesh away. */ + /* NOTE: Watch out, some tools might need it! + * So keep around for now.. + */ + /* Store original ID as a pointer in evaluated ID. + * This way we can restore original object data when we are freeing + * evaluated mesh. + */ + new_mesh->id.newid = &mesh->id; + } #if 0 - if (ob->derivedFinal != NULL) { - ob->derivedFinal->needsFree = 1; - ob->derivedFinal->release(ob->derivedFinal); - ob->derivedFinal = NULL; - } - if (ob->derivedDeform != NULL) { - ob->derivedDeform->needsFree = 1; - ob->derivedDeform->release(ob->derivedDeform); - ob->derivedDeform = NULL; - } + if (ob->derivedFinal != NULL) { + ob->derivedFinal->needsFree = 1; + ob->derivedFinal->release(ob->derivedFinal); + ob->derivedFinal = NULL; + } + if (ob->derivedDeform != NULL) { + ob->derivedDeform->needsFree = 1; + ob->derivedDeform->release(ob->derivedDeform); + ob->derivedDeform = NULL; + } #endif + } } -#endif ob->recalc &= ~(OB_RECALC_DATA | OB_RECALC_TIME); } |