GP: Add z-depth offset parameter
This parameter allows to define the percentage of offset of a stroke when uses surface mode. Before, this was a fixed value, but for some artists' purposes, it's good to have the option to change it.
This commit is contained in:
parent
2d21eb79ad
commit
8d26705b3e
|
@ -344,6 +344,7 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
|
|||
layout.prop(gpd, "show_stroke_direction", text="Show Stroke Directions")
|
||||
|
||||
layout.prop(gpd, "use_force_fill_recalc", text="Force Fill Update")
|
||||
layout.prop(gpd, "zdepth_offset", text="Surface Offset")
|
||||
|
||||
|
||||
class DATA_PT_custom_props_gpencil(DataButtonsPanel, PropertyPanel, Panel):
|
||||
|
|
|
@ -371,12 +371,9 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
|
|||
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
|
||||
if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) {
|
||||
|
||||
/* add small offset to keep stroke over the surface.
|
||||
* This could be a UI parameter, but the value is too sensitive for
|
||||
* the user to use it and don't improve the result.
|
||||
*/
|
||||
if (depth) {
|
||||
*depth *= 0.99998f;
|
||||
/* add small offset to keep stroke over the surface */
|
||||
if ((depth) && (gpd->zdepth_offset > 0.0f)) {
|
||||
*depth *= (1.0f - gpd->zdepth_offset);
|
||||
}
|
||||
|
||||
if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
|
||||
|
|
|
@ -354,7 +354,7 @@ typedef struct bGPdata {
|
|||
float gcolor_prev[3]; /* optional color for ghosts before the active frame */
|
||||
float gcolor_next[3]; /* optional color for ghosts after the active frame */
|
||||
|
||||
char pad[4];
|
||||
float zdepth_offset; /* offset for drawing over surfaces to keep strokes on top */
|
||||
struct Material **mat; /* materials array */
|
||||
short totcol; /* total materials */
|
||||
|
||||
|
|
|
@ -1404,6 +1404,14 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames");
|
||||
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
|
||||
|
||||
prop = RNA_def_property(srna, "zdepth_offset", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "zdepth_offset");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 5);
|
||||
RNA_def_property_ui_text(prop, "Surface Offset",
|
||||
"Offset amount when drawing in surface mode");
|
||||
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
|
||||
|
||||
/* API Functions */
|
||||
func = RNA_def_function(srna, "clear", "rna_GPencil_clear");
|
||||
RNA_def_function_ui_description(func, "Remove all the grease pencil data");
|
||||
|
|
Loading…
Reference in New Issue