[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34164] trunk/blender/source/blender/ editors/sculpt_paint: Paint/Sculpt:

Nicholas Bishop nicholasbishop at gmail.com
Fri Jan 7 23:46:53 CET 2011


Revision: 34164
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34164
Author:   nicholasbishop
Date:     2011-01-07 22:46:52 +0000 (Fri, 07 Jan 2011)
Log Message:
-----------
Paint/Sculpt:

More minor cleanups: fixed names and factored out a function that was
copy-pasted into paint stroke.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2011-01-07 22:03:16 UTC (rev 34163)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2011-01-07 22:46:52 UTC (rev 34164)
@@ -99,6 +99,7 @@
 
 
 /* paint_utils.c */
+float paint_calc_object_space_radius(struct ViewContext *vc, float center[3], float pixel_radius);
 float paint_get_tex_pixel(struct Brush* br, float u, float v);
 int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, int *xy, float *uv);
@@ -113,11 +114,11 @@
 int facemask_paint_poll(struct bContext *C);
 
 /* stroke operator */
-typedef enum wmBrushStrokeMode {
-	WM_BRUSHSTROKE_NORMAL,
-	WM_BRUSHSTROKE_INVERT,
-	WM_BRUSHSTROKE_SMOOTH,
-} wmBrushStrokeMode;
+typedef enum BrushStrokeMode {
+	BRUSH_STROKE_NORMAL,
+	BRUSH_STROKE_INVERT,
+	BRUSH_STROKE_SMOOTH,
+} BrushStrokeMode;
 
 /* paint_undo.c */
 typedef void (*UndoRestoreCb)(struct bContext *C, struct ListBase *lb);

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2011-01-07 22:03:16 UTC (rev 34163)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2011-01-07 22:46:52 UTC (rev 34164)
@@ -317,12 +317,10 @@
 	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
 	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr,  "mode", WM_RADIALCONTROL_ANGLE);
 
-	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0,        0)->ptr, "mode", WM_BRUSHSTROKE_NORMAL);
-	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL,  0)->ptr, "mode", WM_BRUSHSTROKE_INVERT);
-	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_BRUSHSTROKE_SMOOTH);
+	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0,        0)->ptr, "mode", BRUSH_STROKE_NORMAL);
+	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL,  0)->ptr, "mode", BRUSH_STROKE_INVERT);
+	RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
 
-	//stroke_mode_modal_keymap(keyconf);
-
 	for(i=0; i<=5; i++)
 		RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2011-01-07 22:03:16 UTC (rev 34163)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2011-01-07 22:46:52 UTC (rev 34164)
@@ -411,22 +411,6 @@
 	return hit;
 }
 
-// XXX duplicated from sculpt.c
-float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset)
-{
-	float delta[3], scale, loc[3];
-
-	mul_v3_m4v3(loc, ob->obmat, center);
-
-	initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
-	window_to_3d_delta(vc->ar, delta, offset, 0);
-
-	scale= fabsf(mat4_to_scale(ob->obmat));
-	scale= (scale == 0.0f)? 1.0f: scale;
-
-	return len_v3(delta)/scale;
-}
-
 // XXX paint cursor now does a lot of the same work that is needed during a sculpt stroke
 // problem: all this stuff was not intended to be used at this point, so things feel a
 // bit hacked.  I've put lots of stuff in Brush that probably better goes in Paint
@@ -613,13 +597,13 @@
 			if (visual_strength > 1) visual_strength = 1;
 
 			if (sd->draw_anchored) {
-				unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, sd->anchored_size);
+				unprojected_radius = paint_calc_object_space_radius(&vc, location, sd->anchored_size);
 			}
 			else {
 				if (brush->flag & BRUSH_ANCHORED)
-					unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, 8);
+					unprojected_radius = paint_calc_object_space_radius(&vc, location, 8);
 				else
-					unprojected_radius = unproject_brush_radius(CTX_data_active_object(C), &vc, location, brush_size(brush));
+					unprojected_radius = paint_calc_object_space_radius(&vc, location, brush_size(brush));
 			}
 
 			if (sd->draw_pressure && brush_use_size_pressure(brush))

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2011-01-07 22:03:16 UTC (rev 34163)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_utils.c	2011-01-07 22:46:52 UTC (rev 34164)
@@ -35,6 +35,23 @@
 
 #include "paint_intern.h"
 
+float paint_calc_object_space_radius(ViewContext *vc, float center[3],
+				     float pixel_radius)
+{
+	Object *ob = vc->obact;
+	float delta[3], scale, loc[3];
+
+	mul_v3_m4v3(loc, ob->obmat, center);
+
+	initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
+	window_to_3d_delta(vc->ar, delta, pixel_radius, 0);
+
+	scale= fabsf(mat4_to_scale(ob->obmat));
+	scale= (scale == 0.0f)? 1.0f: scale;
+
+	return len_v3(delta)/scale;
+}
+
 float paint_get_tex_pixel(Brush* br, float u, float v)
 {
 	TexResult texres;

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-01-07 22:03:16 UTC (rev 34163)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-01-07 22:46:52 UTC (rev 34164)
@@ -241,16 +241,6 @@
 	p[1]= uy;
 }
 
-/*XXX: static void project(bglMats *mats, const float v[3], short p[2])
-{
-	float f[2];
-	projectf(mats, v, f);
-
-	p[0]= f[0];
-	p[1]= f[1];
-}
-*/
-
 /*** BVH Tree ***/
 
 /* Get a screen-space rectangle of the modified area */
@@ -2752,21 +2742,6 @@
 /**** Operator for applying a stroke (various attributes including mouse path)
 	  using the current brush. ****/
 
-static float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset)
-{
-	float delta[3], scale, loc[3];
-
-	mul_v3_m4v3(loc, ob->obmat, center);
-
-	initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
-	window_to_3d_delta(vc->ar, delta, offset, 0);
-
-	scale= fabsf(mat4_to_scale(ob->obmat));
-	scale= (scale == 0.0f)? 1.0f: scale;
-
-	return len_v3(delta)/scale;
-}
-
 static void sculpt_cache_free(StrokeCache *cache)
 {
 	if(cache->face_norms)
@@ -2840,8 +2815,8 @@
 	}
 
 	mode = RNA_int_get(op->ptr, "mode");
-	cache->invert = mode == WM_BRUSHSTROKE_INVERT;
-	cache->alt_smooth = mode == WM_BRUSHSTROKE_SMOOTH;
+	cache->invert = mode == BRUSH_STROKE_INVERT;
+	cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH;
 
 	/* not very nice, but with current events system implementation
 	   we can't handle brush appearance inversion hotkey separately (sergey) */
@@ -3019,7 +2994,7 @@
 
 	if(cache->first_time) {
 		if (!brush_use_locked_size(brush)) {
-			cache->initial_radius= unproject_brush_radius(ss->ob, cache->vc, cache->true_location, brush_size(brush));
+			cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(brush));
 			brush_set_unprojected_radius(brush, cache->initial_radius);
 		}
 		else {
@@ -3081,7 +3056,7 @@
 		if (!hit)
 			copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse);
 
-		cache->radius= unproject_brush_radius(ss->ob, paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius);
+		cache->radius= paint_calc_object_space_radius(paint_stroke_view_context(stroke), cache->true_location, cache->pixel_radius);
 		cache->radius_squared = cache->radius*cache->radius;
 
 		copy_v3_v3(sd->anchored_location, cache->true_location);
@@ -3488,10 +3463,10 @@
 static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
 {
 	static EnumPropertyItem stroke_mode_items[] = {
-		{ WM_BRUSHSTROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally" },
-		{ WM_BRUSHSTROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke" },
-		{ WM_BRUSHSTROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke" },
-		{ 0 }
+		{BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"},
+		{BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"},
+		{BRUSH_STROKE_SMOOTH, "SMOOTH", 0, "Smooth", "Switch brush to smooth mode for duration of stroke"},
+		{0}
 	};
 
 	/* identifiers */
@@ -3512,7 +3487,7 @@
 	RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement,
 			"Stroke", "");
 
-	RNA_def_enum(ot->srna, "mode", stroke_mode_items, WM_BRUSHSTROKE_NORMAL, 
+	RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, 
 			"Sculpt Stroke Mode",
 			"Action taken when a sculpt stroke is made");
 




More information about the Bf-blender-cvs mailing list