diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/CMakeLists.txt | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/SConscript | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 132 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 134 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 111 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_fly.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_toolbar.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_walk.c | 17 |
16 files changed, 296 insertions, 193 deletions
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index d8d29d63686..059b384a9e2 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -23,6 +23,7 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../blentranslation ../../bmesh ../../gpu ../../imbuf @@ -89,4 +90,8 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() +if(WITH_LEGACY_DEPSGRAPH) + add_definitions(-DWITH_LEGACY_DEPSGRAPH) +endif() + blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_view3d/SConscript b/source/blender/editors/space_view3d/SConscript index 78f24948070..7fdccce1c0e 100644 --- a/source/blender/editors/space_view3d/SConscript +++ b/source/blender/editors/space_view3d/SConscript @@ -29,7 +29,8 @@ Import ('env') sources = env.Glob('*.c') -defs = env['BF_GL_DEFINITIONS'] +defs = [] +defs += env['BF_GL_DEFINITIONS'] incs = [ '#/intern/guardedalloc', @@ -41,6 +42,7 @@ incs = [ '../../blenfont', '../../blenkernel', '../../blenlib', + '../../blentranslation', '../../bmesh', '../../gpu', '../../imbuf', @@ -66,4 +68,7 @@ if env['WITH_BF_INTERNATIONAL']: if env['WITH_BF_FREESTYLE']: defs.append('WITH_FREESTYLE') +if env['WITH_BF_LEGACY_DEPSGRAPH']: + defs.append('WITH_LEGACY_DEPSGRAPH') + env.BlenderLib ( 'bf_editors_space_view3d', sources, incs, defines = defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index f33f074e6c5..f7698b0e9f3 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1547,7 +1547,7 @@ static void draw_pose_dofs(Object *ob) glPushMatrix(); copy_v3_v3(posetrans, pchan->pose_mat[3]); - glTranslatef(posetrans[0], posetrans[1], posetrans[2]); + glTranslate3fv(posetrans); if (pchan->parent) { copy_m4_m4(mat, pchan->parent->pose_mat); @@ -1778,7 +1778,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } draw_custom_bone(scene, v3d, rv3d, pchan->custom, - OB_SOLID, arm->flag, flag, index, bone->length); + OB_SOLID, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); } } else { @@ -1869,7 +1869,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, flag |= BONE_DRAW_ACTIVE; draw_custom_bone(scene, v3d, rv3d, pchan->custom, - OB_WIRE, arm->flag, flag, index, bone->length); + OB_WIRE, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); glPopMatrix(); } @@ -2366,7 +2366,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base bArmature *arm = ob->data; bPose *posen, *poseo; float start, end, stepsize, range, colfac; - int cfrao, flago, ipoflago; + int cfrao, flago; start = (float)arm->ghostsf; end = (float)arm->ghostef; @@ -2381,8 +2381,6 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base cfrao = CFRA; flago = arm->flag; arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); - ipoflago = ob->ipoflag; - ob->ipoflag |= OB_DISABLE_PATH; /* copy the pose */ poseo = ob->pose; @@ -2418,7 +2416,6 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base ob->pose = poseo; arm->flag = flago; ob->mode |= OB_MODE_POSE; - ob->ipoflag = ipoflago; } /* draw ghosts on keyframes in action within range @@ -2462,8 +2459,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * cfrao = CFRA; flago = arm->flag; arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); - ob->ipoflag |= OB_DISABLE_PATH; - + /* copy the pose */ poseo = ob->pose; BKE_pose_copy_data(&posen, ob->pose, 1); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index d806dfa015a..68e536662d6 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -664,7 +664,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol) else if (ma && (ma->shade_flag & MA_OBCOLOR)) { int loop_index = mp->loopstart; for (j = 0; j < mp->totloop; j++, loop_index++) { - copy_v3_v3_char(&finalCol[loop_index].r, (char *)Gtexdraw.obcol); + copy_v3_v3_uchar(&finalCol[loop_index].r, Gtexdraw.obcol); } copy_mode = COPY_PREV; } @@ -1114,8 +1114,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, /* if not cycles, or preview-modifiers, or drawing matcaps */ if ((draw_flags & DRAW_MODIFIERS_PREVIEW) || (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) || - (BKE_scene_use_new_shading_nodes(scene) == false) || - ((ob->mode & OB_MODE_TEXTURE_PAINT) && ELEM(v3d->drawtype, OB_TEXTURE, OB_SOLID))) + (BKE_scene_use_new_shading_nodes(scene) == false)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 82acc5863c4..6c01bfac9c5 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -74,6 +74,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" +#include "BKE_subsurf.h" #include "BKE_unit.h" #include "BKE_tracking.h" @@ -828,7 +829,7 @@ void view3d_cached_text_draw_add(const float co[3], BLI_LINKS_PREPEND(g_v3d_strings[g_v3d_string_level], vos); copy_v3_v3(vos->vec, co); - copy_v4_v4_char((char *)vos->col.ub, (const char *)col); + copy_v4_v4_uchar(vos->col.ub, col); vos->xoffs = xoffs; vos->flag = flag; vos->str_len = str_len; @@ -975,7 +976,7 @@ static void drawcube_size(const float size[3]) { glPushMatrix(); - glScalef(size[0], size[1], size[2]); + glScale3fv(size); glBegin(GL_LINE_STRIP); @@ -1197,7 +1198,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, Object *ob = base->object; const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]); Lamp *la = ob->data; - float vec[3], lvec[3], vvec[3], circrad, x, y, z; + float vec[3], lvec[3], vvec[3], circrad; float lampsize; float imat[4][4]; @@ -1314,7 +1315,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, mul_v3_v3fl(v2, imat[0], circrad * 2.5f); /* center */ - glTranslatef(vec[0], vec[1], vec[2]); + glTranslate3fv(vec); setlinestyle(3); @@ -1344,7 +1345,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, /* skip drawing extra info */ } else if ((la->type == LA_SPOT) || (la->type == LA_YF_PHOTON)) { - + float x, y, z, z_abs; copy_v3_fl3(lvec, 0.0f, 0.0f, 1.0f); copy_v3_fl3(vvec, rv3d->persmat[0][2], rv3d->persmat[1][2], rv3d->persmat[2][2]); mul_transposed_mat3_m4_v3(ob->obmat, vvec); @@ -1357,46 +1358,75 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, mul_v3_fl(lvec, x); mul_v3_fl(vvec, x); - /* draw the angled sides of the cone */ - glBegin(GL_LINE_STRIP); - glVertex3fv(vvec); - glVertex3fv(vec); - glVertex3fv(lvec); - glEnd(); - x *= y; - /* draw the circle/square at the end of the cone */ - glTranslatef(0.0, 0.0, x); + z_abs = fabsf(z); + if (la->mode & LA_SQUARE) { - float tvec[3]; - float z_abs = fabsf(z); - - tvec[0] = tvec[1] = z_abs; - tvec[2] = 0.0; - - glBegin(GL_LINE_LOOP); - glVertex3fv(tvec); - tvec[1] = -z_abs; /* neg */ - glVertex3fv(tvec); - tvec[0] = -z_abs; /* neg */ - glVertex3fv(tvec); - tvec[1] = z_abs; /* pos */ - glVertex3fv(tvec); - glEnd(); + /* draw pyramid */ + const float vertices[5][3] = { + /* 5 of vertex coords of pyramid */ + {0.0f, 0.0f, 0.0f}, + {z_abs, z_abs, x}, + {-z_abs, -z_abs, x}, + {z_abs, -z_abs, x}, + {-z_abs, z_abs, x}, + }; + const unsigned char indices[] = { + 0, 1, 3, + 0, 3, 2, + 0, 2, 4, + 0, 1, 4, + }; + + /* Draw call: + * activate and specify pointer to vertex array */ + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, vertices); + /* draw the pyramid */ + glDrawElements(GL_LINE_STRIP, 12, GL_UNSIGNED_BYTE, indices); + + /* deactivate vertex arrays after drawing */ + glDisableClientState(GL_VERTEX_ARRAY); + + glTranslatef(0.0f, 0.0f, x); + + /* draw the square representing spotbl */ + if (la->type == LA_SPOT) { + float blend = z_abs * (1.0f - pow2f(la->spotblend)); + + /* hide line if it is zero size or overlaps with outer border, + * previously it adjusted to always to show it but that seems + * confusing because it doesn't show the actual blend size */ + if (blend != 0.0f && blend != z_abs) { + fdrawbox(blend, -blend, -blend, blend); + } + } } else { - circ(0.0, 0.0, fabsf(z)); - } - /* draw the circle/square representing spotbl */ - if (la->type == LA_SPOT) { - float spotblcirc = fabsf(z) * (1.0f - pow2f(la->spotblend)); - /* hide line if it is zero size or overlaps with outer border, - * previously it adjusted to always to show it but that seems - * confusing because it doesn't show the actual blend size */ - if (spotblcirc != 0 && spotblcirc != fabsf(z)) - circ(0.0, 0.0, spotblcirc); + /* draw the angled sides of the cone */ + glBegin(GL_LINE_STRIP); + glVertex3fv(vvec); + glVertex3fv(vec); + glVertex3fv(lvec); + glEnd(); + + /* draw the circle at the end of the cone */ + glTranslatef(0.0f, 0.0f, x); + circ(0.0f, 0.0f, z_abs); + + /* draw the circle representing spotbl */ + if (la->type == LA_SPOT) { + float blend = z_abs * (1.0f - pow2f(la->spotblend)); + + /* hide line if it is zero size or overlaps with outer border, + * previously it adjusted to always to show it but that seems + * confusing because it doesn't show the actual blend size */ + if (blend != 0.0f && blend != z_abs) { + circ(0.0f, 0.0f, blend); + } + } } if (drawcone) @@ -1658,7 +1688,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D GPU_select_load_id(base->selcol + (tracknr << 16)); glPushMatrix(); - glTranslatef(track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]); + glTranslate3fv(track->bundle_pos); glScalef(v3d->bundle_size / 0.05f / camera_size[0], v3d->bundle_size / 0.05f / camera_size[1], v3d->bundle_size / 0.05f / camera_size[2]); @@ -4027,9 +4057,15 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } /* check polys instead of tessfaces because of dyntopo where tessfaces don't exist */ - no_edges = (dm->getNumEdges(dm) == 0); - no_faces = (dm->getNumPolys(dm) == 0); - + if (dm->type == DM_TYPE_CCGDM) { + no_edges = !subsurf_has_edges(dm); + no_faces = !subsurf_has_faces(dm); + } + else { + no_edges = (dm->getNumEdges(dm) == 0); + no_faces = (dm->getNumPolys(dm) == 0); + } + /* vertexpaint, faceselect wants this, but it doesnt work for shaded? */ glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); @@ -7177,7 +7213,7 @@ static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin) glPushMatrix(); if (type == OB_BOUND_SPHERE) { float scale = MAX3(size[0], size[1], size[2]); - glTranslatef(cent[0], cent[1], cent[2]); + glTranslate3fv(cent); glScalef(scale, scale, scale); gluSphere(qobj, 1.0, 8, 5); } @@ -7226,6 +7262,9 @@ static void draw_bounding_volume(Object *ob, char type) else if (ob->type == OB_ARMATURE) { bb = BKE_armature_boundbox_get(ob); } + else if (ob->type == OB_LATTICE) { + bb = BKE_lattice_boundbox_get(ob); + } else { const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; bb = &bb_local; @@ -7643,7 +7682,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } } - if ((md = modifiers_findByType(ob, eModifierType_Smoke)) && (modifier_isEnabled(scene, md, eModifierMode_Realtime))) { + if (((base->flag & OB_FROMDUPLI) == 0) && + (md = modifiers_findByType(ob, eModifierType_Smoke)) && + (modifier_isEnabled(scene, md, eModifierMode_Realtime))) + { smd = (SmokeModifierData *)md; if (smd->domain) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5d65cccb213..7869522e8fb 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -928,6 +928,7 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN case ND_SHADING: case ND_NODES: { +#ifdef WITH_LEGACY_DEPSGRAPH Object *ob = OBACT; if ((v3d->drawtype == OB_MATERIAL) || (ob && (ob->mode == OB_MODE_TEXTURE_PAINT)) || @@ -935,6 +936,7 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN (scene->gm.matmode == GAME_MAT_GLSL || BKE_scene_use_new_shading_nodes(scene))) || !DEG_depsgraph_use_legacy()) +#endif { ED_region_tag_redraw(ar); } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 1f8a69adba0..d5fd18a77db 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -45,7 +45,7 @@ #include "MEM_guardedalloc.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BLI_math.h" #include "BLI_blenlib.h" @@ -992,9 +992,8 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) if (ptr->type == &RNA_Object) { Object *ob = ptr->data; - /* dimensions and material support just happen to be the same checks - * later we may want to add dimensions for lattice, armature etc too */ - if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { + /* dimensions and editmode just happen to be the same checks */ + if (OB_TYPE_SUPPORT_EDITMODE(ob->type)) { uiItemR(layout, ptr, "dimensions", 0, NULL, ICON_NONE); } } @@ -1179,7 +1178,7 @@ void view3d_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel object"); strcpy(pt->idname, "VIEW3D_PT_transform"); strcpy(pt->label, N_("Transform")); /* XXX C panels not available through RNA (bpy.types)! */ - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = view3d_panel_transform; pt->poll = view3d_panel_transform_poll; BLI_addtail(&art->paneltypes, pt); @@ -1187,7 +1186,7 @@ void view3d_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel vgroup"); strcpy(pt->idname, "VIEW3D_PT_vgroup"); strcpy(pt->label, N_("Vertex Weights")); /* XXX C panels are not available through RNA (bpy.types)! */ - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = view3d_panel_vgroup; pt->poll = view3d_panel_vgroup_poll; BLI_addtail(&art->paneltypes, pt); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7f553fe8836..3e0ea5fac07 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -80,7 +80,7 @@ #include "WM_api.h" #include "BLF_api.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "ED_armature.h" #include "ED_keyframing.h" @@ -1381,7 +1381,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) } if (!rv3d->gpuoffscreen) { - rv3d->gpuoffscreen = GPU_offscreen_create(w, h, error); + rv3d->gpuoffscreen = GPU_offscreen_create(w, h, 0, error); if (!rv3d->gpuoffscreen) fprintf(stderr, "Failed to create offscreen selection buffer for multisample: %s\n", error); @@ -1618,7 +1618,7 @@ exit: static void view3d_stereo_bgpic_setup(Scene *scene, View3D *v3d, Image *ima, ImageUser *iuser) { - if ((ima->flag & IMA_IS_STEREO)) { + if (BKE_image_is_stereo(ima)) { iuser->flag |= IMA_SHOW_STEREO; if ((scene->r.scemode & R_MULTIVIEW) == 0) { @@ -1961,15 +1961,13 @@ void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag) /* disables write in zbuffer and draws it over */ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d) { - View3DAfter *v3da, *next; + View3DAfter *v3da; glDepthMask(GL_FALSE); v3d->transp = true; - for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { - next = v3da->next; + while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) { draw_object(scene, ar, v3d, v3da->base, v3da->dflag); - BLI_remlink(&v3d->afterdraw_transp, v3da); MEM_freeN(v3da); } v3d->transp = false; @@ -1981,7 +1979,7 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d) /* clears zbuffer and draws it over */ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear) { - View3DAfter *v3da, *next; + View3DAfter *v3da; if (*clear && v3d->zbuf) { glClear(GL_DEPTH_BUFFER_BIT); @@ -1989,10 +1987,8 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear } v3d->xray = true; - for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { - next = v3da->next; + while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) { draw_object(scene, ar, v3d, v3da->base, v3da->dflag); - BLI_remlink(&v3d->afterdraw_xray, v3da); MEM_freeN(v3da); } v3d->xray = false; @@ -2002,7 +1998,7 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear /* clears zbuffer and draws it over */ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const bool clear) { - View3DAfter *v3da, *next; + View3DAfter *v3da; if (clear && v3d->zbuf) glClear(GL_DEPTH_BUFFER_BIT); @@ -2012,10 +2008,8 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const glDepthMask(GL_FALSE); - for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { - next = v3da->next; + while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) { draw_object(scene, ar, v3d, v3da->base, v3da->dflag); - BLI_remlink(&v3d->afterdraw_xraytransp, v3da); MEM_freeN(v3da); } @@ -2431,7 +2425,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) { - View3DAfter *v3da, *next; + View3DAfter *v3da; int mask_orig; v3d->xray = true; @@ -2442,8 +2436,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) { glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */ - for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { - next = v3da->next; + for (v3da = v3d->afterdraw_xray.first; v3da; v3da = v3da->next) { draw_object(scene, ar, v3d, v3da->base, dflag_depth); } glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */ @@ -2452,28 +2445,22 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover /* draw 3 passes, transp/xray/xraytransp */ v3d->xray = false; v3d->transp = true; - for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { - next = v3da->next; + while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) { draw_object(scene, ar, v3d, v3da->base, dflag_depth); - BLI_remlink(&v3d->afterdraw_transp, v3da); MEM_freeN(v3da); } v3d->xray = true; v3d->transp = false; - for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { - next = v3da->next; + while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) { draw_object(scene, ar, v3d, v3da->base, dflag_depth); - BLI_remlink(&v3d->afterdraw_xray, v3da); MEM_freeN(v3da); } v3d->xray = true; v3d->transp = true; - for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { - next = v3da->next; + while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) { draw_object(scene, ar, v3d, v3da->base, dflag_depth); - BLI_remlink(&v3d->afterdraw_xraytransp, v3da); MEM_freeN(v3da); } @@ -2502,8 +2489,10 @@ typedef struct View3DShadow { GPULamp *lamp; } View3DShadow; -static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object *par, - float obmat[4][4], ListBase *shadows, SceneRenderLayer *srl) +static void gpu_render_lamp_update(Scene *scene, View3D *v3d, + Object *ob, Object *par, + float obmat[4][4], unsigned int lay, + ListBase *shadows, SceneRenderLayer *srl) { GPULamp *lamp; Lamp *la = (Lamp *)ob->data; @@ -2513,10 +2502,10 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object lamp = GPU_lamp_from_blender(scene, ob, par); if (lamp) { - GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat); + GPU_lamp_update(lamp, lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat); GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy); - layers = ob->lay & v3d->lay; + layers = lay & v3d->lay; if (srl) layers &= srl->lay; @@ -2545,7 +2534,7 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d) ob = base->object; if (ob->type == OB_LAMP) - gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, &shadows, srl); + gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, ob->lay, &shadows, srl); if (ob->transflag & OB_DUPLI) { DupliObject *dob; @@ -2553,7 +2542,7 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d) for (dob = lb->first; dob; dob = dob->next) if (dob->ob->type == OB_LAMP) - gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, &shadows, srl); + gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, ob->lay, &shadows, srl); free_object_duplilist(lb); } @@ -3155,10 +3144,9 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) void ED_view3d_draw_offscreen( Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[4][4], float winmat[4][4], - bool do_bgpic, bool do_sky, bool is_persp, - GPUOffScreen *ofs, + bool do_bgpic, bool do_sky, bool is_persp, const char *viewname, GPUFX *fx, GPUFXSettings *fx_settings, - const char *viewname) + GPUOffScreen *ofs) { struct bThemeState theme_state; int bwinx, bwiny; @@ -3258,26 +3246,37 @@ void ED_view3d_draw_offscreen( G.f &= ~G_RENDER_OGL; } -/* utility func for ED_view3d_draw_offscreen */ -ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag, - bool draw_background, int alpha_mode, const char *viewname, char err_out[256]) +/** + * Utility func for ED_view3d_draw_offscreen + * + * \param ofs: Optional off-screen buffer, can be NULL. + * (avoids re-creating when doing multiple GL renders). + */ +ImBuf *ED_view3d_draw_offscreen_imbuf( + Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, + unsigned int flag, bool draw_background, + int alpha_mode, int samples, const char *viewname, + /* output vars */ + GPUOffScreen *ofs, char err_out[256]) { RegionView3D *rv3d = ar->regiondata; ImBuf *ibuf; - GPUOffScreen *ofs; - bool draw_sky = (alpha_mode == R_ADDSKY) && v3d && (v3d->flag3 & V3D_SHOW_WORLD); + const bool draw_sky = (alpha_mode == R_ADDSKY) && v3d && (v3d->flag3 & V3D_SHOW_WORLD); + const bool own_ofs = (ofs == NULL); if (UNLIKELY(v3d == NULL)) return NULL; - /* state changes make normal drawing go weird otherwise */ - glPushAttrib(GL_LIGHTING_BIT); + if (own_ofs) { + /* state changes make normal drawing go weird otherwise */ + glPushAttrib(GL_LIGHTING_BIT); - /* bind */ - ofs = GPU_offscreen_create(sizex, sizey, err_out); - if (ofs == NULL) { - glPopAttrib(); - return NULL; + /* bind */ + ofs = GPU_offscreen_create(sizex, sizey, samples, err_out); + if (ofs == NULL) { + glPopAttrib(); + return NULL; + } } ED_view3d_draw_offscreen_init(scene, v3d); @@ -3303,14 +3302,15 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in ED_view3d_draw_offscreen( scene, v3d, ar, sizex, sizey, NULL, params.winmat, - draw_background, draw_sky, !params.is_ortho, - ofs, NULL, &fx_settings, viewname); + draw_background, draw_sky, !params.is_ortho, viewname, + NULL, &fx_settings, + ofs); } else { ED_view3d_draw_offscreen( scene, v3d, ar, sizex, sizey, NULL, NULL, - draw_background, draw_sky, true, - ofs, NULL, NULL, viewname); + draw_background, draw_sky, true, viewname, + NULL, NULL, ofs); } /* read in pixels & stamp */ @@ -3323,9 +3323,12 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in /* unbind */ GPU_offscreen_unbind(ofs, true); - GPU_offscreen_free(ofs); - glPopAttrib(); + if (own_ofs) { + GPU_offscreen_free(ofs); + + glPopAttrib(); + } if (ibuf->rect_float && ibuf->rect) IMB_rect_from_float(ibuf); @@ -3333,10 +3336,19 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in return ibuf; } -/* creates own 3d views, used by the sequencer */ -ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, - bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, - const char *viewname, char err_out[256]) +/** + * Creates own fake 3d views (wrapping #ED_view3d_draw_offscreen_imbuf) + * + * \param ofs: Optional off-screen buffer can be NULL. + * (avoids re-creating when doing multiple GL renders). + * + * \note used by the sequencer + */ +ImBuf *ED_view3d_draw_offscreen_imbuf_simple( + Scene *scene, Object *camera, int width, int height, + unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background, + int alpha_mode, int samples, const char *viewname, + GPUOffScreen *ofs, char err_out[256]) { View3D v3d = {NULL}; ARegion ar = {NULL}; @@ -3383,8 +3395,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w mul_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat); invert_m4_m4(rv3d.persinv, rv3d.viewinv); - return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag, - draw_background, alpha_mode, viewname, err_out); + return ED_view3d_draw_offscreen_imbuf( + scene, &v3d, &ar, width, height, flag, + draw_background, alpha_mode, samples, viewname, + ofs, err_out); // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index d38de4a426e..cee0af933d0 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -44,6 +44,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BKE_armature.h" #include "BKE_camera.h" #include "BKE_context.h" #include "BKE_font.h" @@ -100,6 +101,9 @@ static bool view3d_operator_offset_lock_check(bContext *C, wmOperator *op) /* ********************** view3d_edit: view manipulations ********************* */ +/** + * \return true when the view-port is locked to its camera. + */ bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d) { return ((v3d->camera) && @@ -108,6 +112,10 @@ bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d) (rv3d->persp == RV3D_CAMOB)); } +/** + * Apply the camera object transformation to the view-port. + * (needed so we can use regular view-port manipulation operators, that sync back to the camera). + */ void ED_view3d_camera_lock_init_ex(View3D *v3d, RegionView3D *rv3d, const bool calc_dist) { if (ED_view3d_camera_lock_check(v3d, rv3d)) { @@ -124,7 +132,11 @@ void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) ED_view3d_camera_lock_init_ex(v3d, rv3d, true); } -/* return true if the camera is moved */ +/** + * Apply the view-port transformation back to the camera object. + * + * \return true if the camera is moved. + */ bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) { if (ED_view3d_camera_lock_check(v3d, rv3d)) { @@ -546,7 +558,7 @@ typedef struct ViewOpsData { } ViewOpsData; -#define TRACKBALLSIZE (1.1) +#define TRACKBALLSIZE (1.1f) static void calctrackballvec(const rcti *rect, int mx, int my, float vec[3]) { @@ -620,7 +632,10 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) Scene *scene = CTX_data_scene(C); Object *ob = OBACT; - if (ob && (ob->mode & OB_MODE_ALL_PAINT) && (BKE_object_pose_armature_get(ob) == NULL)) { + if (ob && (ob->mode & OB_MODE_ALL_PAINT) && + /* with weight-paint + pose-mode, fall through to using calculateTransformCenter */ + ((ob->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob)) == 0) + { /* in case of sculpting use last average stroke position as a rotation * center, in other cases it's not clear what rotation center shall be * so just rotate around object origin @@ -1013,31 +1028,25 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) rv3d->view = RV3D_VIEW_USER; /* need to reset every time because of view snapping */ if (U.flag & USER_TRACKBALL) { - float phi, si, q1[4], dvec[3], newvec[3]; + float axis[3], q1[4], dvec[3], newvec[3]; + float angle; calctrackballvec(&vod->ar->winrct, x, y, newvec); sub_v3_v3v3(dvec, newvec, vod->trackvec); - si = len_v3(dvec); - si /= (float)(2.0 * TRACKBALLSIZE); - - cross_v3_v3v3(q1 + 1, vod->trackvec, newvec); - normalize_v3(q1 + 1); + angle = (len_v3(dvec) / (2.0f * TRACKBALLSIZE)) * (float)M_PI; /* Allow for rotation beyond the interval [-pi, pi] */ - while (si > 1.0f) - si -= 2.0f; - - /* This relation is used instead of - * - phi = asin(si) so that the angle - * - of rotation is linearly proportional - * - to the distance that the mouse is - * - dragged. */ - phi = si * (float)M_PI_2; - - q1[0] = cosf(phi); - mul_v3_fl(q1 + 1, sinf(phi)); + angle = angle_wrap_rad(angle); + + /* This relation is used instead of the actual angle between vectors + * so that the angle of rotation is linearly proportional to + * the distance that the mouse is dragged. */ + + cross_v3_v3v3(axis, vod->trackvec, newvec); + axis_angle_to_quat(q1, axis, angle); + mul_qt_qtqt(vod->viewquat, q1, vod->oldquat); viewrotate_apply_dyn_ofs(vod, vod->viewquat); @@ -1461,8 +1470,7 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, ScrArea *sa, /* Perform the up/down rotation */ angle = ndof->dt * rot[0]; - quat[0] = cosf(angle); - mul_v3_v3fl(quat + 1, xvec, sinf(angle)); + axis_angle_to_quat(quat, xvec, angle * 2); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, quat); /* Perform the orbital rotation */ @@ -3028,24 +3036,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */ } else if (ob && (ob->mode & OB_MODE_POSE)) { - if (ob->pose) { - bArmature *arm = ob->data; - bPoseChannel *pchan; - float vec[3]; - - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - if (pchan->bone->flag & BONE_SELECTED) { - if (pchan->bone->layer & arm->layer) { - bPoseChannel *pchan_tx = pchan->custom_tx ? pchan->custom_tx : pchan; - ok = 1; - mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); - minmax_v3v3_v3(min, max, vec); - mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); - minmax_v3v3_v3(min, max, vec); - } - } - } - } + ok = BKE_pose_minmax(ob, min, max, true, true); } else if (BKE_paint_select_face_test(ob)) { ok = paintface_minmax(ob, min, max); @@ -3754,6 +3745,8 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, { RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */ float quat[4]; + const short orig_persp = rv3d->persp; + normalize_qt_qt(quat, quat_); @@ -3769,7 +3762,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float twmat[3][3]; /* same as transform manipulator when normal is set */ - ED_getTransformOrientationMatrix(C, twmat, true); + ED_getTransformOrientationMatrix(C, twmat, V3D_ACTIVE); mat3_to_quat(obact_quat, twmat); invert_qt(obact_quat); @@ -3796,16 +3789,31 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, } if (rv3d->persp == RV3D_CAMOB && v3d->camera) { + /* to camera */ ED_view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, quat, NULL, NULL, smooth_viewtx); } + else if (orig_persp == RV3D_CAMOB && v3d->camera) { + /* from camera */ + float ofs[3], dist; + + copy_v3_v3(ofs, rv3d->ofs); + dist = rv3d->dist; + + /* so we animate _from_ the camera location */ + ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, &rv3d->dist, NULL); + + ED_view3d_smooth_view(C, v3d, ar, NULL, NULL, + ofs, quat, &dist, NULL, + smooth_viewtx); + } else { + /* no camera involved */ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL, NULL, quat, NULL, NULL, smooth_viewtx); } - } static int viewnumpad_exec(bContext *C, wmOperator *op) @@ -4464,7 +4472,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) /* properties */ RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign"); WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, - WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); } @@ -4807,10 +4815,17 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg return depth_close; } -/* XXX todo Zooms in on a border drawn by the user */ -bool ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, - const int mval[2], float mouse_worldloc[3], - const bool alphaoverride, const float fallback_depth_pt[3]) +/** + * Get the world-space 3d location from a screen-space 2d point. + * + * \param mval: Input screen-space pixel location. + * \param mouse_worldloc: Output world-space loction. + * \param fallback_depth_pt: Use this points depth when no depth can be found. + */ +bool ED_view3d_autodist( + Scene *scene, ARegion *ar, View3D *v3d, + const int mval[2], float mouse_worldloc[3], + const bool alphaoverride, const float fallback_depth_pt[3]) { bglMats mats; /* ZBuffer depth vars */ float depth_close; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 6a020251fca..e6910cf9303 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -39,7 +39,7 @@ #include "BKE_context.h" #include "BKE_report.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BIF_gl.h" diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index f8912345e1c..42895a7530b 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -37,7 +37,7 @@ #include "BLI_utildefines.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BKE_context.h" #include "BKE_depsgraph.h" diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 6a2c948aa8d..8c668b2b8e0 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -236,7 +236,6 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_navigate", FKEY, KM_PRESS, KM_SHIFT, 0); - /* value is set to KM_NOTHING to avoid conflicts with click type (see T44251) */ WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 5a35e9fcad1..69e354d87c7 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1193,7 +1193,10 @@ static short selectbuffer_ret_hits_5(unsigned int *buffer, const short hits15, c /* we want a select buffer with bones, if there are... */ /* so check three selection levels and compare */ -static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, const int mval[2], bool *p_do_nearest, bool enumerate) +static short mixed_bones_object_selectbuffer( + ViewContext *vc, unsigned int *buffer, const int mval[2], + bool use_cycle, bool enumerate, + bool *r_do_nearest) { rcti rect; int offs; @@ -1204,16 +1207,24 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff View3D *v3d = vc->v3d; /* define if we use solid nearest select or not */ - if (v3d->drawtype > OB_WIRE) { - do_nearest = true; - if (len_manhattan_v2v2_int(mval, last_mval) < 3) { - do_nearest = false; + if (use_cycle) { + if (v3d->drawtype > OB_WIRE) { + do_nearest = true; + if (len_manhattan_v2v2_int(mval, last_mval) < 3) { + do_nearest = false; + } + } + copy_v2_v2_int(last_mval, mval); + } + else { + if (v3d->drawtype > OB_WIRE) { + do_nearest = true; } } - copy_v2_v2_int(last_mval, mval); - if (p_do_nearest) - *p_do_nearest = do_nearest; + if (r_do_nearest) { + *r_do_nearest = do_nearest; + } do_nearest = do_nearest && !enumerate; @@ -1353,7 +1364,7 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, &do_nearest, false); + hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest); if (hits > 0) { const bool has_bones = selectbuffer_has_bones(buffer, hits); @@ -1448,7 +1459,7 @@ static bool mouse_select(bContext *C, const int mval[2], /* if objects have posemode set, the bones are in the same selection buffer */ - hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, &do_nearest, enumerate); + hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, true, enumerate, &do_nearest); if (hits > 0) { /* note: bundles are handling in the same way as bones */ diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index af24a99a6f2..065c336d001 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -43,7 +43,7 @@ #include "BLI_utildefines.h" #include "BLI_ghash.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -234,7 +234,7 @@ void view3d_toolshelf_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools"); strcpy(pt->idname, "VIEW3D_PT_tool_shelf"); strcpy(pt->label, N_("Tool Shelf")); - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = view3d_panel_tool_shelf; BLI_addtail(&art->paneltypes, pt); } @@ -246,7 +246,7 @@ void view3d_tool_props_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); strcpy(pt->label, N_("Operator")); - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw_header = view3d_panel_operator_redo_header; pt->draw = view3d_panel_operator_redo; BLI_addtail(&art->paneltypes, pt); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index e111a473fdf..0f05f4e52dd 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -137,6 +137,9 @@ struct SmoothView3DStore { struct SmoothView3DState org; /* original */ bool to_camera; + + /* When smooth-view is enabled, store the 'rv3d->view' here, + * assign back when the view motion is completed. */ char org_view; double time_allowed; @@ -180,12 +183,12 @@ void ED_view3d_smooth_view_ex( /* if smoothview runs multiple times... */ if (rv3d->sms == NULL) { view3d_smooth_view_state_backup(&sms.org, v3d, rv3d); - sms.org_view = rv3d->view; } else { sms.org = rv3d->sms->org; - sms.org_view = rv3d->sms->org_view; } + sms.org_view = rv3d->view; + /* sms.to_camera = false; */ /* initizlized to zero anyway */ /* note on camera locking, this is a little confusing but works ok. @@ -1782,7 +1785,7 @@ float ED_view3d_radius_to_dist( lens = params.lens; sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y); - /* ignore 'rv3d->camzoom' because we wan't to fit to the cameras frame */ + /* ignore 'rv3d->camzoom' because we want to fit to the cameras frame */ zoom = CAMERA_PARAM_ZOOM_INIT_CAMOB; } else { diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 243c6e5c8c3..0bda6e37fd1 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -38,7 +38,7 @@ #include "BKE_context.h" #include "BKE_report.h" -#include "BLF_translation.h" +#include "BLT_translation.h" #include "BIF_gl.h" @@ -62,6 +62,9 @@ #define USE_TABLET_SUPPORT +/* ensure the target position is one we can reach, see: T45771 */ +#define USE_PIXELSIZE_NATIVE_SUPPORT + /* prototypes */ static float getVelocityZeroTime(const float gravity, const float velocity); @@ -519,7 +522,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->speed = 0.0f; walk->is_fast = false; walk->is_slow = false; - walk->grid = 1.f / walk->scene->unit.scale_length; + walk->grid = (walk->scene->unit.system == USER_UNIT_NONE) ? 1.f : 1.f / walk->scene->unit.scale_length; /* user preference settings */ walk->teleport.duration = U.walk_navigation.teleport_time; @@ -578,6 +581,16 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->center_mval[0] = walk->ar->winx * 0.5f; walk->center_mval[1] = walk->ar->winy * 0.5f; +#ifdef USE_PIXELSIZE_NATIVE_SUPPORT + walk->center_mval[0] += walk->ar->winrct.xmin; + walk->center_mval[1] += walk->ar->winrct.ymin; + + WM_cursor_compatible_xy(win, &walk->center_mval[0], &walk->center_mval[1]); + + walk->center_mval[0] -= walk->ar->winrct.xmin; + walk->center_mval[1] -= walk->ar->winrct.ymin; +#endif + copy_v2_v2_int(walk->prev_mval, walk->center_mval); WM_cursor_warp(win, |