Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2009-02-22 22:31:25 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2009-02-22 22:31:25 +0300
commit674aae36b6fadf97613cc11758c32503b0f5f2f4 (patch)
treeaa9d55871c01e52cc6f623c1320bc4c955f6feac /source/blender
parent7c8d98acb83f0568b3db9c700f456d829d509cc3 (diff)
* Added radial control for texture paint (in both view3d and image)
* bugfix: for older files, initialize the brush curve on file load
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_brush.h4
-rw-r--r--source/blender/blenkernel/intern/brush.c8
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c181
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c4
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_ops.c2
9 files changed, 156 insertions, 52 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index eba7558d492..4146d313d41 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -85,8 +85,8 @@ void brush_painter_free(BrushPainter *painter);
unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side);
/* radial control */
-void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br);
-int brush_radial_control_exec(struct wmOperator *op, struct Brush *br);
+void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br, float size_weight);
+int brush_radial_control_exec(struct wmOperator *op, struct Brush *br, float size_weight);
#endif
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ab453fb6f44..e5dd9c2188d 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1053,13 +1053,13 @@ static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
return im;
}
-void brush_radial_control_invoke(wmOperator *op, Brush *br)
+void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight)
{
int mode = RNA_int_get(op->ptr, "mode");
float original_value= 0;
if(mode == WM_RADIALCONTROL_SIZE)
- original_value = br->size;
+ original_value = br->size * size_weight;
else if(mode == WM_RADIALCONTROL_STRENGTH)
original_value = br->alpha;
else if(mode == WM_RADIALCONTROL_ANGLE)
@@ -1069,14 +1069,14 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br)
op->customdata = brush_gen_radial_control_imbuf(br);
}
-int brush_radial_control_exec(wmOperator *op, Brush *br)
+int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight)
{
int mode = RNA_int_get(op->ptr, "mode");
float new_value = RNA_float_get(op->ptr, "new_value");
const float conv = 0.017453293;
if(mode == WM_RADIALCONTROL_SIZE)
- br->size = new_value;
+ br->size = new_value * size_weight;
else if(mode == WM_RADIALCONTROL_STRENGTH)
br->alpha = new_value;
else if(mode == WM_RADIALCONTROL_ANGLE)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 023d7c09171..104c058984b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -109,6 +109,7 @@
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_armature.h"
+#include "BKE_brush.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_cloth.h"
#include "BKE_colortools.h"
@@ -1511,6 +1512,8 @@ static void direct_link_brush(FileData *fd, Brush *brush)
brush->curve= newdataadr(fd, brush->curve);
if(brush->curve)
direct_link_curvemapping(fd, brush->curve);
+ else
+ brush_curve_preset(brush, BRUSH_PRESET_SHARP);
}
static void direct_link_script(FileData *fd, Script *script)
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index ee5aa1ee4a7..cf076f5d464 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -4759,6 +4759,110 @@ void PAINT_OT_image_paint(wmOperatorType *ot)
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
+static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
+{
+ RegionView3D *rv3d= CTX_wm_region_view3d(C);
+
+ if(!rv3d) {
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ ARegion *ar= CTX_wm_region(C);
+
+ ED_space_image_zoom(sima, ar, zoomx, zoomy);
+
+ return 1;
+ }
+
+ *zoomx = *zoomy = 1;
+
+ return 0;
+}
+
+/************************ cursor drawing *******************************/
+
+static void brush_drawcursor(bContext *C, int x, int y, void *customdata)
+{
+ Brush *brush= image_paint_brush(C);
+
+ if(brush) {
+ float zoomx, zoomy;
+ glPushMatrix();
+
+ glTranslatef((float)x, (float)y, 0.0f);
+
+ if(get_imapaint_zoom(C, &zoomx, &zoomy))
+ glScalef(zoomx, zoomy, 1.0f);
+
+ glColor4ub(255, 255, 255, 128);
+ glEnable( GL_LINE_SMOOTH );
+ glEnable(GL_BLEND);
+ glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size*0.5f, 40);
+ glDisable(GL_BLEND);
+ glDisable( GL_LINE_SMOOTH );
+
+ glPopMatrix();
+ }
+}
+
+static void toggle_paint_cursor(bContext *C, int enable)
+{
+ ToolSettings *settings= CTX_data_scene(C)->toolsettings;
+
+ if(settings->imapaint.paintcursor && !enable) {
+ WM_paint_cursor_end(CTX_wm_manager(C), settings->imapaint.paintcursor);
+ settings->imapaint.paintcursor = NULL;
+ }
+ else if(enable)
+ settings->imapaint.paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, brush_drawcursor, NULL);
+}
+
+/* ************ image paint radial control *************/
+static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ float zoom;
+ ToolSettings *ts = CTX_data_scene(C)->toolsettings;
+ get_imapaint_zoom(C, &zoom, &zoom);
+ toggle_paint_cursor(C, !ts->imapaint.paintcursor);
+ brush_radial_control_invoke(op, ts->imapaint.brush, 0.5 * zoom);
+ return WM_radial_control_invoke(C, op, event);
+}
+
+static int paint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ToolSettings *ts = CTX_data_scene(C)->toolsettings;
+ int ret = WM_radial_control_modal(C, op, event);
+ if(ret != OPERATOR_RUNNING_MODAL)
+ toggle_paint_cursor(C, !ts->imapaint.paintcursor);
+ return ret;
+}
+
+static int paint_radial_control_exec(bContext *C, wmOperator *op)
+{
+ float zoom;
+ int ret;
+ char str[256];
+ get_imapaint_zoom(C, &zoom, &zoom);
+ ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2.0 / zoom);
+ WM_radial_control_string(op, str, 256);
+
+ return ret;
+}
+
+void PAINT_OT_image_paint_radial_control(wmOperatorType *ot)
+{
+ WM_OT_radial_control_partial(ot);
+
+ ot->name= "Image Paint Radial Control";
+ ot->idname= "PAINT_OT_image_paint_radial_control";
+
+ ot->invoke= paint_radial_control_invoke;
+ ot->modal= paint_radial_control_modal;
+ ot->exec= paint_radial_control_exec;
+ ot->poll= image_paint_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/************************ grab clone operator ************************/
typedef struct GrabClone {
@@ -4962,50 +5066,6 @@ void PAINT_OT_set_clone_cursor(wmOperatorType *ot)
RNA_def_float_vector(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in world space coordinates.", -10000.0f, 10000.0f);
}
-/************************ cursor drawing *******************************/
-
-static void brush_drawcursor(bContext *C, int x, int y, void *customdata)
-{
- Brush *brush= image_paint_brush(C);
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
-
- if(brush) {
- glPushMatrix();
-
- glTranslatef((float)x, (float)y, 0.0f);
-
- if(!rv3d) {
- SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
- ARegion *ar= CTX_wm_region(C);
- float zoomx, zoomy;
-
- ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
- glScalef(zoomx, zoomy, 1.0f);
- }
-
- glColor4ub(255, 255, 255, 128);
- glEnable( GL_LINE_SMOOTH );
- glEnable(GL_BLEND);
- glutil_draw_lined_arc(0.0, M_PI*2.0, brush->size*0.5f, 40);
- glDisable(GL_BLEND);
- glDisable( GL_LINE_SMOOTH );
-
- glPopMatrix();
- }
-}
-
-static void toggle_paint_cursor(bContext *C, int enable)
-{
- ToolSettings *settings= CTX_data_scene(C)->toolsettings;
-
- if(settings->imapaint.paintcursor && !enable) {
- WM_paint_cursor_end(CTX_wm_manager(C), settings->imapaint.paintcursor);
- settings->imapaint.paintcursor = NULL;
- }
- else if(enable)
- settings->imapaint.paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, brush_drawcursor, NULL);
-}
-
/******************** texture paint toggle operator ********************/
static int texture_paint_toggle_poll(bContext *C)
@@ -5076,3 +5136,36 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/* ************ texture paint radial control *************/
+static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ ToolSettings *ts = CTX_data_scene(C)->toolsettings;
+ toggle_paint_cursor(C, !ts->imapaint.paintcursor);
+ brush_radial_control_invoke(op, ts->imapaint.brush, 0.5);
+ return WM_radial_control_invoke(C, op, event);
+}
+
+static int texture_paint_radial_control_exec(bContext *C, wmOperator *op)
+{
+ int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->imapaint.brush, 2);
+ char str[256];
+ WM_radial_control_string(op, str, 256);
+
+ return ret;
+}
+
+void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot)
+{
+ WM_OT_radial_control_partial(ot);
+
+ ot->name= "Texture Paint Radial Control";
+ ot->idname= "PAINT_OT_texture_paint_radial_control";
+
+ ot->invoke= texture_paint_radial_control_invoke;
+ ot->modal= paint_radial_control_modal;
+ ot->exec= texture_paint_radial_control_exec;
+ ot->poll= texture_paint_toggle_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index a5ac3264eee..7e1ecd9629a 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -47,10 +47,12 @@ void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
/* paint_image.c */
void PAINT_OT_image_paint(struct wmOperatorType *ot);
+void PAINT_OT_image_paint_radial_control(struct wmOperatorType *ot);
void PAINT_OT_grab_clone(struct wmOperatorType *ot);
void PAINT_OT_sample_color(struct wmOperatorType *ot);
void PAINT_OT_set_clone_cursor(struct wmOperatorType *ot);
void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot);
+void PAINT_OT_texture_paint_radial_control(struct wmOperatorType *ot);
/* paint_utils.c */
int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 0918e8c9b94..6b3a36de826 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -12,7 +12,9 @@ void ED_operatortypes_paint(void)
{
/* image */
WM_operatortype_append(PAINT_OT_texture_paint_toggle);
+ WM_operatortype_append(PAINT_OT_texture_paint_radial_control);
WM_operatortype_append(PAINT_OT_image_paint);
+ WM_operatortype_append(PAINT_OT_image_paint_radial_control);
WM_operatortype_append(PAINT_OT_sample_color);
WM_operatortype_append(PAINT_OT_grab_clone);
WM_operatortype_append(PAINT_OT_set_clone_cursor);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8987479bbfc..40aaee758b9 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1261,7 +1261,7 @@ static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot)
static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
toggle_paint_cursor(C);
- brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->sculpt->brush);
+ brush_radial_control_invoke(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1);
return WM_radial_control_invoke(C, op, event);
}
@@ -1275,7 +1275,7 @@ static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *eve
static int sculpt_radial_control_exec(bContext *C, wmOperator *op)
{
- int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush);
+ int ret = brush_radial_control_exec(op, CTX_data_scene(C)->toolsettings->sculpt->brush, 1);
char str[256];
WM_radial_control_string(op, str, 256);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 896522e15de..419eb913edd 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -233,6 +233,8 @@ void image_keymap(struct wmWindowManager *wm)
WM_keymap_add_item(keymap, "PAINT_OT_image_paint", ACTIONMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", SELECTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SELECTMOUSE, KM_PRESS, 0, 0);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
WM_keymap_add_item(keymap, "IMAGE_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0);
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_set_curves_point", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "point", 0);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index 6d071056b78..7ff6e6b88a8 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -209,8 +209,10 @@ void view3d_keymap(wmWindowManager *wm)
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE);
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
+ RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH);
/* TODO - this is just while we have no way to load a text datablock */
RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");