Fix T93728: Greasepencil separate will loose all vertex groups

Caused by {rB3b6ee8cee708}

The raw data is copied here correctly
[`BKE_gpencil_stroke_weights_duplicate` in
`BKE_gpencil_stroke_duplicate`] but the vertex groups names are missing.
Prior to above commit is was enough to have `ED_object_add_duplicate`
(this seemingly took care of duplicating object's defbase).
Now vertex groups names sit on the `bGPdata` rather than the `Object`,
and since the separate operation creates **new** `bGPdata` we have to
copy vertex groups names - and active index - over [via
`BKE_defgroup_copy_list`].

Maniphest Tasks: T93728

Differential Revision: https://developer.blender.org/D13509
This commit is contained in:
Philipp Oeser 2021-12-08 10:31:57 +01:00
parent e23b54a59f
commit 72b39d3f92
Notes: blender-bot 2023-02-14 08:08:54 +01:00
Referenced by issue #93728, When seperating a grease pencil stroke to its own object it will lose all vertex groups
Referenced by issue #93479, 3.0 Potential candidates for corrective releases
1 changed files with 4 additions and 0 deletions

View File

@ -51,6 +51,7 @@
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_gpencil_curve.h"
@ -4569,6 +4570,9 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
id_us_min(ob_dst->data);
ob_dst->data = (bGPdata *)gpd_dst;
BKE_defgroup_copy_list(&gpd_dst->vertex_group_names, &gpd_src->vertex_group_names);
gpd_dst->vertex_group_active_index = gpd_src->vertex_group_active_index;
/* Loop old data-block and separate parts. */
if (ELEM(mode, GP_SEPARATE_POINT, GP_SEPARATE_STROKE)) {
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {