diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 05:14:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 05:14:33 +0400 |
commit | 3c8d86e117b54914524cbc49a8678ecaad8671cf (patch) | |
tree | 8101c8b12f888ded58d7e489e7855e754f0cf065 /source/blender/editors | |
parent | 331dd678c75ba1ef4e714c989c8f1bfae35508c2 (diff) | |
parent | acf30220c9d63e0f060ee69115fe82016de025d4 (diff) |
svn merge ^/trunk/blender -r41961:41998
Diffstat (limited to 'source/blender/editors')
27 files changed, 429 insertions, 453 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 081d604819d..def6cd61370 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -794,7 +794,7 @@ void draw_gpencil_view3d (Scene *scene, View3D *v3d, ARegion *ar, short only3d) * deal with the camera border, otherwise map the coords to the camera border. */ if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) { rctf rectf; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, -1); /* negative shift */ + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, TRUE); /* no shift */ BLI_copy_rcti_rctf(&rect, &rectf); } else { diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 65db5e27ed7..9a492153b7f 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -468,7 +468,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene= CTX_data_scene(C); - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, -1); /* negative shift */ + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, TRUE); /* no shift */ return 1; } } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 2dd8ef4da94..f09797bf6f1 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1258,7 +1258,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, -1); /* negative shift */ + ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, TRUE); /* no shift */ p->subrect= &p->subrect_data; } } diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 37f647abfd9..2ca3e2bfe7f 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -183,10 +183,10 @@ typedef enum SnapMode #define SNAP_MIN_DISTANCE 30 -int peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, float mval[2]); -int peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, float mval[2]); -int snapObjectsTransform(struct TransInfo *t, float mval[2], int *dist, float *loc, float *no, SnapMode mode); -int snapObjectsContext(struct bContext *C, float mval[2], int *dist, float *loc, float *no, SnapMode mode); +int peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, const float mval[2]); +int peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2]); +int snapObjectsTransform(struct TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode); +int snapObjectsContext(struct bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode); #endif diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 51e0e25f545..07fc4e77ac1 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -209,13 +209,13 @@ void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]); void project_float(struct ARegion *ar, const float vec[3], float adr[2]); void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); -void ED_view3d_ob_clip_range_get(struct Object *ob, float *lens, float *clipsta, float *clipend); int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); -int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize); +int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void ED_view3d_project_float(struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); +void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift); void ED_view3d_project_float_v3(struct ARegion *a, float *vec, float *adr, float mat[4][4]); -void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short do_shift); +void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]); /* drawobject.c iterators */ void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BMVert *eve, int x, int y, int index), void *userData, int clipVerts); @@ -294,6 +294,7 @@ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the view to the camera, return TRUE if */ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); -struct BGpic *ED_view3D_background_image_add(struct View3D *v3d); +struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); +void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 4b1371c532c..37a057303e9 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -318,6 +318,9 @@ void UI_ThemeClearColor(int colorid); // internal (blender) usage only, for init and set active void UI_SetTheme(int spacetype, int regionid); +// get current theme +struct bTheme *UI_GetTheme(void); + /* only for buttons in theme editor! */ const unsigned char *UI_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b34b56f31ed..4b7adbc1064 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2618,11 +2618,8 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s else BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value); - if(value == item[i].value) { + if(value == item[i].value) icon= item[i].icon; - if(!tip) - tip= item[i].description; - } } str= BLI_dynstr_get_cstring(dynstr); BLI_dynstr_free(dynstr); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 089458f1da4..1b7308d328e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -506,7 +506,7 @@ static void init_brush_icons(void) static void init_internal_icons(void) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); ImBuf *bbuf= NULL; int x, y, icontype; char iconfilestr[FILE_MAXDIR+FILE_MAXFILE]; @@ -950,6 +950,7 @@ static int get_draw_size(enum eIconSizes size) static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview) { + bTheme *btheme= UI_GetTheme(); Icon *icon = NULL; DrawInfo *di = NULL; IconImage *iimg; @@ -957,6 +958,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al int w, h; icon = BKE_icon_get(icon_id); + alpha *= btheme->tui.icon_alpha; if (icon==NULL) { if (G.f & G_DEBUG) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 16e0153b910..d6460f9046e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -112,7 +112,7 @@ typedef enum { /* internal panel drawing defines */ #define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ -#define PNL_HEADER UI_UNIT_Y /* 20 default */ +#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ /* panel->flag */ #define PNL_SELECT 1 diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index aa80cb632ec..ad79e550575 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -59,6 +59,7 @@ #include "ED_screen.h" #include "UI_interface.h" +#include "UI_resources.h" #include "interface_intern.h" @@ -173,7 +174,6 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar) Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open) { - uiStyle *style= UI_GetStyle(); Panel *pa, *patab, *palast, *panext; char *drawname= pt->label; char *idname= pt->idname; @@ -208,7 +208,7 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int } pa->ofsx= 0; - pa->ofsy= style->panelouter; + pa->ofsy= 0; pa->sizex= 0; pa->sizey= 0; pa->runtime_flag |= PNL_NEW_ADDED; @@ -482,6 +482,7 @@ static void rectf_scale(rctf *rect, float scale) /* panel integrated in buttonswindow, tool/property lists etc */ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) { + bTheme *btheme= UI_GetTheme(); Panel *panel= block->panel; rcti headrect; rctf itemrect; @@ -493,19 +494,37 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* calculate header rect */ /* + 0.001f to prevent flicker due to float inaccuracy */ headrect= *rect; - headrect.ymin= headrect.ymax; + headrect.ymin= headrect.ymax - 2.0f/block->aspect; headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f); - if(!(panel->runtime_flag & PNL_FIRST)) { - float minx= rect->xmin+5.0f/block->aspect; - float maxx= rect->xmax-5.0f/block->aspect; + { + float minx= rect->xmin; + float maxx= rect->xmax; float y= headrect.ymax; - + glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.5f); - fdrawline(minx, y+1, maxx, y+1); - glColor4f(1.0f, 1.0f, 1.0f, 0.25f); - fdrawline(minx, y, maxx, y); + + if(btheme->tui.panel.show_header) { + /* draw with background color */ + glEnable(GL_BLEND); + glColor4ubv((unsigned char*)btheme->tui.panel.header); + glRectf(minx, headrect.ymin, maxx, y); + + fdrawline(minx, y, maxx, y); + fdrawline(minx, y, maxx, y); + } + else if(!(panel->runtime_flag & PNL_FIRST)) { + /* draw embossed separator */ + minx += 5.0f/block->aspect; + maxx -= 5.0f/block->aspect; + + glColor4f(0.0f, 0.0f, 0.0f, 0.5f); + fdrawline(minx, y+1, maxx, y+1); + glColor4f(1.0f, 1.0f, 1.0f, 0.25f); + fdrawline(minx, y, maxx, y); + glDisable(GL_BLEND); + } + glDisable(GL_BLEND); } @@ -518,7 +537,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) itemrect.xmin= itemrect.xmax - (headrect.ymax-headrect.ymin); itemrect.ymin= headrect.ymin; itemrect.ymax= headrect.ymax; - rectf_scale(&itemrect, 0.8f); + + rectf_scale(&itemrect, 0.7f); ui_draw_panel_dragwidget(&itemrect); } @@ -538,7 +558,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* in some occasions, draw a border */ if(panel->flag & PNL_SELECT) { if(panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL); - else uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); + else uiSetRoundBox(UI_CNR_NONE); UI_ThemeColorShade(TH_BACK, -120); uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax+1, 8); @@ -567,7 +587,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) itemrect.ymin= headrect.ymin; itemrect.ymax= headrect.ymax; - rectf_scale(&itemrect, 0.5f); + rectf_scale(&itemrect, 0.35f); if(panel->flag & PNL_CLOSEDY) ui_draw_tria_rect(&itemrect, 'h'); @@ -589,12 +609,12 @@ static int get_panel_header(Panel *pa) return PNL_HEADER; } -static int get_panel_size_y(uiStyle *style, Panel *pa) +static int get_panel_size_y(Panel *pa) { if(pa->type && (pa->type->flag & PNL_NO_HEADER)) return pa->sizey; - return PNL_HEADER + pa->sizey + style->panelouter; + return PNL_HEADER + pa->sizey; } /* this function is needed because uiBlock and Panel itself dont @@ -667,7 +687,6 @@ static int compare_panel(const void *a1, const void *a2) /* returns 1 when it did something */ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) { - uiStyle *style= UI_GetStyle(); Panel *pa; PanelSort *ps, *panelsort, *psnext; int a, tot=0, done; @@ -719,18 +738,18 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) /* no smart other default start loc! this keeps switching f5/f6/etc compatible */ ps= panelsort; ps->pa->ofsx= 0; - ps->pa->ofsy= -get_panel_size_y(style, ps->pa); + ps->pa->ofsy= -get_panel_size_y(ps->pa); for(a=0; a<tot-1; a++, ps++) { psnext= ps+1; if(align==BUT_VERTICAL) { psnext->pa->ofsx= ps->pa->ofsx; - psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - get_panel_size_y(style, psnext->pa); + psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); } else { psnext->pa->ofsx= get_panel_real_ofsx(ps->pa); - psnext->pa->ofsy= ps->pa->ofsy + get_panel_size_y(style, ps->pa) - get_panel_size_y(style, psnext->pa); + psnext->pa->ofsy= ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa); } } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 513f084b6e8..47dde3f03f0 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -376,17 +376,18 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->totline++; } - if(but->type == ROW) { + if(ELEM(but->type, ROW, MENU)) { EnumPropertyItem *item; int i, totitem, free; + int value = (but->type == ROW)? but->hardmax: ui_get_but_val(but); RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &item, &totitem, &free); for(i=0; i<totitem; i++) { - if(item[i].identifier[0] && item[i].value == (int)but->hardmax) { + if(item[i].identifier[0] && item[i].value == value) { if(item[i].description[0]) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "%s: %s", item[i].name, item[i].description); - data->color[data->totline]= 0xFFFFFF; + data->color[data->totline]= 0xDDDDDD; data->totline++; } break; @@ -1446,6 +1447,8 @@ 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); @@ -1462,9 +1465,9 @@ void ui_popup_block_scrolltest(uiBlock *block) block->flag |= UI_BLOCK_CLIPBOTTOM; /* make space for arrow */ if(bt->y2 < block->miny +10) { - if(bt->next && bt->next->y1 > bt->y1) + if(is_flip && bt->next && bt->next->y1 > bt->y1) bt->next->flag |= UI_SCROLLED; - if(bt->prev && bt->prev->y1 > bt->y1) + else if(!is_flip && bt->prev && bt->prev->y1 > bt->y1) bt->prev->flag |= UI_SCROLLED; } } @@ -1473,9 +1476,9 @@ void ui_popup_block_scrolltest(uiBlock *block) block->flag |= UI_BLOCK_CLIPTOP; /* make space for arrow */ if(bt->y1 > block->maxy -10) { - if(bt->next && bt->next->y2 < bt->y2) + if(!is_flip && bt->next && bt->next->y2 < bt->y2) bt->next->flag |= UI_SCROLLED; - if(bt->prev && bt->prev->y2 < bt->y2) + else if(is_flip && bt->prev && bt->prev->y2 < bt->y2) bt->prev->flag |= UI_SCROLLED; } } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 0e9dbaf3022..3caafe308d0 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -124,7 +124,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id style->buttonspacex= 8; style->buttonspacey= 2; style->panelspace= 8; - style->panelouter= 4; return style; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c9fcb7f1d24..9a438070e1e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1617,7 +1617,7 @@ static void widget_state_option_menu(uiWidgetType *wt, int state) if(state & UI_SELECT) UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text); else { - bTheme *btheme= U.themes.first; /* XXX */ + bTheme *btheme= UI_GetTheme(); /* XXX */ copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text); } @@ -2760,7 +2760,7 @@ static void widget_disabled(rcti *rect) static uiWidgetType *widget_type(uiWidgetTypeEnum type) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); static uiWidgetType wt; /* defaults */ @@ -2945,7 +2945,7 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) /* conversion from old to new buttons, so still messy */ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); ThemeUI *tui= &btheme->tui; uiFontStyle *fstyle= &style->widget; uiWidgetType *wt= NULL; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 738531e3bad..66add6d8f0c 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -839,6 +839,11 @@ void UI_SetTheme(int spacetype, int regionid) } } +bTheme *UI_GetTheme() +{ + return U.themes.first; +} + // for space windows only void UI_ThemeColor(int colorid) { @@ -1668,6 +1673,15 @@ void init_userdef_do_versions(void) } } + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + SETCOL(btheme->tui.panel.header, 0, 0, 0, 25); + btheme->tui.icon_alpha= 1.0; + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 5e97e01aed6..c2c482b0a2c 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1558,7 +1558,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v if (scroll & V2D_SCROLL_HORIZONTAL) { /* only draw scrollbar when it doesn't fill the entire space */ if(vs->horfull==0) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; int state; @@ -1669,7 +1669,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v if (scroll & V2D_SCROLL_VERTICAL) { /* only draw scrollbar when it doesn't fill the entire space */ if(vs->vertfull==0) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; int state; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 998e70d5e25..5706da93fe9 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -985,12 +985,12 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* x-axis transform */ dist = (v2d->mask.xmax - v2d->mask.xmin) / 2.0f; - dx= 1.0f - ((float)fabs(vzd->lastx - dist) + 2.0f) / ((float)fabs(event->x - dist) + 2.0f); + dx= 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f); dx*= 0.5f * (v2d->cur.xmax - v2d->cur.xmin); /* y-axis transform */ dist = (v2d->mask.ymax - v2d->mask.ymin) / 2.0f; - dy= 1.0f - ((float)fabs(vzd->lasty - dist) + 2.0f) / ((float)fabs(event->y - dist) + 2.0f); + dy= 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f); dy*= 0.5f * (v2d->cur.ymax - v2d->cur.ymin); } else { diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index fa764e6eefc..843918e9173 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -147,7 +147,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) rctf viewplane; float clipsta, clipend; - int is_ortho= ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL); + int is_ortho= ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend); if(is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend); else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 6a93e39a662..4a06ee6d0ae 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -175,6 +175,7 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) dx= copysign(ceil(0.3f*fabs(dx)), dx); dy= copysign(ceil(0.3f*fabs(dy)), dy); + glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glColor4ub(255, 255, 255, 180); @@ -192,6 +193,7 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) fdrawline(x1, y2-2*dy+1, x2-2*dx+1, y1); glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); } static void region_draw_azone_icon(AZone *az) @@ -228,6 +230,49 @@ static void region_draw_azone_icon(AZone *az) sdrawline(midx-2, midy, midx+3, midy); } +static void draw_azone_plus(float x1, float y1, float x2, float y2) +{ + float width = 2.0f; + float pad = 4.0f; + + glRectf((x1 + x2 - width)*0.5f, y1 + pad, (x1 + x2 + width)*0.5f, y2 - pad); + glRectf(x1 + pad, (y1 + y2 - width)*0.5f, (x1 + x2 - width)*0.5f, (y1 + y2 + width)*0.5f); + glRectf((x1 + x2 + width)*0.5f, (y1 + y2 - width)*0.5f, x2 - pad, (y1 + y2 + width)*0.5f); +} + +static void region_draw_azone_tab_plus(AZone *az) +{ + extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */ + + glEnable(GL_BLEND); + + /* add code to draw region hidden as 'too small' */ + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); + break; + case AE_BOTTOM_TO_TOPLEFT: + uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); + break; + case AE_LEFT_TO_TOPRIGHT: + uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); + break; + case AE_RIGHT_TO_TOPLEFT: + uiSetRoundBox(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); + break; + } + + glColor4f(0.05f, 0.05f, 0.05f, 0.5f); + uiRoundBox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); + + glEnable(GL_BLEND); + + glColor4f(0.8f, 0.8f, 0.8f, 0.5f); + draw_azone_plus((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2); + + glDisable(GL_BLEND); +} + static void region_draw_azone_tab(AZone *az) { float col[3]; @@ -326,13 +371,14 @@ void ED_area_overdraw(bContext *C) if(az->ar) { /* only display tab or icons when the region is hidden */ if (az->ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - - if(G.rt==2) + if(G.rt==3) + region_draw_azone_icon(az); + else if(G.rt==2) region_draw_azone_tria(az); else if(G.rt==1) region_draw_azone_tab(az); else - region_draw_azone_icon(az); + region_draw_azone_tab_plus(az); } } } @@ -665,6 +711,51 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) } } +#define AZONEPAD_TAB_PLUSW 16 +#define AZONEPAD_TAB_PLUSH 16 + +/* region already made zero sized, in shape of edge */ +static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) +{ + AZone *azt; + int tot= 0, add; + + for(azt= sa->actionzones.first; azt; azt= azt->next) { + if(azt->edge == az->edge) tot++; + } + + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + if(ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; + az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; + az->y1= ar->winrct.ymax - add; + az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; + az->y2= ar->winrct.ymax - add + AZONEPAD_TAB_PLUSH; + break; + case AE_BOTTOM_TO_TOPLEFT: + az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; + az->y1= ar->winrct.ymin - AZONEPAD_TAB_PLUSH; + az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; + az->y2= ar->winrct.ymin; + break; + case AE_LEFT_TO_TOPRIGHT: + az->x1= ar->winrct.xmin + 1 - AZONEPAD_TAB_PLUSH; + az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW; + az->x2= ar->winrct.xmin + 1; + az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW; + break; + case AE_RIGHT_TO_TOPLEFT: + az->x1= ar->winrct.xmax - 1; + az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW; + az->x2= ar->winrct.xmax - 1 + AZONEPAD_TAB_PLUSH; + az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW; + break; + } + /* rect needed for mouse pointer test */ + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); +} + + #define AZONEPAD_TABW 18 #define AZONEPAD_TABH 7 @@ -766,12 +857,14 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) az->edge= edge; if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if(G.rt==2) + if(G.rt==3) + region_azone_icon(sa, az, ar); + else if(G.rt==2) region_azone_tria(sa, az, ar); else if(G.rt==1) region_azone_tab(sa, az, ar); else - region_azone_icon(sa, az, ar); + region_azone_tab_plus(sa, az, ar); } else { region_azone_edge(az, ar); } @@ -1481,7 +1574,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * } x= 0; - y= -style->panelouter; + y= 0; /* create panels */ uiBeginPanels(C, ar); @@ -1553,11 +1646,11 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * if(pt->flag & PNL_NO_HEADER) y += yco; else - y += yco-style->panelouter; + y += yco; } else { x += w; - miny= MIN2(y, yco-style->panelouter-header); + miny= MIN2(y, yco-header); } } } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index c0d4b9106e6..7ae5f433ff3 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -3060,25 +3060,24 @@ static void project_paint_begin(ProjPaintState *ps) invert_m4_m4(viewinv, viewmat); } else if (ps->source==PROJ_SRC_IMAGE_CAM) { - Object *camera= ps->scene->camera; - - /* dont actually use these */ - float _viewdx, _viewdy, _ycor, _lens=0.0f, _sensor_x=DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT; - short _sensor_fit= CAMERA_SENSOR_FIT_AUTO; - rctf _viewplane; + Object *cam_ob= ps->scene->camera; + CameraParams params; /* viewmat & viewinv */ - copy_m4_m4(viewinv, ps->scene->camera->obmat); + copy_m4_m4(viewinv, cam_ob->obmat); normalize_m4(viewinv); invert_m4_m4(viewmat, viewinv); - /* camera winmat */ - object_camera_mode(&ps->scene->r, camera); - object_camera_matrix(&ps->scene->r, camera, ps->winx, ps->winy, 0, - winmat, &_viewplane, &ps->clipsta, &ps->clipend, - &_lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_ycor, &_viewdx, &_viewdy); + /* window matrix, clipping and ortho */ + camera_params_init(¶ms); + camera_params_from_object(¶ms, cam_ob); + camera_params_compute_viewplane(¶ms, ps->winx, ps->winy, 1.0f, 1.0f); + camera_params_compute_matrix(¶ms); - ps->is_ortho= (ps->scene->r.mode & R_ORTHO) ? 1 : 0; + copy_m4_m4(winmat, params.winmat); + ps->clipsta= params.clipsta; + ps->clipend= params.clipend; + ps->is_ortho= params.is_ortho; } /* same as view3d_get_object_project_mat */ diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index d59d947f0c8..2465d42bbf1 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1179,7 +1179,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; unsigned char col[4]; float rad; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index bbc72500df4..17cb1ce2995 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -115,7 +115,7 @@ static void set_pchan_colorset (Object *ob, bPoseChannel *pchan) * color set (based on the theme colors for 3d-view) is used. */ if (color_index > 0) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); bcolor= &btheme->tarm[(color_index - 1)]; } else if (color_index == -1) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 44bacd7a20e..959e267f50e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1696,7 +1696,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base if(cam->flag & CAM_SHOWLIMITS) { draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); /* qdn: was yafray only, now also enabled for Blender to be used with defocus composit node */ - draw_focus_cross(dof_camera(ob), cam->drawsize); + draw_focus_cross(object_camera_dof_distance(ob), cam->drawsize); } wrld= scene->world; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7ce758d4f47..7dae02aba39 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -923,75 +923,48 @@ static void draw_selected_name(Scene *scene, Object *ob) BLF_draw_default(offset, 10, 0.0f, info, sizeof(info)-1); } -void view3d_viewborder_size_get(Scene *scene, Object *camob, ARegion *ar, float size_r[2]) +static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift, short no_zoom) { - float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); - short sensor_fit= CAMERA_SENSOR_FIT_AUTO; - - if(camob && camob->type==OB_CAMERA) { - Camera *cam= (Camera *)camob->data; - sensor_fit= cam->sensor_fit; - } + CameraParams params; + rctf rect_view, rect_camera; + + /* get viewport viewplane */ + camera_params_init(¶ms); + camera_params_from_view3d(¶ms, v3d, rv3d); + if(no_zoom) + params.zoom= 1.0f; + camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); + rect_view= params.viewplane; + + /* get camera viewplane */ + camera_params_init(¶ms); + camera_params_from_object(¶ms, v3d->camera); + if(no_shift) { + params.shiftx= 0.0f; + params.shifty= 0.0f; + } + camera_params_compute_viewplane(¶ms, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp); + rect_camera= params.viewplane; + + /* get camera border within viewport */ + viewborder_r->xmin= ((rect_camera.xmin - rect_view.xmin)/(rect_view.xmax - rect_view.xmin))*ar->winx; + viewborder_r->xmax= ((rect_camera.xmax - rect_view.xmin)/(rect_view.xmax - rect_view.xmin))*ar->winx; + viewborder_r->ymin= ((rect_camera.ymin - rect_view.ymin)/(rect_view.ymax - rect_view.ymin))*ar->winy; + viewborder_r->ymax= ((rect_camera.ymax - rect_view.ymin)/(rect_view.ymax - rect_view.ymin))*ar->winy; +} - if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) { - float winmax= MAX2(ar->winx, ar->winy); +void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2]) +{ + rctf viewborder; - if(aspect > 1.0f) { - size_r[0]= winmax; - size_r[1]= winmax/aspect; - } else { - size_r[0]= winmax*aspect; - size_r[1]= winmax; - } - } - else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { - size_r[0]= ar->winx; - size_r[1]= ar->winx/aspect; - } - else { - size_r[0]= ar->winy*aspect; - size_r[1]= ar->winy; - } + view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE); + size_r[0]= viewborder.xmax - viewborder.xmin; + size_r[1]= viewborder.ymax - viewborder.ymin; } -void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short do_shift) +void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift) { - const float zoomfac= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); - float size[2]; - float dx= 0.0f, dy= 0.0f; - - view3d_viewborder_size_get(scene, v3d->camera, ar, size); - - size[0]= size[0]*zoomfac; - size[1]= size[1]*zoomfac; - - /* center in window */ - viewborder_r->xmin= 0.5f * ar->winx - 0.5f * size[0]; - viewborder_r->ymin= 0.5f * ar->winy - 0.5f * size[1]; - viewborder_r->xmax= viewborder_r->xmin + size[0]; - viewborder_r->ymax= viewborder_r->ymin + size[1]; - - dx= ar->winx*rv3d->camdx*zoomfac*2.0f; - dy= ar->winy*rv3d->camdy*zoomfac*2.0f; - - /* apply offset */ - viewborder_r->xmin-= dx; - viewborder_r->ymin-= dy; - viewborder_r->xmax-= dx; - viewborder_r->ymax-= dy; - - if(do_shift && v3d->camera && v3d->camera->type==OB_CAMERA) { - Camera *cam= v3d->camera->data; - float w = viewborder_r->xmax - viewborder_r->xmin; - float h = viewborder_r->ymax - viewborder_r->ymin; - float side = MAX2(w, h); - - if(do_shift == -1) side *= -1; - viewborder_r->xmin+= cam->shiftx*side; - viewborder_r->xmax+= cam->shiftx*side; - viewborder_r->ymin+= cam->shifty*side; - viewborder_r->ymax+= cam->shifty*side; - } + view3d_camera_border(scene, ar, v3d, rv3d, viewborder_r, no_shift, FALSE); } static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac) @@ -1228,19 +1201,39 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); } if (ca && (ca->flag & CAM_SHOWSENSOR)) { - /* assume fixed sensor width for now */ - - /* float sensor_aspect = ca->sensor_x / ca->sensor_y; */ /* UNUSED */ - float sensor_scale = (x2i-x1i) / ca->sensor_x; - float sensor_height = sensor_scale * ca->sensor_y; + /* determine sensor fit, and get sensor x/y, for auto fit we + assume and square sensor and only use sensor_x */ + float sizex= scene->r.xsch*scene->r.xasp; + float sizey= scene->r.ysch*scene->r.yasp; + int sensor_fit = camera_sensor_fit(ca->sensor_fit, sizex, sizey); + float sensor_x= ca->sensor_x; + float sensor_y= (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO)? ca->sensor_x: ca->sensor_y; + + /* determine sensor plane */ + rctf rect; + + if(sensor_fit == CAMERA_SENSOR_FIT_HOR) { + float sensor_scale = (x2i-x1i) / sensor_x; + float sensor_height = sensor_scale * sensor_y; + + rect.xmin= x1i; + rect.xmax= x2i; + rect.ymin= (y1i + y2i)*0.5f - sensor_height*0.5f; + rect.ymax= rect.ymin + sensor_height; + } + else { + float sensor_scale = (y2i-y1i) / sensor_y; + float sensor_width = sensor_scale * sensor_x; - float ymid = y1i + (y2i-y1i)/2.f; - float sy1= ymid - sensor_height/2.f; - float sy2= ymid + sensor_height/2.f; + rect.xmin= (x1i + x2i)*0.5f - sensor_width*0.5f; + rect.xmax= rect.xmin + sensor_width; + rect.ymin= y1i; + rect.ymax= y2i; + } + /* draw */ UI_ThemeColorShade(TH_WIRE, 100); - - uiDrawBox(GL_LINE_LOOP, x1i, sy1, x2i, sy2, 2.0f); + uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f); } } @@ -2485,15 +2478,14 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in /* render 3d view */ if(rv3d->persp==RV3D_CAMOB && v3d->camera) { - float winmat[4][4]; - float _clipsta, _clipend, _lens, _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT; - short _sensor_fit= CAMERA_SENSOR_FIT_AUTO; - rctf _viewplane; + CameraParams params; - object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens, - &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy); + camera_params_init(¶ms); + camera_params_from_object(¶ms, v3d->camera); + camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp); + camera_params_compute_matrix(¶ms); - ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat); + ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat); } else { ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL); @@ -2546,10 +2538,17 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w invert_m4_m4(rv3d.viewmat, rv3d.viewinv); { - float _yco, _dx, _dy, _sensor_x= DEFAULT_SENSOR_WIDTH, _sensor_y= DEFAULT_SENSOR_HEIGHT; - short _sensor_fit= CAMERA_SENSOR_FIT_AUTO; - rctf _viewplane; - object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_sensor_x, &_sensor_y, &_sensor_fit, &_yco, &_dx, &_dy); + CameraParams params; + + camera_params_init(¶ms); + camera_params_from_object(¶ms, v3d.camera); + camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp); + camera_params_compute_matrix(¶ms); + + copy_m4_m4(rv3d.winmat, params.winmat); + v3d.near= params.clipsta; + v3d.far= params.clipend; + v3d.lens= params.lens; } mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 7eaa5d42dd0..32e162fd09c 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -47,6 +47,7 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BKE_camera.h" #include "BKE_context.h" #include "BKE_image.h" #include "BKE_library.h" @@ -2265,7 +2266,7 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was rv3d->camdx= rv3d->camdy= 0.0f; - view3d_viewborder_size_get(scene, v3d->camera, ar, size); + ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size); /* 4px is just a little room from the edge of the area */ xfac= (float)ar->winx / (float)(size[0] + 4); @@ -2533,7 +2534,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar, View3D *v3d) float size[2]; int im_width= (scene->r.size*scene->r.xsch)/100; - view3d_viewborder_size_get(scene, v3d->camera, ar, size); + ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size); rv3d->camzoom= BKE_screen_view3d_zoom_from_fac((float)im_width/size[0]); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); @@ -2944,7 +2945,7 @@ static BGpic *background_image_add(bContext *C) { View3D *v3d= CTX_wm_view3d(C); - return ED_view3D_background_image_add(v3d); + return ED_view3D_background_image_new(v3d); } static int background_image_add_exec(bContext *C, wmOperator *UNUSED(op)) @@ -3014,16 +3015,13 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) /* ***** remove image operator ******* */ static int background_image_remove_exec(bContext *C, wmOperator *op) { - View3D *vd = CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); int index = RNA_int_get(op->ptr, "index"); - BGpic *bgpic_rem= BLI_findlink(&vd->bgpicbase, index); + BGpic *bgpic_rem= BLI_findlink(&v3d->bgpicbase, index); if(bgpic_rem) { - BLI_remlink(&vd->bgpicbase, bgpic_rem); - if(bgpic_rem->ima) id_us_min(&bgpic_rem->ima->id); - if(bgpic_rem->clip) id_us_min(&bgpic_rem->clip->id); - MEM_freeN(bgpic_rem); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, vd); + ED_view3D_background_image_remove(v3d, bgpic_rem); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); return OPERATOR_FINISHED; } else { @@ -3516,8 +3514,12 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, { ED_view3d_from_m4(ob->obmat, ofs, quat, dist); - if (lens) { - ED_view3d_ob_clip_range_get(ob, lens, NULL, NULL); + if(lens) { + CameraParams params; + + camera_params_init(¶ms); + camera_params_from_object(¶ms, ob); + *lens= params.lens; } } @@ -3529,7 +3531,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co object_apply_mat4(ob, mat, TRUE, TRUE); } -BGpic *ED_view3D_background_image_add(View3D *v3d) +BGpic *ED_view3D_background_image_new(View3D *v3d) { BGpic *bgpic= MEM_callocN(sizeof(BGpic), "Background Image"); @@ -3538,8 +3540,22 @@ BGpic *ED_view3D_background_image_add(View3D *v3d) bgpic->iuser.fie_ima= 2; bgpic->iuser.ok= 1; bgpic->view= 0; /* 0 for all */ + bgpic->flag |= V3D_BGPIC_EXPANDED; BLI_addtail(&v3d->bgpicbase, bgpic); return bgpic; } + +void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) +{ + BLI_remlink(&v3d->bgpicbase, bgpic); + + if(bgpic->ima) + id_us_min(&bgpic->ima->id); + + if(bgpic->clip) + id_us_min(&bgpic->clip->id); + + MEM_freeN(bgpic); +} diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 775cb45066a..42f58ba26f7 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -140,7 +140,6 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d); void view3d_clr_clipping(void); void view3d_set_clipping(RegionView3D *rv3d); void add_view3d_after(ListBase *lb, Base *base, int flag); -void view3d_viewborder_size_get(struct Scene *scene, struct Object *camob, struct ARegion *ar, float size_r[2]); void circf(float x, float y, float rad); void circ(float x, float y, float rad); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 1b4b26aeaaa..1a5e86aee71 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -104,31 +104,6 @@ float *give_cursor(Scene *scene, View3D *v3d) } -/* Gets the lens and clipping values from a camera of lamp type object */ -void ED_view3d_ob_clip_range_get(Object *ob, float *lens, float *clipsta, float *clipend) -{ - if(ob->type==OB_LAMP ) { - Lamp *la = ob->data; - if (lens) { - float x1, fac; - fac= cosf((float)M_PI*la->spotsize/360.0f); - x1= saacos(fac); - *lens= 16.0f*fac/sinf(x1); - } - if (clipsta) *clipsta= la->clipsta; - if (clipend) *clipend= la->clipend; - } - else if(ob->type==OB_CAMERA) { - Camera *cam= ob->data; - if (lens) *lens= cam->lens; - if (clipsta) *clipsta= cam->clipsta; - if (clipend) *clipend= cam->clipend; - } - else { - if (lens) *lens= 35.0f; - } -} - /* ****************** smooth view operator ****************** */ /* This operator is one of the 'timer refresh' ones like animation playback */ @@ -367,7 +342,7 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) /* ****************** change view operators ****************** */ -static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op)) +static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); @@ -394,7 +369,7 @@ static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op)) } -static int view3d_setcameratoview_poll(bContext *C) +static int view3d_camera_to_view_poll(bContext *C) { View3D *v3d= CTX_wm_view3d(C); if(v3d && v3d->camera && v3d->camera->id.lib==NULL) { @@ -415,8 +390,8 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot) ot->idname= "VIEW3D_OT_camera_to_view"; /* api callbacks */ - ot->exec= view3d_setcameratoview_exec; - ot->poll= view3d_setcameratoview_poll; + ot->exec= view3d_camera_to_view_exec; + ot->poll= view3d_camera_to_view_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -456,6 +431,24 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o } } +static int view3d_camera_to_view_selected_poll(bContext *C) +{ + View3D *v3d= CTX_wm_view3d(C); + if(v3d && v3d->camera && v3d->camera->id.lib==NULL) { + RegionView3D *rv3d= CTX_wm_region_view3d(C); + if(rv3d) { + if (rv3d->is_persp == FALSE) { + CTX_wm_operator_poll_msg_set(C, "Only valid for a perspective camera view"); + } + else if (!rv3d->viewlock) { + return 1; + } + } + } + + return 0; +} + void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot) { /* identifiers */ @@ -465,7 +458,7 @@ void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot) /* api callbacks */ ot->exec= view3d_camera_to_view_selected_exec; - // ot->poll= view3d_setcameratoview_poll; + ot->poll= view3d_camera_to_view_selected_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -983,202 +976,31 @@ void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) /* copies logic of get_view3d_viewplane(), keep in sync */ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, float *clipend) { - int orth= 0; + CameraParams params; - *clipsta= v3d->near; - *clipend= v3d->far; + camera_params_init(¶ms); + camera_params_from_view3d(¶ms, v3d, rv3d); - if(rv3d->persp==RV3D_CAMOB) { - if(v3d->camera) { - if(v3d->camera->type==OB_LAMP ) { - Lamp *la= v3d->camera->data; - *clipsta= la->clipsta; - *clipend= la->clipend; - } - else if(v3d->camera->type==OB_CAMERA) { - Camera *cam= v3d->camera->data; - *clipsta= cam->clipsta; - *clipend= cam->clipend; - - if(cam->type==CAM_ORTHO) - orth= 1; - } - } - } - - if(rv3d->persp==RV3D_ORTHO) { - *clipend *= 0.5f; // otherwise too extreme low zbuffer quality - *clipsta= - *clipend; - orth= 1; - } + if(clipsta) *clipsta= params.clipsta; + if(clipend) *clipend= params.clipend; - return orth; + return params.is_ortho; } /* also exposed in previewrender.c */ -int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize) +int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy, rctf *viewplane, float *clipsta, float *clipend) { - Camera *cam=NULL; - float lens, sensor_x =DEFAULT_SENSOR_WIDTH, sensor_y= DEFAULT_SENSOR_HEIGHT, fac, x1, y1, x2, y2; - float winx= (float)winxi, winy= (float)winyi; - int orth= 0; - short sensor_fit= CAMERA_SENSOR_FIT_AUTO; - - /* currnetly using sensor size (depends on fov calculating method) */ - float sensor= DEFAULT_SENSOR_WIDTH; - - lens= v3d->lens; - - *clipsta= v3d->near; - *clipend= v3d->far; - - if(rv3d->persp==RV3D_CAMOB) { - if(v3d->camera) { - if(v3d->camera->type==OB_LAMP ) { - Lamp *la; - - la= v3d->camera->data; - fac= cosf(((float)M_PI)*la->spotsize/360.0f); - - x1= saacos(fac); - lens= 16.0f*fac/sinf(x1); - - *clipsta= la->clipsta; - *clipend= la->clipend; - } - else if(v3d->camera->type==OB_CAMERA) { - cam= v3d->camera->data; - lens= cam->lens; - sensor_x= cam->sensor_x; - sensor_y= cam->sensor_y; - *clipsta= cam->clipsta; - *clipend= cam->clipend; - sensor_fit= cam->sensor_fit; - - sensor= (cam->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (cam->sensor_y) : (cam->sensor_x); - } - } - } - - if(rv3d->persp==RV3D_ORTHO) { - if(winx>winy) x1= -rv3d->dist; - else x1= -winx*rv3d->dist/winy; - x2= -x1; - - if(winx>winy) y1= -winy*rv3d->dist/winx; - else y1= -rv3d->dist; - y2= -y1; - - *clipend *= 0.5f; // otherwise too extreme low zbuffer quality - *clipsta= - *clipend; - orth= 1; - } - else { - /* fac for zoom, also used for camdx */ - if(rv3d->persp==RV3D_CAMOB) { - fac= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom) * 4.0f; - } - else { - fac= 2.0; - } - - /* viewplane size depends... */ - if(cam && cam->type==CAM_ORTHO) { - /* ortho_scale == 1 means exact 1 to 1 mapping */ - float dfac= 2.0f*cam->ortho_scale/fac; - - if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) { - if(winx>winy) { - x1= -dfac; - y1= -winy*dfac/winx; - } - else { - x1= -winx*dfac/winy; - y1= -dfac; - } - } - else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { - x1= -dfac; - y1= -winy*dfac/winx; - } - else { - x1= -winx*dfac/winy; - y1= -dfac; - } - - x2= -x1; - y2= -y1; - - orth= 1; - } - else { - float dfac; - - if(sensor_fit==CAMERA_SENSOR_FIT_AUTO) { - if(winx>winy) dfac= (sensor_x * 2.0f) / (fac*winx*lens); - else dfac= (sensor_x * 2.0f) / (fac*winy*lens); - } - else if(sensor_fit==CAMERA_SENSOR_FIT_HOR) { - dfac= (sensor_x * 2.0f) / (fac*winx*lens); - } - else { - dfac= (sensor_y * 2.0f) / (fac*winy*lens); - } - - x1= - *clipsta * winx*dfac; - x2= -x1; - y1= - *clipsta * winy*dfac; - y2= -y1; - orth= 0; - } - /* cam view offset */ - if(cam) { - float dx= 0.5f*fac*rv3d->camdx*(x2-x1); - float dy= 0.5f*fac*rv3d->camdy*(y2-y1); - - /* shift offset */ - if(cam->type==CAM_ORTHO) { - dx += cam->shiftx * cam->ortho_scale; - dy += cam->shifty * cam->ortho_scale; - } - else { - dx += cam->shiftx * (cam->clipsta / cam->lens) * sensor; - dy += cam->shifty * (cam->clipsta / cam->lens) * sensor; - } + CameraParams params; - x1+= dx; - x2+= dx; - y1+= dy; - y2+= dy; - } - } - - if(pixsize) { - float viewfac; - - if(orth) { - viewfac= (winx >= winy)? winx: winy; - *pixsize= 1.0f/viewfac; - } - else { - float size= ((winx >= winy)? winx: winy); - - if(sensor_fit==CAMERA_SENSOR_FIT_HOR) - size= winx; - else if(sensor_fit==CAMERA_SENSOR_FIT_VERT) - size= winy; + camera_params_init(¶ms); + camera_params_from_view3d(¶ms, v3d, rv3d); + camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); - viewfac= (size*lens)/sensor; - *pixsize= *clipsta/viewfac; - } - } - - viewplane->xmin= x1; - viewplane->ymin= y1; - viewplane->xmax= x2; - viewplane->ymax= y2; + if(viewplane) *viewplane= params.viewplane; + if(clipsta) *clipsta= params.clipsta; + if(clipend) *clipend= params.clipend; - return orth; + return params.is_ortho; } void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for picking */ @@ -1188,7 +1010,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for pick float clipsta, clipend, x1, y1, x2, y2; int orth; - orth= ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); + orth= ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend); rv3d->is_persp= !orth; // printf("%d %d %f %f %f %f %f %f\n", winx, winy, viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax, clipsta, clipend); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index cf8defe3968..e108262758a 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -96,9 +96,9 @@ static void setSnappingCallback(TransInfo *t); static void ApplySnapTranslation(TransInfo *t, float vec[3]); static void ApplySnapRotation(TransInfo *t, float *vec); -static void ApplySnapResize(TransInfo *t, float *vec); +static void ApplySnapResize(TransInfo *t, float vec[2]); -static void CalcSnapGrid(TransInfo *t, float *vec); +/* static void CalcSnapGrid(TransInfo *t, float *vec); */ static void CalcSnapGeometry(TransInfo *t, float *vec); static void TargetSnapMedian(TransInfo *t); @@ -703,7 +703,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) /********************** CALC **************************/ -static void CalcSnapGrid(TransInfo *t, float *UNUSED(vec)) +static void UNUSED_FUNCTION(CalcSnapGrid)(TransInfo *t, float *UNUSED(vec)) { snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS); } @@ -1037,7 +1037,7 @@ static void TargetSnapClosest(TransInfo *t) } /*================================================================*/ #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, float *no, int *dist, float *depth) +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; @@ -1089,7 +1089,9 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl } #endif -static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], 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, float *no, int *dist, float *depth) +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], + float r_loc[3], float r_no[3], int *r_dist, float *r_depth) { float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3]; int result; @@ -1143,11 +1145,11 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh * this takes care of series of connected edges a bit slanted w.r.t the viewport * otherwise, it would stick to the verts of the closest edge and not slide along merrily * */ - if (new_dist <= *dist && new_depth < *depth * 1.001f) + if (new_dist <= *r_dist && new_depth < *r_depth * 1.001f) { float n1[3], n2[3]; - *depth = new_depth; + *r_depth = new_depth; retval = 1; sub_v3_v3v3(edge_loc, v1co, v2co); @@ -1155,18 +1157,18 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc); - if (no) + if (r_no) { normal_short_to_float_v3(n1, v1no); normal_short_to_float_v3(n2, v2no); - interp_v3_v3v3(no, n2, n1, mul); - mul_m3_v3(timat, no); - normalize_v3(no); + interp_v3_v3v3(r_no, n2, n1, mul); + mul_m3_v3(timat, r_no); + normalize_v3(r_no); } - copy_v3_v3(loc, location); + copy_v3_v3(r_loc, location); - *dist = new_dist; + *r_dist = new_dist; } } } @@ -1174,7 +1176,9 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh return retval; } -static int snapVertex(ARegion *ar, float vco[3], short vno[3], 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, float *no, int *dist, float *depth) +static int snapVertex(ARegion *ar, float vco[3], short vno[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], + float r_loc[3], float r_no[3], int *r_dist, float *r_depth) { int retval = 0; float dvec[3]; @@ -1192,33 +1196,35 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float mval[2], fl mul_m4_v3(obmat, location); - new_depth = len_v3v3(location, ray_start); + new_depth = len_v3v3(location, ray_start); 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) + if (new_dist <= *r_dist && new_depth < *r_depth) { - *depth = new_depth; + *r_depth = new_depth; retval = 1; - copy_v3_v3(loc, location); + copy_v3_v3(r_loc, location); - if (no) + if (r_no) { - normal_short_to_float_v3(no, vno); - mul_m3_v3(timat, no); - normalize_v3(no); + normal_short_to_float_v3(r_no, vno); + mul_m3_v3(timat, r_no); + normalize_v3(r_no); } - *dist = new_dist; + *r_dist = new_dist; } } return retval; } -static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[][4], float ray_start[3], float ray_normal[3], float mval[2], float *loc, float *UNUSED(no), int *dist, float *depth) +static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[][4], + const float ray_start[3], const float ray_normal[3], const float mval[2], + float r_loc[3], float *UNUSED(r_no), int *r_dist, float *r_depth) { float imat[4][4]; float ray_start_local[3], ray_normal_local[3]; @@ -1243,11 +1249,11 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm switch (snap_mode) { case SCE_SNAP_MODE_VERTEX: - retval |= snapVertex(ar, eBone->head, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth); - retval |= snapVertex(ar, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth); + retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); + retval |= snapVertex(ar, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); break; case SCE_SNAP_MODE_EDGE: - retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth); + retval |= snapEdge(ar, eBone->head, NULL, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); break; } } @@ -1269,11 +1275,11 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm switch (snap_mode) { case SCE_SNAP_MODE_VERTEX: - retval |= snapVertex(ar, head_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth); - retval |= snapVertex(ar, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth); + retval |= snapVertex(ar, head_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); + retval |= snapVertex(ar, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); break; case SCE_SNAP_MODE_EDGE: - retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, mval, ray_start, ray_start_local, ray_normal_local, obmat, NULL, loc, NULL, dist, depth); + retval |= snapEdge(ar, head_vec, NULL, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); break; } } @@ -1283,10 +1289,9 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm return retval; } -static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, - DerivedMesh *dm, BMEditMesh *em, float obmat[][4], - float ray_start[3], float ray_normal[3], float mval[2], - float *loc, float *no, int *dist, float *depth) +static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[][4], + const float ray_start[3], const float ray_normal[3], const float mval[2], + float r_loc[3], float r_no[3], int *r_dist, float *r_depth) { int retval = 0; int totvert = dm->getNumVerts(dm); @@ -1335,21 +1340,21 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6); hit.index = -1; - hit.dist = *depth * (*depth == FLT_MAX ? 1.0f : local_scale); + hit.dist = *r_depth * (*r_depth == FLT_MAX ? 1.0f : local_scale); if(treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { - if(hit.dist/local_scale <= *depth) { - *depth= hit.dist/local_scale; - copy_v3_v3(loc, hit.co); - copy_v3_v3(no, hit.no); + if(hit.dist/local_scale <= *r_depth) { + *r_depth= hit.dist/local_scale; + copy_v3_v3(r_loc, hit.co); + copy_v3_v3(r_no, hit.no); /* back to worldspace */ - mul_m4_v3(obmat, loc); - copy_v3_v3(no, hit.no); + mul_m4_v3(obmat, r_loc); + copy_v3_v3(r_no, hit.no); - mul_m3_v3(timat, no); - normalize_v3(no); + mul_m3_v3(timat, r_no); + normalize_v3(r_no); retval |= 1; } @@ -1488,7 +1493,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, if (test) { - retval |= snapVertex(ar, v->co, v->no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth); + retval |= snapVertex(ar, v->co, v->no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist, r_depth); } } @@ -1550,7 +1555,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, if (test) { - retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth); + retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist, r_depth); } } @@ -1567,7 +1572,9 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, return retval; } -static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[][4], float ray_start[3], float ray_normal[3], float mval[2], float *loc, float *no, int *dist, float *depth) +static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[][4], + const float ray_start[3], const float ray_normal[3], const float mval[2], + float r_loc[3], float r_no[3], int *r_dist, float *r_depth) { ToolSettings *ts= scene->toolsettings; int retval = 0; @@ -1588,19 +1595,20 @@ static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, flo dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); } - retval = snapDerivedMesh(ts->snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, mval, loc, no, dist, depth); + retval = snapDerivedMesh(ts->snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, r_depth); dm->release(dm); } else if (ob->type == OB_ARMATURE) { - retval = snapArmature(ts->snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, loc, no, dist, depth); + retval = snapArmature(ts->snap_mode, ar, ob, ob->data, obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, r_depth); } return retval; } -static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, float mval[2], int *dist, float *loc, float *no, SnapMode mode) +static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, const float mval[2], + int *r_dist, float r_loc[3], float r_no[3], SnapMode mode) { Base *base; float depth = FLT_MAX; @@ -1613,7 +1621,7 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, f { Object *ob = obedit; - retval |= snapObject(scene, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth); + retval |= snapObject(scene, ar, ob, 1, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth); } /* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA @@ -1625,7 +1633,7 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, f if(base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) { Object *ob = base->object; - retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth); + retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth); } for ( base = FIRSTBASE; base != NULL; base = base->next ) { @@ -1641,30 +1649,30 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, f { Object *dob = dupli_ob->ob; - retval |= snapObject(scene, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, loc, no, dist, &depth); + retval |= snapObject(scene, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth); } free_object_duplilist(lb); } - retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, loc, no, dist, &depth); + retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth); } } return retval; } -int snapObjectsTransform(TransInfo *t, float mval[2], int *dist, float *loc, float *no, SnapMode mode) +int snapObjectsTransform(TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode) { - return snapObjects(t->scene, t->view, t->ar, t->obedit, mval, dist, loc, no, mode); + return snapObjects(t->scene, t->view, t->ar, t->obedit, mval, r_dist, r_loc, r_no, mode); } -int snapObjectsContext(bContext *C, float mval[2], int *dist, float *loc, float *no, SnapMode mode) +int snapObjectsContext(bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode) { ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; - return snapObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), mval, dist, loc, no, mode); + return snapObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), mval, r_dist, r_loc, r_no, mode); } /******************** PEELING *********************************/ @@ -1724,7 +1732,9 @@ static void addDepthPeel(ListBase *depth_peels, float depth, float p[3], float n peel->flag = 0; } -static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float ray_start[3], float ray_normal[3], float UNUSED(mval[2]), ListBase *depth_peels) +static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], + const float ray_start[3], const float ray_normal[3], const float UNUSED(mval[2]), + ListBase *depth_peels) { int retval = 0; int totvert = dm->getNumVerts(dm); @@ -1832,7 +1842,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], float return retval; } -static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase *depth_peels, float mval[2]) +static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase *depth_peels, const float mval[2]) { Base *base; int retval = 0; @@ -1915,12 +1925,12 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L return retval; } -int peelObjectsTransForm(TransInfo *t, ListBase *depth_peels, float mval[2]) +int peelObjectsTransForm(TransInfo *t, ListBase *depth_peels, const float mval[2]) { return peelObjects(t->scene, t->view, t->ar, t->obedit, depth_peels, mval); } -int peelObjectsContext(bContext *C, ListBase *depth_peels, float mval[2]) +int peelObjectsContext(bContext *C, ListBase *depth_peels, const float mval[2]) { ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; |