diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-24 12:13:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-24 13:23:00 +0300 |
commit | 27da305a404f72a75a37892e1ac080c6531d059b (patch) | |
tree | 3fb809530c31b63882e95fa6c4ed1d9d6577e13f /source/blender/blenkernel/intern/lib_id_eval.c | |
parent | 67b352f9c5317c81c8e862a49be656c56e8f0743 (diff) |
Depsgraph: support flushing parameters without a full COW update
Avoid computationally expensive copying operations
when only some settings have been modified.
This is done by adding support for updating parameters
without tagging for copy-on-write.
Currently only mesh data blocks are supported,
other data-blocks can be added individually.
This prepares for changing values such as edit-mesh auto-smooth angle
in edit-mode without duplicating all mesh-data.
The benefit will only be seen when the user interface no longer tags
all ID's for copy on write updates.
ID_RECALC_GEOMETRY_ALL_MODES has been added to support situations
where non edit-mode geometry is modified in edit-mode.
While this isn't something user are likely to do,
Python scripts may change the underlying mesh.
Reviewed By: sergey
Ref D11377
Diffstat (limited to 'source/blender/blenkernel/intern/lib_id_eval.c')
-rw-r--r-- | source/blender/blenkernel/intern/lib_id_eval.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/lib_id_eval.c b/source/blender/blenkernel/intern/lib_id_eval.c new file mode 100644 index 00000000000..140fe403ac3 --- /dev/null +++ b/source/blender/blenkernel/intern/lib_id_eval.c @@ -0,0 +1,48 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup bke + * + * Contains management of ID's and libraries + * allocate and free of all library data + */ + +#include "DNA_ID.h" +#include "DNA_mesh_types.h" + +#include "BLI_utildefines.h" + +#include "BKE_lib_id.h" +#include "BKE_mesh.h" + +/** + * Copy relatives parameters, from `id` to `id_cow`. + * Use handle the #ID_RECALC_PARAMETERS tag. + * \note Keep in sync with #ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW. + */ +void BKE_id_eval_properties_copy(ID *id_cow, ID *id) +{ + const ID_Type id_type = GS(id->name); + BLI_assert((id_cow->tag & LIB_TAG_COPIED_ON_WRITE) && !(id->tag & LIB_TAG_COPIED_ON_WRITE)); + BLI_assert(ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(id_type)); + if (id_type == ID_ME) { + BKE_mesh_copy_parameters((Mesh *)id_cow, (const Mesh *)id); + } + else { + BLI_assert_unreachable(); + } +} |