diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-11-04 06:22:56 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-11-04 06:22:56 +0400 |
commit | dd8e83606776d1d3c51cd8f5c89bf6d1a7e05f74 (patch) | |
tree | 710d8682910d03d019ca0f4a1cb86fcf2b268c2e /source/blender/editors | |
parent | 6dfa1601092b9aa4de88420ce1e60371cd6aed69 (diff) | |
parent | 2f2c0a51a5b108213004dcda3da6defda82e6e41 (diff) |
Merged changes in the trunk up to revision 51853.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/bmesh/operators/bmo_utils.c
This commit also includes a fix of a bug identified during the merge and committed in revision 51853.
Thanks Thomas (dingto) for the timely fix!
Diffstat (limited to 'source/blender/editors')
57 files changed, 576 insertions, 449 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 81ebca7b2fb..c353b64607d 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -753,7 +753,7 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[ /* highlight only for active */ if (ale->flag & AGRP_ACTIVE) - copy_v3_v3_char((char *)cp, agrp->cs.active); + copy_v3_v3_char((char *)cp, agrp->cs.select); else copy_v3_v3_char((char *)cp, agrp->cs.solid); diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index a591b51b0b3..79a4c9a769d 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -167,7 +167,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, "y =", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, ""); /* coefficient */ - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, bwidth/2, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, bwidth / 2, 20, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Coefficient for polynomial")); /* 'x' param (and '+' if necessary) */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4f16c1a6622..8ba330e7c3c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -479,10 +479,10 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) /* Frame in which to add a new-keyframe occurs after all other keys * -> If there are at least two existing keyframes, then if the values of the - * last two keyframes and the new-keyframe match, the last existing keyframe - * gets deleted as it is no longer required. + * last two keyframes and the new-keyframe match, the last existing keyframe + * gets deleted as it is no longer required. * -> Otherwise, a keyframe is just added. 1.0 is added so that fake-2nd-to-last - * keyframe is not equal to last keyframe. + * keyframe is not equal to last keyframe. */ bezt = (fcu->bezt + (fcu->totvert - 1)); valA = bezt->vec[1][1]; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index e7586311312..9152ea8e198 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1226,7 +1226,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r hit->dist = dist; copy_v3_v3(hit->co, co); - isec->isect = dot_v3v3(no, ray->direction) <= 0.0; + isec->isect = (dot_v3v3(no, ray->direction) <= 0.0f); isec->labda = dist; isec->face = mf; } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 9ae5d3ca557..485d73974cd 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5641,8 +5641,8 @@ static int select_nth_exec(bContext *C, wmOperator *op) void CURVE_OT_select_nth(wmOperatorType *ot) { /* identifiers */ - ot->name = "Select Nth"; - ot->description = ""; + ot->name = "Checker Deselect"; + ot->description = "Deselect every other vertex"; ot->idname = "CURVE_OT_select_nth"; /* api callbacks */ diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 2d039cfaf7f..d92c20a1265 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -94,7 +94,8 @@ static char findaccent(char char1, unsigned int code) } else if (char1 == 'c') { if (code == ',') new = 231; - if (code == '|') new = 162; + else if (code == '|') new = 162; + else if (code == 'o') new = 169; } else if (char1 == 'e') { if (code == '`') new = 232; @@ -120,10 +121,18 @@ static char findaccent(char char1, unsigned int code) else if (code == '/') new = 248; else if (code == '-') new = 186; else if (code == 'e') new = 143; + else if (code == 'c') new = 169; + else if (code == 'r') new = 174; + } + else if (char1 == 'r') { + if (code == 'o') new = 174; } else if (char1 == 's') { if (code == 's') new = 167; } + else if (char1 == 't') { + if (code == 'm') new = 153; + } else if (char1 == 'u') { if (code == '`') new = 249; else if (code == 39) new = 250; @@ -1251,8 +1260,12 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) else ascii = 9; } - else if (event == BACKSPACEKEY) - ascii = 0; + + if (event == BACKSPACEKEY) { + if (alt && cu->len != 0 && cu->pos > 0) + accentcode = 1; + return OPERATOR_PASS_THROUGH; + } if (val && (ascii || evt->utf8_buf[0])) { /* handle case like TAB (== 9) */ @@ -1263,19 +1276,19 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) (evt->utf8_buf[0])) { - if (evt->utf8_buf[0]) { - BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1); - ascii = inserted_text[0]; - insert_into_textbuf(obedit, ascii); - accentcode = 0; - } - else if (accentcode) { + if (accentcode) { if (cu->pos > 0) { inserted_text[0] = findaccent(ef->textbuf[cu->pos - 1], ascii); ef->textbuf[cu->pos - 1] = inserted_text[0]; } accentcode = 0; } + else if (evt->utf8_buf[0]) { + BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1); + ascii = inserted_text[0]; + insert_into_textbuf(obedit, ascii); + accentcode = 0; + } else if (cu->len < MAXTEXT - 1) { if (alt) { /* might become obsolete, apple has default values for this, other OS's too? */ @@ -1312,12 +1325,6 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) text_update_edited(C, scene, obedit, 1, FO_EDIT); } } - else if (val && event == BACKSPACEKEY) { - if (alt && cu->len != 0 && cu->pos > 0) - accentcode = 1; - - return OPERATOR_PASS_THROUGH; - } else return OPERATOR_PASS_THROUGH; @@ -1330,7 +1337,8 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) } /* reset property? */ - accentcode = 0; + if (val == 0) + accentcode = 0; return OPERATOR_FINISHED; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 42ea924522c..9bfd89075af 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1648,7 +1648,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) * painting should start immediately. Otherwise, this was called from a toolbar, in which * case we should wait for the mouse to be clicked. */ - if (event->type) { + if (event->val == KM_PRESS) { /* hotkey invoked - start drawing */ //printf("\tGP - set first spot\n"); p->status = GP_STATUS_PAINTING; @@ -1723,7 +1723,7 @@ static void gpencil_stroke_end(wmOperator *op) static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p = op->customdata; - int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ + int estate = OPERATOR_RUNNING_MODAL; /* default exit state - we don't pass on events, GP is used with key-modifiers */ /* if (event->type == NDOF_MOTION) * return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h index dc40b687dfd..46ed9798d32 100644 --- a/source/blender/editors/include/ED_mask.h +++ b/source/blender/editors/include/ED_mask.h @@ -88,8 +88,8 @@ void free_gpcopybuf(void); void copy_gpdata(void); void paste_gpdata(void); - void snap_masklayer_frames(struct MaskLayer *masklay, short mode); - void mirror_masklayer_frames(struct MaskLayer *masklay, short mode); +void snap_masklayer_frames(struct MaskLayer *masklay, short mode); +void mirror_masklayer_frames(struct MaskLayer *masklay, short mode); #endif #endif /* __ED_MASK_H__ */ diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 078762065b4..5ffcfbd94f0 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -250,7 +250,7 @@ void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int c int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me, const char *name, int active_set); int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh *me); int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me); -int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum); +int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum); int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set); int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me); int ED_mesh_color_remove_named(struct bContext *C, struct Object *ob, struct Mesh *me, const char *name); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index a73954e2075..469bd11215e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -643,7 +643,7 @@ static void draw_scope_end(const rctf *rect, GLint *scissor) /* scale widget */ scaler_x1 = rect->xmin + BLI_rctf_size_x(rect) / 2 - SCOPE_RESIZE_PAD; - scaler_x2 = rect->xmin + BLI_rctf_size_y(rect) / 2 + SCOPE_RESIZE_PAD; + scaler_x2 = rect->xmin + BLI_rctf_size_x(rect) / 2 + SCOPE_RESIZE_PAD; glColor4f(0.f, 0.f, 0.f, 0.25f); fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 55b20bddd80..6d262daab12 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4933,8 +4933,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) if (but->flag & UI_BUT_DISABLED) return WM_UI_HANDLER_CONTINUE; - if ((data->state == BUTTON_STATE_HIGHLIGHT) || (event->type == EVT_DROP)) - { + if ((data->state == BUTTON_STATE_HIGHLIGHT) || (event->type == EVT_DROP)) { /* handle copy-paste */ if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && (event->ctrl || event->oskey)) { @@ -6308,67 +6307,75 @@ static char ui_menu_scroll_test(uiBlock *block, int my) { if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) { if (block->flag & UI_BLOCK_CLIPTOP) - if (my > block->rect.ymax - 14) + if (my > block->rect.ymax - UI_MENU_SCROLL_MOUSE) return 't'; if (block->flag & UI_BLOCK_CLIPBOTTOM) - if (my < block->rect.ymin + 14) + if (my < block->rect.ymin + UI_MENU_SCROLL_MOUSE) return 'b'; } return 0; } -static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) +static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt) { - char test = ui_menu_scroll_test(block, my); - - if (test) { - uiBut *b1 = block->buttons.first; - uiBut *b2 = block->buttons.last; - uiBut *bnext; - uiBut *bprev; - int dy = 0; - - /* get first and last visible buttons */ - while (b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED)) - b1 = ui_but_next(b1); - while (b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED)) - b2 = ui_but_prev(b2); - /* skips separators */ - bnext = ui_but_next(b1); - bprev = ui_but_prev(b2); + uiBut *bt; + float dy = 0.0f; + + if (to_bt) { + /* scroll to activated button */ + if (block->flag & UI_BLOCK_CLIPTOP) { + if (to_bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) + dy = block->rect.ymax - to_bt->rect.ymax - UI_MENU_SCROLL_ARROW; + } + if (block->flag & UI_BLOCK_CLIPBOTTOM) { + if (to_bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) + dy = block->rect.ymin - to_bt->rect.ymin + UI_MENU_SCROLL_ARROW; + } + } + else { + /* scroll when mouse over arrow buttons */ + char test = ui_menu_scroll_test(block, my); + + if (test == 't') + dy = -UI_UNIT_Y; /* scroll to the top */ + else if (test == 'b') + dy = UI_UNIT_Y; /* scroll to the bottom */ + } + + if (dy != 0.0f) { + if (dy < 0.0f) { + /* stop at top item, extra 0.5 unit Y makes it snap nicer */ + float ymax = -FLT_MAX; + + for (bt = block->buttons.first; bt; bt = bt->next) + ymax = max_ff(ymax, bt->rect.ymax); + + if (ymax + dy - UI_UNIT_Y*0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) + dy = block->rect.ymax - ymax - UI_MENU_SCROLL_PAD; + } + else { + /* stop at bottom item, extra 0.5 unit Y makes it snap nicer */ + float ymin = FLT_MAX; + + for (bt = block->buttons.first; bt; bt = bt->next) + ymin = min_ff(ymin, bt->rect.ymin); + + if (ymin + dy + UI_UNIT_Y*0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) + dy = block->rect.ymin - ymin + UI_MENU_SCROLL_PAD; + } + + /* apply scroll offset */ + for (bt = block->buttons.first; bt; bt = bt->next) { + bt->rect.ymin += dy; + bt->rect.ymax += dy; + } + + /* set flags again */ + ui_popup_block_scrolltest(block); - if (bnext == NULL || bprev == NULL) - return 0; + ED_region_tag_redraw(ar); - if (test == 't') { - /* bottom button is first button */ - if (b1->rect.ymin < b2->rect.ymin) - dy = bnext->rect.ymin - b1->rect.ymin; - /* bottom button is last button */ - else - dy = bprev->rect.ymin - b2->rect.ymin; - } - else if (test == 'b') { - /* bottom button is first button */ - if (b1->rect.ymin < b2->rect.ymin) - dy = b1->rect.ymin - bnext->rect.ymin; - /* bottom button is last button */ - else - dy = b2->rect.ymin - bprev->rect.ymin; - } - if (dy) { - - for (b1 = block->buttons.first; b1; b1 = b1->next) { - b1->rect.ymin -= dy; - b1->rect.ymax -= dy; - } - /* set flags again */ - ui_popup_block_scrolltest(block); - - ED_region_tag_redraw(ar); - - return 1; - } + return 1; } return 0; @@ -6404,7 +6411,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } else if (event->type == TIMER) { if (event->customdata == menu->scrolltimer) - ui_menu_scroll(ar, block, my); + ui_menu_scroll(ar, block, my, NULL); } else { /* for ui_mouse_motion_towards_block */ @@ -6499,8 +6506,10 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle but = ui_but_next(but); } - if (but) + if (but) { ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); + ui_menu_scroll(ar, block, my, but); + } } if (!but) { @@ -6526,6 +6535,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle if (bt) { ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE); + ui_menu_scroll(ar, block, my, bt); } } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 98b75060aa8..16159e0f73a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -97,6 +97,11 @@ typedef enum { UI_WTYPE_PROGRESSBAR } uiWidgetTypeEnum; +/* menu scrolling */ +#define UI_MENU_SCROLL_ARROW 12 +#define UI_MENU_SCROLL_MOUSE (UI_MENU_SCROLL_ARROW + 2) +#define UI_MENU_SCROLL_PAD 4 + /* panel limits */ #define UI_PANEL_MINX 100 #define UI_PANEL_MINY 70 diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index f522af51c42..28e361ccf5a 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1570,8 +1570,6 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block) void ui_popup_block_scrolltest(uiBlock *block) { uiBut *bt; - /* Knowing direction is necessary for multi-column menus... */ - int is_flip = (block->direction & UI_TOP) && !(block->flag & UI_BLOCK_NO_FLIP); block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP); @@ -1581,29 +1579,27 @@ void ui_popup_block_scrolltest(uiBlock *block) if (block->buttons.first == block->buttons.last) return; - /* mark buttons that are outside boundary and the ones next to it for arrow(s) */ + /* mark buttons that are outside boundary */ for (bt = block->buttons.first; bt; bt = bt->next) { if (bt->rect.ymin < block->rect.ymin) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPBOTTOM; - /* make space for arrow */ - if (bt->rect.ymax < block->rect.ymin + 10) { - if (is_flip && bt->next && bt->next->rect.ymin > bt->rect.ymin) - bt->next->flag |= UI_SCROLLED; - else if (!is_flip && bt->prev && bt->prev->rect.ymin > bt->rect.ymin) - bt->prev->flag |= UI_SCROLLED; - } } if (bt->rect.ymax > block->rect.ymax) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPTOP; - /* make space for arrow */ - if (bt->rect.ymin > block->rect.ymax - 10) { - if (!is_flip && bt->next && bt->next->rect.ymax < bt->rect.ymax) - bt->next->flag |= UI_SCROLLED; - else if (is_flip && bt->prev && bt->prev->rect.ymax < bt->rect.ymax) - bt->prev->flag |= UI_SCROLLED; - } + } + } + + /* mark buttons overlapping arrows, if we have them */ + for (bt = block->buttons.first; bt; bt = bt->next) { + if (block->flag & UI_BLOCK_CLIPBOTTOM) { + if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) + bt->flag |= UI_SCROLLED; + } + if (block->flag & UI_BLOCK_CLIPTOP) { + if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) + bt->flag |= UI_SCROLLED; } } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 238024a0856..f41abce947e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2000,7 +2000,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * /* draws in resolution of 20x4 colors */ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha) { - const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f; + const float color_step = (type == UI_GRAD_H) ? 0.02f : 0.05f; int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; @@ -2668,7 +2668,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), widgetbase_draw(&wtb, wcol); /* text space, arrows are about 0.6 height of button */ - rect->xmax -= (6*BLI_rcti_size_y(rect))/10; + rect->xmax -= (6 * BLI_rcti_size_y(rect)) / 10; } static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index fb7a2615583..f1a3f59bc22 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -599,7 +599,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) { /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ temp = BLI_rctf_cent_x(tot); - diff = curheight * 0.5f; + diff = curwidth * 0.5f; cur->xmin = temp - diff; cur->xmax = temp + diff; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 1c23df1c11e..74cdf4c2a11 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -479,7 +479,7 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline (void)draw_type; } -static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag,const char draw_type, +static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, const char draw_type, int width, int height) { MaskLayer *masklay; diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 417cf92c29f..c51d2cfb2e5 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -74,7 +74,7 @@ if(WITH_INTERNATIONAL) endif() if(WITH_BULLET) - add_definitions(-DWITH_BULLET) + add_definitions(-DWITH_BULLET) endif() blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 429b2148894..4350c005f95 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -85,7 +85,7 @@ void paintface_flush_flags(Object *ob) * - Final derived polys => Final derived tessfaces */ - if ((index_array = CustomData_get_layer(&me->fdata, CD_POLYINDEX))) { + if ((index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX))) { faces = me->mface; totface = me->totface; @@ -109,7 +109,7 @@ void paintface_flush_flags(Object *ob) } } - if ((index_array = CustomData_get_layer(&dm->faceData, CD_POLYINDEX))) { + if ((index_array = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))) { polys = dm->getPolyArray(dm); faces = dm->getTessFaceArray(dm); totface = dm->getNumTessFaces(dm); diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index e84fa90fe5c..468d0d8d8c6 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -405,8 +405,7 @@ int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Obje mul_m4_v3(invmat, origin); copy_v3_v3(co1, e->v1->co); - add_v3_v3v3(co2, e->v1->co, e->v2->co); - mul_v3_fl(co2, 0.5f); + mid_v3_v3v3(co2, e->v1->co, e->v2->co); copy_v3_v3(co3, e->v2->co); scale_point(co1, co2, 0.99); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 99eee19f66d..3e985a9779c 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -671,6 +671,13 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed, } /* **************** SIMILAR "group" SELECTS. FACE, EDGE AND VERTEX ************** */ +static EnumPropertyItem prop_similar_compare_types[] = { + {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""}, + {SIM_CMP_GT, "GREATER", 0, "Greater", ""}, + {SIM_CMP_LT, "LESS", 0, "Less", ""}, + + {0, NULL, 0, NULL, NULL} +}; static EnumPropertyItem prop_similar_types[] = { {SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""}, @@ -691,6 +698,7 @@ static EnumPropertyItem prop_similar_types[] = { {SIMFACE_MATERIAL, "MATERIAL", 0, "Material", ""}, {SIMFACE_IMAGE, "IMAGE", 0, "Image", ""}, {SIMFACE_AREA, "AREA", 0, "Area", ""}, + {SIMFACE_SIDES, "SIDES", 0, "Polygon Sides", ""}, {SIMFACE_PERIMETER, "PERIMETER", 0, "Perimeter", ""}, {SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""}, {SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""}, @@ -708,11 +716,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the type from RNA */ - int type = RNA_enum_get(op->ptr, "type"); - float thresh = RNA_float_get(op->ptr, "threshold"); + const int type = RNA_enum_get(op->ptr, "type"); + const float thresh = RNA_float_get(op->ptr, "threshold"); + const int compare = RNA_enum_get(op->ptr, "compare"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similar_faces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, + "similar_faces faces=%hf type=%i thresh=%f compare=%i", + BM_ELEM_SELECT, type, thresh, compare); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -746,11 +757,14 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the type from RNA */ - int type = RNA_enum_get(op->ptr, "type"); - float thresh = RNA_float_get(op->ptr, "threshold"); + const int type = RNA_enum_get(op->ptr, "type"); + const float thresh = RNA_float_get(op->ptr, "threshold"); + const int compare = RNA_enum_get(op->ptr, "compare"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similar_edges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, + "similar_edges edges=%he type=%i thresh=%f compare=%i", + BM_ELEM_SELECT, type, thresh, compare); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -787,11 +801,14 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; /* get the type from RNA */ - int type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); float thresh = RNA_float_get(op->ptr, "threshold"); + const int compare = RNA_enum_get(op->ptr, "compare"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similar_verts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, + "similar_verts verts=%hv type=%i thresh=%f compare=%i", + BM_ELEM_SELECT, type, thresh, compare); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -820,7 +837,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); PropertyRNA *prop = RNA_struct_find_property(op->ptr, "threshold"); - int type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); if (!RNA_property_is_set(op->ptr, prop)) { RNA_property_float_set(op->ptr, prop, ts->select_thresh); @@ -831,7 +848,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) if (type < 100) return similar_vert_select_exec(C, op); else if (type < 200) return similar_edge_select_exec(C, op); - else return similar_face_select_exec(C, op); + else return similar_face_select_exec(C, op); } static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), @@ -895,7 +912,9 @@ void MESH_OT_select_similar(wmOperatorType *ot) prop = ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", ""); RNA_def_enum_funcs(prop, select_similar_type_itemf); - RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.01, 1.0); + RNA_def_enum(ot->srna, "compare", prop_similar_compare_types, SIM_CMP_EQ, "Compare", ""); + + RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.0, 1.0); } /* ***************************************************** */ @@ -2299,9 +2318,9 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op) void MESH_OT_select_nth(wmOperatorType *ot) { /* identifiers */ - ot->name = "Select Nth"; + ot->name = "Checker Deselect"; ot->idname = "MESH_OT_select_nth"; - ot->description = "Select every Nth element starting from a selected vertex, edge or face"; + ot->description = "Deselect every Nth element starting from a selected vertex, edge or face"; /* api callbacks */ ot->exec = edbm_select_nth_exec; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 9d3cc7b7c76..df22cbcb294 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3808,30 +3808,36 @@ void MESH_OT_screw(wmOperatorType *ot) "Axis", "Axis in global view space", -1.0f, 1.0f); } -static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op) +static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMFace *efa; BMIter iter; - int numverts = RNA_int_get(op->ptr, "number"); - int type = RNA_enum_get(op->ptr, "type"); + const int numverts = RNA_int_get(op->ptr, "number"); + const int type = RNA_enum_get(op->ptr, "type"); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - int select = 0; + int select; - if (type == 0 && efa->len < numverts) { - select = 1; - } - else if (type == 1 && efa->len == numverts) { - select = 1; - } - else if (type == 2 && efa->len > numverts) { - select = 1; - } - else if (type == 3 && efa->len != numverts) { - select = 1; + switch (type) { + case 0: + select = (efa->len < numverts); + break; + case 1: + select = (efa->len == numverts); + break; + case 2: + select = (efa->len > numverts); + break; + case 3: + select = (efa->len != numverts); + break; + default: + BLI_assert(0); + select = FALSE; + break; } if (select) { @@ -3845,7 +3851,7 @@ static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void MESH_OT_select_by_number_vertices(wmOperatorType *ot) +void MESH_OT_select_face_by_sides(wmOperatorType *ot) { static const EnumPropertyItem type_items[] = { {0, "LESS", 0, "Less Than", ""}, @@ -3856,12 +3862,12 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot) }; /* identifiers */ - ot->name = "Select by Number of Vertices"; - ot->description = "Select vertices or faces by vertex count"; - ot->idname = "MESH_OT_select_by_number_vertices"; + ot->name = "Select Faces by Sides"; + ot->description = "Select vertices or faces by the number of polygon sides"; + ot->idname = "MESH_OT_select_face_by_sides"; /* api callbacks */ - ot->exec = edbm_select_by_number_vertices_exec; + ot->exec = edbm_select_face_by_sides_exec; ot->poll = ED_operator_editmesh; /* flags */ diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 4adf37a14c3..e9906f852de 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -235,7 +235,8 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la } } -int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum) +/* without bContext, called in uvedit */ +int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) { BMEditMesh *em = me->edit_btmesh; MLoopUV *luv; @@ -338,7 +339,6 @@ int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int laye BLI_array_free(polylengths); DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); return 1; } @@ -348,7 +348,11 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) /* could be ldata or pdata */ CustomData *pdata = GET_CD_DATA(me, pdata); const int layernum = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY); - return ED_mesh_uv_loop_reset_ex(C, me, layernum); + int retval = ED_mesh_uv_loop_reset_ex(me, layernum); + + WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + + return retval; } /* note: keep in sync with ED_mesh_color_add */ @@ -419,7 +423,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s /* don't overwrite our copied coords */ if (is_init == FALSE) { - ED_mesh_uv_loop_reset_ex(C, me, layernum_dst); + ED_mesh_uv_loop_reset_ex(me, layernum_dst); } DAG_id_tag_update(&me->id, 0); @@ -902,7 +906,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) * so rather then add poly-index layer and calculate normals for it * calculate normals only for the mvert's. - campbell */ #ifdef USE_BMESH_MPOLY_NORMALS - polyindex = CustomData_get_layer(&mesh->fdata, CD_POLYINDEX); + polyindex = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX); /* add a normals layer for tessellated faces, a tessface normal will * contain the normal of the poly the face was tessellated from. */ face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface); @@ -947,6 +951,7 @@ static void mesh_add_verts(Mesh *mesh, int len) /* scan the input list and insert the new vertices */ + /* set default flags */ mvert = &mesh->mvert[mesh->totvert]; for (i = 0; i < len; i++, mvert++) mvert->flag |= SELECT; diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 65701663df4..881e4bc02e2 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -121,7 +121,7 @@ void MESH_OT_select_linked(struct wmOperatorType *ot); void MESH_OT_select_linked_pick(struct wmOperatorType *ot); void MESH_OT_hide(struct wmOperatorType *ot); void MESH_OT_reveal(struct wmOperatorType *ot); -void MESH_OT_select_by_number_vertices(struct wmOperatorType *ot); +void MESH_OT_select_face_by_sides(struct wmOperatorType *ot); void MESH_OT_select_loose_verts(struct wmOperatorType *ot); void MESH_OT_select_mirror(struct wmOperatorType *ot); void MESH_OT_normals_make_consistent(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 64e61d436ee..4036e0c6822 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -68,7 +68,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_select_random); WM_operatortype_append(MESH_OT_hide); WM_operatortype_append(MESH_OT_reveal); - WM_operatortype_append(MESH_OT_select_by_number_vertices); + WM_operatortype_append(MESH_OT_select_face_by_sides); WM_operatortype_append(MESH_OT_select_loose_verts); WM_operatortype_append(MESH_OT_select_mirror); WM_operatortype_append(MESH_OT_normals_make_consistent); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 765f9307247..c0b6327d740 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -299,12 +299,12 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* setup new data for destination mesh */ - memset(&vdata, 0, sizeof(vdata)); - memset(&edata, 0, sizeof(edata)); - memset(&fdata, 0, sizeof(fdata)); - memset(&ldata, 0, sizeof(ldata)); - memset(&pdata, 0, sizeof(pdata)); - + CustomData_reset(&vdata); + CustomData_reset(&edata); + CustomData_reset(&fdata); + CustomData_reset(&ldata); + CustomData_reset(&pdata); + mvert = CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert); medge = CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); mloop = CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 2914a1ff673..ee3c66b6eac 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -150,11 +150,13 @@ typedef struct { float height_min, height_max; Image *ima; DerivedMesh *ssdm; - const int *origindex; + const int *orig_index_mf_to_mpoly; + const int *orig_index_mp_to_orig; } MHeightBakeData; typedef struct { - const int *origindex; + const int *orig_index_mf_to_mpoly; + const int *orig_index_mp_to_orig; } MNormalBakeData; static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int face_num, const int vert_index) @@ -508,7 +510,9 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float interp_bilinear_quad_data(data, u, v, res); } -static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *origindex, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3]) +static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, + const int *index_mf_to_mpoly, const int *index_mp_to_orig, + const int lvl, const int face_index, const float u, const float v, float co[3], float n[3]) { MFace mface; CCGElem **grid_data; @@ -532,7 +536,7 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig } else { int side = (1 << (lvl - 1)) + 1; - int grid_index = origindex[face_index]; + int grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index); int loc_offs = face_index % (1 << (2 * lvl)); int cell_index = loc_offs % ((side - 1) * (side - 1)); int cell_side = (grid_size - 1) / (side - 1); @@ -628,7 +632,8 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) } } - height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); + height_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); + height_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX); return (void *)height_data; } @@ -640,7 +645,8 @@ static void *init_normal_data(MultiresBakeRender *bkr, Image *UNUSED(ima)) normal_data = MEM_callocN(sizeof(MNormalBakeData), "MultiresBake normalData"); - normal_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); + normal_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); + normal_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX); return (void *)normal_data; } @@ -735,10 +741,14 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, CLAMP(uv[0], 0.0f, 1.0f); CLAMP(uv[1], 0.0f, 1.0f); - get_ccgdm_data(lores_dm, hires_dm, height_data->origindex, lvl, face_index, uv[0], uv[1], p1, 0); + get_ccgdm_data(lores_dm, hires_dm, + height_data->orig_index_mf_to_mpoly, height_data->orig_index_mf_to_mpoly, + lvl, face_index, uv[0], uv[1], p1, 0); if (height_data->ssdm) { - get_ccgdm_data(lores_dm, height_data->ssdm, height_data->origindex, 0, face_index, uv[0], uv[1], p0, n); + get_ccgdm_data(lores_dm, height_data->ssdm, + height_data->orig_index_mf_to_mpoly, height_data->orig_index_mf_to_mpoly, + 0, face_index, uv[0], uv[1], p0, n); } else { lores_dm->getTessFace(lores_dm, face_index, &mface); @@ -808,7 +818,9 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, CLAMP(uv[0], 0.0f, 1.0f); CLAMP(uv[1], 0.0f, 1.0f); - get_ccgdm_data(lores_dm, hires_dm, normal_data->origindex, lvl, face_index, uv[0], uv[1], NULL, n); + get_ccgdm_data(lores_dm, hires_dm, + normal_data->orig_index_mf_to_mpoly, normal_data->orig_index_mp_to_orig, + lvl, face_index, uv[0], uv[1], NULL, n); mul_v3_m3v3(vec, tangmat, n); normalize_v3(vec); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index c0f9ecfa5a2..05524af34f0 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -138,21 +138,12 @@ bDeformGroup *ED_vgroup_add(Object *ob) void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) { - bDeformGroup *dg = (bDeformGroup *)ob->defbase.first; - - while (dg) { - if (dg == defgroup) - break; - dg = dg->next; - } - - if (dg == NULL) - return; + BLI_assert(BLI_findindex(&ob->defbase, defgroup) != -1); if (ED_vgroup_object_is_edit_mode(ob)) - vgroup_delete_edit_mode(ob, dg); + vgroup_delete_edit_mode(ob, defgroup); else - vgroup_delete_object_mode(ob, dg); + vgroup_delete_object_mode(ob, defgroup); } void ED_vgroup_clear(Object *ob) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 4a313079ad0..9a21595e482 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -944,8 +944,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor if (domainSettings->resolutionxyz>128) { gridlevels = 2; } - else - if (domainSettings->resolutionxyz>64) { + else if (domainSettings->resolutionxyz > 64) { gridlevels = 1; } else { diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index ad9b082d044..fe802abc3a9 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -497,8 +497,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - /* stop all running jobs, currently previews frustrate Render */ - WM_jobs_stop_all(CTX_wm_manager(C)); + /* stop all running jobs, except screen one. currently previews frustrate Render */ + WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C)); /* get main */ if (G.debug_value == 101) { diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 0b6b5cb8e4a..e4592a4f77e 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -333,8 +333,8 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) return 0; } - /* stop all running jobs, currently previews frustrate Render */ - WM_jobs_stop_all(CTX_wm_manager(C)); + /* stop all running jobs, except screen one. currently previews frustrate Render */ + WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C)); /* create offscreen buffer */ sizex = (scene->r.size * scene->r.xsch) / 100; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bd171ef247a..6a9c24d2913 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3156,11 +3156,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e for (sa = window->screen->areabase.first; sa; sa = sa->next) { ARegion *ar; for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar == sad->ar) + if (ar == sad->ar) { ED_region_tag_redraw(ar); - else - if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) + } + else if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) { ED_region_tag_redraw(ar); + } } if (match_area_with_refresh(sa->spacetype, sad->refresh)) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 91a0a3821c9..e00a8776bea 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5266,10 +5266,12 @@ static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) if (!rv3d) { SpaceImage *sima = CTX_wm_space_image(C); ARegion *ar = CTX_wm_region(C); - - ED_space_image_get_zoom(sima, ar, zoomx, zoomy); - return 1; + if (sima->mode == SI_MODE_PAINT) { + ED_space_image_get_zoom(sima, ar, zoomx, zoomy); + + return 1; + } } *zoomx = *zoomy = 1; @@ -5290,16 +5292,13 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) Brush *brush = paint_brush(paint); if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { - ToolSettings *ts; float zoomx, zoomy; const float size = (float)BKE_brush_size_get(scene, brush); short use_zoom; float pixel_size; float alpha = 0.5f; - ts = scene->toolsettings; - use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy) && - !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT)); + use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy); if (use_zoom) { pixel_size = size * max_ff(zoomx, zoomy); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index b3679516fff..c5eff1a1f0e 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -248,19 +248,25 @@ static void imapaint_tri_weights(Object *ob, void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2]) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - const int *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); MTFace *tface = dm->getTessFaceDataArray(dm, CD_MTFACE), *tf; int numfaces = dm->getNumTessFaces(dm), a, findex; float p[2], w[3], absw, minabsw; MFace mf; MVert mv[4]; + /* double lookup */ + const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); + const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); + if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { + index_mf_to_mpoly = index_mp_to_orig = NULL; + } + minabsw = 1e10; uv[0] = uv[1] = 0.0; /* test all faces in the derivedmesh with the original index of the picked face */ for (a = 0; a < numfaces; a++) { - findex = index ? index[a] : a; + findex = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a; if (findex == faceindex) { dm->getTessFace(dm, a, &mf); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index b8ac88f4d65..56d46a22e10 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -79,6 +79,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "GPU_buffers.h" #include "ED_armature.h" #include "ED_mesh.h" @@ -106,18 +107,40 @@ static int vertex_paint_use_fast_update_check(Object *ob) /* if the polygons from the mesh and the 'derivedFinal' match * we can assume that no modifiers are applied and that its worth adding tessellated faces * so 'vertex_paint_use_fast_update_check()' returns TRUE */ -static int vertex_paint_use_tessface_check(Object *ob) +static int vertex_paint_use_tessface_check(Object *ob, Mesh *me) { DerivedMesh *dm = ob->derivedFinal; - if (dm) { - Mesh *me = BKE_mesh_from_object(ob); - return (me->mpoly == CustomData_get_layer(&dm->faceData, CD_MPOLY)); + if (me && dm) { + return (me->mpoly == CustomData_get_layer(&dm->polyData, CD_MPOLY)); } return FALSE; } +static void update_tessface_data(Object *ob, Mesh *me) +{ + if (vertex_paint_use_tessface_check(ob, me)) { + /* assume if these exist, that they are up to date & valid */ + if (!me->mcol || !me->mface) { + /* should always be true */ + /* XXX Why this clearing? tessface_calc will reset it anyway! */ +/* if (me->mcol) {*/ +/* memset(me->mcol, 255, 4 * sizeof(MCol) * me->totface);*/ +/* }*/ + + /* create tessfaces because they will be used for drawing & fast updates */ + BKE_mesh_tessface_calc(me); /* does own call to update pointers */ + } + } + else { + if (me->totface) { + /* this wont be used, theres no need to keep it */ + BKE_mesh_tessface_clear(me); + } + } + +} /* polling - retrieve whether cursor should be set or operator should be done */ /* Returns true if vertex paint mode is active */ @@ -331,24 +354,7 @@ static void make_vertexcol(Object *ob) /* single ob */ mesh_update_customdata_pointers(me, TRUE); } - if (vertex_paint_use_tessface_check(ob)) { - /* assume if these exist, that they are up to date & valid */ - if (!me->mcol || !me->mface) { - /* should always be true */ - if (me->mcol) { - memset(me->mcol, 255, 4 * sizeof(MCol) * me->totface); - } - - /* create tessfaces because they will be used for drawing & fast updates */ - BKE_mesh_tessface_calc(me); /* does own call to update pointers */ - } - } - else { - if (me->totface) { - /* this wont be used, theres no need to keep it */ - BKE_mesh_tessface_clear(me); - } - } + update_tessface_data(ob, me); //if (shade) // shadeMeshMCol(scene, ob, me); @@ -2564,7 +2570,7 @@ static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me) vd->polyfacemap = BLI_memarena_alloc(vd->polyfacemap_arena, sizeof(ListBase) * me->totpoly); - origIndex = CustomData_get_layer(&me->fdata, CD_POLYINDEX); + origIndex = CustomData_get_layer(&me->fdata, CD_ORIGINDEX); mf = me->mface; if (!origIndex) @@ -2600,7 +2606,12 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl make_vertexcol(ob); if (me->mloopcol == NULL) return OPERATOR_CANCELLED; - + + /* Update tessface data if needed + * Added here too because e.g. switching to/from edit mode would remove tessface data, + * yet "fast_update" could still be used! */ + update_tessface_data(ob, me); + /* make mode data storage */ vpd = MEM_callocN(sizeof(struct VPaintData), "VPaintData"); paint_stroke_set_mode_data(stroke, vpd); @@ -2616,9 +2627,11 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl if (vertex_paint_use_fast_update_check(ob)) { vpaint_build_poly_facemap(vpd, me); vpd->use_fast_update = TRUE; +/* printf("Fast update!\n");*/ } else { vpd->use_fast_update = FALSE; +/* printf("No fast update!\n");*/ } /* for filtering */ @@ -2632,14 +2645,6 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl return 1; } -static void copy_lcol_to_mcol(MCol *mcol, const MLoopCol *lcol) -{ - mcol->a = lcol->a; - mcol->r = lcol->r; - mcol->g = lcol->g; - mcol->b = lcol->b; -} - static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, const unsigned int index, const float mval[2], const float brush_size_pressure, const float brush_alpha_pressure) @@ -2707,11 +2712,18 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, ml = me->mloop + mpoly->loopstart; mlc = me->mloopcol + mpoly->loopstart; for (j = 0; j < mpoly->totloop; j++, ml++, mlc++) { - if (ml->v == mf->v1) copy_lcol_to_mcol(mc + 0, mlc); - else if (ml->v == mf->v2) copy_lcol_to_mcol(mc + 1, mlc); - else if (ml->v == mf->v3) copy_lcol_to_mcol(mc + 2, mlc); - else if (mf->v4 && ml->v == mf->v4) copy_lcol_to_mcol(mc + 3, mlc); - + if (ml->v == mf->v1) { + MESH_MLOOPCOL_TO_MCOL(mlc, mc + 0); + } + else if (ml->v == mf->v2) { + MESH_MLOOPCOL_TO_MCOL(mlc, mc + 1); + } + else if (ml->v == mf->v3) { + MESH_MLOOPCOL_TO_MCOL(mlc, mc + 2); + } + else if (mf->v4 && ml->v == mf->v4) { + MESH_MLOOPCOL_TO_MCOL(mlc, mc + 3); + } } } } @@ -2792,6 +2804,10 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P * avoid this if we can! */ DAG_id_tag_update(ob->data, 0); } + else if (!GPU_buffer_legacy(ob->derivedFinal)) { + /* If using new VBO drawing, mark mcol as dirty to force colors gpu buffer refresh! */ + ob->derivedFinal->dirty |= DM_DIRTY_MCOL_UPDATE_DRAW; + } } static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index c2344cca557..d3ae5373a18 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -450,7 +450,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op)) memmove(ci->line + len, ci->line, ci->len); memset(ci->line, ' ', len); ci->len += len; + BLI_assert(ci->len >= 0); console_line_cursor_set(ci, ci->cursor + len); + console_select_offset(sc, len); console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); @@ -496,9 +498,10 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op)) memmove(ci->line, ci->line + len, (ci->len - len) + 1); ci->len -= len; - console_line_cursor_set(ci, ci->cursor - len); + BLI_assert(ci->len >= 0); - //console_select_offset(sc, -4); + console_line_cursor_set(ci, ci->cursor - len); + console_select_offset(sc, -len); console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); @@ -555,6 +558,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) if (stride) { memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); ci->len -= stride; + BLI_assert(ci->len >= 0); done = TRUE; } } @@ -571,6 +575,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) ci->cursor -= stride; /* same as above */ memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); ci->len -= stride; + BLI_assert(ci->len >= 0); done = TRUE; } } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index b505fed7baa..0b5f636cedd 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -785,6 +785,7 @@ static int file_extension_type(const char *relname) } else if (BLI_testextensie(relname, ".txt") || BLI_testextensie(relname, ".glsl") || + BLI_testextensie(relname, ".osl") || BLI_testextensie(relname, ".data")) { return TEXTFILE; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index c57bfaeeb2c..a5647c06b92 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -367,7 +367,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) FSRefMakePath(&dir, path, FILE_MAX); if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) { /* /net and /home are meaningless on OSX, home folders are stored in /Users */ - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, (char *)path, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); } } @@ -429,7 +429,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII)) continue; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED); CFRelease(pathString); CFRelease(cfURL); @@ -456,7 +456,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) FSRefMakePath(&dir, path, FILE_MAX); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, (char *)path, FS_INSERT_SORTED); + if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) { + /* /net and /home are meaningless on OSX, home folders are stored in /Users */ + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); + } } /* Finally get user favorite places */ diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index bffabe6d160..5a8a7cef119 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -56,6 +56,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_sca.h" +#include "BKE_screen.h" #include "ED_util.h" @@ -66,6 +67,7 @@ #include "BLF_translation.h" #include "UI_interface.h" +#include "UI_view2d.h" #include "RNA_access.h" @@ -2208,15 +2210,13 @@ void logic_buttons(bContext *C, ARegion *ar) SpaceLogic *slogic= CTX_wm_space_logic(C); Object *ob= CTX_data_active_object(C); ID **idar; - PointerRNA logic_ptr, settings_ptr, object_ptr; - uiLayout *layout, *row, *box; uiBlock *block; uiBut *but; char uiblockstr[32]; short a, count; - int xco, yco, width; + int xco, yco, width, height; if (ob==NULL) return; @@ -2270,7 +2270,7 @@ void logic_buttons(bContext *C, ARegion *ar) /* ****************** Controllers ****************** */ - xco= 420; yco= 170; width= 300; + xco= 420; yco= -10; width= 300; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); @@ -2373,11 +2373,11 @@ void logic_buttons(bContext *C, ARegion *ar) } } uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ - + height = yco; /* ****************** Sensors ****************** */ - xco= 10; yco= 170; width= 340; + xco= 10; yco= -10; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); @@ -2442,10 +2442,11 @@ void logic_buttons(bContext *C, ARegion *ar) } } uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ + height = MIN2(height, yco); /* ****************** Actuators ****************** */ - xco= 800; yco= 170; width= 340; + xco= 800; yco= -10; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); @@ -2513,13 +2514,21 @@ void logic_buttons(bContext *C, ARegion *ar) } } uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ + height = MIN2(height, yco); + + UI_view2d_totRect_set(&ar->v2d, 1150, height); - + /* set the view */ + UI_view2d_view_ortho(&ar->v2d); + uiComposeLinks(block); uiEndBlock(C, block); uiDrawBlock(C, block); + /* restore view matrix */ + UI_view2d_view_restore(C); + if (idar) MEM_freeN(idar); } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index c4ec801d6ed..4cd53215697 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -84,8 +84,9 @@ ARegion *logic_has_buttons_region(ScrArea *sa) /* ******************** default callbacks for image space ***************** */ -static SpaceLink *logic_new(const bContext *UNUSED(C)) +static SpaceLink *logic_new(const bContext *C) { + ScrArea *sa= CTX_wm_area(C); ARegion *ar; SpaceLogic *slogic; @@ -93,10 +94,10 @@ static SpaceLink *logic_new(const bContext *UNUSED(C)) slogic->spacetype= SPACE_LOGIC; /* default options */ - slogic->scaflag = (BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) | - (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) | - (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) | - (BUTS_SENS_STATE|BUTS_ACT_STATE); + slogic->scaflag = ((BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) | + (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) | + (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) | + (BUTS_SENS_STATE|BUTS_ACT_STATE)); /* header */ @@ -120,14 +121,11 @@ static SpaceLink *logic_new(const bContext *UNUSED(C)) ar->regiontype= RGN_TYPE_WINDOW; ar->v2d.tot.xmin = 0.0f; - ar->v2d.tot.ymin = 0.0f; - ar->v2d.tot.xmax = 1280; - ar->v2d.tot.ymax = 240.0f; + ar->v2d.tot.ymax = 0.0f; + ar->v2d.tot.xmax = 1150.0f; + ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy; - ar->v2d.cur.xmin = 0.0f; - ar->v2d.cur.ymin = 0.0f; - ar->v2d.cur.xmax = 1280.0f; - ar->v2d.cur.ymax = 240.0f; + ar->v2d.cur = ar->v2d.tot; ar->v2d.min[0] = 1.0f; ar->v2d.min[1] = 1.0f; @@ -136,12 +134,13 @@ static SpaceLink *logic_new(const bContext *UNUSED(C)) ar->v2d.max[1] = 32000.0f; ar->v2d.minzoom = 0.5f; - ar->v2d.maxzoom = 1.21f; + ar->v2d.maxzoom = 1.5f; ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT; - ar->v2d.keeptot = 0; - + ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; + ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X; + ar->v2d.keepofs = V2D_KEEPOFS_Y; return (SpaceLink *)slogic; } @@ -183,6 +182,9 @@ static void logic_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_item(keymap, "VIEW2D_OT_reset", HOMEKEY, KM_PRESS, 0, 0); + } static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa)) @@ -234,7 +236,7 @@ static void logic_main_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -259,7 +261,7 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 711944809fd..0938562857b 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1384,11 +1384,39 @@ static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), Point uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE); } +static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiLayout *row; + + row = uiLayoutRow(layout, FALSE); + uiItemR(row, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + + row = uiLayoutRow(layout, TRUE); + + if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL) + uiItemR(row, ptr, "script", 0, "", ICON_NONE); + else + uiItemR(row, ptr, "filepath", 0, "", ICON_NONE); + + uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update"); +} + +static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr) +{ + uiItemS(layout); + + node_shader_buts_script(layout, C, ptr); + + /* not implemented yet + if(RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL) + uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);*/ +} + /* only once called */ static void node_shader_set_butfunc(bNodeType *ntype) { switch (ntype->type) { - /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */ + /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */ case SH_NODE_MATERIAL: case SH_NODE_MATERIAL_EXT: @@ -1467,6 +1495,10 @@ static void node_shader_set_butfunc(bNodeType *ntype) case SH_NODE_BSDF_GLASS: ntype->uifunc = node_shader_buts_glossy; break; + case SH_NODE_SCRIPT: + ntype->uifunc = node_shader_buts_script; + ntype->uifuncbut = node_shader_buts_script_details; + break; } } @@ -2639,7 +2671,7 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN static void node_composit_set_butfunc(bNodeType *ntype) { switch (ntype->type) { - /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */ + /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */ case CMP_NODE_IMAGE: ntype->uifunc = node_composit_buts_image; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index f21f343ea2b..6bf0e9f73e3 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -35,6 +35,7 @@ #include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_text_types.h" #include "DNA_world_types.h" #include "BLI_math.h" @@ -54,6 +55,7 @@ #include "BKE_scene.h" #include "BKE_texture.h" +#include "RE_engine.h" #include "RE_pipeline.h" @@ -2137,3 +2139,120 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +/* ********************** Shader Script Update ******************/ + +typedef struct ScriptUpdateData { + RenderEngine *engine; + RenderEngineType *type; + + Text *text; + int found; +} ScriptUpdateData; + +static int node_shader_script_update_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + RenderEngineType *type = RE_engines_find(scene->r.engine); + bNode *node; + Text *text; + + /* test if we have a render engine that supports shaders scripts */ + if (!(type && type->update_script_node)) + return 0; + + /* see if we have a shader script node in context */ + node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data; + if (node && node->type == SH_NODE_SCRIPT) { + NodeShaderScript *nss = node->storage; + + if (node->id || nss->filepath[0]) { + return 1; + } + } + + /* see if we have a text datablock in context */ + text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data; + if (text) + return 1; + + /* we don't check if text datablock is actually in use, too slow for poll */ + + return 0; +} + +static void node_shader_script_update_text(void *data_, ID *UNUSED(id), bNodeTree *ntree) +{ + ScriptUpdateData *data = (ScriptUpdateData *)data_; + bNode *node; + + /* update each script that is using this text datablock */ + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_GROUP) { + node_shader_script_update_text(data_, NULL, (bNodeTree *)node->id); + } + else if (node->type == SH_NODE_SCRIPT && node->id == &data->text->id) { + data->type->update_script_node(data->engine, ntree, node); + data->found = TRUE; + } + } +} + +static int node_shader_script_update_exec(bContext *C, wmOperator *op) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ScriptUpdateData data; + PointerRNA nodeptr = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript); + + /* setup render engine */ + data.type = RE_engines_find(scene->r.engine); + data.engine = RE_engine_create(data.type); + data.engine->reports = op->reports; + data.text = NULL; + data.found = FALSE; + + if (nodeptr.data) { + /* update single node */ + bNodeTree *ntree = nodeptr.id.data; + bNode *node = nodeptr.data; + + data.type->update_script_node(data.engine, ntree, node); + + data.found = TRUE; + } + else { + /* update all nodes using text datablock */ + data.text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data; + + if (data.text) { + bNodeTreeType *ntreetype = ntreeGetType(NTREE_SHADER); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(bmain, &data, node_shader_script_update_text); + + if (!data.found) + BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done."); + } + } + + RE_engine_free(data.engine); + + return (data.found)? OPERATOR_FINISHED: OPERATOR_CANCELLED; +} + +void NODE_OT_shader_script_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Script Node Update"; + ot->description = "Update shader script node with new sockets and options from the script"; + ot->idname = "NODE_OT_shader_script_update"; + + /* api callbacks */ + ot->exec = node_shader_script_update_exec; + ot->poll = node_shader_script_update_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 36ebddc8d22..45509e02226 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -206,6 +206,8 @@ void NODE_OT_output_file_move_active_socket(struct wmOperatorType *ot); void NODE_OT_clipboard_copy(struct wmOperatorType *ot); void NODE_OT_clipboard_paste(struct wmOperatorType *ot); +void NODE_OT_shader_script_update(struct wmOperatorType *ot); + extern const char *node_context_dir[]; // XXXXXX diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 560ef9e8a29..64e5f67a348 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -117,6 +117,8 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_clipboard_copy); WM_operatortype_append(NODE_OT_clipboard_paste); + + WM_operatortype_append(NODE_OT_shader_script_update); } void ED_operatormacros_node(void) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index d4df449a41b..23f4e948794 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -292,8 +292,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) BLI_strncpy(node_name, node->typeinfo->name, UI_MAX_NAME_STR); if (node->inputs.first == NULL && - node->outputs.first != node->outputs.last && - !(node->typeinfo->flag & NODE_OPTIONS)) + node->outputs.first != node->outputs.last) { BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", IFACE_(node_name), IFACE_(sock->link->fromsock->name)); } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 5fb9780c700..3b83279e09d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -158,11 +158,16 @@ static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEl totcol = mb->totcol; matar = mb->mat; } + else { + BLI_assert(0); + } - for (a = 0; a < totcol; a++) { - if (a == te->index && matar[a]) { - matar[a]->id.us--; - matar[a] = NULL; + if (LIKELY(matar != NULL)) { + for (a = 0; a < totcol; a++) { + if (a == te->index && matar[a]) { + matar[a]->id.us--; + matar[a] = NULL; + } } } } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index c4df89547ef..192f45ac918 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -414,8 +414,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); } } - else - if (seq->type == SEQ_TYPE_SOUND_RAM) { + else if (seq->type == SEQ_TYPE_SOUND_RAM) { if (seq->strip) { BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 27a660eac2b..d46eb51f2c5 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -132,7 +132,8 @@ typedef struct drawDMFacesSel_userData { BMEditMesh *em; /* BMESH BRANCH ONLY */ BMFace *efa_act; - int *orig_index; + int *orig_index_mf_to_mpoly; + int *orig_index_mp_to_orig; } drawDMFacesSel_userData; typedef struct drawDMNormal_userData { @@ -233,12 +234,13 @@ static int check_alpha_pass(Base *base) } /***/ -static unsigned int colortab[24] = -{0x0, 0xFF88FF, 0xFFBBFF, - 0x403000, 0xFFFF88, 0xFFFFBB, - 0x104040, 0x66CCCC, 0x77CCCC, - 0x104010, 0x55BB55, 0x66FF66, - 0xFFFFFF}; +static unsigned int colortab[24] = { + 0x0, 0xFF88FF, 0xFFBBFF, + 0x403000, 0xFFFF88, 0xFFFFBB, + 0x104040, 0x66CCCC, 0x77CCCC, + 0x104010, 0x55BB55, 0x66FF66, + 0xFFFFFF +}; static float cube[8][3] = { @@ -2325,11 +2327,11 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int unsigned char *col, *next_col; - if (!data->orig_index) + if (!data->orig_index_mf_to_mpoly) return 0; - efa = EDBM_face_at_index(data->em, data->orig_index[index]); - next_efa = EDBM_face_at_index(data->em, data->orig_index[next_index]); + efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index)); + next_efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index)); if (efa == next_efa) return 1; @@ -2358,7 +2360,12 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba data.cols[2] = markCol; data.cols[3] = actCol; data.efa_act = efa_act; - data.orig_index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); + /* double lookup */ + data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); + data.orig_index_mp_to_orig = DM_get_poly_data_layer(dm, CD_ORIGINDEX); + if ((data.orig_index_mf_to_mpoly && data.orig_index_mp_to_orig) == FALSE) { + data.orig_index_mf_to_mpoly = data.orig_index_mp_to_orig = NULL; + } dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions, &data, 0); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index d61ba5f1181..0a282a17f74 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1216,13 +1216,13 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (ca->flag & CAM_SHOWTITLESAFE) { UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - hmargin = 0.1 * (x2 - x1); - vmargin = 0.05 * (y2 - y1); - uiDrawBox(GL_LINE_LOOP, x1+hmargin, y1+vmargin, x2-hmargin, y2-vmargin, 2.0); + hmargin = 0.1f * (x2 - x1); + vmargin = 0.05f * (y2 - y1); + uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1+vmargin, x2 - hmargin, y2 - vmargin, 2.0f); - hmargin = 0.035 * (x2 - x1); - vmargin = 0.035 * (y2 - y1); - uiDrawBox(GL_LINE_LOOP, x1+hmargin, y1+vmargin, x2-hmargin, y2-vmargin, 2.0); + hmargin = 0.035f * (x2 - x1); + vmargin = 0.035f * (y2 - y1); + uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1+vmargin, x2 - hmargin, y2 - vmargin, 2.0f); } if (ca && (ca->flag & CAM_SHOWSENSOR)) { /* determine sensor fit, and get sensor x/y, for auto fit we diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 242a3327b78..36d7341f2f2 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2204,8 +2204,8 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, } } - add_v3_v3v3(new_ofs, min, max); - mul_v3_fl(new_ofs, -0.5f); + mid_v3_v3v3(new_ofs, min, max); + negate_v3(new_ofs); new_dist = size; diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 5362f0377c3..6ba05abae9a 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -163,8 +163,8 @@ eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], con float tvec[2]; eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { - if ((tvec[0] > -32700.0 && tvec[0] < 32700.0f) && - (tvec[1] > -32700.0 && tvec[1] < 32700.0f)) + if ((tvec[0] > -32700.0f && tvec[0] < 32700.0f) && + (tvec[1] > -32700.0f && tvec[1] < 32700.0f)) { r_co[0] = (short)floor(tvec[0]); r_co[1] = (short)floor(tvec[1]); @@ -182,8 +182,8 @@ eV3DProjStatus ED_view3d_project_int_ex(ARegion *ar, float perspmat[4][4], const float tvec[2]; eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); if (ret == V3D_PROJ_RET_OK) { - if ((tvec[0] > -2140000000.0 && tvec[0] < 2140000000.0f) && - (tvec[1] > -2140000000.0 && tvec[1] < 2140000000.0f)) + if ((tvec[0] > -2140000000.0f && tvec[0] < 2140000000.0f) && + (tvec[1] > -2140000000.0f && tvec[1] < 2140000000.0f)) { r_co[0] = (int)floor(tvec[0]); r_co[1] = (int)floor(tvec[1]); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 1537b4f61ce..76296b6d3e0 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4793,8 +4793,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l, cross_v3_v3v3(a, f2, l->f->no); mul_v3_fl(a, -1.0f); - add_v3_v3(a, f3); - mul_v3_fl(a, 0.5f); + mid_v3_v3v3(a, a, f3); } copy_v3_v3(vec, a); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 53cedc78d5c..2a01b03ec14 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -130,9 +130,9 @@ static int trans_data_compare_dist(const void *A, const void *B) const TransData *td_A = (const TransData*)A; const TransData *td_B = (const TransData*)B; - if(td_A->dist < td_B->dist) + if (td_A->dist < td_B->dist) return -1; - else if(td_A->dist > td_B->dist) + else if (td_A->dist > td_B->dist) return 1; return 0; @@ -143,9 +143,9 @@ static int trans_data_compare_rdist(const void *A, const void *B) const TransData *td_A = (const TransData*)A; const TransData *td_B = (const TransData*)B; - if(td_A->rdist < td_B->rdist) + if (td_A->rdist < td_B->rdist) return -1; - else if(td_A->rdist > td_B->rdist) + else if (td_A->rdist > td_B->rdist) return 1; return 0; @@ -318,12 +318,8 @@ static void createTransEdge(TransInfo *t) BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) { - float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); - float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); - /* need to set center for center calculations */ - add_v3_v3v3(td->center, eed->v1->co, eed->v2->co); - mul_v3_fl(td->center, 0.5f); + mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co); td->loc = NULL; if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) @@ -331,16 +327,18 @@ static void createTransEdge(TransInfo *t) else td->flag = 0; - copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); td->ext = NULL; if (t->mode == TFM_BWEIGHT) { + float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); td->val = bweight; td->ival = bweight ? *bweight : 1.0f; } else { + float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); + BLI_assert(t->mode == TFM_CREASE); td->val = crease; td->ival = crease ? *crease : 0.0f; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index f550cb05a8b..615bb786071 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1568,9 +1568,8 @@ void calculateCenterBound(TransInfo *t) copy_v3_v3(min, t->data[i].center); } } - add_v3_v3v3(t->center, min, max); - mul_v3_fl(t->center, 0.5); - + mid_v3_v3v3(t->center, min, max); + calculateCenter2D(t); } @@ -1712,7 +1711,7 @@ void calculatePropRatio(TransInfo *t) /* * The elements are sorted according to their dist member in the array, * that means we can stop when it finds one element outside of the propsize. - * do not set td->flag |= TD_NOACTION , the prop circle is being changed. + * do not set 'td->flag |= TD_NOACTION', the prop circle is being changed. */ td->factor = 0.0f; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index baca4629883..a6fb7e7ed00 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -78,8 +78,6 @@ #include "transform.h" -#define USE_BVH_FACE_SNAP - #define TRANSFORM_DIST_MAX_PX 1000 /********************* PROTOTYPES ***********************/ @@ -1136,58 +1134,6 @@ static void TargetSnapClosest(TransInfo *t) t->tsnap.status |= TARGET_INIT; } } -/*================================================================*/ -#ifndef USE_BVH_FACE_SNAP -static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], float *v4co, float mval[2], float ray_start[3], float ray_start_local[3], float ray_normal_local[3], float obmat[][4], float timat[][3], float loc[3], float no[3], int *dist, float *depth) -{ - float lambda; - int result; - int retval = 0; - - result = isect_ray_tri_threshold_v3(ray_start_local, ray_normal_local, v1co, v2co, v3co, &lambda, NULL, 0.001); - - if (result) { - float location[3], normal[3]; - float intersect[3]; - float new_depth; - int screen_loc[2]; - int new_dist; - - copy_v3_v3(intersect, ray_normal_local); - mul_v3_fl(intersect, lambda); - add_v3_v3(intersect, ray_start_local); - - copy_v3_v3(location, intersect); - - if (v4co) - normal_quad_v3(normal, v1co, v2co, v3co, v4co); - else - normal_tri_v3(normal, v1co, v2co, v3co); - - mul_m4_v3(obmat, location); - - new_depth = len_v3v3(location, ray_start); - - ED_view3d_project_int(ar, location, screen_loc); - new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); - - if (new_dist <= *dist && new_depth < *depth) { - *depth = new_depth; - retval = 1; - - copy_v3_v3(loc, location); - copy_v3_v3(no, normal); - - mul_m3_v3(timat, no); - normalize_v3(no); - - *dist = new_dist; - } - } - - return retval; -} -#endif static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float obmat[][4], float timat[][3], const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2], @@ -1426,7 +1372,6 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh switch (snap_mode) { case SCE_SNAP_MODE_FACE: { -#ifdef USE_BVH_FACE_SNAP // Added for durian BVHTreeRayHit hit; BVHTreeFromMesh treeData; @@ -1456,80 +1401,6 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh } } break; - -#else - MVert *verts = dm->getVertArray(dm); - MFace *faces = dm->getTessFaceArray(dm); - int *index_array = NULL; - int index = 0; - int i; - - if (em != NULL) { - index_array = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); - EDBM_index_arrays_init(em, 0, 0, 1); - } - - for (i = 0; i < totface; i++) { - BMFace *efa = NULL; - MFace *f = faces + i; - - test = 1; /* reset for every face */ - - if (em != NULL) { - if (index_array) { - index = index_array[i]; - } - else { - index = i; - } - - if (index == ORIGINDEX_NONE) { - test = 0; - } - else { - efa = EDBM_face_at_index(em, index); - - if (efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { - test = 0; - } - else if (efa) { - BMIter iter; - BMLoop *l; - - l = BM_iter_new(&iter, em->bm, BM_LOOPS_OF_FACE, efa); - for (; l; l = BM_iter_step(&iter)) { - if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) { - test = 0; - break; - } - } - } - } - } - - - if (test) { - int result; - float *v4co = NULL; - - if (f->v4) { - v4co = verts[f->v4].co; - } - - result = snapFace(ar, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, v4co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth); - retval |= result; - - if (f->v4 && result == 0) { - retval |= snapFace(ar, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, verts[f->v2].co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth); - } - } - } - - if (em != NULL) { - EDBM_index_arrays_free(em); - } -#endif - break; } case SCE_SNAP_MODE_VERTEX: { diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index b0edc702e48..e953aa2f0ed 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -409,7 +409,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 MEM_freeN(quats); } - if (!*deformmats) { + if (*deformmats == NULL) { int a, numVerts; Mesh *me = (Mesh *)ob->data; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 4b008d9a30f..e860d486ea3 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -215,6 +215,8 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY); BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV); + /* make UVs all nice 0-1 */ + ED_mesh_uv_loop_reset_ex(obedit->data, CustomData_get_active_layer_index(&em->bm->pdata, CD_MTEXPOLY)); update = 1; } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 74d007e92c0..393c119b347 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -369,7 +369,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e /* Used to hold subsurfed Mesh */ DerivedMesh *derivedMesh, *initialDerived; /* holds original indices for subsurfed mesh */ - int *origVertIndices, *origFaceIndices, *origEdgeIndices; + int *origVertIndices, *origEdgeIndices, *origFaceIndices, *origPolyIndices; /* Holds vertices of subsurfed mesh */ MVert *subsurfedVerts; MEdge *subsurfedEdges; @@ -422,6 +422,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e origVertIndices = derivedMesh->getVertDataArray(derivedMesh, CD_ORIGINDEX); origEdgeIndices = derivedMesh->getEdgeDataArray(derivedMesh, CD_ORIGINDEX); origFaceIndices = derivedMesh->getTessFaceDataArray(derivedMesh, CD_ORIGINDEX); + origPolyIndices = derivedMesh->getPolyDataArray(derivedMesh, CD_ORIGINDEX); numOfEdges = derivedMesh->getNumEdges(derivedMesh); numOfFaces = derivedMesh->getNumTessFaces(derivedMesh); @@ -433,7 +434,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e /* map subsurfed faces to original editFaces */ for (i = 0; i < numOfFaces; i++) - faceMap[i] = EDBM_face_at_index(em, origFaceIndices[i]); + faceMap[i] = EDBM_face_at_index(em, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i)); edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map"); @@ -1170,7 +1171,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) int correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect"); int use_subsurf = RNA_boolean_get(op->ptr, "use_subsurf_data"); int subsurf_level = RNA_int_get(op->ptr, "uv_subsurf_level"); - float obsize[3], unitsize[3] = {1.0f, 1.0f, 1.0f}; + float obsize[3]; short implicit = 0; if (!uvedit_have_selection(scene, em, implicit)) { @@ -1183,9 +1184,9 @@ static int unwrap_exec(bContext *C, wmOperator *op) } mat4_to_size(obsize, obedit->obmat); - if (!compare_v3v3(obsize, unitsize, 1e-4f)) + if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f)) BKE_report(op->reports, RPT_INFO, - "Object scale is not 1.0, unwrap will operate on a non-scaled version of the mesh"); + "Object has non-uniform scale, unwrap will operate on a non-scaled version of the mesh"); /* remember last method for live unwrap */ if (RNA_struct_property_is_set(op->ptr, "method")) |