Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-02-11 16:09:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-02-11 16:40:58 +0300
commit196dfc01a3e99c3bef0e44acf599bca50ae0300e (patch)
tree5d1b42a947e5f339b0a79e5f8d7a4617128d907a /source/blender/editors/mesh/editmesh_undo.c
parentb20872d36ebcf8777b8a6970425ebbdd81eac29d (diff)
Fix T84114: Existence of vertex groups slows down mesh editing
Having a vertex group in a mesh slowed down unrelated operations such as selection. De-duplicating custom-data arrays for layers that contain pointers can become slow without any benefit as the content never matches. Use full copies when storing custom-data for edit-mesh undo.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_undo.c')
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 1cbbbccdfa9..41bb3faa135 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -153,6 +153,23 @@ static void um_arraystore_cd_compact(struct CustomData *cdata,
for (int layer_start = 0, layer_end; layer_start < cdata->totlayer; layer_start = layer_end) {
const CustomDataType type = cdata->layers[layer_start].type;
+ /* Perform a full copy on dynamic layers.
+ *
+ * Unfortunately we can't compare dynamic layer types as they contain allocated pointers,
+ * which burns CPU cycles looking for duplicate data that doesn't exist.
+ * The array data isn't comparable once copied from the mesh,
+ * this bottlenecks on high poly meshes, see T84114.
+ *
+ * Notes:
+ *
+ * - Ideally the data would be expanded into a format that could be de-duplicated effectively,
+ * this would require a flat representation of each dynamic custom-data layer.
+ *
+ * - The data in the layer could be kept as-is to save on the extra copy,
+ * it would complicate logic in this function.
+ */
+ const bool layer_type_is_dynamic = CustomData_layertype_is_dynamic(type);
+
layer_end = layer_start + 1;
while ((layer_end < cdata->totlayer) && (type == cdata->layers[layer_end].type)) {
layer_end++;
@@ -209,6 +226,11 @@ static void um_arraystore_cd_compact(struct CustomData *cdata,
i < bcd_reference_current->states_len) ?
bcd_reference_current->states[i] :
NULL;
+ /* See comment on `layer_type_is_dynamic` above. */
+ if (layer_type_is_dynamic) {
+ state_reference = NULL;
+ }
+
bcd->states[i] = BLI_array_store_state_add(
bs, layer->data, (size_t)data_len * stride, state_reference);
}