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-11-04 15:00:19 +0300
committerAntonioya <blendergit@gmail.com>2018-11-04 15:00:37 +0300
commit5cfcee8c393de6781423c9ef83716c94237fddfd (patch)
treeee6722664cc4f00c0f79058de878030ae42afdc6 /source/blender
parentd3c815bd0831f46c18bb4bddc9f290b5f47e2c45 (diff)
GP: Reorganize Canvas Grid
Now the grid is always controlled by the topbar selector and not in the canvas panel. To have two places to define orientation was confuse. The orientation by default (no lock) is always to view plane.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/gpencil.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c1
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c79
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c18
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h2
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c2
-rw-r--r--source/blender/makesdna/DNA_gpencil_types.h10
-rw-r--r--source/blender/makesdna/DNA_scene_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c13
-rw-r--r--source/blender/makesrna/intern/rna_sculpt_paint.c8
12 files changed, 62 insertions, 80 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 63d7f3697f0..c540d6e0c35 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -457,7 +457,6 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
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 = GP_GRID_AXIS_Y;
/* onion-skinning settings (datablock level) */
gpd->onion_flag |= (GP_ONION_GHOST_PREVCOL | GP_ONION_GHOST_NEXTCOL);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 7243cb5b522..c470a3a6d96 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2170,7 +2170,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
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 = 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 8e7d16e60ba..d388b617d60 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -615,29 +615,45 @@ GPUBatch *DRW_gpencil_get_edlin_geom(bGPDstroke *gps, float alpha, short UNUSED(
static void set_grid_point(
GPUVertBuf *vbo, int idx, float col_grid[4],
uint pos_id, uint color_id,
- float v1, float v2, int axis)
+ float v1, float v2, const int axis)
{
GPU_vertbuf_attr_set(vbo, color_id, idx, col_grid);
float pos[3];
- /* Set the grid in the selected axis (default is always Y axis) */
- if (axis & GP_GRID_AXIS_X) {
- pos[0] = 0.0f;
- pos[1] = v1;
- pos[2] = v2;
- }
- else if (axis & GP_GRID_AXIS_Z) {
- pos[0] = v1;
- pos[1] = v2;
- pos[2] = 0.0f;
- }
- else {
- pos[0] = v1;
- pos[1] = 0.0f;
- pos[2] = v2;
- }
-
+ /* Set the grid in the selected axis */
+ switch (axis)
+ {
+ case GP_LOCKAXIS_X:
+ {
+ pos[0] = 0.0f;
+ pos[1] = v1;
+ pos[2] = v2;
+ break;
+ }
+ case GP_LOCKAXIS_Y:
+ {
+ pos[0] = v1;
+ pos[1] = 0.0f;
+ pos[2] = v2;
+ break;
+ }
+ case GP_LOCKAXIS_Z:
+ {
+ pos[0] = v1;
+ pos[1] = v2;
+ pos[2] = 0.0f;
+ break;
+ }
+ default:
+ {
+ /* aligned to view */
+ pos[0] = v1;
+ pos[1] = v2;
+ pos[2] = 0.0f;
+ break;
+ }
+ }
GPU_vertbuf_attr_set(vbo, pos_id, idx, pos);
}
@@ -670,32 +686,7 @@ GPUBatch *DRW_gpencil_get_grid(Object *ob)
copy_v3_v3(col_grid, gpd->grid.color);
col_grid[3] = v3d->overlay.gpencil_grid_opacity;
- /* if use locked axis, copy value */
- int axis = gpd->grid.axis;
- if ((gpd->grid.axis & GP_GRID_AXIS_LOCK) == 0) {
-
- axis = gpd->grid.axis;
- }
- else {
- switch (ts->gp_sculpt.lock_axis) {
- case GP_LOCKAXIS_X:
- {
- axis = GP_GRID_AXIS_X;
- break;
- }
- case GP_LOCKAXIS_NONE:
- case GP_LOCKAXIS_Y:
- {
- axis = GP_GRID_AXIS_Y;
- break;
- }
- case GP_LOCKAXIS_Z:
- {
- axis = GP_GRID_AXIS_Z;
- break;
- }
- }
- }
+ const int axis = ts->gp_sculpt.lock_axis;
const char *grid_unit = NULL;
const int gridlines = (gpd->grid.lines <= 0) ? 1 : gpd->grid.lines;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index ba64288d147..9308bdbd084 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -598,10 +598,22 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
MEM_SAFE_FREE(e_data.batch_grid);
e_data.batch_grid = DRW_gpencil_get_grid(ob);
+
+ /* define grid orientation */
+ if (ts->gp_sculpt.lock_axis != GP_LOCKAXIS_VIEW) {
+ copy_m4_m4(stl->storage->grid_matrix, ob->obmat);
+ }
+ else {
+ /* align always to view */
+ invert_m4_m4(stl->storage->grid_matrix, draw_ctx->rv3d->viewmat);
+ /* copy ob location */
+ copy_v3_v3(stl->storage->grid_matrix[3], ob->obmat[3]);
+ }
+
DRW_shgroup_call_add(
- stl->g_data->shgrps_grid,
- e_data.batch_grid,
- ob->obmat);
+ stl->g_data->shgrps_grid,
+ e_data.batch_grid,
+ stl->storage->grid_matrix);
}
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index e2e6bf4edf0..8e68fdef952 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -134,6 +134,8 @@ typedef struct GPENCIL_Storage {
float winmat[4][4], wininv[4][4];
float view_vecs[2][4]; /* vec4[2] */
+ float grid_matrix[4][4];
+
Object *camera; /* camera pointer for render mode */
} GPENCIL_Storage;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index d8580f872f4..12dc3451902 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2866,7 +2866,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
int lock_axis = ts->gp_sculpt.lock_axis;
float origin[3];
- if ((mode == GP_REPROJECT_AXIS) && (lock_axis == GP_LOCKAXIS_NONE)) {
+ if ((mode == GP_REPROJECT_AXIS) && (lock_axis == GP_LOCKAXIS_VIEW)) {
BKE_report(op->reports, RPT_ERROR, "To reproject by axis, a lock axis must be set before");
return OPERATOR_CANCELLED;
}
@@ -2909,7 +2909,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* Project stroke in the axis locked */
if (mode == GP_REPROJECT_AXIS) {
- if (lock_axis > GP_LOCKAXIS_NONE) {
+ if (lock_axis > GP_LOCKAXIS_VIEW) {
ED_gp_get_drawing_reference(v3d, scene, ob, gpl,
ts->gpencil_v3d_align, origin);
ED_gp_project_point_to_plane(ob, rv3d, origin,
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index f940b18dac6..9b6a36ce8af 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -918,7 +918,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
}
/* if axis locked, reproject to plane locked */
- if ((tgpf->lock_axis > GP_LOCKAXIS_NONE) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0)) {
+ if ((tgpf->lock_axis > GP_LOCKAXIS_VIEW) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0)) {
float origin[3];
ED_gp_get_drawing_reference(
tgpf->v3d, tgpf->scene, tgpf->ob, tgpf->gpl,
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index baa8bc5d181..338fb7f5c6a 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -369,7 +369,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
/* if axis locked, reproject to plane locked */
- if (tgpi->lock_axis > GP_LOCKAXIS_NONE) {
+ if (tgpi->lock_axis > GP_LOCKAXIS_VIEW) {
bGPDspoint *tpt = gps->points;
float origin[3];
ED_gp_get_drawing_reference(tgpi->v3d, tgpi->scene, tgpi->ob, tgpi->gpl,
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 42070839fac..fcaf8b00cde 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -335,7 +335,7 @@ typedef struct bGPgrid {
char _pad1[4];
int lines;
- int axis;
+ char pad_[4];
} bGPgrid;
/* Grease-Pencil Annotations - 'DataBlock' */
@@ -480,14 +480,6 @@ typedef enum eGP_DepthOrdering {
GP_XRAY_BACK = 2
} eGP_DepthOrdering;
-/* gpencil_grid_axis */
-enum {
- GP_GRID_AXIS_LOCK = (1 << 0),
- GP_GRID_AXIS_X = (1 << 1),
- GP_GRID_AXIS_Y = (1 << 2),
- GP_GRID_AXIS_Z = (1 << 3),
-};
-
/* ***************************************** */
/* Mode Checking Macros */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 31627760aa3..795a48532ce 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -973,7 +973,7 @@ typedef enum eGP_EditBrush_Types {
/* GP_BrushEdit_Settings.lock_axis */
typedef enum eGP_Lockaxis_Types {
- GP_LOCKAXIS_NONE = 0,
+ GP_LOCKAXIS_VIEW = 0,
GP_LOCKAXIS_X = 1,
GP_LOCKAXIS_Y = 2,
GP_LOCKAXIS_Z = 3
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index c6bf4317064..1dbca8b27c9 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -72,13 +72,6 @@ static EnumPropertyItem rna_enum_gpencil_onion_modes_items[] = {
{ 0, NULL, 0, NULL, NULL }
};
-static const EnumPropertyItem rna_enum_gpencil_grid_axis_items[] = {
- {GP_GRID_AXIS_LOCK, "LOCK", 0, "Drawing Plane", "Use current drawing locked axis" },
- {GP_GRID_AXIS_X, "X", 0, "Y-Z", ""},
- {GP_GRID_AXIS_Y, "Y", 0, "X-Z", ""},
- {GP_GRID_AXIS_Z, "Z", 0, "X-Y", ""},
- {0, NULL, 0, NULL, NULL}
-};
#endif
#ifdef RNA_RUNTIME
@@ -1332,12 +1325,6 @@ static void rna_def_gpencil_grid(BlenderRNA *brna)
RNA_def_property_array(prop, 2);
RNA_def_property_ui_text(prop, "Offset", "Offset of the canvas");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
-
- prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "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_GPENCIL | ND_DATA, "rna_GPencil_update");
}
static void rna_def_gpencil_data(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index ed60e90c033..d3ff9d94a23 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -84,10 +84,10 @@ static EnumPropertyItem rna_enum_gpencil_weight_brush_items[] = {
};
static const EnumPropertyItem rna_enum_gpencil_lock_axis_items[] = {
- { GP_LOCKAXIS_NONE, "GP_LOCKAXIS_NONE", ICON_UNLOCKED, "None", "" },
- { GP_LOCKAXIS_X, "GP_LOCKAXIS_X", ICON_AXIS_SIDE, "Y-Z Plane", "Project strokes to plane locked to X" },
- { GP_LOCKAXIS_Y, "GP_LOCKAXIS_Y", ICON_AXIS_FRONT, "X-Z Plane", "Project strokes to plane locked to Y" },
- { GP_LOCKAXIS_Z, "GP_LOCKAXIS_Z", ICON_AXIS_TOP, "X-Y Plane", "Project strokes to plane locked to Z" },
+ { GP_LOCKAXIS_VIEW, "VIEW", ICON_UNLOCKED, "View", "" },
+ { GP_LOCKAXIS_X, "AXIS_X", ICON_AXIS_SIDE, "Y-Z Plane", "Project strokes to plane locked to X" },
+ { GP_LOCKAXIS_Y, "AXIS_Y", ICON_AXIS_FRONT, "X-Z Plane", "Project strokes to plane locked to Y" },
+ { GP_LOCKAXIS_Z, "AXIS_Z", ICON_AXIS_TOP, "X-Y Plane", "Project strokes to plane locked to Z" },
{ 0, NULL, 0, NULL, NULL }
};
#endif