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:
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index b1ddf1172c8..65857cccb15 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -68,7 +68,7 @@
#include <float.h>
#include <math.h>
-#define DEBUG_TIME
+//#define DEBUG_TIME
#ifdef DEBUG_TIME
# include "PIL_time_utildefines.h"
@@ -466,7 +466,10 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float
copy_v2_v2(mouse_out, mouse_in);
}
- if (!paint_brush_update(C, brush, mode, stroke, mouse_in, mouse_out, pressure, location)) {
+
+ ups->last_hit = paint_brush_update(C, brush, mode, stroke, mouse_in, mouse_out, pressure, location);
+ copy_v3_v3(ups->last_location, location);
+ if (!ups->last_hit) {
return;
}
@@ -870,8 +873,7 @@ static void paint_stroke_add_sample(const Paint *paint,
float x, float y, float pressure)
{
PaintSample *sample = &stroke->samples[stroke->cur_sample];
- int max_samples = MIN2(PAINT_MAX_INPUT_SAMPLES,
- MAX2(paint->num_input_samples, 1));
+ int max_samples = CLAMPIS(paint->num_input_samples, 1, PAINT_MAX_INPUT_SAMPLES);
sample->mouse[0] = x;
sample->mouse[1] = y;
@@ -981,7 +983,7 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
return true;
#ifdef DEBUG_TIME
- TIMEIT_START(stroke);
+ TIMEIT_START_AVERAGED(whole_stroke);
#endif
pcp = pc->points;
@@ -1042,7 +1044,7 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
stroke_done(C, op);
#ifdef DEBUG_TIME
- TIMEIT_END(stroke);
+ TIMEIT_END_AVERAGED(whole_stroke);
#endif
return true;
@@ -1237,20 +1239,31 @@ int paint_stroke_exec(bContext *C, wmOperator *op)
/* only when executed for the first time */
if (stroke->stroke_started == 0) {
- /* XXX stroke->last_mouse_position is unset, this may cause problems */
- stroke->test_start(C, op, NULL);
- stroke->stroke_started = 1;
+ PropertyRNA *strokeprop;
+ PointerRNA firstpoint;
+ float mouse[2];
+
+ strokeprop = RNA_struct_find_property(op->ptr, "stroke");
+
+ if (RNA_property_collection_lookup_int(op->ptr, strokeprop, 0, &firstpoint)) {
+ RNA_float_get_array(&firstpoint, "mouse", mouse);
+ stroke->stroke_started = stroke->test_start(C, op, mouse);
+ }
}
- RNA_BEGIN (op->ptr, itemptr, "stroke")
- {
- stroke->update_step(C, stroke, &itemptr);
+ if (stroke->stroke_started) {
+ RNA_BEGIN (op->ptr, itemptr, "stroke")
+ {
+ stroke->update_step(C, stroke, &itemptr);
+ }
+ RNA_END;
}
- RNA_END;
+
+ bool ok = (stroke->stroke_started != 0);
stroke_done(C, op);
- return OPERATOR_FINISHED;
+ return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
void paint_stroke_cancel(bContext *C, wmOperator *op)