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>2018-10-05 00:27:34 +0300
committerAntonioya <blendergit@gmail.com>2018-10-05 00:27:34 +0300
commit3a1e9b9997e33c059d08138da707ac16490fddf7 (patch)
tree770b8bf9c30d10ee4a0866e7f62b5e4cf23f79bc /source/blender
parent65f77ccea1645f8c66fc171377641b08b62010e0 (diff)
GP: Move grid parameters to GP object data level
The grid now can be configured by object because this helps to identify objects and allows to define diferent grid parameters for each objects. Also added a color option.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/gpencil.c6
-rw-r--r--source/blender/blenloader/intern/versioning_280.c50
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c28
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c3
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h20
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h11
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c36
-rw-r--r--source/blender/makesrna/intern/rna_space.c28
10 files changed, 89 insertions, 97 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index d22c7c8808f..1f27c146399 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -467,6 +467,12 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
gpd->runtime.batch_cache_data = NULL;
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
+ /* grid settings */
+ ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); // Color
+ ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); // Scale
+ gpd->grid.lines = GP_DEFAULT_GRID_LINES; // Number of lines
+ gpd->grid.axis = V3D_GP_GRID_AXIS_Y;
+
/* onion-skinning settings (datablock level) */
gpd->onion_flag |= (GP_ONION_GHOST_PREVCOL | GP_ONION_GHOST_NEXTCOL);
gpd->onion_flag |= GP_ONION_FADE;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 5392e1dd4e8..466513d91bb 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1151,10 +1151,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
- ARRAY_SET_ITEMS(v3d->overlay.gpencil_grid_scale, 1.0f, 1.0f); // Scale
- v3d->overlay.gpencil_grid_lines = GP_DEFAULT_GRID_LINES; // NUmber of lines
v3d->overlay.gpencil_paper_opacity = 0.5f;
- v3d->overlay.gpencil_grid_axis = V3D_GP_GRID_AXIS_Y;
v3d->overlay.gpencil_grid_opacity = 0.9f;
}
}
@@ -1925,18 +1922,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_scale")) {
- for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- ARRAY_SET_ITEMS(v3d->overlay.gpencil_grid_scale, 1.0f, 1.0f);
- }
- }
- }
- }
- }
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
@@ -1961,30 +1946,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "gpencil_grid_axis")) {
- for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.gpencil_grid_axis = V3D_GP_GRID_AXIS_Y;
- }
- }
- }
- }
- }
- if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", "gpencil_grid_lines")) {
- for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
- if (sl->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)sl;
- v3d->overlay.gpencil_grid_lines = GP_DEFAULT_GRID_LINES;
- }
- }
- }
- }
- }
+
/* default loc axis */
if (!DNA_struct_elem_find(fd->filesdna, "GP_BrushEdit_Settings", "int", "lock_axis")) {
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
@@ -2192,5 +2154,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
unit->time_unit = bUnit_GetBaseUnitOfType(USER_UNIT_NONE, B_UNIT_TIME);
}
+
+ /* gpencil grid settings */
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+ ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); // Color
+ ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f); // Scale
+ gpd->grid.lines = GP_DEFAULT_GRID_LINES; // Number of lines
+ gpd->grid.axis = V3D_GP_GRID_AXIS_Y;
+ }
+
+
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 3edeb78fbdc..9e0e8c919e2 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -643,36 +643,38 @@ static void set_grid_point(
}
/* Draw grid lines */
-GPUBatch *DRW_gpencil_get_grid(void)
+GPUBatch *DRW_gpencil_get_grid(Object *ob)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
ToolSettings *ts = scene->toolsettings;
View3D *v3d = draw_ctx->v3d;
- const bool do_center = (v3d->overlay.gpencil_grid_lines <= 0) ? false : true;
+ bGPdata *gpd = (bGPdata *)ob->data;
+ const bool do_center = (gpd->grid.lines <= 0) ? false : true;
float col_grid[4];
/* verify we have something to draw and valid values */
- if (v3d->overlay.gpencil_grid_scale[0] == 0.0f) {
- v3d->overlay.gpencil_grid_scale[0] = 1.0f;
+ if (gpd->grid.scale[0] == 0.0f) {
+ gpd->grid.scale[0] = 1.0f;
}
- if (v3d->overlay.gpencil_grid_scale[1] == 0.0f) {
- v3d->overlay.gpencil_grid_scale[1] = 1.0f;
+ if (gpd->grid.scale[1] == 0.0f) {
+ gpd->grid.scale[1] = 1.0f;
}
if (v3d->overlay.gpencil_grid_opacity < 0.1f) {
v3d->overlay.gpencil_grid_opacity = 0.1f;
}
- UI_GetThemeColor3fv(TH_GRID, col_grid);
+ /* set color */
+ copy_v3_v3(col_grid, gpd->grid.color);
col_grid[3] = v3d->overlay.gpencil_grid_opacity;
/* if use locked axis, copy value */
- int axis = v3d->overlay.gpencil_grid_axis;
- if ((v3d->overlay.gpencil_grid_axis & V3D_GP_GRID_AXIS_LOCK) == 0) {
+ int axis = gpd->grid.axis;
+ if ((gpd->grid.axis & V3D_GP_GRID_AXIS_LOCK) == 0) {
- axis = v3d->overlay.gpencil_grid_axis;
+ axis = gpd->grid.axis;
}
else {
switch (ts->gp_sculpt.lock_axis) {
@@ -696,9 +698,9 @@ GPUBatch *DRW_gpencil_get_grid(void)
}
const char *grid_unit = NULL;
- const int gridlines = (v3d->overlay.gpencil_grid_lines <= 0) ? 1 : v3d->overlay.gpencil_grid_lines;
- const float grid_w = v3d->overlay.gpencil_grid_scale[0] * ED_scene_grid_scale(scene, &grid_unit);
- const float grid_h = v3d->overlay.gpencil_grid_scale[1] * ED_scene_grid_scale(scene, &grid_unit);
+ const int gridlines = (gpd->grid.lines <= 0) ? 1 : gpd->grid.lines;
+ const float grid_w = gpd->grid.scale[0] * ED_scene_grid_scale(scene, &grid_unit);
+ const float grid_h = gpd->grid.scale[1] * ED_scene_grid_scale(scene, &grid_unit);
const float space_w = (grid_w / gridlines);
const float space_h = (grid_h / gridlines);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index bc545a1db80..0b318bd974e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -606,7 +606,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
GPU_BATCH_DISCARD_SAFE(e_data.batch_grid);
MEM_SAFE_FREE(e_data.batch_grid);
- e_data.batch_grid = DRW_gpencil_get_grid();
+ e_data.batch_grid = DRW_gpencil_get_grid(ob);
DRW_shgroup_call_add(
stl->g_data->shgrps_grid,
e_data.batch_grid,
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 89a50170eb6..df051f4697b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -316,7 +316,7 @@ struct GPUBatch *DRW_gpencil_get_edlin_geom(struct bGPDstroke *gps, float alpha,
struct GPUBatch *DRW_gpencil_get_buffer_stroke_geom(struct bGPdata *gpd, short thickness);
struct GPUBatch *DRW_gpencil_get_buffer_fill_geom(struct bGPdata *gpd);
struct GPUBatch *DRW_gpencil_get_buffer_point_geom(struct bGPdata *gpd, short thickness);
-struct GPUBatch *DRW_gpencil_get_grid(void);
+struct GPUBatch *DRW_gpencil_get_grid(Object *ob);
/* object cache functions */
struct tGPencilObjectCache *gpencil_object_cache_add(
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c7f02f3c74c..f1394933c26 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -350,10 +350,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->near = 0.01f;
v3d->far = 1000.0f;
- ARRAY_SET_ITEMS(v3d->overlay.gpencil_grid_scale, 1.0f, 1.0f); // Scales
- v3d->overlay.gpencil_grid_lines = GP_DEFAULT_GRID_LINES; // NUmber of Lines
v3d->overlay.gpencil_paper_opacity = 0.5f;
- v3d->overlay.gpencil_grid_axis = V3D_GP_GRID_AXIS_Y;
v3d->overlay.gpencil_grid_opacity = 0.9f;
v3d->bundle_size = 0.2f;
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index b533cb48886..d991bb34a0a 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -39,7 +39,6 @@ struct CurveMapping;
struct GHash;
struct MDeformVert;
-/* TODO: add size as userprefs parameter */
#define GP_OBGPENCIL_DEFAULT_SIZE 0.2f
#define GP_DEFAULT_PIX_FACTOR 1.0f
#define GP_DEFAULT_GRID_LINES 4
@@ -325,6 +324,16 @@ typedef struct bGPdata_runtime {
char pad_[6];
} bGPdata_runtime;
+/* grid configuration */
+typedef struct bGPgrid {
+ float color[3];
+ float scale[2];
+ char _pad1[4];
+
+ int lines;
+ int axis;
+} bGPgrid;
+
/* Grease-Pencil Annotations - 'DataBlock' */
typedef struct bGPdata {
ID id; /* Grease Pencil data is a datablock */
@@ -366,6 +375,7 @@ typedef struct bGPdata {
int totpoint;
char pad_3[4];
bGPdata_runtime runtime;
+ bGPgrid grid;
} bGPdata;
/* bGPdata->flag */
@@ -461,6 +471,14 @@ typedef enum eGP_DepthOrdering {
GP_XRAY_BACK = 2
} eGP_DepthOrdering;
+/* gpencil_grid_axis */
+enum {
+ V3D_GP_GRID_AXIS_LOCK = (1 << 0),
+ V3D_GP_GRID_AXIS_X = (1 << 1),
+ V3D_GP_GRID_AXIS_Y = (1 << 2),
+ V3D_GP_GRID_AXIS_Z = (1 << 3),
+};
+
/* ***************************************** */
/* Mode Checking Macros */
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 7876153cbce..1b8846df4bc 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -190,10 +190,7 @@ typedef struct View3DOverlay {
float wireframe_threshold;
/* grease pencil settings */
- float gpencil_grid_scale[2];
float gpencil_paper_opacity;
- int gpencil_grid_lines;
- int gpencil_grid_axis;
float gpencil_grid_opacity;
char _pad1[4];
@@ -518,12 +515,4 @@ enum {
#define RV3D_CAMZOOM_MIN_FACTOR 0.1657359312880714853f
#define RV3D_CAMZOOM_MAX_FACTOR 44.9852813742385702928f
-/* View3d.gpencil_grid_axis */
-enum {
- V3D_GP_GRID_AXIS_LOCK = (1 << 0),
- V3D_GP_GRID_AXIS_X = (1 << 1),
- V3D_GP_GRID_AXIS_Y = (1 << 2),
- V3D_GP_GRID_AXIS_Z = (1 << 3),
-};
-
#endif
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 0cd738a9552..02419237a9e 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -71,6 +71,14 @@ static EnumPropertyItem rna_enum_gpencil_onion_modes_items[] = {
{ GP_ONION_MODE_SELECTED, "SELECTED", 0, "Selected", "Only Selected Frames" },
{ 0, NULL, 0, NULL, NULL }
};
+
+static const EnumPropertyItem rna_enum_gpencil_grid_axis_items[] = {
+ {V3D_GP_GRID_AXIS_LOCK, "LOCK", 0, "Drawing Plane", "Use current drawing locked axis" },
+ {V3D_GP_GRID_AXIS_X, "X", 0, "Y-Z", ""},
+ {V3D_GP_GRID_AXIS_Y, "Y", 0, "X-Z", ""},
+ {V3D_GP_GRID_AXIS_Z, "Z", 0, "X-Y", ""},
+ {0, NULL, 0, NULL, NULL}
+};
#endif
#ifdef RNA_RUNTIME
@@ -1412,6 +1420,34 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
"Offset amount when drawing in surface mode");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ /* grid config */
+ prop = RNA_def_property(srna, "grid_scale", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_float_sdna(prop, NULL, "grid.scale");
+ RNA_def_property_range(prop, 0.01f, FLT_MAX);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Grid Scale", "Grid scale");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "grid_color", PROP_FLOAT, PROP_COLOR_GAMMA);
+ RNA_def_property_float_sdna(prop, NULL, "grid.color");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Grid Color", "Color for grid lines");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+ prop = RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "grid.lines");
+ RNA_def_property_range(prop, 0, INT_MAX);
+ RNA_def_property_int_default(prop, GP_DEFAULT_GRID_LINES);
+ RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions in each side of symmetry line");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "grid_axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "grid.axis");
+ RNA_def_property_enum_items(prop, rna_enum_gpencil_grid_axis_items);
+ RNA_def_property_ui_text(prop, "Canvas Plane", "Axis to display grid");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
/* API Functions */
func = RNA_def_function(srna, "clear", "rna_GPencil_clear");
RNA_def_function_ui_description(func, "Remove all the grease pencil data");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index fdf16ce37de..6fdfd06a9a0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -310,14 +310,6 @@ const EnumPropertyItem rna_enum_file_sort_items[] = {
{0, NULL, 0, NULL, NULL}
};
-static const EnumPropertyItem rna_enum_gpencil_grid_axis_items[] = {
- {V3D_GP_GRID_AXIS_LOCK, "LOCK", 0, "Drawing Plane", "Use current drawing locked axis" },
- {V3D_GP_GRID_AXIS_X, "X", 0, "Y-Z", ""},
- {V3D_GP_GRID_AXIS_Y, "Y", 0, "X-Z", ""},
- {V3D_GP_GRID_AXIS_Z, "Z", 0, "X-Y", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
#ifdef RNA_RUNTIME
#include "DNA_anim_types.h"
@@ -2961,26 +2953,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
"Display a grid over grease pencil paper");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "gpencil_grid_scale", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_grid_scale");
- RNA_def_property_range(prop, 0.01f, FLT_MAX);
- RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Scale", "Grid scale");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "gpencil_grid_lines", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "overlay.gpencil_grid_lines");
- RNA_def_property_range(prop, 0, INT_MAX);
- RNA_def_property_int_default(prop, GP_DEFAULT_GRID_LINES);
- RNA_def_property_ui_text(prop, "Subdivisions", "Number of subdivisions in each side of symmetry line");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "gpencil_grid_axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "overlay.gpencil_grid_axis");
- RNA_def_property_enum_items(prop, rna_enum_gpencil_grid_axis_items);
- RNA_def_property_ui_text(prop, "Canvas Plane", "Axis to display grid");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
prop = RNA_def_property(srna, "gpencil_grid_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_grid_opacity");
RNA_def_property_range(prop, 0.1f, 1.0f);