[Bf-blender-cvs] [c7c10e5] master: Brush Texture Angle Goodies:

Antony Riakiotakis noreply at git.blender.org
Fri Dec 26 23:51:58 CET 2014


Commit: c7c10e5e283879961356050ba8a965d2239456b8
Author: Antony Riakiotakis
Date:   Fri Dec 26 23:51:27 2014 +0100
Branches: master
https://developer.blender.org/rBc7c10e5e283879961356050ba8a965d2239456b8

Brush Texture Angle Goodies:

This commit includes a few things:

* It moves the Rake and Random flags from the brush to the MTex.
* The first change allows mask textures to have independent rake
support.
* Random rotation now has an angle value that controls the width of the
effect from the rake or default angle
* Rake and Random are now supported together.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_blender.h
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_image_2d.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/DNA_texture_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index f104285..4963498 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -246,21 +246,20 @@ def brush_texture_settings(layout, brush, sculpt):
     if brush.brush_capabilities.has_texture_angle:
         col = layout.column()
         col.label(text="Angle:")
-        row = col.row(align=True)
         if brush.brush_capabilities.has_texture_angle_source:
+            col.prop(tex_slot, "angle", text="")
+            col.prop(tex_slot, "use_rake", text="Rake")
+            
             if brush.brush_capabilities.has_random_texture_angle:
                 if sculpt:
                     if brush.sculpt_capabilities.has_random_texture_angle:
-                        row.prop(brush, "texture_angle_source_random", text="")
-                    else:
-                        row.prop(brush, "texture_angle_source_no_random", text="")
-
+                        col.prop(tex_slot, "use_random", text="Random")
+                        if tex_slot.use_random:
+                            col.prop(tex_slot, "random_angle", text="")
                 else:
-                    row.prop(brush, "texture_angle_source_random", text="")
-            else:
-                row.prop(brush, "texture_angle_source_no_random", text="")
-
-        row.prop(tex_slot, "angle", text="")
+                    col.prop(tex_slot, "use_random", text="Random")
+                    if tex_slot.use_random:
+                        col.prop(tex_slot, "random_angle", text="")
 
     # scale and offset
     split = layout.split()
@@ -290,9 +289,18 @@ def brush_mask_texture_settings(layout, brush):
 
     col = layout.column()
     col.prop(brush, "use_pressure_masking", text="")
-    col.label(text="Angle:")
-    col.active = brush.brush_capabilities.has_texture_angle
-    col.prop(mask_tex_slot, "angle", text="")
+    # angle and texture_angle_source
+    if brush.brush_capabilities.has_texture_angle:
+        col = layout.column()
+        col.label(text="Angle:")
+        if brush.brush_capabilities.has_texture_angle_source:
+            col.prop(mask_tex_slot, "angle", text="")
+            col.prop(mask_tex_slot, "use_rake", text="Rake")
+            
+            if brush.brush_capabilities.has_random_texture_angle:
+                col.prop(mask_tex_slot, "use_random", text="Random")
+                if mask_tex_slot.use_random:
+                    col.prop(mask_tex_slot, "random_angle", text="")
 
     # scale and offset
     split = layout.split()
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 2701dc3..b27f1a6 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         273
-#define BLENDER_SUBVERSION      0
+#define BLENDER_SUBVERSION      1
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index b080ca3..8cf6fdc 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -143,7 +143,7 @@ float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level,
                             unsigned x, unsigned y);
 
 /* stroke related */
-void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, const float mouse_pos[2]);
+void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, const float mouse_pos[2]);
 
 /* Session data (mode-specific) */
 
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 92f66cd..cdbcffe 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -298,7 +298,6 @@ void BKE_brush_debug_print_state(Brush *br)
 	BR_TEST_FLAG(BRUSH_SIZE_PRESSURE);
 	BR_TEST_FLAG(BRUSH_JITTER_PRESSURE);
 	BR_TEST_FLAG(BRUSH_SPACING_PRESSURE);
-	BR_TEST_FLAG(BRUSH_RAKE);
 	BR_TEST_FLAG(BRUSH_ANCHORED);
 	BR_TEST_FLAG(BRUSH_DIR_IN);
 	BR_TEST_FLAG(BRUSH_SPACE);
@@ -314,7 +313,6 @@ void BKE_brush_debug_print_state(Brush *br)
 	BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE);
 	BR_TEST_FLAG(BRUSH_DRAG_DOT);
 	BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE);
-	BR_TEST_FLAG(BRUSH_RANDOM_ROTATION);
 	BR_TEST_FLAG(BRUSH_PLANE_TRIM);
 	BR_TEST_FLAG(BRUSH_FRONTFACE);
 	BR_TEST_FLAG(BRUSH_CUSTOM_ICON);
@@ -700,7 +698,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
 		if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
 			/* keep coordinates relative to mouse */
 
-			rotation += ups->brush_rotation;
+			rotation += ups->brush_rotation_sec;
 
 			x = point_2d[0] - ups->mask_tex_mouse[0];
 			y = point_2d[1] - ups->mask_tex_mouse[1];
@@ -718,7 +716,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
 			y = point_2d[1];
 		}
 		else if (mtex->brush_map_mode == MTEX_MAP_MODE_RANDOM) {
-			rotation += ups->brush_rotation;
+			rotation += ups->brush_rotation_sec;
 			/* these contain a random coordinate */
 			x = point_2d[0] - ups->mask_tex_mouse[0];
 			y = point_2d[1] - ups->mask_tex_mouse[1];
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 96fff33..5f3b9f0 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -477,19 +477,48 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level,
 /* threshold to move before updating the brush rotation */
 #define RAKE_THRESHHOLD 20
 
-void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, const float mouse_pos[2])
+static void update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, float rotation)
 {
-	const float u = 0.5f;
-	const float r = RAKE_THRESHHOLD;
+	if (brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)
+		ups->brush_rotation = rotation;
+	else
+		ups->brush_rotation = 0.0f;
 
-	float dpos[2];
-	sub_v2_v2v2(dpos, ups->last_rake, mouse_pos);
+	if (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)
+		/* here, translation contains the mouse coordinates. */
+		ups->brush_rotation_sec = rotation;
+	else
+		ups->brush_rotation_sec = 0.0f;
+}
+
+void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, const float mouse_pos[2])
+{
+	if ((brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
+		const float u = 0.5f;
+		const float r = RAKE_THRESHHOLD;
+		float rotation;
+
+		float dpos[2];
+		sub_v2_v2v2(dpos, ups->last_rake, mouse_pos);
+
+		if (len_squared_v2(dpos) >= r * r) {
+			rotation = atan2f(dpos[0], dpos[1]);
+
+			interp_v2_v2v2(ups->last_rake, ups->last_rake,
+			               mouse_pos, u);
 
-	if (len_squared_v2(dpos) >= r * r) {
-		ups->brush_rotation = atan2f(dpos[0], dpos[1]);
+			ups->last_rake_angle = rotation;
 
-		interp_v2_v2v2(ups->last_rake, ups->last_rake,
-		               mouse_pos, u);
+			update_brush_rake_rotation(ups, brush, rotation);
+		}
+		/* make sure we reset here to the last rotation to avoid accumulating
+		 * values in case a random rotation is also added */
+		else {
+			update_brush_rake_rotation(ups, brush, ups->last_rake_angle);
+		}
+	}
+	else {
+		ups->brush_rotation = ups->brush_rotation_sec =0.0f;
 	}
 }
 
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 7ce08ac..a653609 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -755,6 +755,8 @@ void default_mtex(MTex *mtex)
 	mtex->fieldfac = 1.0f;
 	mtex->normapspace = MTEX_NSPACE_TANGENT;
 	mtex->brush_map_mode = MTEX_MAP_MODE_TILED;
+	mtex->random_angle = 2.0f * M_PI;
+	mtex->brush_angle_mode = 0;
 }
 
 
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 372a0b0..a26e29d 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -435,4 +435,27 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+
+	if (!MAIN_VERSION_ATLEAST(main, 273, 1)) {
+#define	BRUSH_RAKE (1 << 7)
+#define BRUSH_RANDOM_ROTATION = (1 << 25)
+
+		Brush *br;
+
+		for (br = main->brush.first; br; br = br->id.next) {
+			if (br->flag & BRUSH_RAKE) {
+				br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
+				br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
+			}
+			else if (br->flag & BRUSH_RAKE) {
+				br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
+				br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
+			}
+			br->mtex.random_angle = 2.0f * M_PI;
+			br->mask_mtex.random_angle = 2.0f * M_PI;
+		}
+
+#undef BRUSH_RAKE
+#undef BRUSH_RANDOM_ROTATION
+	}
 }
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index e27ef70..92cb346 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -595,7 +595,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
 		if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
 			/* brush rotation */
 			glTranslatef(0.5, 0.5, 0);
-			glRotatef((double)RAD2DEGF(ups->brush_rotation),
+			glRotatef((double)RAD2DEGF((primary) ? ups->brush_rotation : ups->brush_rotation_sec),
 			          0.0, 0.0, 1.0);
 			glTranslatef(-0.5f, -0.5f, 0);
 
@@ -1000,9 +1000,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 	/* don't calculate rake angles while a stroke is active because the rake variables are global and
 	 * we may get interference with the stroke itself. For line strokes, such interference is visible */
 	if (!ups->stroke_active) {
-		if (brush->flag & BRUSH_RAKE)
-			/* here, translation contains the mouse coordinates. */
-			pai

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list