[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30408] branches/soc-2010-kwk/source/ blender/editors/sculpt_paint: * Fixed paint stroke offset
Konrad Kleine
konrad at konradwilhelm.de
Fri Jul 16 13:57:26 CEST 2010
Revision: 30408
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30408
Author: kwk
Date: 2010-07-16 13:57:26 +0200 (Fri, 16 Jul 2010)
Log Message:
-----------
* Fixed paint stroke offset
* As a quick replacement of PaintOperation->first I've added the paint_stroke_started() function to test if the stroke has just started. This is probably not even needed in the end. Needs further investigation.
Modified Paths:
--------------
branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_stroke.c
Modified: branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_image.c 2010-07-16 10:13:04 UTC (rev 30407)
+++ branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_image.c 2010-07-16 11:57:26 UTC (rev 30408)
@@ -4625,7 +4625,6 @@
Brush *brush= paint_brush(&settings->imapaint.paint);
PaintOperation *pop= MEM_callocN(sizeof(PaintOperation), "PaintOperation"); /* caller frees */
- pop->first= 1;
paint_stroke_set_mode_data(stroke, pop);
// op->customdata= pop;
@@ -4706,17 +4705,19 @@
static void paint_apply(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
{
PaintOperation *pop= paint_stroke_mode_data(stroke);
+ ARegion *ar= CTX_wm_region(C);
float time, mousef[2];
float pressure;
int mouse[2], redraw;
RNA_float_get_array(itemptr, "mouse", mousef);
- mouse[0] = mousef[0];
- mouse[1] = mousef[1];
+ mouse[0] = mousef[0] - ar->winrct.xmin;
+ mouse[1] = mousef[1] - ar->winrct.ymin;
+
time= RNA_float_get(itemptr, "time");
pressure= RNA_float_get(itemptr, "pressure");
- if(pop->first)
+ if(paint_stroke_started(stroke))
project_paint_begin_clone(&pop->ps, mouse);
if(pop->mode == PAINT_MODE_3D)
@@ -4736,8 +4737,6 @@
if(redraw)
paint_redraw(C, &pop->s, 0);
-
- pop->first= 0;
}
//static void paint_exit(bContext *C, wmOperator *op)
@@ -4793,6 +4792,7 @@
{
ARegion *ar= CTX_wm_region(C);
PaintOperation *pop= paint_stroke_mode_data(stroke);
+ ViewContext *vc = paint_stroke_view_context(stroke);
float pressure, mousef[2];
double time;
int mouse[2];
@@ -4804,8 +4804,10 @@
// mouse[1]= event->y - ar->winrct.ymin + 1;
// XXX: (kwk) for now we use the location from paint stroke but it probably needs to be fixed.
RNA_float_get_array(itemptr, "location", mousef);
- mouse[0] = (int) mousef[0] + ar->winrct.xmin + 1;
- mouse[1] = (int) mousef[1] + ar->winrct.ymin + 1;
+// mouse[0] = (int) mousef[0] - vc->ar->winrct.xmin;
+// mouse[1] = (int) mousef[1] - vc->ar->winrct.ymin;
+ mouse[0] = (int) mousef[0] - ar->winrct.xmin;
+ mouse[1] = (int) mousef[1] - ar->winrct.ymin;
time= PIL_check_seconds_timer();
@@ -4819,7 +4821,7 @@
pop->s.blend = IMB_BLEND_ERASE_ALPHA;
}
- if(pop->first) {
+ if(paint_stroke_started(stroke)) {
pop->prevmouse[0]= mouse[0];
pop->prevmouse[1]= mouse[1];
pop->starttime= time;
Modified: branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_intern.h 2010-07-16 10:13:04 UTC (rev 30407)
+++ branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_intern.h 2010-07-16 11:57:26 UTC (rev 30408)
@@ -61,6 +61,7 @@
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
int paint_poll(struct bContext *C);
void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
+int paint_stroke_started(struct PaintStroke *stroke);
/* paint_vertex.c */
int weight_paint_poll(struct bContext *C);
Modified: branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-16 10:13:04 UTC (rev 30407)
+++ branches/soc-2010-kwk/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-16 11:57:26 UTC (rev 30408)
@@ -352,3 +352,8 @@
p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
}
+int paint_stroke_started(struct PaintStroke *stroke)
+{
+ return (stroke && stroke->stroke_started) ? 1 : 0;
+}
+
More information about the Bf-blender-cvs
mailing list