diff options
author | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2010-07-14 18:11:03 +0400 |
---|---|---|
committer | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2010-07-14 18:11:03 +0400 |
commit | 5505697ac508c02b8a2e196c5a8c07431bc687cf (patch) | |
tree | a550a4718d586066017e3861d42104ef09e969bf /source/blender/windowmanager | |
parent | ae1748b98470f08ed805e101b218f44c17d9b6b2 (diff) |
Merge GSOC Sculpt Branch: 28499-30319
https://svn.blender.org/svnroot/bf-blender/branches/soc-2010-jwilkins
See log of that branch for details.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/SConscript | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 99 |
3 files changed, 80 insertions, 27 deletions
diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index 0a86133e614..179b1ddc998 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -24,7 +24,7 @@ if env['WITH_BF_COLLADA']: if env['OURPLATFORM'] == 'linux2': cflags='-pthread' - incs += ' ../../../extern/binreloc/include' + incs += ' ../../../extern/binreloc/include' if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] @@ -35,4 +35,4 @@ if env['WITH_GHOST_COCOA']: if env['BF_BUILDINFO']: defs.append('NAN_BUILDINFO') -env.BlenderLib ( 'bf_windowmanager', sources, Split(incs), defs, libtype=['core'], priority=[5] ) +env.BlenderLib ( 'bf_windowmanager', sources, Split(incs), defines=defs, libtype=['core'], priority=[5] ) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5dbbf35796f..38322b66bbb 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -389,6 +389,7 @@ static void wm_draw_triple_free(wmWindow *win) wmDrawTriple *triple= win->drawdata; glDeleteTextures(triple->nx*triple->ny, triple->bind); + MEM_freeN(triple); win->drawdata= NULL; @@ -560,7 +561,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) else { win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple"); - if(!wm_triple_gen_textures(win, win->drawdata)) { + if(!wm_triple_gen_textures(win, win->drawdata)) + { wm_draw_triple_fail(C, win); return; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0023ded23f0..78e1c7d87a3 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -61,6 +61,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" /* BKE_ST_MAXNAME */ #include "BKE_utildefines.h" +#include "BKE_brush.h" // JW #include "BIF_gl.h" #include "BIF_glutil.h" /* for paint cursor */ @@ -69,6 +70,7 @@ #include "ED_screen.h" #include "ED_util.h" +#include "ED_view3d.h" // JW #include "RNA_access.h" #include "RNA_define.h" @@ -2595,19 +2597,28 @@ typedef struct wmRadialControl { GLuint tex; } wmRadialControl; +extern Paint *paint_get_active(Scene *sce); +extern struct Brush *paint_brush(struct Paint *paint); + static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) { wmRadialControl *rc = (wmRadialControl*)customdata; ARegion *ar = CTX_wm_region(C); float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f; - /* Keep cursor in the original place */ - x = rc->initial_mouse[0] - ar->winrct.xmin; - y = rc->initial_mouse[1] - ar->winrct.ymin; + Paint *paint = paint_get_active(CTX_data_scene(C)); + Brush *brush = paint_brush(paint); - glPushMatrix(); - - glTranslatef((float)x, (float)y, 0.0f); + ViewContext vc; + + int hit = 0; + + int flip; + int sign; + + float* col; + + const float str = rc->mode == WM_RADIALCONTROL_STRENGTH ? (rc->value + 0.5) : (brush->texture_overlay_alpha / 100.0f); if(rc->mode == WM_RADIALCONTROL_SIZE) { r1= rc->value; @@ -2615,29 +2626,37 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) r3= r1; } else if(rc->mode == WM_RADIALCONTROL_STRENGTH) { r1= (1 - rc->value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; - r2= WM_RADIAL_CONTROL_DISPLAY_SIZE; - r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; + r2= r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; } else if(rc->mode == WM_RADIALCONTROL_ANGLE) { - r1= r2= WM_RADIAL_CONTROL_DISPLAY_SIZE; - r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; + r1= r2= r3= WM_RADIAL_CONTROL_DISPLAY_SIZE; angle = rc->value; } - glColor4ub(255, 255, 255, 128); - glEnable( GL_LINE_SMOOTH ); - glEnable(GL_BLEND); + /* Keep cursor in the original place */ + x = rc->initial_mouse[0] - ar->winrct.xmin; + y = rc->initial_mouse[1] - ar->winrct.ymin; - if(rc->mode == WM_RADIALCONTROL_ANGLE) - fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + view3d_set_viewcontext(C, &vc); - if(rc->tex) { - const float str = rc->mode == WM_RADIALCONTROL_STRENGTH ? (rc->value + 0.5) : 1; + // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke + flip = 1; - if(rc->mode == WM_RADIALCONTROL_ANGLE) { - glRotatef(angle, 0, 0, 1); - fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); - } + sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1); + + if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) + col = brush->sub_col; + else + col = brush->add_col; + + glTranslatef((float)x, (float)y, 0.0f); + + glEnable(GL_BLEND); + if(rc->mode == WM_RADIALCONTROL_ANGLE) { + glRotatef(angle, 0, 0, 1); + } + + if (rc->tex) { glBindTexture(GL_TEXTURE_2D, rc->tex); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -2645,7 +2664,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glColor4f(0,0,0, str); + glColor4f(U.sculpt_paint_overlay_col[0],U.sculpt_paint_overlay_col[1],U.sculpt_paint_overlay_col[2], str); glTexCoord2f(0,0); glVertex2f(-r3, -r3); glTexCoord2f(1,0); @@ -2658,11 +2677,20 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) glDisable(GL_TEXTURE_2D); } - glColor4ub(255, 255, 255, 128); + if(rc->mode == WM_RADIALCONTROL_ANGLE) { + glColor4f(col[0], col[1], col[2], 0.5f); + glEnable(GL_LINE_SMOOTH); + glRotatef(-angle, 0, 0, 1); + fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + glRotatef(angle, 0, 0, 1); + fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0); + glDisable(GL_LINE_SMOOTH); + } + + glColor4f(col[0], col[1], col[2], 0.5f); glutil_draw_lined_arc(0.0, M_PI*2.0, r1, 40); glutil_draw_lined_arc(0.0, M_PI*2.0, r2, 40); glDisable(GL_BLEND); - glDisable( GL_LINE_SMOOTH ); glPopMatrix(); } @@ -2674,6 +2702,7 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) float dist; double new_value = RNA_float_get(op->ptr, "new_value"); int ret = OPERATOR_RUNNING_MODAL; + float initial_value = RNA_float_get(op->ptr, "initial_value"); mode = RNA_int_get(op->ptr, "mode"); RNA_int_get_array(op->ptr, "initial_mouse", initial_mouse); @@ -2682,6 +2711,16 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: delta[0]= initial_mouse[0] - event->x; delta[1]= initial_mouse[1] - event->y; + + //if (mode == WM_RADIALCONTROL_SIZE) + // delta[0]+= initial_value; + //else if(mode == WM_RADIALCONTROL_STRENGTH) + // delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - initial_value); + //else if(mode == WM_RADIALCONTROL_ANGLE) { + // delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value*M_PI/180.0f); + // delta[1]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value*M_PI/180.0f); + //} + dist= sqrt(delta[0]*delta[0]+delta[1]*delta[1]); if(mode == WM_RADIALCONTROL_SIZE) @@ -2728,6 +2767,11 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); + //if (ret != OPERATOR_RUNNING_MODAL) { + // wmWindow *win = CTX_wm_window(C); + // WM_cursor_restore(win); + //} + return ret; } @@ -2735,10 +2779,15 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { wmRadialControl *rc = MEM_callocN(sizeof(wmRadialControl), "radial control"); + wmWindow *win = CTX_wm_window(C); int mode = RNA_int_get(op->ptr, "mode"); float initial_value = RNA_float_get(op->ptr, "initial_value"); + //float initial_size = RNA_float_get(op->ptr, "initial_size"); int mouse[2] = {event->x, event->y}; + //if (initial_size == 0) + // initial_size = WM_RADIAL_CONTROL_DISPLAY_SIZE; + if(mode == WM_RADIALCONTROL_SIZE) { rc->max_value = 200; mouse[0]-= initial_value; @@ -2775,6 +2824,8 @@ int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) rc->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), op->type->poll, wm_radial_control_paint, op->customdata); + //WM_cursor_modal(win, CURSOR_NONE); + /* add modal handler */ WM_event_add_modal_handler(C, op); |