Cleanup: add arg to GP_EDITABLE_STROKES macro
Without this, we use arguments defined in the macro making code hard to read.
This commit is contained in:
parent
184ab749c3
commit
3437cd9ac2
@ -2883,7 +2883,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||||||
// TODO: For deforming geometry workflow, create new frames?
|
// TODO: For deforming geometry workflow, create new frames?
|
||||||
|
|
||||||
/* Go through each editable + selected stroke, adjusting each of its points one by one... */
|
/* Go through each editable + selected stroke, adjusting each of its points one by one... */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
if (gps->flag & GP_STROKE_SELECT) {
|
if (gps->flag & GP_STROKE_SELECT) {
|
||||||
bGPDspoint *pt;
|
bGPDspoint *pt;
|
||||||
@ -2892,7 +2892,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
/* Compute inverse matrix for unapplying parenting once instead of doing per-point */
|
/* Compute inverse matrix for unapplying parenting once instead of doing per-point */
|
||||||
/* TODO: add this bit to the iteration macro? */
|
/* TODO: add this bit to the iteration macro? */
|
||||||
invert_m4_m4(inverse_diff_mat, diff_mat);
|
invert_m4_m4(inverse_diff_mat, gpstroke_iter.diff_mat);
|
||||||
|
|
||||||
/* Adjust each point */
|
/* Adjust each point */
|
||||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||||
@ -2904,7 +2904,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||||||
* artifacts in the final points.
|
* artifacts in the final points.
|
||||||
*/
|
*/
|
||||||
bGPDspoint pt2;
|
bGPDspoint pt2;
|
||||||
gp_point_to_parent_space(pt, diff_mat, &pt2);
|
gp_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
|
||||||
gp_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]);
|
gp_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]);
|
||||||
|
|
||||||
/* Project stroke in the axis locked */
|
/* Project stroke in the axis locked */
|
||||||
@ -2953,7 +2953,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
||||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||||
@ -3028,7 +3028,7 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
/* Go through each editable + selected stroke */
|
/* Go through each editable + selected stroke */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
if (gps->flag & GP_STROKE_SELECT) {
|
if (gps->flag & GP_STROKE_SELECT) {
|
||||||
/* loop as many times as cuts */
|
/* loop as many times as cuts */
|
||||||
@ -3126,7 +3126,7 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
/* notifiers */
|
/* notifiers */
|
||||||
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
||||||
@ -3169,14 +3169,14 @@ static int gp_stroke_simplify_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
/* Go through each editable + selected stroke */
|
/* Go through each editable + selected stroke */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
if (gps->flag & GP_STROKE_SELECT) {
|
if (gps->flag & GP_STROKE_SELECT) {
|
||||||
/* simplify stroke using Ramer-Douglas-Peucker algorithm */
|
/* simplify stroke using Ramer-Douglas-Peucker algorithm */
|
||||||
BKE_gpencil_simplify_stroke(gps, factor);
|
BKE_gpencil_simplify_stroke(gps, factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
/* notifiers */
|
/* notifiers */
|
||||||
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
||||||
@ -3218,7 +3218,7 @@ static int gp_stroke_simplify_fixed_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
|
|
||||||
/* Go through each editable + selected stroke */
|
/* Go through each editable + selected stroke */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
if (gps->flag & GP_STROKE_SELECT) {
|
if (gps->flag & GP_STROKE_SELECT) {
|
||||||
for (int i = 0; i < steps; i++) {
|
for (int i = 0; i < steps; i++) {
|
||||||
@ -3226,7 +3226,7 @@ static int gp_stroke_simplify_fixed_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
/* notifiers */
|
/* notifiers */
|
||||||
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
DEG_id_tag_update(&gpd->id, OB_RECALC_OB | OB_RECALC_DATA);
|
||||||
|
@ -474,6 +474,10 @@ typedef enum ACTCONT_TYPES {
|
|||||||
/* ****************************************************** */
|
/* ****************************************************** */
|
||||||
/* Stroke Iteration Utilities */
|
/* Stroke Iteration Utilities */
|
||||||
|
|
||||||
|
struct GP_EditableStrokes_Iter {
|
||||||
|
float diff_mat[4][4];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate over all editable strokes in the current context,
|
* Iterate over all editable strokes in the current context,
|
||||||
* stopping on each usable layer + stroke pair (i.e. gpl and gps)
|
* stopping on each usable layer + stroke pair (i.e. gpl and gps)
|
||||||
@ -484,37 +488,36 @@ typedef enum ACTCONT_TYPES {
|
|||||||
* \param gps The identifier to use for current stroke being processed.
|
* \param gps The identifier to use for current stroke being processed.
|
||||||
* Choose a suitable value to avoid name clashes.
|
* Choose a suitable value to avoid name clashes.
|
||||||
*/
|
*/
|
||||||
#define GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) \
|
#define GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps) \
|
||||||
{ \
|
{ \
|
||||||
|
struct GP_EditableStrokes_Iter gpstroke_iter = {0}; \
|
||||||
Depsgraph *depsgraph_ = CTX_data_depsgraph(C); \
|
Depsgraph *depsgraph_ = CTX_data_depsgraph(C); \
|
||||||
Object *obact_ = CTX_data_active_object(C); \
|
Object *obact_ = CTX_data_active_object(C); \
|
||||||
bGPdata *gpd_ = CTX_data_gpencil_data(C); \
|
bGPdata *gpd_ = CTX_data_gpencil_data(C); \
|
||||||
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \
|
const bool is_multiedit_ = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \
|
||||||
CTX_DATA_BEGIN(C, bGPDlayer*, gpl, editable_gpencil_layers) \
|
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) \
|
||||||
{ \
|
{ \
|
||||||
bGPDframe *init_gpf = gpl->actframe; \
|
bGPDframe *init_gpf_ = gpl->actframe; \
|
||||||
if (is_multiedit) { \
|
if (is_multiedit_) { \
|
||||||
init_gpf = gpl->frames.first; \
|
init_gpf_ = gpl->frames.first; \
|
||||||
} \
|
} \
|
||||||
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { \
|
for (bGPDframe *gpf_ = init_gpf_; gpf_; gpf_ = gpf_->next) { \
|
||||||
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { \
|
if ((gpf_ == gpl->actframe) || ((gpf_->flag & GP_FRAME_SELECT) && is_multiedit_)) { \
|
||||||
/* calculate difference matrix */ \
|
ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, gpstroke_iter.diff_mat); \
|
||||||
float diff_mat[4][4]; \
|
|
||||||
ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, diff_mat); \
|
|
||||||
/* loop over strokes */ \
|
/* loop over strokes */ \
|
||||||
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { \
|
for (bGPDstroke *gps = gpf_->strokes.first; gps; gps = gps->next) { \
|
||||||
/* skip strokes that are invalid for current view */ \
|
/* skip strokes that are invalid for current view */ \
|
||||||
if (ED_gpencil_stroke_can_use(C, gps) == false) \
|
if (ED_gpencil_stroke_can_use(C, gps) == false) \
|
||||||
continue; \
|
continue; \
|
||||||
/* check if the color is editable */ \
|
/* check if the color is editable */ \
|
||||||
if (ED_gpencil_stroke_color_use(obact_, gpl, gps) == false) \
|
if (ED_gpencil_stroke_color_use(obact_, gpl, gps) == false) \
|
||||||
continue; \
|
continue; \
|
||||||
/* ... Do Stuff With Strokes ... */
|
/* ... Do Stuff With Strokes ... */
|
||||||
|
|
||||||
#define GP_EDITABLE_STROKES_END \
|
#define GP_EDITABLE_STROKES_END(gpstroke_iter) \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
if (!is_multiedit) { \
|
if (!is_multiedit_) { \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -1001,12 +1001,12 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
|
|
||||||
/* find visible strokes, and select if hit */
|
/* find visible strokes, and select if hit */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
changed |= gp_stroke_do_circle_sel(
|
changed |= gp_stroke_do_circle_sel(
|
||||||
gps, &gsc, mx, my, radius, select, &rect, diff_mat, selectmode);
|
gps, &gsc, mx, my, radius, select, &rect, gpstroke_iter.diff_mat, selectmode);
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
/* updates */
|
/* updates */
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@ -1099,7 +1099,7 @@ static int gpencil_generic_select_exec(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* select/deselect points */
|
/* select/deselect points */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
|
|
||||||
bGPDspoint *pt;
|
bGPDspoint *pt;
|
||||||
@ -1107,7 +1107,7 @@ static int gpencil_generic_select_exec(
|
|||||||
bool hit = false;
|
bool hit = false;
|
||||||
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
|
||||||
/* convert point coords to screenspace */
|
/* convert point coords to screenspace */
|
||||||
const bool is_inside = is_inside_fn(gps, pt, &gsc, diff_mat, user_data);
|
const bool is_inside = is_inside_fn(gps, pt, &gsc, gpstroke_iter.diff_mat, user_data);
|
||||||
|
|
||||||
if (strokemode == false) {
|
if (strokemode == false) {
|
||||||
const bool is_select = (pt->flag & GP_SPOINT_SELECT) != 0;
|
const bool is_select = (pt->flag & GP_SPOINT_SELECT) != 0;
|
||||||
@ -1146,7 +1146,7 @@ static int gpencil_generic_select_exec(
|
|||||||
/* Ensure that stroke selection is in sync with its points */
|
/* Ensure that stroke selection is in sync with its points */
|
||||||
BKE_gpencil_stroke_sync_selection(gps);
|
BKE_gpencil_stroke_sync_selection(gps);
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
/* if paint mode,delete selected points */
|
/* if paint mode,delete selected points */
|
||||||
if (gpd->flag & GP_DATA_STROKE_PAINTMODE) {
|
if (gpd->flag & GP_DATA_STROKE_PAINTMODE) {
|
||||||
@ -1341,7 +1341,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
/* First Pass: Find stroke point which gets hit */
|
/* First Pass: Find stroke point which gets hit */
|
||||||
/* XXX: maybe we should go from the top of the stack down instead... */
|
/* XXX: maybe we should go from the top of the stack down instead... */
|
||||||
GP_EDITABLE_STROKES_BEGIN(C, gpl, gps)
|
GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||||
{
|
{
|
||||||
bGPDspoint *pt;
|
bGPDspoint *pt;
|
||||||
int i;
|
int i;
|
||||||
@ -1351,7 +1351,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
|
|||||||
int xy[2];
|
int xy[2];
|
||||||
|
|
||||||
bGPDspoint pt2;
|
bGPDspoint pt2;
|
||||||
gp_point_to_parent_space(pt, diff_mat, &pt2);
|
gp_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
|
||||||
gp_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
|
gp_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
|
||||||
|
|
||||||
/* do boundbox check first */
|
/* do boundbox check first */
|
||||||
@ -1370,7 +1370,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GP_EDITABLE_STROKES_END;
|
GP_EDITABLE_STROKES_END(gpstroke_iter);
|
||||||
|
|
||||||
/* Abort if nothing hit... */
|
/* Abort if nothing hit... */
|
||||||
if (ELEM(NULL, hit_stroke, hit_point)) {
|
if (ELEM(NULL, hit_stroke, hit_point)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user