source/blender/blenkernel/BKE_paint.h | 2 ++ source/blender/editors/sculpt_paint/paint_stroke.c | 4 +++- source/blender/editors/sculpt_paint/sculpt.c | 17 +++++++++++++++-- source/blender/windowmanager/WM_types.h | 1 + source/blender/windowmanager/intern/wm_event_system.c | 7 +++++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index db35fbde2c8..9f8a7f808c2 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -324,6 +324,8 @@ typedef struct SculptSession { float init_pivot_rot[4]; float init_pivot_scale[3]; + double last_redraw; + union { struct { struct SculptVertexPaintGeomMap gmap; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 372ea954630..7e4a3fd0c0f 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1323,7 +1323,7 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2]) mouse[1] = stroke->constrained_pos[1] = len * sinf(angle) + stroke->last_mouse_position[1]; } } - +int in_stroke = 0; int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) { Paint *p = BKE_paint_get_active_from_context(C); @@ -1380,6 +1380,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) /* one time stroke initialization */ if (!stroke->stroke_started) { + in_stroke = 1; stroke->last_pressure = sample_average.pressure; copy_v2_v2(stroke->last_mouse_position, sample_average.mouse); if (paint_stroke_use_scene_spacing(br, mode)) { @@ -1422,6 +1423,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->type == stroke->event_type && !first_modal) { if (event->val == KM_RELEASE) { + in_stroke =0; copy_v2_fl2(mouse, event->mval[0], event->mval[1]); paint_stroke_line_constrain(stroke, mouse); paint_stroke_line_end(C, op, stroke, mouse); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a9334edd39b..d283e0dc045 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -35,6 +35,8 @@ #include "BLT_translation.h" +#include "PIL_time.h" + #include "DNA_customdata_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -7482,6 +7484,8 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) is_smooth = sculpt_needs_connectivity_info(brush, ss, mode); BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask); + + ss->last_redraw = PIL_check_seconds_timer(); } static void sculpt_restore_mesh(Sculpt *sd, Object *ob) @@ -7536,7 +7540,6 @@ static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags) /* Slow update with full dependency graph update and all that comes with it. * Needed when there are modifiers or full shading in the 3D viewport. */ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - ED_region_tag_redraw(ar); } else { /* Fast path where we just update the BVH nodes that changed. */ @@ -7548,8 +7551,18 @@ static void sculpt_flush_update_step(bContext *C, SculptUpdateType update_flags) * draw_mesh_object(). [#33790] */ sculpt_update_object_bounding_box(ob); } - + } +#if 1 + double tdraw = PIL_check_seconds_timer(); + bool redraw = (tdraw - ss->last_redraw) > (1.0f / 30.0f); +#else + bool redraw = true; +#endif + if (redraw) { ED_region_tag_redraw(ar); +#if 1 + ss->last_redraw = tdraw; +#endif } } diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index e9e4b7c6d12..2bd30506fcf 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -550,6 +550,7 @@ typedef struct wmEvent { /** Tablet info, only use when the tablet is active. */ const struct wmTabletData *tablet_data; + double time_stamp; /* custom data */ /** Custom data type, stylus, 6dof, see wm_event_types.h */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d90eab6f94f..c64276ef5b5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -124,7 +124,7 @@ wmEvent *wm_event_add_ex(wmWindow *win, wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent"); *event = *event_to_add; - + event->time_stamp = PIL_check_seconds_timer(); update_tablet_data(win, event); if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { @@ -160,9 +160,12 @@ wmEvent *WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add) win->eventstate->y = event->y; return event; } - +extern int in_stroke ; void wm_event_free(wmEvent *event) { + if (event->type == MOUSEMOVE && in_stroke==1) + printf("%.8f\n", (PIL_check_seconds_timer() - event->time_stamp) *1000 ); + if (event->customdata) { if (event->customdatafree) { /* note: pointer to listbase struct elsewhere */