[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48214] branches/soc-2012-bratwurst/source /blender/editors/sculpt_paint: More unification of paint cursor code.
Antony Riakiotakis
kalast at gmail.com
Sat Jun 23 00:39:18 CEST 2012
Revision: 48214
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48214
Author: psy-fi
Date: 2012-06-22 22:39:17 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
More unification of paint cursor code. Move image editor zoom factor to
paint_draw_cursor.
Modified Paths:
--------------
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-22 22:34:02 UTC (rev 48213)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-22 22:39:17 UTC (rev 48214)
@@ -354,9 +354,6 @@
hit = 1;
}
else {
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
- Brush *brush = paint_brush(&sd->paint);
-
*pixel_radius = BKE_brush_size_get(scene, brush);
hit = 0;
}
@@ -508,8 +505,8 @@
float translation[2];
float outline_alpha, *outline_col;
float location[3];
- int pixel_radius, hit = 0, is_view3d;
- ScrArea *sa = CTX_wm_area(C);
+ int pixel_radius, hit = 0, in_uv_editor;
+ float zoomx, zoomy;
/* set various defaults */
translation[0] = x;
@@ -522,7 +519,8 @@
if (!(paint->flags & PAINT_SHOW_BRUSH))
return;
- is_view3d = (sa && sa->spacetype == SPACE_VIEW3D)? TRUE : FALSE;
+ in_uv_editor = get_imapaint_zoom(C, &zoomx, &zoomy);
+
/* can't use stroke vc here because this will be called during
* mouse over too, not just during a stroke */
view3d_set_viewcontext(C, &vc);
@@ -548,15 +546,34 @@
}
}
- if(is_view3d) {
+ if(!in_uv_editor) {
/* test if brush is over the mesh. sculpt only for now */
hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location);
+
+ /* uv sculpting brush won't get scaled maybe I should make this respect the setting
+ * of lock size */
+ } else if(!(scene->toolsettings->use_uv_sculpt)){
+#define PX_SIZE_FADE_MAX 12.0f
+#define PX_SIZE_FADE_MIN 4.0f
+
+ final_radius = MAX2(final_radius * zoomx, final_radius * zoomy);
+
+ if (final_radius < PX_SIZE_FADE_MIN) {
+ return;
+ }
+ else if (final_radius < PX_SIZE_FADE_MAX) {
+ outline_alpha *= (final_radius - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN);
+ }
+#undef PX_SIZE_FADE_MAX
+#undef PX_SIZE_FADE_MIN
}
/* draw overlay */
paint_draw_alpha_overlay(ups, brush, &vc, x, y);
- if (BKE_brush_use_locked_size(scene, brush))
+ if (BKE_brush_use_locked_size(scene, brush)) {
BKE_brush_size_set(scene, brush, pixel_radius);
+ final_radius = pixel_radius;
+ }
/* check if brush is subtracting, use different color then */
/* TODO: no way currently to know state of pen flip or
@@ -589,9 +606,12 @@
glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha);
/* draw brush outline */
+ glPushMatrix();
glTranslatef(translation[0], translation[1], 0);
+ if(in_uv_editor)
+ glScalef(zoomx, zoomy, 1.0f);
glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius, 40);
- glTranslatef(-translation[0], -translation[1], 0);
+ glPopMatrix();
/* restore GL state */
glDisable(GL_BLEND);
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c 2012-06-22 22:34:02 UTC (rev 48213)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c 2012-06-22 22:39:17 UTC (rev 48214)
@@ -5251,7 +5251,7 @@
ts = scene->toolsettings;
use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy) &&
- !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT));
+ !(ts->use_uv_sculpt);
if (use_zoom) {
pixel_size = MAX2(size * zoomx, size * zoomy);
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h 2012-06-22 22:34:02 UTC (rev 48213)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h 2012-06-22 22:39:17 UTC (rev 48214)
@@ -73,6 +73,7 @@
int paint_poll(struct bContext *C);
void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
void paint_draw_cursor(struct bContext *C, int x, int y, void *UNUSED(unused));
+int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy);
/* paint_vertex.c */
int weight_paint_poll(struct bContext *C);
More information about the Bf-blender-cvs
mailing list