[Bf-blender-cvs] [a4023605dc2] greasepencil-object: Change number of subdivision to avoid int division problem in Grid

Antonioya noreply at git.blender.org
Sun Jul 29 12:25:07 CEST 2018


Commit: a4023605dc222acebe886f8033bb79ad7a198c25
Author: Antonioya
Date:   Sun Jul 29 12:22:43 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBa4023605dc222acebe886f8033bb79ad7a198c25

Change number of subdivision to avoid int division problem in Grid

Before, if you selected 5 subdivisions, the number of boxes in the grid was 5/2= 2, so the odds values were not working.

Now, the subdivisions means the number of boxes in each side of the symmetry line 5= (5 Right side + 5 Left side) = 5 * 2 = 10 Boxes.

===================================================================

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

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 e60293a6d03..6b4e07281f4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -641,7 +641,7 @@ GPUBatch *DRW_gpencil_get_grid(void)
 	float col_grid[4];
 
 	/* verify we have something to draw and valid values */
-	if (v3d->overlay.gpencil_grid_lines < 4) {
+	if (v3d->overlay.gpencil_grid_lines < 1) {
 		v3d->overlay.gpencil_grid_lines = GP_DEFAULT_GRID_LINES;
 	}
 
@@ -684,7 +684,7 @@ GPUBatch *DRW_gpencil_get_grid(void)
 	}
 
 	const char *grid_unit = NULL;
-	const int gridlines = v3d->overlay.gpencil_grid_lines / 2;
+	const int gridlines = v3d->overlay.gpencil_grid_lines;
 	const float grid_scale = v3d->overlay.gpencil_grid_scale * ED_scene_grid_scale(scene, &grid_unit);
 	const float grid = gridlines * grid_scale;
 
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index fdb4bd9c68f..9127214bb43 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -42,7 +42,7 @@ 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 30
+#define GP_DEFAULT_GRID_LINES 15
 #define GP_MAX_INPUT_SAMPLES 10
 
 /* ***************************************** */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index adb7007e664..63665e73104 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -40,6 +40,7 @@
 #include "BLI_math.h"
 
 #include "DNA_action_types.h"
+#include "DNA_gpencil_types.h"
 #include "DNA_key_types.h"
 #include "DNA_material_types.h"
 #include "DNA_node_types.h"
@@ -2884,9 +2885,9 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
 
 	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, 4, INT_MAX);
-	RNA_def_property_int_default(prop, 20);
-	RNA_def_property_ui_text(prop, "Lines", "Number of lines");
+	RNA_def_property_range(prop, 1, 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 simmetry line");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
 	prop = RNA_def_property(srna, "gpencil_grid_axis", PROP_ENUM, PROP_NONE);



More information about the Bf-blender-cvs mailing list