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:
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_paint.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 5b70da80a5e..f4d398ccaad 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -493,7 +493,7 @@ static void gpencil_brush_jitter(bGPdata *gpd, tGPspoint *pt, const float amplit
/* Mouse movement in ints -> floats. */
if (gpd->runtime.sbuffer_used > 1) {
tGPspoint *pt_prev = pt - 1;
- sub_v2_v2v2(mvec, &pt->x, &pt_prev->x);
+ sub_v2_v2v2(mvec, pt->m_xy, pt_prev->m_xy);
normalize_v2(mvec);
/* Rotate mvec by 90 degrees... */
float angle = angle_v2v2(mvec, axis);
@@ -502,7 +502,7 @@ static void gpencil_brush_jitter(bGPdata *gpd, tGPspoint *pt, const float amplit
mvec[1] *= sin(angle);
/* Scale by displacement amount, and apply. */
- madd_v2_v2fl(&pt->x, mvec, amplitude * 10.0f);
+ madd_v2_v2fl(pt->m_xy, mvec, amplitude * 10.0f);
}
}
@@ -520,8 +520,7 @@ static void gpencil_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const
/* Apply to first point (only if there are 2 points because before no data to do it ) */
if (gpd->runtime.sbuffer_used == 1) {
- mvec[0] = (mval[0] - (pt - 1)->x);
- mvec[1] = (mval[1] - (pt - 1)->y);
+ sub_v2_v2v2(mvec, mval, (pt - 1)->m_xy);
normalize_v2(mvec);
/* uses > 1.0f to get a smooth transition in first point */
@@ -533,8 +532,7 @@ static void gpencil_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const
/* apply from second point */
if (gpd->runtime.sbuffer_used >= 1) {
- mvec[0] = (mval[0] - (pt - 1)->x);
- mvec[1] = (mval[1] - (pt - 1)->y);
+ sub_v2_v2v2(mvec, mval, (pt - 1)->m_xy);
normalize_v2(mvec);
fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */
@@ -581,25 +579,25 @@ static void gpencil_smooth_buffer(tGPsdata *p, float inf, int idx)
/* Compute smoothed coordinate by taking the ones nearby */
if (pta) {
- copy_v2_v2(a, &pta->x);
+ copy_v2_v2(a, pta->m_xy);
madd_v2_v2fl(sco, a, average_fac);
pressure += pta->pressure * average_fac;
strength += pta->strength * average_fac;
}
if (ptb) {
- copy_v2_v2(b, &ptb->x);
+ copy_v2_v2(b, &ptb->m_xy);
madd_v2_v2fl(sco, b, average_fac);
pressure += ptb->pressure * average_fac;
strength += ptb->strength * average_fac;
}
if (ptc) {
- copy_v2_v2(c, &ptc->x);
+ copy_v2_v2(c, ptc->m_xy);
madd_v2_v2fl(sco, c, average_fac);
pressure += ptc->pressure * average_fac;
strength += ptc->strength * average_fac;
}
if (ptd) {
- copy_v2_v2(d, &ptd->x);
+ copy_v2_v2(d, ptd->m_xy);
madd_v2_v2fl(sco, d, average_fac);
pressure += ptd->pressure * average_fac;
strength += ptd->strength * average_fac;
@@ -609,7 +607,7 @@ static void gpencil_smooth_buffer(tGPsdata *p, float inf, int idx)
* for Guide mode. */
if (!guide->use_guide) {
interp_v2_v2v2(c, c, sco, inf);
- copy_v2_v2(&ptc->x, c);
+ copy_v2_v2(ptc->m_xy, c);
}
/* Interpolate pressure. */
ptc->pressure = interpf(ptc->pressure, pressure, inf);
@@ -646,37 +644,37 @@ static void gpencil_smooth_segment(bGPdata *gpd, const float inf, int from_idx,
/* Compute smoothed coordinate by taking the ones nearby */
if (pta) {
- madd_v2_v2fl(sco, &pta->x, average_fac);
+ madd_v2_v2fl(sco, pta->m_xy, average_fac);
pressure += pta->pressure * average_fac;
strength += pta->strength * average_fac;
}
else {
- madd_v2_v2fl(sco, &ptc->x, average_fac);
+ madd_v2_v2fl(sco, ptc->m_xy, average_fac);
pressure += ptc->pressure * average_fac;
strength += ptc->strength * average_fac;
}
if (ptb) {
- madd_v2_v2fl(sco, &ptb->x, average_fac);
+ madd_v2_v2fl(sco, ptb->m_xy, average_fac);
pressure += ptb->pressure * average_fac;
strength += ptb->strength * average_fac;
}
else {
- madd_v2_v2fl(sco, &ptc->x, average_fac);
+ madd_v2_v2fl(sco, ptc->m_xy, average_fac);
pressure += ptc->pressure * average_fac;
strength += ptc->strength * average_fac;
}
- madd_v2_v2fl(sco, &ptc->x, average_fac);
+ madd_v2_v2fl(sco, ptc->m_xy, average_fac);
pressure += ptc->pressure * average_fac;
strength += ptc->strength * average_fac;
- madd_v2_v2fl(sco, &ptd->x, average_fac);
+ madd_v2_v2fl(sco, ptd->m_xy, average_fac);
pressure += ptd->pressure * average_fac;
strength += ptd->strength * average_fac;
/* Based on influence factor, blend between original and optimal smoothed coordinate. */
- interp_v2_v2v2(&ptc->x, &ptc->x, sco, inf);
+ interp_v2_v2v2(ptc->m_xy, ptc->m_xy, sco, inf);
/* Interpolate pressure. */
ptc->pressure = interpf(ptc->pressure, pressure, inf);
@@ -738,7 +736,7 @@ static void gpencil_apply_randomness(tGPsdata *p,
/* Apply randomness to uv texture rotation. */
if ((brush_settings->uv_random > 0.0f) && (uv)) {
if ((brush_settings->flag2 & GP_BRUSH_USE_UV_AT_STROKE) == 0) {
- float rand = BLI_hash_int_01(BLI_hash_int_2d((int)pt->x, gpd->runtime.sbuffer_used)) * 2.0f -
+ float rand = BLI_hash_int_01(BLI_hash_int_2d((int)pt->m_xy[0], gpd->runtime.sbuffer_used)) * 2.0f -
1.0f;
value = rand * M_PI_2 * brush_settings->uv_random;
}
@@ -778,7 +776,7 @@ static short gpencil_stroke_addpoint(tGPsdata *p,
pt = (tGPspoint *)(gpd->runtime.sbuffer);
/* store settings */
- copy_v2_v2(&pt->x, mval);
+ copy_v2_v2(pt->m_xy, mval);
/* T44932 - Pressure vals are unreliable, so ignore for now */
pt->pressure = 1.0f;
pt->strength = 1.0f;
@@ -794,7 +792,7 @@ static short gpencil_stroke_addpoint(tGPsdata *p,
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1);
/* store settings */
- copy_v2_v2(&pt->x, mval);
+ copy_v2_v2(pt->m_xy, mval);
/* T44932 - Pressure vals are unreliable, so ignore for now */
pt->pressure = 1.0f;
pt->strength = 1.0f;
@@ -825,7 +823,7 @@ static short gpencil_stroke_addpoint(tGPsdata *p,
pt->strength = brush_settings->draw_strength;
pt->pressure = 1.0f;
pt->uv_rot = 0.0f;
- copy_v2_v2(&pt->x, mval);
+ copy_v2_v2(pt->m_xy, mval);
/* pressure */
if (brush_settings->flag & GP_BRUSH_USE_PRESSURE) {
@@ -1013,7 +1011,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
ptc = gpd->runtime.sbuffer;
/* convert screen-coordinates to appropriate coordinates (and store them) */
- gpencil_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
+ gpencil_stroke_convertcoords(p, ptc->m_xy, &pt->x, NULL);
/* copy pressure and time */
pt->pressure = ptc->pressure;
pt->strength = ptc->strength;
@@ -1047,7 +1045,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_used - 1);
/* convert screen-coordinates to appropriate coordinates (and store them) */
- gpencil_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
+ gpencil_stroke_convertcoords(p, ptc->m_xy, &pt->x, NULL);
/* copy pressure and time */
pt->pressure = ptc->pressure;
pt->strength = ptc->strength;
@@ -1100,7 +1098,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
int i;
for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) {
- round_v2i_v2fl(mval_i, &ptc->x);
+ round_v2i_v2fl(mval_i, ptc->m_xy);
if ((ED_view3d_depth_read_cached(depths, mval_i, depth_margin, depth_arr + i) == 0) &&
(i && (ED_view3d_depth_read_cached_seg(
@@ -1171,7 +1169,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc;
i++, ptc++, pt++) {
/* convert screen-coordinates to appropriate coordinates (and store them) */
- gpencil_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL);
+ gpencil_stroke_convertcoords(p, ptc->m_xy, &pt->x, depth_arr ? depth_arr + i : NULL);
/* copy pressure and time */
pt->pressure = ptc->pressure;
@@ -2798,14 +2796,14 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
if (p->paintmode != GP_PAINTMODE_ERASER) {
- ED_gpencil_toggle_brush_cursor(C, true, &pt->x);
+ ED_gpencil_toggle_brush_cursor(C, true, pt->m_xy);
}
}
else if ((p->brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) &&
(gpd->runtime.sbuffer_used > 0)) {
pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
if (p->paintmode != GP_PAINTMODE_ERASER) {
- ED_gpencil_toggle_brush_cursor(C, true, &pt->x);
+ ED_gpencil_toggle_brush_cursor(C, true, pt->m_xy);
}
}
}
@@ -3303,8 +3301,7 @@ static void gpencil_brush_angle_segment(tGPsdata *p, tGPspoint *pt_prev, tGPspoi
/* angle vector of the brush with full thickness */
const float v0[2] = {cos(angle), sin(angle)};
- mvec[0] = pt->x - pt_prev->x;
- mvec[1] = pt->y - pt_prev->y;
+ sub_v2_v2v2(mvec, pt->m_xy, pt_prev->m_xy);
normalize_v2(mvec);
fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */
/* interpolate with previous point for smoother transitions */
@@ -3355,11 +3352,11 @@ static void gpencil_add_arc_points(tGPsdata *p, const float mval[2], int segment
* for arc curve.
*/
float v_prev[2], v_cur[2], v_half[2];
- sub_v2_v2v2(v_cur, mval, &pt_prev->x);
+ sub_v2_v2v2(v_cur, mval, pt_prev->m_xy);
- sub_v2_v2v2(v_prev, &pt_prev->x, &pt_before->x);
- interp_v2_v2v2(v_half, &pt_prev->x, mval, 0.5f);
- sub_v2_v2(v_half, &pt_prev->x);
+ sub_v2_v2v2(v_prev, pt_prev->m_xy, pt_before->m_xy);
+ interp_v2_v2v2(v_half, pt_prev->m_xy, mval, 0.5f);
+ sub_v2_v2(v_half, pt_prev->m_xy);
/* If angle is too sharp undo all changes and return. */
const float min_angle = DEG2RADF(120.0f);
@@ -3378,14 +3375,14 @@ static void gpencil_add_arc_points(tGPsdata *p, const float mval[2], int segment
/* Calc the position of the control point. */
float ctl[2];
- add_v2_v2v2(ctl, &pt_prev->x, v_prev);
+ add_v2_v2v2(ctl, pt_prev->m_xy, v_prev);
float step = M_PI_2 / (float)(segments + 1);
float a = step;
float midpoint[2], start[2], end[2], cp1[2], corner[2];
- mid_v2_v2v2(midpoint, &pt_prev->x, mval);
- copy_v2_v2(start, &pt_prev->x);
+ mid_v2_v2v2(midpoint, pt_prev->m_xy, mval);
+ copy_v2_v2(start, pt_prev->m_xy);
copy_v2_v2(end, mval);
copy_v2_v2(cp1, ctl);
@@ -3396,8 +3393,8 @@ static void gpencil_add_arc_points(tGPsdata *p, const float mval[2], int segment
tGPspoint *pt_step = pt_prev;
for (int i = 0; i < segments; i++) {
pt = &points[idx_prev + i - 1];
- pt->x = corner[0] + (end[0] - corner[0]) * sinf(a) + (start[0] - corner[0]) * cosf(a);
- pt->y = corner[1] + (end[1] - corner[1]) * sinf(a) + (start[1] - corner[1]) * cosf(a);
+ pt->m_xy[0] = corner[0] + (end[0] - corner[0]) * sinf(a) + (start[0] - corner[0]) * cosf(a);
+ pt->m_xy[1] = corner[1] + (end[1] - corner[1]) * sinf(a) + (start[1] - corner[1]) * cosf(a);
/* Set pressure and strength equals to previous. It will be smoothed later. */
pt->pressure = pt_prev->pressure;
@@ -3460,8 +3457,8 @@ static void gpencil_add_guide_points(const tGPsdata *p,
for (int i = 0; i < segments; i++) {
pt = &points[idx_prev + i - 1];
- gpencil_rotate_v2_v2v2fl(&pt->x, start, p->guide.origin, -a);
- gpencil_snap_to_guide(p, guide, &pt->x);
+ gpencil_rotate_v2_v2v2fl(pt->m_xy, start, p->guide.origin, -a);
+ gpencil_snap_to_guide(p, guide, pt->m_xy);
a += step;
/* Set pressure and strength equals to previous. It will be smoothed later. */
@@ -3477,8 +3474,8 @@ static void gpencil_add_guide_points(const tGPsdata *p,
for (int i = 0; i < segments; i++) {
pt = &points[idx_prev + i - 1];
- interp_v2_v2v2(&pt->x, start, end, a);
- gpencil_snap_to_guide(p, guide, &pt->x);
+ interp_v2_v2v2(pt->m_xy, start, end, a);
+ gpencil_snap_to_guide(p, guide, pt->m_xy);
a += step;
/* Set pressure and strength equals to previous. It will be smoothed later. */