Fix T76417: Gpencil Join did not supported weight join
Now the operator keep the weights of all strokes when joining.
This commit is contained in:
@@ -3186,6 +3186,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps)
|
||||
|
||||
/* Helper: copy point between strokes */
|
||||
static void gpencil_stroke_copy_point(bGPDstroke *gps,
|
||||
MDeformVert *dvert,
|
||||
bGPDspoint *point,
|
||||
int idx,
|
||||
const float delta[3],
|
||||
@@ -3199,6 +3200,13 @@ static void gpencil_stroke_copy_point(bGPDstroke *gps,
|
||||
if (gps->dvert != NULL) {
|
||||
gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * (gps->totpoints + 1));
|
||||
}
|
||||
else {
|
||||
/* If destination has weight add weight to origin. */
|
||||
if (dvert != NULL) {
|
||||
gps->dvert = MEM_callocN(sizeof(MDeformVert) * (gps->totpoints + 1), __func__);
|
||||
}
|
||||
}
|
||||
|
||||
gps->totpoints++;
|
||||
newpoint = &gps->points[gps->totpoints - 1];
|
||||
|
||||
@@ -3212,11 +3220,16 @@ static void gpencil_stroke_copy_point(bGPDstroke *gps,
|
||||
copy_v4_v4(newpoint->vert_color, point->vert_color);
|
||||
|
||||
if (gps->dvert != NULL) {
|
||||
MDeformVert *dvert = &gps->dvert[idx];
|
||||
MDeformVert *newdvert = &gps->dvert[gps->totpoints - 1];
|
||||
|
||||
newdvert->totweight = dvert->totweight;
|
||||
newdvert->dw = MEM_dupallocN(dvert->dw);
|
||||
if (dvert != NULL) {
|
||||
newdvert->totweight = dvert->totweight;
|
||||
newdvert->dw = MEM_dupallocN(dvert->dw);
|
||||
}
|
||||
else {
|
||||
newdvert->totweight = 0;
|
||||
newdvert->dw = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3267,16 +3280,18 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
|
||||
/* 1st: add one tail point to start invisible area */
|
||||
point = gps_a->points[gps_a->totpoints - 1];
|
||||
deltatime = point.time;
|
||||
gpencil_stroke_copy_point(gps_a, &point, gps_a->totpoints - 1, delta, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
gpencil_stroke_copy_point(gps_a, NULL, &point, gps_a->totpoints - 1, delta, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
/* 2nd: add one head point to finish invisible area */
|
||||
point = gps_b->points[0];
|
||||
gpencil_stroke_copy_point(gps_a, &point, 0, delta, 0.0f, 0.0f, deltatime);
|
||||
gpencil_stroke_copy_point(gps_a, NULL, &point, 0, delta, 0.0f, 0.0f, deltatime);
|
||||
}
|
||||
|
||||
/* 3rd: add all points */
|
||||
for (i = 0, pt = gps_b->points; i < gps_b->totpoints && pt; i++, pt++) {
|
||||
gpencil_stroke_copy_point(gps_a, pt, i, delta, pt->pressure, pt->strength, deltatime);
|
||||
MDeformVert *dvert = (gps_b->dvert) ? &gps_b->dvert[i] : NULL;
|
||||
gpencil_stroke_copy_point(gps_a, dvert, pt, i, delta, pt->pressure, pt->strength, deltatime);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user