Fix T43283: Crash on undo/redo/ and save/reload after (new) weight transfer.

Mesh stores its dvert in a specific pointer too, in addition of regular CD layer...
That whole vgroup handling is really breaking apart the 'universality' of CD system. :(

Also added some DAG and WM updates in operators...
This commit is contained in:
Bastien Montagne 2015-01-17 17:38:31 +01:00
parent c9e5d9226b
commit 119ff676e1
Notes: blender-bot 2023-02-14 09:36:40 +01:00
Referenced by issue #43283, Crash Upon Opening File
2 changed files with 21 additions and 4 deletions

View File

@ -690,13 +690,19 @@ static bool data_transfer_layersmapping_generate(
return true;
}
else if (cddata_type == CD_FAKE_MDEFORMVERT) {
bool ret;
cd_src = dm_src->getVertDataLayout(dm_src);
cd_dst = dm_dst ? dm_dst->getVertDataLayout(dm_dst) : &me_dst->vdata;
return data_transfer_layersmapping_vgroups(r_map, mix_mode, mix_factor, mix_weights,
num_elem_dst, use_create, use_delete,
ob_src, ob_dst, cd_src, cd_dst, dm_dst != NULL,
fromlayers, tolayers);
ret = data_transfer_layersmapping_vgroups(r_map, mix_mode, mix_factor, mix_weights,
num_elem_dst, use_create, use_delete,
ob_src, ob_dst, cd_src, cd_dst, dm_dst != NULL,
fromlayers, tolayers);
/* Mesh stores its dvert in a specific pointer too. :( */
me_dst->dvert = CustomData_get_layer(&me_dst->vdata, CD_MDEFORMVERT);
return ret;
}
else if (cddata_type == CD_FAKE_SHAPEKEY) {
/* TODO: leaving shapekeys asside for now, quite specific case, since we can't access them from MVert :/ */

View File

@ -42,6 +42,7 @@
#include "BKE_context.h"
#include "BKE_data_transfer.h"
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_mesh_remap.h"
@ -393,6 +394,8 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
}
}
DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
if (reverse_transfer) {
SWAP(Object *, ob_src, ob_dst);
}
@ -400,6 +403,8 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
BLI_freelistN(&ctx_objects);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
#if 0 /* TODO */
/* Note: issue with that is that if canceled, operator cannot be redone... Nasty in our case. */
return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@ -592,6 +597,8 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
BKE_object_data_transfer_layout(scene, ob_src, ob_dst, dtmd->data_types, use_delete,
dtmd->layers_select_src, dtmd->layers_select_dst);
DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
}
else {
Object *ob_src = ob_act;
@ -621,11 +628,15 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op)
BKE_object_data_transfer_layout(scene, ob_src, ob_dst, data_type, use_delete,
layers_select_src, layers_select_dst);
}
DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
}
BLI_freelistN(&ctx_objects);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
return OPERATOR_FINISHED;
}