diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 342 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 260 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_fly.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 13 |
8 files changed, 404 insertions, 271 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b31550af289..6a9be8d979c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -193,6 +193,17 @@ static void drawcircle_size(float size); static void draw_empty_sphere(float size); static void draw_empty_cone(float size); +static void ob_wire_color_blend_theme_id(const unsigned char ob_wire_col[4], const int theme_id, float fac) +{ + float col_wire[3], col_bg[3], col[3]; + + rgb_uchar_to_float(col_wire, ob_wire_col); + + UI_GetThemeColor3fv(theme_id, col_bg); + interp_v3_v3v3(col, col_bg, col_wire, fac); + glColor3fv(col); +} + /* this condition has been made more complex since editmode can draw textures */ static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) { @@ -653,7 +664,7 @@ void drawaxes(float size, char drawtype) /* Function to draw an Image on a empty Object */ -static void draw_empty_image(Object *ob) +static void draw_empty_image(Object *ob, const short dflag, const unsigned char ob_wire_col[4]) { Image *ima = (Image *)ob->data; ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; @@ -726,15 +737,17 @@ static void draw_empty_image(Object *ob) glDisable(GL_BLEND); } - UI_ThemeColor((ob->flag & SELECT) ? TH_SELECT : TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); - /* Calculate the outline vertex positions */ - glBegin(GL_LINE_LOOP); - glVertex2f(ofs_x, ofs_y); - glVertex2f(ofs_x + ima_x, ofs_y); - glVertex2f(ofs_x + ima_x, ofs_y + ima_y); - glVertex2f(ofs_x, ofs_y + ima_y); - glEnd(); + /* Calculate the outline vertex positions */ + glBegin(GL_LINE_LOOP); + glVertex2f(ofs_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y + ima_y); + glVertex2f(ofs_x, ofs_y + ima_y); + glEnd(); + } /* Reset GL settings */ glMatrixMode(GL_MODELVIEW); @@ -1559,17 +1572,18 @@ static void draw_bundle_sphere(void) static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, MovieTrackingObject *tracking_object, - const short dflag, int *global_track_index, int draw_selected) + const short dflag, const unsigned char ob_wire_col[4], + int *global_track_index, int draw_selected) { MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; float mat[4][4], imat[4][4]; - unsigned char col[4], scol[4]; + unsigned char col_unsel[4], col_sel[4]; int tracknr = *global_track_index; ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); - UI_GetThemeColor4ubv(TH_TEXT, col); - UI_GetThemeColor4ubv(TH_SELECT, scol); + UI_GetThemeColor4ubv(TH_TEXT, col_unsel); + UI_GetThemeColor4ubv(TH_SELECT, col_sel); BKE_tracking_get_camera_object_matrix(scene, base->object, mat); @@ -1612,13 +1626,13 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if (v3d->drawtype == OB_WIRE) { glDisable(GL_LIGHTING); - if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); - } - else { - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } + else { + glColor3fv(track->color); + } } drawaxes(0.05f, v3d->bundle_drawtype); @@ -1629,8 +1643,9 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) { /* selection outline */ if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } glLineWidth(2.f); glDisable(GL_LIGHTING); @@ -1643,21 +1658,24 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glLineWidth(1.f); } - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_BUNDLE_SOLID); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); + else UI_ThemeColor(TH_BUNDLE_SOLID); + } draw_bundle_sphere(); } else { glDisable(GL_LIGHTING); - if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); - } - else { - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (selected) { + glColor3ubv(ob_wire_col); + } + else { + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); + else UI_ThemeColor(TH_WIRE); + } } drawaxes(0.05f, v3d->bundle_drawtype); @@ -1670,13 +1688,9 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) { float pos[3]; - unsigned char tcol[4]; - - if (selected) memcpy(tcol, scol, sizeof(tcol)); - else memcpy(tcol, col, sizeof(tcol)); mul_v3_m4v3(pos, mat, track->bundle_pos); - view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, tcol); + view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, selected ? col_sel : col_unsel); } tracknr++; @@ -1734,7 +1748,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, tracking_object = tracking->objects.first; while (tracking_object) { draw_viewport_object_reconstruction(scene, base, v3d, clip, tracking_object, - dflag, &global_track_index, draw_selected); + dflag, ob_wire_col, &global_track_index, draw_selected); tracking_object = tracking_object->next; } @@ -2242,9 +2256,9 @@ void mesh_foreachScreenFace( } void nurbs_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), - void *userData) + ViewContext *vc, + void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), + void *userData) { Curve *cu = vc->obedit->data; short s[2] = {IS_CLIPPED, 0}; @@ -3354,7 +3368,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) } static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const short dflag) + const short dt, const unsigned char ob_wire_col[4], const short dflag) { Object *ob = base->object; Mesh *me = ob->data; @@ -3428,13 +3442,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } if (!(draw_flags & DRAW_FACE_SELECT)) { - if (base->flag & SELECT) - UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); - else - UI_ThemeColor(TH_WIRE); - - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } dm->drawLooseEdges(dm); + } } } else if (dt == OB_SOLID) { @@ -3518,14 +3531,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); - if (base->flag & SELECT) { - UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); - } - else { - UI_ThemeColor(TH_WIRE); - } - if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) + if (!ob->sculpt && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } dm->drawLooseEdges(dm); + } } } else if (dt == OB_PAINT) { @@ -3534,42 +3545,22 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* since we already draw wire as wp guide, don't draw over the top */ draw_wire = OBDRAW_WIRE_OFF; } - - /* set default draw color back for wire or for draw-extra later on */ - if (dt != OB_WIRE) { - if (base->flag & SELECT) { - if (is_obact && ob->flag & OB_FROMGROUP) - UI_ThemeColor(TH_GROUP_ACTIVE); - else if (ob->flag & OB_FROMGROUP) - UI_ThemeColorShade(TH_GROUP_ACTIVE, -16); - else if (dflag != DRAW_CONSTCOLOR) - UI_ThemeColor(is_obact ? TH_ACTIVE : TH_SELECT); - else - glColor3ub(80, 80, 80); - } - else { - if (ob->flag & OB_FROMGROUP) - UI_ThemeColor(TH_GROUP); - else { - if (ob->dtx & OB_DRAWWIRE && dflag == DRAW_CONSTCOLOR) - glColor3ub(80, 80, 80); - else - UI_ThemeColor(TH_WIRE); - } - } - } - if (draw_wire != OBDRAW_WIRE_OFF) { + if ((draw_wire != OBDRAW_WIRE_OFF) && /* draw extra wire */ + /* when overriding with render only, don't bother */ + (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0)) + { /* When using wireframe object draw in particle edit mode * the mesh gets in the way of seeing the particles, fade the wire color * with the background. */ - if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { - float col_wire[4], col_bg[4], col[3]; - UI_GetThemeColor3fv(TH_BACK, col_bg); - glGetFloatv(GL_CURRENT_COLOR, col_wire); - interp_v3_v3v3(col, col_bg, col_wire, 0.15); - glColor3fv(col); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (is_obact && (ob->mode & OB_MODE_PARTICLE_EDIT)) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.15f); + } + else { + glColor3ubv(ob_wire_col); + } } /* If drawing wire and drawtype is not OB_WIRE then we are @@ -3586,8 +3577,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ } - if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) - dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), me->drawflag & ME_ALLEDGES); + dm->drawEdges(dm, (dt == OB_WIRE || totface == 0), me->drawflag & ME_ALLEDGES); if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { glDepthMask(1); @@ -3609,7 +3599,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* returns 1 if nothing was drawn, for detecting to draw an object center */ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const short dflag) + const short dt, const unsigned char ob_wire_col[4], const short dflag) { Object *ob = base->object; Object *obedit = scene->obedit; @@ -3673,7 +3663,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D (check_alpha) ? &do_alpha_after : NULL); } - draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, dflag); + draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); GPU_end_object_materials(); @@ -5913,9 +5903,9 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[ glVertex3f(cur[0], cur[1] - radius, cur[2]); glEnd(); } -/* return 1 if nothing was drawn */ +/* return TRUE if nothing was drawn */ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, - const short dt, const unsigned char ob_wire_col[4]) + const short dt, const short dflag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; MetaBall *mb; @@ -5942,27 +5932,32 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ml = mb->elems.first; } - if (ml == NULL) return 1; + if (ml == NULL) { + return TRUE; + } - if (v3d->flag2 & V3D_RENDER_OVERRIDE) return 0; - - /* in case solid draw, reset wire colors */ - if (ob->flag & SELECT) { - if (ob == OBACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); + if (v3d->flag2 & V3D_RENDER_OVERRIDE) { + return FALSE; } - else UI_ThemeColor(TH_WIRE); invert_m4_m4(imat, rv3d->viewmatob); normalize_v3(imat[0]); normalize_v3(imat[1]); + + if (mb->editelems == NULL) { + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } + } while (ml) { /* draw radius */ if (mb->editelems) { - if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0); - else cpack(0x3030A0); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0); + else cpack(0x3030A0); + } if (G.f & G_PICKSEL) { ml->selcol1 = code; @@ -5973,8 +5968,10 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* draw stiffness */ if (mb->editelems) { - if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0); - else cpack(0x30A030); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0); + else cpack(0x30A030); + } if (G.f & G_PICKSEL) { ml->selcol2 = code; @@ -5985,23 +5982,16 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ml = ml->next; } - return 0; + return FALSE; } -static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) +static void draw_forcefield(Object *ob, RegionView3D *rv3d, + const short dflag, const unsigned char ob_wire_col[4]) { PartDeflect *pd = ob->pd; float imat[4][4], tmat[4][4]; float vec[3] = {0.0, 0.0, 0.0}; - int curcol; float size; - - /* XXX why? */ - if (ob != scene->obedit && (ob->flag & SELECT)) { - if (ob == OBACT) curcol = TH_ACTIVE; - else curcol = TH_SELECT; - } - else curcol = TH_EMPTY; /* scale size of circle etc with the empty drawsize */ if (ob->type == OB_EMPTY) size = ob->empty_drawsize; @@ -6014,16 +6004,19 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) if (pd->forcefield == PFIELD_WIND) { float force_val; - - unit_m4(tmat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); - + + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); + } + //if (has_ipo_code(ob->ipo, OB_PD_FSTR)) // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); //else { force_val = pd->f_strength; } + + unit_m4(tmat); force_val *= 0.1f; drawcircball(GL_LINE_LOOP, vec, size, tmat); vec[2] = 0.5f * force_val; @@ -6045,11 +6038,11 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) ffall_val = pd->f_power; } - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); + if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); drawcircball(GL_LINE_LOOP, vec, size, imat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val)); + if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val)); drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val)); + if ((dflag & DRAW_CONSTCOLOR) == 0) ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val)); drawcircball(GL_LINE_LOOP, vec, size * 2.0f, imat); } else if (pd->forcefield == PFIELD_VORTEX) { @@ -6068,7 +6061,10 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) force_val = pd->f_strength; } - UI_ThemeColorBlend(curcol, TH_BACK, 0.7f); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.7f); + } + if (force_val < 0) { drawspiral(vec, size, tmat, 1); drawspiral(vec, size, tmat, 16); @@ -6090,16 +6086,18 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) mindist = pd->f_strength; } + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); + } + /*path end*/ setlinestyle(3); where_on_path(ob, 1.0f, guidevec1, guidevec2, NULL, NULL, NULL); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat); /*path beginning*/ setlinestyle(0); where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat); copy_v3_v3(vec, guidevec1); /* max center */ @@ -6107,7 +6105,10 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) } setlinestyle(3); - UI_ThemeColorBlend(curcol, TH_BACK, 0.5); + + if ((dflag & DRAW_CONSTCOLOR) == 0) { + ob_wire_color_blend_theme_id(ob_wire_col, TH_BACK, 0.5f); + } if (pd->falloff == PFIELD_FALL_SPHERE) { /* as last, guide curve alters it */ @@ -6357,59 +6358,46 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glDepthMask(1); } -static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) +static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsigned char ob_wire_col[4]) { - if (ob != scene->obedit && (ob->flag & SELECT)) { - if (ob == OBACT) { - if (ob->flag & OB_FROMGROUP) UI_ThemeColor(TH_GROUP_ACTIVE); - else UI_ThemeColor(TH_ACTIVE); + if (ELEM4(ob->type, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)) { + + if (scene->obedit == ob) { + UI_ThemeColor(TH_WIRE); } - else if (ob->flag & OB_FROMGROUP) - UI_ThemeColorShade(TH_GROUP_ACTIVE, -16); - else - UI_ThemeColor(TH_SELECT); - } - else { - if (ob->flag & OB_FROMGROUP) - UI_ThemeColor(TH_GROUP); else { - if (ob->dtx & OB_DRAWWIRE) { - glColor3ub(80, 80, 80); - } - else { - UI_ThemeColor(TH_WIRE); - } + glColor3ubv(ob_wire_col); } - } - - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ - if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - Curve *cu = ob->data; - if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - if (ob->type == OB_CURVE) - draw_index_wire = 0; + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ + + if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { + Curve *cu = ob->data; + if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { + if (ob->type == OB_CURVE) + draw_index_wire = 0; + + if (ob->derivedFinal) { + drawCurveDMWired(ob); + } + else { + drawDispListwire(&ob->disp); + } - if (ob->derivedFinal) { - drawCurveDMWired(ob); + if (ob->type == OB_CURVE) + draw_index_wire = 1; } - else { + } + else if (ob->type == OB_MBALL) { + if (BKE_mball_is_basis(ob)) { drawDispListwire(&ob->disp); } - - if (ob->type == OB_CURVE) - draw_index_wire = 1; - } - } - else if (ob->type == OB_MBALL) { - if (BKE_mball_is_basis(ob)) { - drawDispListwire(&ob->disp); } - } - glDepthMask(1); - bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + bglPolygonOffset(rv3d->dist, 0.0); + } } /* should be called in view space */ @@ -6550,7 +6538,10 @@ static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_ r_ob_wire_col[3] = 255; } -/* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET */ +/** + * main object drawing function, draws in selection + * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET + */ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag) { static int warning_recursive = 0; @@ -6692,7 +6683,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short switch (ob->type) { case OB_MESH: - empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, dflag); + empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE; // mesh draws wire itself break; @@ -6812,20 +6803,20 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short MetaBall *mb = ob->data; if (mb->editelems) - drawmball(scene, v3d, rv3d, base, dt, ob_wire_col); + drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); } } else - empty_object = drawmball(scene, v3d, rv3d, base, dt, ob_wire_col); + empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); break; } case OB_EMPTY: if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - draw_empty_image(ob); + draw_empty_image(ob, dflag, ob_wire_col); } else { drawaxes(ob->empty_drawsize, ob->empty_drawtype); @@ -6897,7 +6888,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } if (ob->pd && ob->pd->forcefield) { - draw_forcefield(scene, ob, rv3d); + draw_forcefield(ob, rv3d, dflag, ob_wire_col); } } @@ -7106,7 +7097,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } /*if (dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/ if ((dtx & OB_DRAWWIRE) && dt >= OB_SOLID) { - drawWireExtra(scene, rv3d, ob); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + draw_wire_extra(scene, rv3d, ob, ob_wire_col); + } } } } @@ -7578,7 +7571,8 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object break; case OB_EMPTY: if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - draw_empty_image(ob); + /* CONSTCOLOR == no wire outline */ + draw_empty_image(ob, DRAW_CONSTCOLOR, NULL); } else { drawaxes(ob->empty_drawsize, ob->empty_drawtype); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 199a1751f9d..24395865a5e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -971,10 +971,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV 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; + viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx; + viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx; + viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy; + viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy; } void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2]) @@ -982,8 +982,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R rctf viewborder; view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE); - size_r[0] = viewborder.xmax - viewborder.xmin; - size_r[1] = viewborder.ymax - viewborder.ymin; + size_r[0] = BLI_RCT_SIZE_X(&viewborder); + size_r[1] = BLI_RCT_SIZE_Y(&viewborder); } void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, @@ -1339,7 +1339,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glDisable(GL_MULTISAMPLE_ARB); region_scissor_winrct(ar, &winrct); - glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin); + glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct)); glClearColor(0.0, 0.0, 0.0, 0.0); if (v3d->zbuf) { @@ -2038,8 +2038,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) x = rect->xmin; y = rect->ymin; - w = rect->xmax - rect->xmin; - h = rect->ymax - rect->ymin; + w = BLI_RCT_SIZE_X(rect); + h = BLI_RCT_SIZE_Y(rect); if (w <= 0 || h <= 0) { if (d->depths) @@ -2846,10 +2846,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); - cliprct.xmin = viewborder.xmin + scene->r.border.xmin * (viewborder.xmax - viewborder.xmin); - cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin); - cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin); - cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin); + cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder); + cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder); + cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder); + cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_SIZE_Y(&viewborder); cliprct.xmin += ar->winrct.xmin; cliprct.xmax += ar->winrct.xmin; @@ -2863,7 +2863,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) { glGetIntegerv(GL_SCISSOR_BOX, scissor); - glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin); + glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct)); } else return 0; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 8b8adb193bf..e74bda87a43 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -382,10 +382,10 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3]) radius = TRACKBALLSIZE; /* normalize x and y */ - x = (rect->xmax + rect->xmin) / 2 - mx; - x /= (float)((rect->xmax - rect->xmin) / 4); - y = (rect->ymax + rect->ymin) / 2 - my; - y /= (float)((rect->ymax - rect->ymin) / 2); + x = BLI_RCT_CENTER_X(rect) - mx; + x /= (float)(BLI_RCT_SIZE_X(rect) / 4); + y = BLI_RCT_CENTER_Y(rect) - my; + y /= (float)(BLI_RCT_SIZE_Y(rect) / 2); d = sqrt(x * x + y * y); if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */ @@ -662,8 +662,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) if (vod->use_dyn_ofs) { /* compute the post multiplication quat, to rotate the offset correctly */ - copy_qt_qt(q1, vod->oldquat); - conjugate_qt(q1); + conjugate_qt_qt(q1, vod->oldquat); mul_qt_qtqt(q1, q1, vod->viewquat); conjugate_qt(q1); /* conj == inv for unit quat */ @@ -1022,9 +1021,10 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event /* tune these until everything feels right */ const float rot_sensitivity = 1.f; +#if 0 const float zoom_sensitivity = 1.f; +#endif const float pan_sensitivity = 1.f; - const int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec); float view_inv[4]; @@ -1036,20 +1036,6 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); #endif - if (ndof->tz) { - /* Zoom! - * velocity should be proportional to the linear velocity attained by rotational motion of same strength - * [got that?] - * proportional to arclength = radius * angle - */ - float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz; - - if (U.ndof_flag & NDOF_ZOOM_INVERT) - zoom_distance = -zoom_distance; - - rv3d->dist += zoom_distance; - } - if (rv3d->viewlock == RV3D_LOCKED) { /* rotation not allowed -- explore panning options instead */ float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f}; @@ -1067,34 +1053,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rv3d->view = RV3D_VIEW_USER; - if (U.flag & USER_TRACKBALL) { - float rot[4]; - float axis[3]; - float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); - - if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) - axis[2] = -axis[2]; - - if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) - axis[0] = -axis[0]; - - if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) - axis[1] = -axis[1]; - - /* transform rotation axis from view to world coordinates */ - mul_qt_v3(view_inv, axis); - - /* update the onscreen doo-dad */ - rv3d->rot_angle = angle; - copy_v3_v3(rv3d->rot_axis, axis); - - axis_angle_to_quat(rot, axis, angle); - - /* apply rotation */ - mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); - - } - else { + if (U.ndof_flag & NDOF_TURNTABLE) { /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ float angle, rot[4]; @@ -1127,6 +1086,33 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event rot[3] = sin(angle); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); } + else { + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) + axis[2] = -axis[2]; + + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + axis[0] = -axis[0]; + + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + axis[1] = -axis[1]; + + /* transform rotation axis from view to world coordinates */ + mul_qt_v3(view_inv, axis); + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + copy_v3_v3(rv3d->rot_axis, axis); + + axis_angle_to_quat(rot, axis, angle); + + /* apply rotation */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } } } @@ -1247,6 +1233,160 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot) ot->flag = 0; } + +/* +* this is basically just the pan only code + the rotate only code crammed into one function that does both +*/ +static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + if (event->type != NDOF_MOTION) + return OPERATOR_CANCELLED; + else { + + ViewOpsData *vod; + RegionView3D *rv3d; + + View3D *v3d = CTX_wm_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; + + viewops_data_create(C, op, event); + vod = op->customdata; + rv3d = vod->rv3d; + + ED_view3d_camera_lock_init(v3d, rv3d); + + if (ndof->progress != P_FINISHING) { + + const float dt = ndof->dt; + float view_inv[4]; + + float speed = 10.f; /* blender units per second */ + /* ^^ this is ok for default cube scene, but should scale with.. something */ + + /* tune these until everything feels right */ + const float forward_sensitivity = 1.f; + const float vertical_sensitivity = 0.4f; + const float lateral_sensitivity = 0.6f; + + float pan_vec[3]; + const float rot_sensitivity = 1.f; +#if 0 + const float zoom_sensitivity = 1.f; + const float pan_sensitivity = 1.f; + float rot[4]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + float axis[3]; +#endif + + if (U.ndof_flag & NDOF_PANX_INVERT_AXIS) + pan_vec[0] = -lateral_sensitivity * ndof->tvec[0]; + else + pan_vec[0] = lateral_sensitivity * ndof->tvec[0]; + + if (U.ndof_flag & NDOF_PANZ_INVERT_AXIS) + pan_vec[1] = -vertical_sensitivity * ndof->tvec[1]; + else + pan_vec[1] = vertical_sensitivity * ndof->tvec[1]; + + if (U.ndof_flag & NDOF_PANY_INVERT_AXIS) + pan_vec[2] = -forward_sensitivity * ndof->tvec[2]; + else + pan_vec[2] = forward_sensitivity * ndof->tvec[2]; + + mul_v3_fl(pan_vec, speed * dt); + + /* transform motion from view to world coordinates */ + invert_qt_qt(view_inv, rv3d->viewquat); + mul_qt_v3(view_inv, pan_vec); + + /* move center of view opposite of hand motion (this is camera mode, not object mode) */ + sub_v3_v3(rv3d->ofs, pan_vec); + + if (U.ndof_flag & NDOF_TURNTABLE) { + /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ + float angle, rot[4]; + float xvec[3] = {1, 0, 0}; + + /* Determine the direction of the x vector (for rotating up and down) */ + mul_qt_v3(view_inv, xvec); + + /* Perform the up/down rotation */ + angle = rot_sensitivity * dt * ndof->rx; + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + angle = -angle; + rot[0] = cos(angle); + mul_v3_v3fl(rot + 1, xvec, sin(angle)); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + /* Perform the orbital rotation */ + angle = rot_sensitivity * dt * ndof->ry; + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + angle = -angle; + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + rv3d->rot_axis[0] = 0; + rv3d->rot_axis[1] = 0; + rv3d->rot_axis[2] = 1; + + rot[0] = cos(angle); + rot[1] = rot[2] = 0.0; + rot[3] = sin(angle); + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } + else { + + float rot[4]; + float axis[3]; + float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis); + + if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) + axis[2] = -axis[2]; + + if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) + axis[0] = -axis[0]; + + if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) + axis[1] = -axis[1]; + + /* transform rotation axis from view to world coordinates */ + mul_qt_v3(view_inv, axis); + + /* update the onscreen doo-dad */ + rv3d->rot_angle = angle; + copy_v3_v3(rv3d->rot_axis, axis); + + axis_angle_to_quat(rot, axis, angle); + + /* apply rotation */ + mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + + } + } + ED_view3d_camera_lock_sync(v3d, rv3d); + + ED_region_tag_redraw(CTX_wm_region(C)); + viewops_data_free(C, op); + return OPERATOR_FINISHED; + } +} + +void VIEW3D_OT_ndof_all(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "NDOF move View"; + ot->description = "Position your viewpoint with the 3D mouse"; + ot->idname = "VIEW3D_OT_ndof_all"; + + /* api callbacks */ + ot->invoke = ndof_all_invoke; + ot->poll = ED_operator_view3d_active; + + /* flags */ + ot->flag = 0; +} + /* ************************ viewmove ******************************** */ @@ -1525,8 +1665,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, int ctr[2], len1, len2; /* method which zooms based on how far you move the mouse */ - ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2; - ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2; + ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct); + ctr[1] = BLI_RCT_CENTER_Y(&vod->ar->winrct); len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5; len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5; @@ -2072,7 +2212,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in continue; } - BKE_object_minmax(base->object, min, max); + BKE_object_minmax(base->object, min, max, FALSE); } } if (!onedone) { @@ -2218,8 +2358,8 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (BKE_object_minmax_dupli(scene, base->object, min, max) == 0) - BKE_object_minmax(base->object, min, max); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max, FALSE) == 0) + BKE_object_minmax(base->object, min, max, FALSE); /* use if duplis not found */ ok = 1; } @@ -2476,10 +2616,10 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); - scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / (vb.xmax - vb.xmin); - scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / (vb.ymax - vb.ymin); - scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / (vb.xmax - vb.xmin); - scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / (vb.ymax - vb.ymin); + scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb); + scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb); + scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb); + scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb); /* actually set border */ CLAMP(scene->r.border.xmin, 0.0f, 1.0f); @@ -2643,8 +2783,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) } /* work out the ratios, so that everything selected fits when we zoom */ - xscale = ((rect.xmax - rect.xmin) / vb[0]); - yscale = ((rect.ymax - rect.ymin) / vb[1]); + xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]); + yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]); new_dist *= maxf(xscale, yscale); /* zoom in as required, or as far as we can go */ diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 561e97a8393..855771b17a2 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -489,7 +489,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) else if (event->type == NDOF_MOTION) { /* do these automagically get delivered? yes. */ // puts("ndof motion detected in fly mode!"); - // static const char* tag_name = "3D mouse position"; + // static const char *tag_name = "3D mouse position"; wmNDOFMotionData *incoming_ndof = (wmNDOFMotionData *)event->customdata; switch (incoming_ndof->progress) { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index a6a22d85cd9..996525d2be4 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -79,6 +79,7 @@ void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot); void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); +void VIEW3D_OT_ndof_all(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 7b3e7358978..14c02c2357e 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -64,6 +64,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_dolly); WM_operatortype_append(VIEW3D_OT_ndof_orbit); WM_operatortype_append(VIEW3D_OT_ndof_pan); + WM_operatortype_append(VIEW3D_OT_ndof_all); WM_operatortype_append(VIEW3D_OT_view_all); WM_operatortype_append(VIEW3D_OT_viewnumpad); WM_operatortype_append(VIEW3D_OT_view_orbit); @@ -221,8 +222,9 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "align_active", TRUE); /* 3D mouse */ - WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_pan", NDOF_MOTION, 0, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_all", NDOF_MOTION, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 69fa42b0abb..6f3cc744537 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -291,7 +291,7 @@ static int view3d_selectable_data(bContext *C) /* helper also for borderselect */ static int edge_fully_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) { - return BLI_in_rcti(rect, x1, y1) && BLI_in_rcti(rect, x2, y2); + return BLI_rcti_isect_pt(rect, x1, y1) && BLI_rcti_isect_pt(rect, x2, y2); } static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) @@ -394,7 +394,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && + if (BLI_rcti_isect_pt(data->rect, x, y) && BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { BM_vert_select_set(data->vc->em->bm, eve, data->select); @@ -425,7 +425,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && + if (BLI_rcti_isect_pt(data->rect, x, y) && BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { BM_face_select_set(data->vc->em->bm, efa, data->select); @@ -654,8 +654,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) unsigned int *rt; int a, index; char *selar; - int sx = rect->xmax - rect->xmin + 1; - int sy = rect->ymax - rect->ymin + 1; + int sx = BLI_RCT_SIZE_X(rect) + 1; + int sy = BLI_RCT_SIZE_Y(rect) + 1; me = vc->obact->data; @@ -765,12 +765,11 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) /* store selection in temp test flag */ for (node = snode->edittree->nodes.first; node; node = node->next) { - - node_centf[0] = (node->totr.xmin + node->totr.xmax) / 2; - node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; + node_centf[0] = BLI_RCT_CENTER_X(&node->totr); + node_centf[1] = BLI_RCT_CENTER_Y(&node->totr); ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); - if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { + if (BLI_rcti_isect_pt_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { node->flag |= SELECT; } @@ -1553,7 +1552,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi Object *obedit = data->vc->obedit; Curve *cu = (Curve *)obedit->data; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; @@ -1600,7 +1599,7 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } @@ -1625,7 +1624,7 @@ static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, int x, { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { BM_vert_select_set(data->vc->em->bm, eve, data->select); } } @@ -1651,7 +1650,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, { BoxSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y)) { + if (BLI_rcti_isect_pt(data->rect, x, y)) { BM_face_select_set(data->vc->em->bm, efa, data->select); } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 604d101abd5..fbbf23beca4 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -308,11 +308,11 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent step_inv = 1.0f - step; - interp_v3_v3v3(rv3d->ofs, sms->new_ofs, sms->orig_ofs, step); + interp_v3_v3v3(rv3d->ofs, sms->orig_ofs, sms->new_ofs, step); interp_qt_qtqt(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); rv3d->dist = sms->new_dist * step + sms->orig_dist * step_inv; - v3d->lens = sms->new_lens * step + sms->orig_lens * step_inv; + v3d->lens = sms->new_lens * step + sms->orig_lens * step_inv; ED_view3d_camera_lock_sync(v3d, rv3d); } @@ -1212,10 +1212,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b rect.ymax = input->ymin + 12; } else { - rect.xmin = input->xmin; - rect.xmax = input->xmax; - rect.ymin = input->ymin; - rect.ymax = input->ymax; + BLI_rctf_rcti_copy(&rect, input); } setwinmatrixview3d(ar, v3d, &rect); @@ -1409,7 +1406,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL } else { if (scene->obedit) { - BKE_object_minmax(scene->obedit, min, max); + BKE_object_minmax(scene->obedit, min, max, FALSE); ok = TRUE; @@ -1419,7 +1416,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - BKE_object_minmax(base->object, min, max); + BKE_object_minmax(base->object, min, max, FALSE); base->lay |= locallay; base->object->lay = base->lay; ok = TRUE; |