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:
authorAntonioya <blendergit@gmail.com>2019-04-01 17:47:01 +0300
committerAntonioya <blendergit@gmail.com>2019-04-01 17:48:01 +0300
commitfa6c2c7dba909e5d8a88817854b215990eea7051 (patch)
treec46512d643ad66b7d03aff959f99f5e775697483 /source/blender/editors/gpencil/gpencil_edit.c
parentaf6df8416e4f09ba6dfa3ff58ace0cb770a44316 (diff)
GPencil: Handle vertex groups weights correctly
In extrude operator when the point was added, the weight data pointer was wrongly connected to old pointer. Now, when move the data, the pointer is moved, but when a new point is added, the memory is duplicated to keep separated copies of the pointer. This is related T62872 Thanks to @sergey for his help fixing this bug.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_edit.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index b6499200e01..99d37f87da7 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -757,11 +757,11 @@ void GPENCIL_OT_duplicate(wmOperatorType *ot)
/* ************** Extrude Selected Strokes **************** */
/* helper to copy a point to temp area */
-static void copy_point(
+static void copy_move_point(
bGPDstroke *gps,
bGPDspoint *temp_points,
MDeformVert *temp_dverts,
- int from_idx, int to_idx)
+ int from_idx, int to_idx, const bool copy)
{
bGPDspoint *pt = &temp_points[from_idx];
bGPDspoint *pt_final = &gps->points[to_idx];
@@ -779,7 +779,13 @@ static void copy_point(
MDeformVert *dvert_final = &gps->dvert[to_idx];
dvert_final->totweight = dvert->totweight;
- dvert_final->dw = dvert->dw;
+ /* if copy, duplicate memory, otherwise move only the pointer */
+ if (copy) {
+ dvert_final->dw = MEM_dupallocN(dvert->dw);
+ }
+ else {
+ dvert_final->dw = dvert->dw;
+ }
}
}
@@ -822,7 +828,7 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
BLI_insertlinkafter(&gpf->strokes, gps, gps_new);
/* copy selected point data to new stroke */
- copy_point(gps_new, gps->points, gps->dvert, i, 0);
+ copy_move_point(gps_new, gps->points, gps->dvert, i, 0, true);
/* deselect orinal point */
pt->flag &= ~GP_SPOINT_SELECT;
@@ -863,14 +869,14 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
/* move points to new position */
for (int i = 0; i < oldtotpoints; i++) {
- copy_point(gps, temp_points, temp_dverts, i, i2);
+ copy_move_point(gps, temp_points, temp_dverts, i, i2, false);
i2++;
}
gps->flag |= GP_STROKE_RECALC_GEOMETRY;
/* if first point, add new point at the begining */
if (do_first) {
- copy_point(gps, temp_points, temp_dverts, 0, 0);
+ copy_move_point(gps, temp_points, temp_dverts, 0, 0, true);
/* deselect old */
pt = &gps->points[1];
pt->flag &= ~GP_SPOINT_SELECT;
@@ -881,9 +887,9 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps)
/* if last point, add new point at the end */
if (do_last) {
- copy_point(
+ copy_move_point(
gps, temp_points, temp_dverts,
- oldtotpoints - 1, gps->totpoints - 1);
+ oldtotpoints - 1, gps->totpoints - 1, true);
/* deselect old */
pt = &gps->points[gps->totpoints - 2];