[Bf-blender-cvs] [2e64865c51f] greasepencil-object: Cleanup: Various fixes
Joshua Leung
noreply at git.blender.org
Wed Jan 31 06:30:39 CET 2018
Commit: 2e64865c51fa2624db0174b44ed641bd7cdb082f
Author: Joshua Leung
Date: Wed Jan 31 18:30:29 2018 +1300
Branches: greasepencil-object
https://developer.blender.org/rB2e64865c51fa2624db0174b44ed641bd7cdb082f
Cleanup: Various fixes
* Remove redundant operations (e.g. extra copies of data)
* Remove duplicate functions (e.g. vector copying, for non-floats)
TODO: We still have copy_v2int_v2float() and copy_v2float_v2int()
to fix (i.e. rename + move to BLI_math.h)
* Cleanup redundant struct forward defs in headers (including some duplicates)
* Hacky fix for compiler warning in gpencil_colorpick.c (about const vs non-const)
UI_FSTYLE_WIDGET is const, but UI_text_clip_middle_ex() needs non-const
===================================================================
M source/blender/editors/gpencil/drawgpencil.c
M source/blender/editors/gpencil/gpencil_colorpick.c
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/editors/gpencil/gpencil_intern.h
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/editors/include/ED_gpencil.h
===================================================================
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index ecccd05650e..e3438527b4b 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1913,6 +1913,7 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm,
int offsx, offsy, winx, winy;
/* check that we have grease-pencil stuff to draw */
+ // XXX: This is the only place that still uses this function
bGPdata *gpd = ED_gpencil_data_get_active_v3d(scene, view_layer);
if (gpd == NULL) return;
@@ -1960,7 +1961,8 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm,
}
/* draw grease-pencil sketches to specified 3d-view for gp object
-* assuming that matrices are already set correctly */
+ * assuming that matrices are already set correctly
+ */
void ED_gpencil_draw_view3d_object(wmWindowManager *wm, Scene *scene, const struct Depsgraph *depsgraph, Object *ob, View3D *v3d, ARegion *ar, bool only3d)
{
int dflag = 0;
diff --git a/source/blender/editors/gpencil/gpencil_colorpick.c b/source/blender/editors/gpencil/gpencil_colorpick.c
index 4bae928791f..f700dd77547 100644
--- a/source/blender/editors/gpencil/gpencil_colorpick.c
+++ b/source/blender/editors/gpencil/gpencil_colorpick.c
@@ -79,7 +79,7 @@
#define GP_BOX_GAP (18 * U.ui_scale)
/* draw color name using default font */
-static void gp_draw_color_name(tGPDpick *tgpk, tGPDpickColor *col, const uiFontStyle *fstyle, bool focus)
+static void gp_draw_color_name(tGPDpick *tgpk, tGPDpickColor *col, uiFontStyle *fstyle, bool focus)
{
bTheme *btheme = UI_GetTheme();
uiWidgetColors menuBack = btheme->tui.wcol_menu_back;
@@ -127,7 +127,7 @@ static void gpencil_draw_color_table(const bContext *UNUSED(C), tGPDpick *tgpk)
if (!tgpk->palette) {
return;
}
- const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+ uiFontStyle *fstyle = (uiFontStyle *)UI_FSTYLE_WIDGET; /* XXX: was const, but drawfuncs expect modifable */
float ink[4];
float line[4];
float radius = (0.4f * U.widget_unit);
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 4efe907968e..98912bac97b 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -564,13 +564,6 @@ static void gpencil_clean_borders(tGPDfill *tgpf)
tgpf->ima->id.tag |= LIB_TAG_DOIT;
}
-/* helper to copy points 2D */
-static void copyint_v2_v2(int r[2], const int a[2])
-{
- r[0] = a[0];
- r[1] = a[1];
-}
-
/* Get the outline points of a shape using Moore Neighborhood algorithm
*
* This is a Blender customized version of the general algorithm described
@@ -614,12 +607,12 @@ static void gpencil_get_outline_points(tGPDfill *tgpf)
if (rgba[1] == 1.0f) {
boundary_co[0] = idx % ibuf->x;
boundary_co[1] = idx / ibuf->x;
- copyint_v2_v2(start_co, boundary_co);
+ copy_v2_v2_int(start_co, boundary_co);
backtracked_co[0] = (idx - 1) % ibuf->x;
backtracked_co[1] = (idx - 1) / ibuf->x;
backtracked_offset[0][0] = backtracked_co[0] - boundary_co[0];
backtracked_offset[0][1] = backtracked_co[1] - boundary_co[1];
- copyint_v2_v2(prev_check_co, start_co);
+ copy_v2_v2_int(prev_check_co, start_co);
BLI_stack_push(tgpf->stack, &boundary_co);
start_found = true;
@@ -651,8 +644,8 @@ static void gpencil_get_outline_points(tGPDfill *tgpf)
/* find next boundary pixel */
if (rgba[1] == 1.0f) {
- copyint_v2_v2(boundary_co, current_check_co);
- copyint_v2_v2(backtracked_co, prev_check_co);
+ copy_v2_v2_int(boundary_co, current_check_co);
+ copy_v2_v2_int(backtracked_co, prev_check_co);
backtracked_offset[0][0] = backtracked_co[0] - boundary_co[0];
backtracked_offset[0][1] = backtracked_co[1] - boundary_co[1];
@@ -660,7 +653,7 @@ static void gpencil_get_outline_points(tGPDfill *tgpf)
break;
}
- copyint_v2_v2(prev_check_co, current_check_co);
+ copy_v2_v2_int(prev_check_co, current_check_co);
cur_back_offset++;
loop++;
}
@@ -777,7 +770,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
bGPDspoint *pt;
tGPspoint *point2D;
- float r_out[3];
+
if (tgpf->sbuffer_size == 0) {
return;
}
@@ -824,8 +817,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
gp_stroke_convertcoords_tpoint(tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob,
tgpf->gpl, point2D,
tgpf->depth_arr ? tgpf->depth_arr + i : NULL,
- r_out);
- copy_v3_v3(&pt->x, r_out);
+ &pt->x);
pt->pressure = 1.0f;
pt->strength = 1.0f;;
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index df10cedc658..054a0e5bd72 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -43,6 +43,7 @@ struct bGPDstroke;
struct bGPDspoint;
struct tGPspoint;
+struct BLI_Stack;
struct GHash;
struct Scene;
@@ -50,6 +51,7 @@ struct ARegion;
struct View3D;
struct View2D;
struct wmOperatorType;
+struct Image;
struct PointerRNA;
struct PropertyRNA;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index b72e9f09404..aa8a2920aed 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -277,18 +277,14 @@ static void gp_get_3d_reference(tGPsdata *p, float vec[3])
ED_gp_get_drawing_reference(v3d, p->scene, ob, p->gpl, *p->align_flag, vec);
}
-static void copy_v2int_v2int(int r[2], const int a[2])
-{
- r[0] = (int)roundf(a[0]);
- r[1] = (int)roundf(a[1]);
-}
-
+// XXX: Rename and move to BLI_math_vector.h
static void copy_v2int_v2float(int r[2], const float a[2])
{
r[0] = (int)roundf(a[0]);
r[1] = (int)roundf(a[1]);
}
+// XXX: Rename and move to BLI_math_vector.h
static void copy_v2float_v2int(float r[2], const int a[2])
{
r[0] = (float)a[0];
@@ -317,7 +313,7 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
else {
/* If the mouse is moving within the radius of the last move,
* don't update the mouse position. This allows sharp turns. */
- copy_v2int_v2int(p->mval, p->mvalo);
+ copy_v2_v2_int(p->mval, p->mvalo);
return false;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 74f6ae751a5..e8650e60cb4 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -210,12 +210,15 @@ bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene, ViewLayer *view_layer)
{
Base *base = view_layer->basact;
bGPdata *gpd = NULL;
+
/* We have to make sure active object is actually visible and selected, else we must use default scene gpd,
* to be consistent with ED_gpencil_data_get_active's behavior.
*/
-
if (base && TESTBASE(base)) {
- gpd = base->object->gpd;
+ if (base->object->type == OB_GPENCIL)
+ gpd = base->object->data;
+ else
+ gpd = base->object->gpd;
}
return gpd ? gpd : scene->gpd;
}
@@ -805,6 +808,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
* to 3D coordinates.
*
* \param point2D: The screenspace 2D point data to convert
+ * \param depth: Depth array (via ED_view3d_autodist_depth())
* \param[out] r_out: The resulting 2D point data
*/
void gp_stroke_convertcoords_tpoint(
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index a3f4be72a3b..9c6cf8e1cf9 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -32,38 +32,37 @@
struct ID;
struct ListBase;
-struct bContext;
-struct Depsgraph;
-struct ScrArea;
-struct ARegion;
-struct bAnimContext;
-struct wmOperator;
+struct PointerRNA;
+struct rcti;
+
struct bGPdata;
struct bGPDlayer;
struct bGPDframe;
struct bGPDstroke;
-struct bGPDpalette;
-struct bGPDpalettecolor;
struct bGPDspoint;
-struct tGPDdraw;
-struct Image;
-struct BLI_Stack;
-struct KeyframeEditData;
-struct Object;
-struct Palette;
-struct PaletteColor;
-struct PointerRNA;
+
+struct bContext;
+struct EvaluationContext;
+struct Depsgraph;
+struct ScrArea;
+struct ARegion;
struct RegionView3D;
-struct ToolSettings;
-struct View3D;
struct Scene;
+struct ToolSettings;
struct ViewLayer;
-struct wmWindowManager;
+struct View3D;
+
+struct Object;
+struct Palette;
+struct PaletteColor;
+
+struct bAnimContext;
+struct KeyframeEditData;
+
struct wmKeyConfig;
-struct wmWindowManager;
-struct EvaluationContext;
+struct wmOperator;
struct wmWindow;
-struct rcti;
+struct wmWindowManager;
struct tGPDdraw;
struct tGPDinterpolate;
More information about the Bf-blender-cvs
mailing list