diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 10 | ||||
-rw-r--r-- | source/blender/blenlib/intern/task.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_walk.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 50 | ||||
-rw-r--r-- | source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c | 2 |
10 files changed, 57 insertions, 52 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e3af77166a9..3cfa8787f4b 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1991,7 +1991,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo float compare; float bstune = sb->ballstiff; - for (c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { + /* running in a slice we must not assume anything done with obp neither alter the data of obp */ + for (c=sb->totpoint, obp= sb->bpoint; c>0; c--, obp++) { compare = (obp->colball + bp->colball); sub_v3_v3v3(def, bp->pos, obp->pos); /* rather check the AABBoxes before ever calulating the real distance */ @@ -2016,13 +2017,6 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo madd_v3_v3fl(bp->force, def, f * (1.0f - sb->balldamp)); madd_v3_v3fl(bp->force, dvel, sb->balldamp); - - /* exploit force(a, b) == -force(b, a) part2/2 */ - sub_v3_v3v3(dvel, velcenter, obp->vec); - mul_v3_fl(dvel, _final_mass(ob, bp)); - - madd_v3_v3fl(obp->force, dvel, sb->balldamp); - madd_v3_v3fl(obp->force, def, -f * (1.0f - sb->balldamp)); } } } diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index 2c756aa6d65..29daac1ae48 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -1097,7 +1097,6 @@ void BLI_task_parallel_range(const int start, const int stop, } task_scheduler = BLI_task_scheduler_get(); - task_pool = BLI_task_pool_create_suspended(task_scheduler, &state); num_threads = BLI_task_scheduler_num_threads(task_scheduler); /* The idea here is to prevent creating task for each of the loop iterations @@ -1123,11 +1122,18 @@ void BLI_task_parallel_range(const int start, const int stop, break; } - num_tasks = min_ii(num_tasks, (stop - start) / state.chunk_size); + num_tasks = min_ii(num_tasks, + max_ii(1, (stop - start) / state.chunk_size)); - /* TODO(sergey): If number of tasks happened to be 1, use single threaded - * path. - */ + if (num_tasks == 1) { + palallel_range_single_thread(start, stop, + userdata, + func, + settings); + return; + } + + task_pool = BLI_task_pool_create_suspended(task_scheduler, &state); /* NOTE: This way we are adding a memory barrier and ensure all worker * threads can read and modify the value, without any locks. */ diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 76da1faf530..dd8607bb3eb 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -716,7 +716,7 @@ static void walkEvent(bContext *C, wmOperator *op, WalkInfo *walk, const wmEvent return; } - if ((walk->is_cursor_absolute == false) && WM_event_is_absolute(event)) { + if ((walk->is_cursor_absolute == false) && event->is_motion_absolute) { walk->is_cursor_absolute = true; copy_v2_v2_int(walk->prev_mval, event->mval); copy_v2_v2_int(walk->center_mval, event->mval); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 00b22ed4918..e62869f966b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -5780,13 +5780,10 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr) static char *rna_pointer_as_string__bldata(PointerRNA *ptr) { - if (ptr->type == NULL) { + if (ptr->type == NULL || ptr->id.data == NULL) { return BLI_strdup("None"); } else if (RNA_struct_is_ID(ptr->type)) { - if (ptr->id.data == NULL) { - return BLI_strdup("None"); - } return RNA_path_full_ID_py(ptr->id.data); } else { diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 36f07db727b..eda91c5156d 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1908,7 +1908,12 @@ static void rna_def_event(BlenderRNA *brna) prop = RNA_def_property(srna, "is_tablet", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Event_is_tablet_get", NULL); - RNA_def_property_ui_text(prop, "Tablet Pressure", "The pressure of the tablet or 1.0 if no tablet present"); + RNA_def_property_ui_text(prop, "Is Tablet", "The event has tablet data"); + + prop = RNA_def_property(srna, "is_mouse_absolute", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "is_motion_absolute", 1); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Absolute Motion", "The last motion event was an absolute input"); /* modifiers */ prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1db84b7d2ee..e3f53e4b5cb 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -214,7 +214,6 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase /* mouse */ void WM_event_add_mousemove(struct bContext *C); bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event); -bool WM_event_is_absolute(const struct wmEvent *event); bool WM_event_is_last_mousemove(const struct wmEvent *event); #ifdef WITH_INPUT_NDOF @@ -232,11 +231,11 @@ void WM_report_banner_show(void); void WM_report(ReportType type, const char *message); void WM_reportf(ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(2, 3); -void wm_event_add_ex( +struct wmEvent *wm_event_add_ex( struct wmWindow *win, const struct wmEvent *event_to_add, const struct wmEvent *event_to_add_after) ATTR_NONNULL(1, 2); -void wm_event_add( +struct wmEvent *wm_event_add( struct wmWindow *win, const struct wmEvent *event_to_add) ATTR_NONNULL(1, 2); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 9edae85cc3c..883a680acd7 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -473,8 +473,9 @@ typedef struct wmEvent { short keymodifier; /* rawkey modifier */ /* set in case a KM_PRESS went by unhandled */ - short check_click; - + char check_click; + char is_motion_absolute; + /* keymap item, set by handler (weak?) */ const char *keymap_idname; diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index d4c3928bd6c..ad5e83ceda7 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -213,13 +213,10 @@ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) } if ((G.debug & G_DEBUG) == 0) { if (win->ghostwin) { - const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); - /* Note: There is no tabletdata on Windows if no tablet device is connected. */ - if (!tabletdata) - GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); - else if (tabletdata->Active == GHOST_kTabletModeNone) + if (win->eventstate->is_motion_absolute == false) { GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); + } win->grabcursor = mode; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 3d5016af94b..154e120cde8 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -97,7 +97,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* ************ event management ************** */ -void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after) +wmEvent *wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after) { wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent"); @@ -105,6 +105,13 @@ void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent * update_tablet_data(win, event); + if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { + /* We could have a preference to support relative tablet motion (we can't detect that). */ + event->is_motion_absolute = ( + (event->tablet_data != NULL) && + (event->tablet_data->Active != GHOST_kTabletModeNone)); + } + if (event_to_add_after == NULL) { BLI_addtail(&win->queue, event); } @@ -112,11 +119,12 @@ void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent * /* note, strictly speaking this breaks const-correctness, however we're only changing 'next' member */ BLI_insertlinkafter(&win->queue, (void *)event_to_add_after, event); } + return event; } -void wm_event_add(wmWindow *win, const wmEvent *event_to_add) +wmEvent *wm_event_add(wmWindow *win, const wmEvent *event_to_add) { - wm_event_add_ex(win, event_to_add, NULL); + return wm_event_add_ex(win, event_to_add, NULL); } void wm_event_free(wmEvent *event) @@ -689,11 +697,6 @@ void WM_report_banner_show(void) wm_reports->reporttimer->customdata = rti; } -bool WM_event_is_absolute(const wmEvent *event) -{ - return (event->tablet_data != NULL); -} - bool WM_event_is_last_mousemove(const wmEvent *event) { while ((event = event->next)) { @@ -3523,7 +3526,7 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state) return false; } -static void wm_event_add_mousemove(wmWindow *win, const wmEvent *event) +static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event) { wmEvent *event_last = win->queue.last; @@ -3533,16 +3536,13 @@ static void wm_event_add_mousemove(wmWindow *win, const wmEvent *event) if (event_last && event_last->type == MOUSEMOVE) event_last->type = INBETWEEN_MOUSEMOVE; - wm_event_add(win, event); - - { - wmEvent *event_new = win->queue.last; - if (event_last == NULL) { - event_last = win->eventstate; - } - - copy_v2_v2_int(&event_new->prevx, &event_last->x); + wmEvent *event_new = wm_event_add(win, event); + if (event_last == NULL) { + event_last = win->eventstate; } + + copy_v2_v2_int(&event_new->prevx, &event_last->x); + return event_new; } /* windows store own event queues, no bContext here */ @@ -3572,8 +3572,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U wm_stereo3d_mouse_offset_apply(win, &event.x); event.type = MOUSEMOVE; - wm_event_add_mousemove(win, &event); - copy_v2_v2_int(&evt->x, &event.x); + { + wmEvent *event_new = wm_event_add_mousemove(win, &event); + copy_v2_v2_int(&evt->x, &event_new->x); + evt->is_motion_absolute = event_new->is_motion_absolute; + } /* also add to other window if event is there, this makes overdraws disappear nicely */ /* it remaps mousecoord to other window in event */ @@ -3585,8 +3588,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U copy_v2_v2_int(&oevent.x, &event.x); oevent.type = MOUSEMOVE; - wm_event_add_mousemove(owin, &oevent); - copy_v2_v2_int(&oevt->x, &oevent.x); + { + wmEvent *event_new = wm_event_add_mousemove(owin, &oevent); + copy_v2_v2_int(&oevt->x, &event_new->x); + oevt->is_motion_absolute = event_new->is_motion_absolute; + } } break; diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c index bf9b5b72c67..d051c93d892 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c @@ -906,7 +906,7 @@ void wm_manipulatormap_modal_set( mmap->mmap_context.modal = mpr; if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) && - (WM_event_is_absolute(event) == false)) + (event->is_motion_absolute == false)) { WM_cursor_grab_enable(win, true, true, NULL); copy_v2_v2_int(mmap->mmap_context.event_xy, &event->x); |