diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
18 files changed, 791 insertions, 697 deletions
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 17f90fc54e3..d8b18140cde 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -54,7 +54,6 @@ #include "ED_armature.h" #include "ED_keyframes_draw.h" -#include "BLF_api.h" #include "UI_resources.h" diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index dfa373f111f..691da78f26b 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -61,7 +61,6 @@ #include "ED_armature.h" #include "ED_keyframes_draw.h" -#include "BLF_api.h" #include "UI_resources.h" @@ -2088,6 +2087,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } } + + if (index != -1) { + GPU_select_load_id(-1); + } } /* in editmode, we don't store the bone matrix... */ @@ -2392,7 +2395,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base if (v3d->zbuf) glDisable(GL_DEPTH_TEST); /* draw from first frame of range to last */ - for (CFRA = (int)start; CFRA < end; CFRA += (int)stepsize) { + for (CFRA = (int)start; CFRA <= end; CFRA += (int)stepsize) { colfac = (end - (float)CFRA) / range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac))); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index fa9ba23e454..755c633531d 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -60,7 +60,6 @@ #include "UI_resources.h" -#include "GPU_buffers.h" #include "GPU_extensions.h" #include "GPU_draw.h" #include "GPU_material.h" @@ -97,7 +96,7 @@ typedef struct drawTFace_userData { BLI_INLINE int edge_vis_index(const int index) { return index * 2; } BLI_INLINE int edge_sel_index(const int index) { return index * 2 + 1; } -static BLI_bitmap *get_tface_mesh_marked_edge_info(Mesh *me) +static BLI_bitmap *get_tface_mesh_marked_edge_info(Mesh *me, bool draw_select_edges) { BLI_bitmap *bitmap_edge_flags = BLI_BITMAP_NEW(me->totedge * 2, __func__); MPoly *mp; @@ -113,8 +112,17 @@ static BLI_bitmap *get_tface_mesh_marked_edge_info(Mesh *me) ml = me->mloop + mp->loopstart; for (j = 0; j < mp->totloop; j++, ml++) { - BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_vis_index(ml->e)); - if (select_set) BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_sel_index(ml->e)); + if ((draw_select_edges == false) && + (select_set && BLI_BITMAP_TEST(bitmap_edge_flags, edge_sel_index(ml->e)))) + { + BLI_BITMAP_DISABLE(bitmap_edge_flags, edge_vis_index(ml->e)); + } + else { + BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_vis_index(ml->e)); + if (select_set) { + BLI_BITMAP_ENABLE(bitmap_edge_flags, edge_sel_index(ml->e)); + } + } } } } @@ -129,21 +137,26 @@ static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int ind Mesh *me = data->me; if (me->drawflag & ME_DRAWEDGES) { - if ((me->drawflag & ME_HIDDENEDGES) || (BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index)))) + if ((BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index)))) return DM_DRAW_OPTION_NORMAL; else return DM_DRAW_OPTION_SKIP; } - else if (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index))) + else if (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index)) && + BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index))) + { return DM_DRAW_OPTION_NORMAL; - else + } + else { return DM_DRAW_OPTION_SKIP; + } } static DMDrawOption draw_mesh_face_select__setSelectOpts(void *userData, int index) { drawMeshFaceSelect_userData *data = userData; - return (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index))) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP; + return (BLI_BITMAP_TEST(data->edge_flags, edge_sel_index(index)) && + BLI_BITMAP_TEST(data->edge_flags, edge_vis_index(index))) ? DM_DRAW_OPTION_NORMAL : DM_DRAW_OPTION_SKIP; } /* draws unselected */ @@ -158,12 +171,12 @@ static DMDrawOption draw_mesh_face_select__drawFaceOptsInv(void *userData, int i return DM_DRAW_OPTION_SKIP; } -void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) +void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, bool draw_select_edges) { drawMeshFaceSelect_userData data; data.me = me; - data.edge_flags = get_tface_mesh_marked_edge_info(me); + data.edge_flags = get_tface_mesh_marked_edge_info(me, draw_select_edges); glEnable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); @@ -562,14 +575,6 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc } } -static DMDrawOption draw_mcol__set_draw_legacy(MTFace *UNUSED(tface), const bool has_mcol, int UNUSED(matnr)) -{ - if (has_mcol) - return DM_DRAW_OPTION_NORMAL; - else - return DM_DRAW_OPTION_NO_MCOL; -} - static DMDrawOption draw_tface__set_draw(MTFace *tface, const bool UNUSED(has_mcol), int matnr) { Material *ma = give_current_material(Gtexdraw.ob, matnr + 1); @@ -668,48 +673,48 @@ static void update_tface_color_layer(DerivedMesh *dm) } } -static DMDrawOption draw_tface_mapped__set_draw(void *userData, int index) +static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, int UNUSED(mat_nr)) { Mesh *me = ((drawTFace_userData *)userData)->me; /* array checked for NULL before calling */ - MPoly *mpoly = &me->mpoly[index]; + MPoly *mpoly = &me->mpoly[origindex]; - BLI_assert(index >= 0 && index < me->totpoly); + BLI_assert(origindex >= 0 && origindex < me->totpoly); if (mpoly->flag & ME_HIDE) { return DM_DRAW_OPTION_SKIP; } else { - MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[index] : NULL; + MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[origindex] : NULL; MTFace mtf = {{{0}}}; int matnr = mpoly->mat_nr; if (tpoly) { ME_MTEXFACE_CPY(&mtf, tpoly); } - + return draw_tface__set_draw(&mtf, (me->mloopcol != NULL), matnr); } } -static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int index) +static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, int mat_nr) { drawEMTFMapped_userData *data = userData; BMEditMesh *em = data->em; BMFace *efa; - if (UNLIKELY(index >= em->bm->totface)) + if (UNLIKELY(origindex >= em->bm->totface)) return DM_DRAW_OPTION_NORMAL; - efa = BM_face_at_index(em->bm, index); + efa = BM_face_at_index(em->bm, origindex); if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { return DM_DRAW_OPTION_SKIP; } else { MTFace mtf = {{{0}}}; - int matnr = efa->mat_nr; + int matnr = (mat_nr != -1) ? mat_nr : efa->mat_nr; if (data->has_mtface) { MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); @@ -929,24 +934,16 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, compareDrawOptions, &userData, uvflag); } } - else { - if (GPU_buffer_legacy(dm)) { - if (draw_flags & DRAW_MODIFIERS_PREVIEW) - dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL, uvflag); - else - dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL, uvflag); - } - else { - drawTFace_userData userData; - - update_tface_color_layer(dm); - - userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE); - userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); - userData.me = NULL; - - dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData, uvflag); - } + else { + drawTFace_userData userData; + + update_tface_color_layer(dm); + + userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE); + userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); + userData.me = NULL; + + dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData, uvflag); } /* draw game engine text hack */ @@ -956,8 +953,10 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d draw_textured_end(); /* draw edges and selected faces over textured mesh */ - if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) - draw_mesh_face_select(rv3d, me, dm); + if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) { + bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0; + draw_mesh_face_select(rv3d, me, dm, draw_select_edges); + } /* reset from negative scale correction */ glFrontFace(GL_CCW); @@ -1153,8 +1152,10 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, glMatrixMode(GL_MODELVIEW); /* faceselect mode drawing over textured mesh */ - if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) - draw_mesh_face_select(rv3d, ob->data, dm); + if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) { + bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0; + draw_mesh_face_select(rv3d, ob->data, dm, draw_select_edges); + } } /* Vertex Paint and Weight Paint */ @@ -1189,7 +1190,7 @@ void draw_mesh_paint_weight_faces(DerivedMesh *dm, const bool use_light, } dm->drawMappedFaces(dm, (DMSetDrawOptions)facemask_cb, GPU_enable_material, NULL, user_data, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS); if (use_light) { draw_mesh_paint_light_end(); @@ -1206,12 +1207,11 @@ void draw_mesh_paint_vcolor_faces(DerivedMesh *dm, const bool use_light, if (me->mloopcol) { dm->drawMappedFaces(dm, facemask_cb, GPU_enable_material, NULL, user_data, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS); } else { glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, facemask_cb, GPU_enable_material, NULL, user_data, - DM_DRAW_ALWAYS_SMOOTH); + dm->drawMappedFaces(dm, facemask_cb, GPU_enable_material, NULL, user_data, 0); } if (use_light) { @@ -1279,7 +1279,8 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, /* draw face selection on top */ if (draw_flags & DRAW_FACE_SELECT) { - draw_mesh_face_select(rv3d, me, dm); + bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0; + draw_mesh_face_select(rv3d, me, dm, draw_select_edges); } else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) { const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index db04d3ccd66..a63b166969e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1331,7 +1331,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, /* draw the circle/square representing spotbl */ if (la->type == LA_SPOT) { - float spotblcirc = fabsf(z) * (1.0f - powf(la->spotblend, 2)); + 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 */ @@ -2153,8 +2153,7 @@ static void calcDrawDMNormalScale(Object *ob, drawDMNormal_userData *data) invert_m3_m3(data->imat, obmat); /* transposed inverted matrix */ - copy_m3_m3(data->tmat, data->imat); - transpose_m3(data->tmat); + transpose_m3_m3(data->tmat, data->imat); } } @@ -2497,7 +2496,7 @@ static void draw_dm_edges_weight_interp(BMEditMesh *em, DerivedMesh *dm, const c data.bm = em->bm; data.cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); - data.defgroup_tot = BLI_countlist(&ob->defbase); + data.defgroup_tot = BLI_listbase_count(&ob->defbase); data.vgroup_index = ob->actdef - 1; data.weight_user = weight_user; UI_GetThemeColor3fv(TH_VERTEX_UNREFERENCED, data.alert_color); @@ -3375,7 +3374,6 @@ static DMDrawOption draw_em_fancy__setFaceOpts(void *userData, int index) efa = BM_face_at_index(em->bm, index); if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { - GPU_enable_material(efa->mat_nr + 1, NULL); return DM_DRAW_OPTION_NORMAL; } else { @@ -3773,7 +3771,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glFrontFace(GL_CCW); if (draw_flags & DRAW_FACE_SELECT) - draw_mesh_face_select(rv3d, me, dm); + draw_mesh_face_select(rv3d, me, dm, false); } else { draw_mesh_textured(scene, v3d, rv3d, ob, dm, draw_flags); @@ -6859,15 +6857,18 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glDepthMask(0); if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - DerivedMesh *dm = ob->derivedFinal; + DerivedMesh *dm; bool has_faces = false; - if (dm) - DM_update_materials(dm, ob); #ifdef SEQUENCER_DAG_WORKAROUND ensure_curve_cache(scene, ob); #endif + dm = ob->derivedFinal; + if (dm) { + DM_update_materials(dm, ob); + } + if (dm) { has_faces = dm->getNumTessFaces(dm) > 0; } diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 59798f97d93..a220e1e39b0 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -27,8 +27,6 @@ * \ingroup spview3d */ - - #include <string.h> #include <math.h> @@ -38,7 +36,6 @@ #include "DNA_screen_types.h" #include "DNA_smoke_types.h" #include "DNA_view3d_types.h" -#include "DNA_property_types.h" #include "BLI_utildefines.h" #include "BLI_math.h" @@ -53,8 +50,6 @@ #include "ED_mesh.h" -#include "BLF_api.h" - #include "view3d_intern.h" // own include struct GPUTexture; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index b3accb431ee..55d5273b198 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -414,7 +414,7 @@ static void view3d_free(SpaceLink *sl) /* matcap material, its preview rect gets freed via icons */ if (vd->defmaterial) { if (vd->defmaterial->gpumaterial.first) - GPU_material_free(vd->defmaterial); + GPU_material_free(&vd->defmaterial->gpumaterial); BKE_previewimg_free(&vd->defmaterial->preview); MEM_freeN(vd->defmaterial); } @@ -599,7 +599,7 @@ static int view3d_ima_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent return 1; } else if (drag->type == WM_DRAG_PATH) { - if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + if (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE)) /* rule might not work? */ return 1; } return 0; @@ -665,10 +665,14 @@ static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - if (id) + if (id) { RNA_string_set(drop->ptr, "name", id->name + 2); - if (drag->path[0]) + RNA_struct_property_unset(drop->ptr, "filepath"); + } + else if (drag->path[0]) { RNA_string_set(drop->ptr, "filepath", drag->path); + RNA_struct_property_unset(drop->ptr, "image"); + } } @@ -950,8 +954,9 @@ static void view3d_main_area_listener(bScreen *sc, ScrArea *sa, ARegion *ar, wmN break; case NC_GPENCIL: - if (wmn->action == NA_EDITED) + if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } break; } } @@ -1007,6 +1012,10 @@ static void view3d_header_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) if (wmn->data == ND_SPACE_VIEW3D) ED_region_tag_redraw(ar); break; + case NC_GPENCIL: + if (wmn->data & ND_GPENCIL_EDITMODE) + ED_region_tag_redraw(ar); + break; } } @@ -1104,7 +1113,7 @@ static void view3d_buttons_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa ED_region_tag_redraw(ar); break; case NC_GPENCIL: - if (wmn->data == ND_DATA || wmn->action == NA_EDITED) + if ((wmn->data & (ND_DATA | ND_GPENCIL_EDITMODE)) || (wmn->action == NA_EDITED)) ED_region_tag_redraw(ar); break; case NC_IMAGE: @@ -1168,7 +1177,8 @@ static void space_view3d_listener(bScreen *UNUSED(sc), ScrArea *sa, struct wmNot case NC_WORLD: switch (wmn->data) { case ND_WORLD_DRAW: - if (v3d->flag2 & V3D_RENDER_OVERRIDE) + case ND_WORLD: + if (v3d->flag3 & V3D_SHOW_WORLD) ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); break; } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index cf589cdd946..42b7f62c8d1 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -60,6 +60,7 @@ #include "BKE_editmesh.h" #include "BKE_deform.h" #include "BKE_object.h" +#include "BKE_object_deform.h" #include "WM_api.h" #include "WM_types.h" @@ -68,7 +69,6 @@ #include "ED_armature.h" #include "ED_gpencil.h" -#include "ED_object.h" #include "ED_mesh.h" #include "ED_screen.h" @@ -82,7 +82,7 @@ #define B_REDR 2 #define B_OBJECTPANELMEDIAN 1008 -#define NBR_TRANSFORM_PROPERTIES 7 +#define NBR_TRANSFORM_PROPERTIES 8 /* temporary struct for storing transform properties */ typedef struct { @@ -124,38 +124,84 @@ static float compute_scale_factor(const float ve_median, const float median) } } +/* Apply helpers. + * Note: In case we only have one element, copy directly the value instead of applying the diff or scale factor. + * Avoids some glitches when going e.g. from 3 to 0.0001 (see T37327). + */ +static void apply_raw_diff(float *val, const int tot, const float ve_median, const float median) +{ + *val = (tot == 1) ? ve_median : (*val + median); +} + +static void apply_raw_diff_v3(float val[3], const int tot, const float ve_median[3], const float median[3]) +{ + if (tot == 1) { + copy_v3_v3(val, ve_median); + } + else { + add_v3_v3(val, median); + } +} + +static void apply_scale_factor(float *val, const int tot, const float ve_median, const float median, const float sca) +{ + if (tot == 1 || ve_median == median) { + *val = ve_median; + } + else { + *val *= sca; + } +} + +static void apply_scale_factor_clamp(float *val, const int tot, const float ve_median, const float sca) +{ + if (tot == 1) { + *val = ve_median; + CLAMP(*val, 0.0f, 1.0f); + } + else if (ELEM(sca, 0.0f, 1.0f)) { + *val = sca; + } + else { + *val = (sca > 0.0f) ? (*val * sca) : (1.0f + ((1.0f - *val) * sca)); + CLAMP(*val, 0.0f, 1.0f); + } +} + /* is used for both read and write... */ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float lim) { /* Get rid of those ugly magic numbers, even in a single func they become confusing! */ /* Location, common to all. */ -/* XXX Those two *must* remain contiguous (used as array)! */ -#define LOC_X 0 -#define LOC_Y 1 -#define LOC_Z 2 +/* Next three *must* remain contiguous (used as array)! */ +#define LOC_X 0 +#define LOC_Y 1 +#define LOC_Z 2 /* Meshes... */ -#define M_CREASE 3 -#define M_WEIGHT 4 -/* XXX Those two *must* remain contiguous (used as array)! */ -#define M_SKIN_X 5 -#define M_SKIN_Y 6 +#define M_BV_WEIGHT 3 +/* Next two *must* remain contiguous (used as array)! */ +#define M_SKIN_X 4 +#define M_SKIN_Y 5 +#define M_BE_WEIGHT 6 +#define M_CREASE 7 /* Curves... */ -#define C_BWEIGHT 3 -#define C_WEIGHT 4 -#define C_RADIUS 5 -#define C_TILT 6 +#define C_BWEIGHT 3 +#define C_WEIGHT 4 +#define C_RADIUS 5 +#define C_TILT 6 /*Lattice... */ -#define L_WEIGHT 4 +#define L_WEIGHT 4 uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : NULL; TransformProperties *tfp; float median[NBR_TRANSFORM_PROPERTIES], ve_median[NBR_TRANSFORM_PROPERTIES]; - int tot, totedgedata, totcurvedata, totlattdata, totskinradius, totcurvebweight; + int tot, totedgedata, totcurvedata, totlattdata, totcurvebweight; bool has_meshdata = false; + bool has_skinradius = false; PointerRNA data_ptr; fill_vn_fl(median, NBR_TRANSFORM_PROPERTIES, 0.0f); - tot = totedgedata = totcurvedata = totlattdata = totskinradius = totcurvebweight = 0; + tot = totedgedata = totcurvedata = totlattdata = totcurvebweight = 0; /* make sure we got storage */ if (v3d->properties_storage == NULL) @@ -170,37 +216,37 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float BMEdge *eed; BMIter iter; - const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT); + const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); const int cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT); const int cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE); + has_skinradius = (cd_vert_skin_offset != -1); + if (bm->totvertsel) { BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { tot++; add_v3_v3(&median[LOC_X], eve->co); - /* TODO cd_vert_bweight_offset */ - (void)cd_vert_bweight_offset; + if (cd_vert_bweight_offset != -1) { + median[M_BV_WEIGHT] += BM_ELEM_CD_GET_FLOAT(eve, cd_vert_bweight_offset); + } - if (cd_vert_skin_offset != -1) { + if (has_skinradius) { MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset); add_v2_v2(&median[M_SKIN_X], vs->radius); /* Third val not used currently. */ - totskinradius++; } } } } - if ((cd_edge_bweight_offset != -1) || - (cd_edge_crease_offset != -1)) - { + if ((cd_edge_bweight_offset != -1) || (cd_edge_crease_offset != -1)) { if (bm->totedgesel) { BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { if (cd_edge_bweight_offset != -1) { - median[M_WEIGHT] += BM_ELEM_CD_GET_FLOAT(eed, cd_edge_bweight_offset); + median[M_BE_WEIGHT] += BM_ELEM_CD_GET_FLOAT(eed, cd_edge_bweight_offset); } if (cd_edge_crease_offset != -1) { @@ -216,7 +262,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float totedgedata = bm->totedgesel; } - has_meshdata = (totedgedata || totskinradius); + has_meshdata = (tot || totedgedata); } else if (ob->type == OB_CURVE || ob->type == OB_SURF) { Curve *cu = ob->data; @@ -314,7 +360,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } if (tot == 0) { - uiDefBut(block, LABEL, 0, IFACE_("Nothing selected"), 0, 130, 200, 20, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Nothing selected"), 0, 130, 200, 20, NULL, 0, 0, 0, 0, ""); return; } @@ -326,22 +372,27 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if (has_meshdata) { if (totedgedata) { median[M_CREASE] /= (float)totedgedata; - median[M_WEIGHT] /= (float)totedgedata; + median[M_BE_WEIGHT] /= (float)totedgedata; } - if (totskinradius) { - median[M_SKIN_X] /= (float)totskinradius; - median[M_SKIN_Y] /= (float)totskinradius; + if (tot) { + median[M_BV_WEIGHT] /= (float)tot; + if (has_skinradius) { + median[M_SKIN_X] /= (float)tot; + median[M_SKIN_Y] /= (float)tot; + } } } else if (totcurvedata) { + if (totcurvebweight) { + median[C_BWEIGHT] /= (float)totcurvebweight; + } median[C_WEIGHT] /= (float)totcurvedata; median[C_RADIUS] /= (float)totcurvedata; median[C_TILT] /= (float)totcurvedata; - if (totcurvebweight) - median[C_BWEIGHT] /= (float)totcurvebweight; } - else if (totlattdata) + else if (totlattdata) { median[L_WEIGHT] /= (float)totlattdata; + } if (block) { /* buttons */ uiBut *but; @@ -353,7 +404,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float memcpy(tfp->ve_median, median, sizeof(tfp->ve_median)); - uiBlockBeginAlign(block); + UI_block_align_begin(block); if (tot == 1) { if (totcurvedata) /* Curve */ c = IFACE_("Control Point:"); @@ -362,98 +413,111 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else c = IFACE_("Median:"); - uiDefBut(block, LABEL, 0, c, 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, UI_BTYPE_LABEL, 0, c, 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, ""); - uiBlockBeginAlign(block); + UI_block_align_begin(block); /* Should be no need to translate these. */ - but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("X:"), 0, yi -= buth, 200, buth, + but = uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("X:"), 0, yi -= buth, 200, buth, &(tfp->ve_median[LOC_X]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); - uiButSetUnitType(but, PROP_UNIT_LENGTH); - but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Y:"), 0, yi -= buth, 200, buth, + UI_but_unit_type_set(but, PROP_UNIT_LENGTH); + but = uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("Y:"), 0, yi -= buth, 200, buth, &(tfp->ve_median[LOC_Y]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); - uiButSetUnitType(but, PROP_UNIT_LENGTH); - but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Z:"), 0, yi -= buth, 200, buth, + UI_but_unit_type_set(but, PROP_UNIT_LENGTH); + but = uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("Z:"), 0, yi -= buth, 200, buth, &(tfp->ve_median[LOC_Z]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); - uiButSetUnitType(but, PROP_UNIT_LENGTH); + UI_but_unit_type_set(but, PROP_UNIT_LENGTH); if (totcurvebweight == tot) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("W:"), 0, yi -= buth, 200, buth, + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("W:"), 0, yi -= buth, 200, buth, &(tfp->ve_median[C_BWEIGHT]), 0.01, 100.0, 1, 3, ""); } - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, V3D_GLOBAL_STATS, B_REDR, IFACE_("Global"), + UI_block_align_begin(block); + uiDefButBitS(block, UI_BTYPE_TOGGLE, V3D_GLOBAL_STATS, B_REDR, IFACE_("Global"), 0, yi -= buth + but_margin, 100, buth, &v3d->flag, 0, 0, 0, 0, TIP_("Displays global values")); - uiDefButBitS(block, TOGN, V3D_GLOBAL_STATS, B_REDR, IFACE_("Local"), + uiDefButBitS(block, UI_BTYPE_TOGGLE_N, V3D_GLOBAL_STATS, B_REDR, IFACE_("Local"), 100, yi, 100, buth, &v3d->flag, 0, 0, 0, 0, TIP_("Displays local values")); - uiBlockEndAlign(block); + UI_block_align_end(block); /* Meshes... */ if (has_meshdata) { - if (totedgedata) { + if (tot) { + uiDefBut(block, UI_BTYPE_LABEL, 0, tot == 1 ? IFACE_("Vertex Data:") : IFACE_("Vertices Data:"), + 0, yi -= buth + but_margin, 200, buth, NULL, 0.0, 0.0, 0, 0, ""); /* customdata layer added on demand */ - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, - totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"), + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, + tot == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"), 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[M_CREASE]), 0.0, 1.0, 1, 2, TIP_("Weight used by SubSurf modifier")); - /* customdata layer added on demand */ - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, - totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[M_WEIGHT]), 0.0, 1.0, 1, 2, TIP_("Weight used by Bevel modifier")); + &(tfp->ve_median[M_BV_WEIGHT]), 0.0, 1.0, 1, 2, TIP_("Vertex weight used by Bevel modifier")); } - if (totskinradius) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, - totskinradius == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"), + if (has_skinradius) { + UI_block_align_begin(block); + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, + tot == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[M_SKIN_X]), 0.0, 100.0, 1, 3, TIP_("X radius used by Skin modifier")); - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, - totskinradius == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"), + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, + tot == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[M_SKIN_Y]), 0.0, 100.0, 1, 3, TIP_("Y radius used by Skin modifier")); + UI_block_align_end(block); + } + if (totedgedata) { + uiDefBut(block, UI_BTYPE_LABEL, 0, totedgedata == 1 ? IFACE_("Edge Data:") : IFACE_("Edges Data:"), + 0, yi -= buth + but_margin, 200, buth, NULL, 0.0, 0.0, 0, 0, ""); + /* customdata layer added on demand */ + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, + totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[M_BE_WEIGHT]), 0.0, 1.0, 1, 2, TIP_("Edge weight used by Bevel modifier")); + /* customdata layer added on demand */ + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, + totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[M_CREASE]), 0.0, 1.0, 1, 2, TIP_("Weight used by SubSurf modifier")); } } /* Curve... */ else if (totcurvedata == 1) { - uiDefButR(block, NUM, 0, IFACE_("Weight:"), 0, yi -= buth + but_margin, 200, buth, + uiDefButR(block, UI_BTYPE_NUM, 0, IFACE_("Weight:"), 0, yi -= buth + but_margin, 200, buth, &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL); - uiDefButR(block, NUM, 0, IFACE_("Radius:"), 0, yi -= buth + but_margin, 200, buth, + uiDefButR(block, UI_BTYPE_NUM, 0, IFACE_("Radius:"), 0, yi -= buth + but_margin, 200, buth, &data_ptr, "radius", 0, 0.0, 100.0, 1, 3, NULL); - uiDefButR(block, NUM, 0, IFACE_("Tilt:"), 0, yi -= buth + but_margin, 200, buth, + uiDefButR(block, UI_BTYPE_NUM, 0, IFACE_("Tilt:"), 0, yi -= buth + but_margin, 200, buth, &data_ptr, "tilt", 0, -tilt_limit, tilt_limit, 1, 3, NULL); } else if (totcurvedata > 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[C_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius:"), + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[C_RADIUS]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points")); - but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Tilt:"), + but = uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Tilt:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[C_TILT]), -tilt_limit, tilt_limit, 1, 3, TIP_("Tilt of curve control points")); - uiButSetUnitType(but, PROP_UNIT_ROTATION); + UI_but_unit_type_set(but, PROP_UNIT_ROTATION); } /* Lattice... */ else if (totlattdata == 1) { - uiDefButR(block, NUM, 0, IFACE_("Weight:"), 0, yi -= buth + but_margin, 200, buth, + uiDefButR(block, UI_BTYPE_NUM, 0, IFACE_("Weight:"), 0, yi -= buth + but_margin, 200, buth, &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL); } else if (totlattdata > 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), + uiDefButF(block, UI_BTYPE_NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[L_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); } - uiBlockEndAlign(block); - + UI_block_align_end(block); } else { /* apply */ int i; + bool apply_vcos; memcpy(ve_median, tfp->ve_median, sizeof(tfp->ve_median)); @@ -466,155 +530,130 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float while (i--) median[i] = ve_median[i] - median[i]; - if (ob->type == OB_MESH) { + /* Note with a single element selected, we always do. */ + apply_vcos = (tot == 1) || (len_squared_v3(&median[LOC_X]) != 0.0f); + + if ((ob->type == OB_MESH) && + (apply_vcos || median[M_BV_WEIGHT] || median[M_SKIN_X] || median[M_SKIN_Y] || + median[M_BE_WEIGHT] || median[M_CREASE])) + { Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; BMesh *bm = em->bm; BMIter iter; + BMVert *eve; + BMEdge *eed; - if (tot == 1 || len_v3(&median[LOC_X]) != 0.0f) { - BMVert *eve; + int cd_vert_bweight_offset = -1; + int cd_vert_skin_offset = -1; + int cd_edge_bweight_offset = -1; + int cd_edge_crease_offset = -1; - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - if (tot == 1) { - /* In case we only have one element selected, copy directly the value instead of applying - * the diff. Avoids some glitches when going e.g. from 3 to 0.0001 (see [#37327]). - */ - copy_v3_v3(eve->co, &ve_median[LOC_X]); - } - else { - add_v3_v3(eve->co, &median[LOC_X]); - } - } - } + float scale_bv_weight = 1.0f; + float scale_skin_x = 1.0f; + float scale_skin_y = 1.0f; + float scale_be_weight = 1.0f; + float scale_crease = 1.0f; - EDBM_mesh_normals_update(em); - } + /* Vertices */ - if (median[M_CREASE] != 0.0f) { - const int cd_edge_crease_offset = (BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_CREASE), - CustomData_get_offset(&bm->edata, CD_CREASE)); - const float sca = compute_scale_factor(ve_median[M_CREASE], median[M_CREASE]); - BMEdge *eed; + if (apply_vcos || median[M_BV_WEIGHT] || median[M_SKIN_X] || median[M_SKIN_Y]) { + if (median[M_BV_WEIGHT]) { + BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_VERT_BWEIGHT); + cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT); + BLI_assert(cd_vert_bweight_offset != -1); - if (ELEM(sca, 0.0f, 1.0f)) { - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { - BM_ELEM_CD_SET_FLOAT(eed, cd_edge_crease_offset, sca); - } - } - } - else if (sca > 0.0f) { - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - float *crease = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_crease_offset); - *crease *= sca; - CLAMP(*crease, 0.0f, 1.0f); - } - } + scale_bv_weight = compute_scale_factor(ve_median[M_BV_WEIGHT], median[M_BV_WEIGHT]); } - else { - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - float *crease = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_crease_offset); - *crease = 1.0f + ((1.0f - *crease) * sca); - CLAMP(*crease, 0.0f, 1.0f); - } - } - } - } - if (median[M_WEIGHT] != 0.0f) { - const int cd_edge_bweight_offset = (BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_BWEIGHT), - CustomData_get_offset(&bm->edata, CD_BWEIGHT)); - const float sca = compute_scale_factor(ve_median[M_WEIGHT], median[M_WEIGHT]); - BMEdge *eed; + if (median[M_SKIN_X]) { + cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); + BLI_assert(cd_vert_skin_offset != -1); - BLI_assert(cd_edge_bweight_offset != -1); - - if (ELEM(sca, 0.0f, 1.0f)) { - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { - float *bweight = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_bweight_offset); - *bweight = sca; - } + if (ve_median[M_SKIN_X] != median[M_SKIN_X]) { + scale_skin_x = ve_median[M_SKIN_X] / (ve_median[M_SKIN_X] - median[M_SKIN_X]); } } - else if (sca > 0.0f) { - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - float *bweight = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_bweight_offset); - *bweight *= sca; - CLAMP(*bweight, 0.0f, 1.0f); - } + if (median[M_SKIN_Y]) { + if (cd_vert_skin_offset == -1) { + cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); + BLI_assert(cd_vert_skin_offset != -1); } - } - else { - BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT) && !BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - float *bweight = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_bweight_offset); - *bweight = 1.0f + ((1.0f - *bweight) * sca); - CLAMP(*bweight, 0.0f, 1.0f); - } + + if (ve_median[M_SKIN_Y] != median[M_SKIN_Y]) { + scale_skin_y = ve_median[M_SKIN_Y] / (ve_median[M_SKIN_Y] - median[M_SKIN_Y]); } } - } - - if (median[M_SKIN_X] != 0.0f) { - const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); - /* That one is not clamped to [0.0, 1.0]. */ - float sca = ve_median[M_SKIN_X]; - BMVert *eve; - BLI_assert(cd_vert_skin_offset != -1); + BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + if (apply_vcos) { + apply_raw_diff_v3(eve->co, tot, &ve_median[LOC_X], &median[LOC_X]); + } - if (ve_median[M_SKIN_X] - median[M_SKIN_X] == 0.0f) { - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset); - vs->radius[0] = sca; + if (cd_vert_bweight_offset != -1) { + float *bweight = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset); + apply_scale_factor_clamp(bweight, tot, ve_median[M_BV_WEIGHT], scale_bv_weight); } - } - } - else { - sca /= (ve_median[M_SKIN_X] - median[M_SKIN_X]); - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + + if (cd_vert_skin_offset != -1) { MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset); - vs->radius[0] *= sca; + + /* That one is not clamped to [0.0, 1.0]. */ + if (median[M_SKIN_X] != 0.0f) { + apply_scale_factor(&vs->radius[0], tot, ve_median[M_SKIN_X], median[M_SKIN_X], + scale_skin_x); + } + if (median[M_SKIN_Y] != 0.0f) { + apply_scale_factor(&vs->radius[1], tot, ve_median[M_SKIN_Y], median[M_SKIN_Y], + scale_skin_y); + } } } } } - if (median[M_SKIN_Y] != 0.0f) { - const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN); - /* That one is not clamped to [0.0, 1.0]. */ - float sca = ve_median[M_SKIN_Y]; - BMVert *eve; - BLI_assert(cd_vert_skin_offset != -1); + if (apply_vcos) { + EDBM_mesh_normals_update(em); + } - if (ve_median[M_SKIN_Y] - median[M_SKIN_Y] == 0.0f) { - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset); - vs->radius[1] = sca; - } - } + /* Edges */ + + if (median[M_BE_WEIGHT] || median[M_CREASE]) { + if (median[M_BE_WEIGHT]) { + BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_BWEIGHT); + cd_edge_bweight_offset = CustomData_get_offset(&bm->edata, CD_BWEIGHT); + BLI_assert(cd_edge_bweight_offset != -1); + + scale_be_weight = compute_scale_factor(ve_median[M_BE_WEIGHT], median[M_BE_WEIGHT]); } - else { - sca /= (ve_median[M_SKIN_Y] - median[M_SKIN_Y]); - BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(eve, cd_vert_skin_offset); - vs->radius[1] *= sca; + + if (median[M_CREASE]) { + BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_CREASE); + cd_edge_crease_offset = CustomData_get_offset(&bm->edata, CD_CREASE); + BLI_assert(cd_edge_crease_offset != -1); + + scale_crease = compute_scale_factor(ve_median[M_CREASE], median[M_CREASE]); + } + + BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { + if (median[M_BE_WEIGHT] != 0.0f) { + float *bweight = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_bweight_offset); + apply_scale_factor_clamp(bweight, tot, ve_median[M_BE_WEIGHT], scale_be_weight); + } + + if (median[M_CREASE] != 0.0f) { + float *crease = BM_ELEM_CD_GET_VOID_P(eed, cd_edge_crease_offset); + apply_scale_factor_clamp(crease, tot, ve_median[M_CREASE], scale_crease); } } } } } - else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { + else if (ELEM(ob->type, OB_CURVE, OB_SURF) && + (apply_vcos || median[C_BWEIGHT] || median[C_WEIGHT] || median[C_RADIUS] || median[C_TILT])) + { Curve *cu = ob->data; Nurb *nu; BPoint *bp; @@ -628,44 +667,31 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if (nu->type == CU_BEZIER) { for (a = nu->pntsu, bezt = nu->bezt; a--; bezt++) { if (bezt->f2 & SELECT) { - /* Here we always have to use the diff... :/ - * Cannot avoid some glitches when going e.g. from 3 to 0.0001 (see [#37327]), - * unless we use doubles. - */ - add_v3_v3(bezt->vec[0], &median[LOC_X]); - add_v3_v3(bezt->vec[1], &median[LOC_X]); - add_v3_v3(bezt->vec[2], &median[LOC_X]); - - if (median[C_WEIGHT] != 0.0f) { - if (ELEM(scale_w, 0.0f, 1.0f)) { - bezt->weight = scale_w; - } - else { - bezt->weight = scale_w > 0.0f ? bezt->weight * scale_w : - 1.0f + ((1.0f - bezt->weight) * scale_w); - CLAMP(bezt->weight, 0.0f, 1.0f); - } + if (apply_vcos) { + /* Here we always have to use the diff... :/ + * Cannot avoid some glitches when going e.g. from 3 to 0.0001 (see T37327), + * unless we use doubles. + */ + add_v3_v3(bezt->vec[0], &median[LOC_X]); + add_v3_v3(bezt->vec[1], &median[LOC_X]); + add_v3_v3(bezt->vec[2], &median[LOC_X]); + } + if (median[C_WEIGHT]) { + apply_scale_factor_clamp(&bezt->weight, tot, ve_median[C_WEIGHT], scale_w); + } + if (median[C_RADIUS]) { + apply_raw_diff(&bezt->radius, tot, ve_median[C_RADIUS], median[C_RADIUS]); + } + if (median[C_TILT]) { + apply_raw_diff(&bezt->alfa, tot, ve_median[C_TILT], median[C_TILT]); } - - bezt->radius += median[C_RADIUS]; - bezt->alfa += median[C_TILT]; } - else { + else if (apply_vcos) { /* Handles can only have their coordinates changed here. */ if (bezt->f1 & SELECT) { - if (tot == 1) { - copy_v3_v3(bezt->vec[0], &ve_median[LOC_X]); - } - else { - add_v3_v3(bezt->vec[0], &median[LOC_X]); - } + apply_raw_diff_v3(bezt->vec[0], tot, &ve_median[LOC_X], &median[LOC_X]); } if (bezt->f3 & SELECT) { - if (tot == 1) { - copy_v3_v3(bezt->vec[2], &ve_median[LOC_X]); - } - else { - add_v3_v3(bezt->vec[2], &median[LOC_X]); - } + apply_raw_diff_v3(bezt->vec[2], tot, &ve_median[LOC_X], &median[LOC_X]); } } } @@ -673,28 +699,20 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float else { for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a--; bp++) { if (bp->f1 & SELECT) { - if (tot == 1) { - copy_v3_v3(bp->vec, &ve_median[LOC_X]); - bp->vec[3] = ve_median[C_BWEIGHT]; - bp->radius = ve_median[C_RADIUS]; - bp->alfa = ve_median[C_TILT]; + if (apply_vcos) { + apply_raw_diff_v3(bp->vec, tot, &ve_median[LOC_X], &median[LOC_X]); } - else { - add_v3_v3(bp->vec, &median[LOC_X]); - bp->vec[3] += median[C_BWEIGHT]; - bp->radius += median[C_RADIUS]; - bp->alfa += median[C_TILT]; + if (median[C_BWEIGHT]) { + apply_raw_diff(&bp->vec[3], tot, ve_median[C_BWEIGHT], median[C_BWEIGHT]); } - - if (median[C_WEIGHT] != 0.0f) { - if (ELEM(scale_w, 0.0f, 1.0f)) { - bp->weight = scale_w; - } - else { - bp->weight = scale_w > 0.0f ? bp->weight * scale_w : - 1.0f + ((1.0f - bp->weight) * scale_w); - CLAMP(bp->weight, 0.0f, 1.0f); - } + if (median[C_WEIGHT]) { + apply_scale_factor_clamp(&bp->weight, tot, ve_median[C_WEIGHT], scale_w); + } + if (median[C_RADIUS]) { + apply_raw_diff(&bp->radius, tot, ve_median[C_RADIUS], median[C_RADIUS]); + } + if (median[C_TILT]) { + apply_raw_diff(&bp->alfa, tot, ve_median[C_TILT], median[C_TILT]); } } } @@ -705,7 +723,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float nu = nu->next; } } - else if (ob->type == OB_LATTICE) { + else if ((ob->type == OB_LATTICE) && (apply_vcos || median[L_WEIGHT])) { Lattice *lt = ob->data; BPoint *bp; int a; @@ -715,22 +733,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float bp = lt->editlatt->latt->def; while (a--) { if (bp->f1 & SELECT) { - if (tot == 1) { - copy_v3_v3(bp->vec, &ve_median[LOC_X]); - } - else { - add_v3_v3(bp->vec, &median[LOC_X]); + if (apply_vcos) { + apply_raw_diff_v3(bp->vec, tot, &ve_median[LOC_X], &median[LOC_X]); } - - if (median[L_WEIGHT] != 0.0f) { - if (ELEM(scale_w, 0.0f, 1.0f)) { - bp->weight = scale_w; - } - else { - bp->weight = scale_w > 0.0f ? bp->weight * scale_w : - 1.0f + ((1.0f - bp->weight) * scale_w); - CLAMP(bp->weight, 0.0f, 1.0f); - } + if (median[L_WEIGHT]) { + apply_scale_factor_clamp(&bp->weight, tot, ve_median[L_WEIGHT], scale_w); } } bp++; @@ -746,10 +753,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float #undef LOC_Y #undef LOC_Z /* Meshes (and lattice)... */ -#undef M_CREASE -#undef M_WEIGHT +#undef M_BV_WEIGHT #undef M_SKIN_X #undef M_SKIN_Y +#undef M_BE_WEIGHT +#undef M_CREASE /* Curves... */ #undef C_BWEIGHT #undef C_WEIGHT @@ -826,7 +834,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) int yco = 0; int lock_count = 0; - uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL); + UI_block_func_handle_set(block, do_view3d_vgroup_buttons, NULL); bcol = uiLayoutColumn(pa->layout, true); row = uiLayoutRow(bcol, true); /* The filter button row */ @@ -836,7 +844,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) col = uiLayoutColumn(bcol, true); - vgroup_validmap = ED_vgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); + vgroup_validmap = BKE_object_defgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); for (i = 0, dg = ob->defbase.first; dg; i++, dg = dg->next) { bool locked = dg->flag & DG_LOCK_WEIGHT; if (vgroup_validmap[i]) { @@ -850,13 +858,13 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) /* The Weight Group Name */ ot = ot_weight_set_active; - but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, dg->name, + but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, WM_OP_EXEC_DEFAULT, dg->name, xco, yco, (x = UI_UNIT_X * 5), UI_UNIT_Y, ""); - but_ptr = uiButGetOperatorPtrRNA(but); + but_ptr = UI_but_operator_ptr_get(but); RNA_int_set(but_ptr, "weight_group", i); - uiButSetDrawFlag(but, UI_BUT_TEXT_RIGHT); + UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT); if (ob->actdef != i + 1) { - uiButSetFlag(but, UI_BUT_INACTIVE); + UI_but_flag_enable(but, UI_BUT_INACTIVE); } xco += x; @@ -865,10 +873,10 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) /* The weight group value */ /* To be reworked still */ - but = uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + i, "", + but = uiDefButF(block, UI_BTYPE_NUM, B_VGRP_PNL_EDIT_SINGLE + i, "", xco, yco, (x = UI_UNIT_X * 4), UI_UNIT_Y, &dw->weight, 0.0, 1.0, 1, 3, ""); - uiButSetDrawFlag(but, UI_BUT_TEXT_LEFT); + UI_but_drawflag_enable(but, UI_BUT_TEXT_LEFT); if (locked) { lock_count++; } @@ -903,19 +911,19 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) row = uiLayoutRow(col, true); ot = WM_operatortype_find("OBJECT_OT_vertex_weight_normalize_active_vertex", 1); - but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Normalize", + but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, WM_OP_EXEC_DEFAULT, "Normalize", 0, yco, UI_UNIT_X * 5, UI_UNIT_Y, TIP_("Normalize weights of active vertex (if affected groups are unlocked)")); if (lock_count) { - uiButSetFlag(but, UI_BUT_DISABLED); + UI_but_flag_enable(but, UI_BUT_DISABLED); } ot = WM_operatortype_find("OBJECT_OT_vertex_weight_copy", 1); - but = uiDefButO_ptr(block, BUT, ot, WM_OP_EXEC_DEFAULT, "Copy", + but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, WM_OP_EXEC_DEFAULT, "Copy", UI_UNIT_X * 5, yco, UI_UNIT_X * 5, UI_UNIT_Y, TIP_("Copy active vertex to other selected vertices (if affected groups are unlocked)")); if (lock_count) { - uiButSetFlag(but, UI_BUT_DISABLED); + UI_but_flag_enable(but, UI_BUT_DISABLED); } } @@ -1137,7 +1145,7 @@ static void view3d_panel_transform(const bContext *C, Panel *pa) uiLayout *col; block = uiLayoutGetBlock(pa->layout); - uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); + UI_block_func_handle_set(block, do_view3d_region_buttons, NULL); col = uiLayoutColumn(pa->layout, false); @@ -1177,14 +1185,6 @@ void view3d_buttons_register(ARegionType *art) pt->poll = view3d_panel_transform_poll; BLI_addtail(&art->paneltypes, pt); - pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel gpencil"); - strcpy(pt->idname, "VIEW3D_PT_gpencil"); - strcpy(pt->label, N_("Grease Pencil")); /* XXX C panels are not available through RNA (bpy.types)! */ - strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw_header = ED_gpencil_panel_standard_header; - pt->draw = ED_gpencil_panel_standard; - BLI_addtail(&art->paneltypes, pt); - 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)! */ diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c index ee0f3da18b4..95e918abdcf 100644 --- a/source/blender/editors/space_view3d/view3d_camera_control.c +++ b/source/blender/editors/space_view3d/view3d_camera_control.c @@ -51,14 +51,12 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" -#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BKE_object.h" #include "BKE_depsgraph.h" /* for object updating */ -#include "ED_keyframing.h" #include "ED_screen.h" #include "view3d_intern.h" /* own include */ @@ -266,6 +264,8 @@ void ED_view3d_cameracontrol_update( BKE_object_apply_mat4(v3d->camera, view_mat, true, true); + DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); + copy_v3_v3(v3d->camera->size, size_back); id_key = &v3d->camera->id; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 61bfb0176ef..b3884cb2b72 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1146,10 +1146,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (scene->r.mode & R_BORDER) { float x3, y3, x4, y4; - x3 = x1 + scene->r.border.xmin * (x2 - x1); - y3 = y1 + scene->r.border.ymin * (y2 - y1); - x4 = x1 + scene->r.border.xmax * (x2 - x1); - y4 = y1 + scene->r.border.ymax * (y2 - y1); + x3 = x1i + 1 + roundf(scene->r.border.xmin * (x2 - x1)); + y3 = y1i + 1 + roundf(scene->r.border.ymin * (y2 - y1)); + x4 = x1i + 1 + roundf(scene->r.border.xmax * (x2 - x1)); + y4 = y1i + 1 + roundf(scene->r.border.ymax * (y2 - y1)); cpack(0x4040FF); glRecti(x3, y3, x4, y4); @@ -1221,11 +1221,11 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) hmargin = 0.1f * (x2 - x1); vmargin = 0.05f * (y2 - y1); - uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); + UI_draw_roundbox_gl_mode(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); hmargin = 0.035f * (x2 - x1); vmargin = 0.035f * (y2 - y1); - uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); + UI_draw_roundbox_gl_mode(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f); } if (ca->flag & CAM_SHOWSENSOR) { /* determine sensor fit, and get sensor x/y, for auto fit we @@ -1260,7 +1260,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* draw */ UI_ThemeColorShade(TH_VIEW_OVERLAY, 100); - uiDrawBox(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f); + UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f); } } @@ -1362,7 +1362,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) else glScissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct)); - glClearColor(0.0, 0.0, 0.0, 0.0); + glClearColor(0.0, 0.0, 0.0, 0.0); if (v3d->zbuf) { glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -2003,7 +2003,7 @@ static void draw_dupli_objects_color( tbase.flag = OB_FROMDUPLI | base->flag; lb = object_duplilist(G.main->eval_ctx, scene, base->object); - // BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ + // BLI_listbase_sort(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ apply_data = duplilist_apply(base->object, lb); @@ -2646,10 +2646,7 @@ static void view3d_draw_objects( if (!draw_offscreen) { /* needs to be done always, gridview is adjusted in drawgrid() now, but only for ortho views. */ - rv3d->gridview = v3d->grid; - if (scene->unit.system) { - rv3d->gridview /= scene->unit.scale_length; - } + rv3d->gridview = ED_view3d_grid_scale(scene, v3d, grid_unit); if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { @@ -2801,6 +2798,203 @@ void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d) gpu_update_lamps_shadows(scene, v3d); } +/* + * Function to clear the view + */ +static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar, bool force) +{ + /* clear background */ + if (scene->world && ((v3d->flag3 & V3D_SHOW_WORLD) || force)) { + float alpha = (force) ? 1.0f : 0.0; + bool glsl = GPU_glsl_support() && BKE_scene_use_new_shading_nodes(scene) && scene->world->nodetree && scene->world->use_nodes; + + if (glsl) { + RegionView3D *rv3d = ar->regiondata; + GPUMaterial *gpumat = GPU_material_world(scene, scene->world); + + /* calculate full shader for background */ + GPU_material_bind(gpumat, 1, 1, 1.0, false, rv3d->viewmat, rv3d->viewinv, (v3d->scenelock != 0)); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + glShadeModel(GL_SMOOTH); + glBegin(GL_QUADS); + glVertex3f(-1.0, -1.0, 1.0); + glVertex3f(1.0, -1.0, 1.0); + glVertex3f(1.0, 1.0, 1.0); + glVertex3f(-1.0, 1.0, 1.0); + glEnd(); + glShadeModel(GL_FLAT); + + GPU_material_unbind(gpumat); + + glDepthFunc(GL_LEQUAL); + glDisable(GL_DEPTH_TEST); + } + else if (scene->world->skytype & WO_SKYBLEND) { /* blend sky */ + int x, y; + float col_hor[3]; + float col_zen[3]; + +#define VIEWGRAD_RES_X 16 +#define VIEWGRAD_RES_Y 16 + + GLubyte grid_col[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][4]; + static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][3]; + static GLushort indices[VIEWGRAD_RES_X - 1][VIEWGRAD_RES_X - 1][4]; + static bool buf_calculated = false; + + IMB_colormanagement_pixel_to_display_space_v3(col_hor, &scene->world->horr, &scene->view_settings, + &scene->display_settings); + IMB_colormanagement_pixel_to_display_space_v3(col_zen, &scene->world->zenr, &scene->view_settings, + &scene->display_settings); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glShadeModel(GL_SMOOTH); + + /* calculate buffers the first time only */ + if (!buf_calculated) { + for (x = 0; x < VIEWGRAD_RES_X; x++) { + for (y = 0; y < VIEWGRAD_RES_Y; y++) { + const float xf = (float)x / (float)(VIEWGRAD_RES_X - 1); + const float yf = (float)y / (float)(VIEWGRAD_RES_Y - 1); + + /* -1..1 range */ + grid_pos[x][y][0] = (xf - 0.5f) * 2.0f; + grid_pos[x][y][1] = (yf - 0.5f) * 2.0f; + grid_pos[x][y][2] = 1.0; + } + } + + for (x = 0; x < VIEWGRAD_RES_X - 1; x++) { + for (y = 0; y < VIEWGRAD_RES_Y - 1; y++) { + indices[x][y][0] = x * VIEWGRAD_RES_X + y; + indices[x][y][1] = x * VIEWGRAD_RES_X + y + 1; + indices[x][y][2] = (x + 1) * VIEWGRAD_RES_X + y + 1; + indices[x][y][3] = (x + 1) * VIEWGRAD_RES_X + y; + } + } + + buf_calculated = true; + } + + for (x = 0; x < VIEWGRAD_RES_X; x++) { + for (y = 0; y < VIEWGRAD_RES_Y; y++) { + const float xf = (float)x / (float)(VIEWGRAD_RES_X - 1); + const float yf = (float)y / (float)(VIEWGRAD_RES_Y - 1); + const float mval[2] = {xf * (float)ar->winx, yf * ar->winy}; + const float z_up[3] = {0.0f, 0.0f, 1.0f}; + float out[3]; + GLubyte *col_ub = grid_col[x][y]; + + float col_fac; + float col_fl[3]; + + ED_view3d_win_to_vector(ar, mval, out); + + if (scene->world->skytype & WO_SKYPAPER) { + if (scene->world->skytype & WO_SKYREAL) { + col_fac = fabsf(((float)y / (float)VIEWGRAD_RES_Y) - 0.5f) * 2.0f; + } + else { + col_fac = (float)y / (float)VIEWGRAD_RES_Y; + } + } + else { + if (scene->world->skytype & WO_SKYREAL) { + col_fac = fabsf((angle_normalized_v3v3(z_up, out) / (float)M_PI) - 0.5f) * 2.0f; + } + else { + col_fac = 1.0f - (angle_normalized_v3v3(z_up, out) / (float)M_PI); + } + } + + interp_v3_v3v3(col_fl, col_hor, col_zen, col_fac); + + rgb_float_to_uchar(col_ub, col_fl); + col_ub[3] = alpha * 255; + } + } + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, grid_pos); + glColorPointer(4, GL_UNSIGNED_BYTE, 0, grid_col); + + glDrawElements(GL_QUADS, (VIEWGRAD_RES_X - 1) * (VIEWGRAD_RES_Y - 1) * 4, GL_UNSIGNED_SHORT, indices); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + + glDepthFunc(GL_LEQUAL); + glDisable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glShadeModel(GL_FLAT); + +#undef VIEWGRAD_RES_X +#undef VIEWGRAD_RES_Y + } + else { /* solid sky */ + float col_hor[3]; + IMB_colormanagement_pixel_to_display_space_v3(col_hor, &scene->world->horr, &scene->view_settings, + &scene->display_settings); + + glClearColor(col_hor[0], col_hor[1], col_hor[2], alpha); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + } + else { + if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) { + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + glShadeModel(GL_SMOOTH); + glBegin(GL_QUADS); + UI_ThemeColor(TH_LOW_GRAD); + glVertex3f(-1.0, -1.0, 1.0); + glVertex3f(1.0, -1.0, 1.0); + UI_ThemeColor(TH_HIGH_GRAD); + glVertex3f(1.0, 1.0, 1.0); + glVertex3f(-1.0, 1.0, 1.0); + glEnd(); + glShadeModel(GL_FLAT); + + glDepthFunc(GL_LEQUAL); + glDisable(GL_DEPTH_TEST); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + } + else { + UI_ThemeClearColor(TH_HIGH_GRAD); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + } +} + /* ED_view3d_draw_offscreen_init should be called before this to initialize * stuff like shadow buffers */ @@ -2836,25 +3030,18 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, * warning! can be slow so only free animated images - campbell */ GPU_free_images_anim(); } - + /* setup view matrices */ + view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat); + /* clear opengl buffers */ if (do_sky) { - float sky_color[3]; - - ED_view3d_offscreen_sky_color_get(scene, sky_color); - glClearColor(sky_color[0], sky_color[1], sky_color[2], 1.0f); + view3d_main_area_clear(scene, v3d, ar, true); } else { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - - /* setup view matrices */ - view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat); - - /* main drawing call */ view3d_draw_objects(NULL, scene, v3d, ar, NULL, do_bgpic, true); @@ -2957,7 +3144,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in /* 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 draw_background, int alpha_mode, char err_out[256]) + bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, char err_out[256]) { View3D v3d = {NULL}; ARegion ar = {NULL}; @@ -2972,6 +3159,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w v3d.lay = scene->lay; v3d.drawtype = drawtype; v3d.flag2 = V3D_RENDER_OVERRIDE; + + if (use_gpencil) + v3d.flag2 |= V3D_SHOW_GPENCIL; if (use_solid_tex) v3d.flag2 |= V3D_SOLID_TEX; @@ -3205,178 +3395,6 @@ static void view3d_main_area_draw_engine_info(View3D *v3d, RegionView3D *rv3d, A ED_region_info_draw(ar, rv3d->render_engine->text, 1, fill_color); } -/* - * Function to clear the view - */ -static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) -{ - /* clear background */ - if (scene->world && (v3d->flag2 & V3D_RENDER_OVERRIDE)) { /* clear with solid color */ - if (scene->world->skytype & WO_SKYBLEND) { /* blend sky */ - int x, y; - float col_hor[3]; - float col_zen[3]; - -#define VIEWGRAD_RES_X 16 -#define VIEWGRAD_RES_Y 16 - - GLubyte grid_col[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][4]; - static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][3]; - static GLushort indices[VIEWGRAD_RES_X - 1][VIEWGRAD_RES_X - 1][4]; - static bool buf_calculated = false; - - IMB_colormanagement_pixel_to_display_space_v3(col_hor, &scene->world->horr, &scene->view_settings, - &scene->display_settings); - IMB_colormanagement_pixel_to_display_space_v3(col_zen, &scene->world->zenr, &scene->view_settings, - &scene->display_settings); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glShadeModel(GL_SMOOTH); - - /* calculate buffers the first time only */ - if (!buf_calculated) { - for (x = 0; x < VIEWGRAD_RES_X; x++) { - for (y = 0; y < VIEWGRAD_RES_Y; y++) { - const float xf = (float)x / (float)(VIEWGRAD_RES_X - 1); - const float yf = (float)y / (float)(VIEWGRAD_RES_Y - 1); - - /* -1..1 range */ - grid_pos[x][y][0] = (xf - 0.5f) * 2.0f; - grid_pos[x][y][1] = (yf - 0.5f) * 2.0f; - grid_pos[x][y][2] = 1.0; - } - } - - for (x = 0; x < VIEWGRAD_RES_X - 1; x++) { - for (y = 0; y < VIEWGRAD_RES_Y - 1; y++) { - indices[x][y][0] = x * VIEWGRAD_RES_X + y; - indices[x][y][1] = x * VIEWGRAD_RES_X + y + 1; - indices[x][y][2] = (x + 1) * VIEWGRAD_RES_X + y + 1; - indices[x][y][3] = (x + 1) * VIEWGRAD_RES_X + y; - } - } - - buf_calculated = true; - } - - for (x = 0; x < VIEWGRAD_RES_X; x++) { - for (y = 0; y < VIEWGRAD_RES_Y; y++) { - const float xf = (float)x / (float)(VIEWGRAD_RES_X - 1); - const float yf = (float)y / (float)(VIEWGRAD_RES_Y - 1); - const float mval[2] = {xf * (float)ar->winx, yf * ar->winy}; - const float z_up[3] = {0.0f, 0.0f, 1.0f}; - float out[3]; - GLubyte *col_ub = grid_col[x][y]; - - float col_fac; - float col_fl[3]; - - ED_view3d_win_to_vector(ar, mval, out); - - if (scene->world->skytype & WO_SKYPAPER) { - if (scene->world->skytype & WO_SKYREAL) { - col_fac = fabsf(((float)y / (float)VIEWGRAD_RES_Y) - 0.5f) * 2.0f; - } - else { - col_fac = (float)y / (float)VIEWGRAD_RES_Y; - } - } - else { - if (scene->world->skytype & WO_SKYREAL) { - col_fac = fabsf((angle_normalized_v3v3(z_up, out) / (float)M_PI) - 0.5f) * 2.0f; - } - else { - col_fac = 1.0f - (angle_normalized_v3v3(z_up, out) / (float)M_PI); - } - } - - interp_v3_v3v3(col_fl, col_hor, col_zen, col_fac); - - rgb_float_to_uchar(col_ub, col_fl); - col_ub[3] = 0; - } - } - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, grid_pos); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, grid_col); - - glDrawElements(GL_QUADS, (VIEWGRAD_RES_X - 1) * (VIEWGRAD_RES_Y - 1) * 4, GL_UNSIGNED_SHORT, indices); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - - glDepthFunc(GL_LEQUAL); - glDisable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - glShadeModel(GL_FLAT); - -#undef VIEWGRAD_RES_X -#undef VIEWGRAD_RES_Y - } - else { /* solid sky */ - float col_hor[3]; - IMB_colormanagement_pixel_to_display_space_v3(col_hor, &scene->world->horr, &scene->view_settings, - &scene->display_settings); - - glClearColor(col_hor[0], col_hor[1], col_hor[2], 0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - } - else { - if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) { - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); - glShadeModel(GL_SMOOTH); - glBegin(GL_QUADS); - UI_ThemeColor(TH_LOW_GRAD); - glVertex3f(-1.0, -1.0, 1.0); - glVertex3f(1.0, -1.0, 1.0); - UI_ThemeColor(TH_HIGH_GRAD); - glVertex3f(1.0, 1.0, 1.0); - glVertex3f(-1.0, 1.0, 1.0); - glEnd(); - glShadeModel(GL_FLAT); - - glDepthFunc(GL_LEQUAL); - glDisable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - } - else { - UI_ThemeClearColor(TH_HIGH_GRAD); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - } -} - - #ifdef WITH_GAMEENGINE static void update_lods(Scene *scene, float camera_pos[3]) { @@ -3413,7 +3431,7 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3 rv3d->rflag &= ~RV3D_IS_GAME_ENGINE; #ifdef WITH_GAMEENGINE - if (STREQ(scene->r.engine, "BLENDER_GAME")) { + if (STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME)) { rv3d->rflag |= RV3D_IS_GAME_ENGINE; /* Make sure LoDs are up to date */ @@ -3422,7 +3440,7 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3 #endif /* clear the background */ - view3d_main_area_clear(scene, v3d, ar); + view3d_main_area_clear(scene, v3d, ar, false); /* enables anti-aliasing for 3D view drawing */ if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f54e7ae06f6..8ee6c7d8df4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -49,7 +49,6 @@ #include "BKE_camera.h" #include "BKE_context.h" #include "BKE_font.h" -#include "BKE_image.h" #include "BKE_library.h" #include "BKE_object.h" #include "BKE_paint.h" @@ -1119,6 +1118,8 @@ static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod = op->customdata; short event_code = VIEW_PASS; + bool use_autokey = false; + int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ if (event->type == MOUSEMOVE) { @@ -1153,17 +1154,25 @@ static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event_code == VIEW_APPLY) { viewrotate_apply(vod, event->x, event->y); + if (ED_screen_animation_playing(CTX_wm_manager(C))) { + use_autokey = true; + } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, true); ED_view3d_depth_tag_update(vod->rv3d); + use_autokey = true; + ret = OPERATOR_FINISHED; + } - viewops_data_free(C, op); + if (use_autokey) { + ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, true); + } - return OPERATOR_FINISHED; + if (ret & OPERATOR_FINISHED) { + viewops_data_free(C, op); } - return OPERATOR_RUNNING_MODAL; + return ret; } /** @@ -1221,26 +1230,31 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event) ED_region_tag_redraw(vod->ar); } - if (event->type == MOUSEPAN) { + if (ELEM(event->type, MOUSEPAN, MOUSEROTATE)) { /* Rotate direction we keep always same */ - if (U.uiflag2 & USER_TRACKPAD_NATURAL) - viewrotate_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy); - else - viewrotate_apply(vod, event->prevx, event->prevy); - - ED_view3d_depth_tag_update(vod->rv3d); - - viewops_data_free(C, op); - - return OPERATOR_FINISHED; - } - else if (event->type == MOUSEROTATE) { - /* MOUSEROTATE performs orbital rotation, so y axis delta is set to 0 */ - viewrotate_apply(vod, event->prevx, event->y); + int x, y; + + if (event->type == MOUSEPAN) { + if (U.uiflag2 & USER_TRACKPAD_NATURAL) { + x = 2 * event->x - event->prevx; + y = 2 * event->y - event->prevy; + } + else { + x = event->prevx; + y = event->prevy; + } + } + else { + /* MOUSEROTATE performs orbital rotation, so y axis delta is set to 0 */ + x = event->prevx; + y = event->y; + } + + viewrotate_apply(vod, x, y); ED_view3d_depth_tag_update(vod->rv3d); - + viewops_data_free(C, op); - + return OPERATOR_FINISHED; } else { @@ -1946,6 +1960,8 @@ static int viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event) ViewOpsData *vod = op->customdata; short event_code = VIEW_PASS; + bool use_autokey = false; + int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ if (event->type == MOUSEMOVE) { @@ -1972,17 +1988,25 @@ static int viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event_code == VIEW_APPLY) { viewmove_apply(vod, event->x, event->y); + if (ED_screen_animation_playing(CTX_wm_manager(C))) { + use_autokey = true; + } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); ED_view3d_depth_tag_update(vod->rv3d); + use_autokey = true; + ret = OPERATOR_FINISHED; + } - viewops_data_free(C, op); + if (use_autokey) { + ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); + } - return OPERATOR_FINISHED; + if (ret & OPERATOR_FINISHED) { + viewops_data_free(C, op); } - return OPERATOR_RUNNING_MODAL; + return ret; } static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -2214,6 +2238,8 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod = op->customdata; short event_code = VIEW_PASS; + bool use_autokey = false; + int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ if (event->type == TIMER && event->customdata == vod->timer) { @@ -2244,16 +2270,25 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event_code == VIEW_APPLY) { viewzoom_apply(vod, &event->x, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0); + if (ED_screen_animation_playing(CTX_wm_manager(C))) { + use_autokey = true; + } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); ED_view3d_depth_tag_update(vod->rv3d); - viewops_data_free(C, op); + use_autokey = true; + ret = OPERATOR_FINISHED; + } - return OPERATOR_FINISHED; + if (use_autokey) { + ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); + } + + if (ret & OPERATOR_FINISHED) { + viewops_data_free(C, op); } - return OPERATOR_RUNNING_MODAL; + return ret; } static int viewzoom_exec(bContext *C, wmOperator *op) @@ -2315,6 +2350,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) ED_view3d_depth_tag_update(rv3d); ED_view3d_camera_lock_sync(v3d, rv3d); + ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, true); ED_region_tag_redraw(ar); @@ -2389,8 +2425,10 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) vod->origy = vod->oldy = vod->origy + event->x - event->prevx; viewzoom_apply(vod, &event->prevx, USER_ZOOM_DOLLY, (U.uiflag & USER_ZOOM_INVERT) != 0); } + ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); + ED_view3d_depth_tag_update(vod->rv3d); - + viewops_data_free(C, op); return OPERATOR_FINISHED; } @@ -2486,6 +2524,8 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod = op->customdata; short event_code = VIEW_PASS; + bool use_autokey = false; + int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ if (event->type == MOUSEMOVE) { @@ -2512,16 +2552,25 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event_code == VIEW_APPLY) { viewdolly_apply(vod, event->x, event->y, (U.uiflag & USER_ZOOM_INVERT) != 0); + if (ED_screen_animation_playing(CTX_wm_manager(C))) { + use_autokey = true; + } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); ED_view3d_depth_tag_update(vod->rv3d); - viewops_data_free(C, op); + use_autokey = true; + ret = OPERATOR_FINISHED; + } - return OPERATOR_FINISHED; + if (use_autokey) { + ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true); + } + + if (ret & OPERATOR_FINISHED) { + viewops_data_free(C, op); } - return OPERATOR_RUNNING_MODAL; + return ret; } static int viewdolly_exec(bContext *C, wmOperator *op) @@ -3970,6 +4019,8 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod = op->customdata; short event_code = VIEW_PASS; + bool use_autokey = false; + int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ if (event->type == MOUSEMOVE) { @@ -3996,18 +4047,35 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event_code == VIEW_APPLY) { viewroll_apply(vod, event->x, event->y); + if (ED_screen_animation_playing(CTX_wm_manager(C))) { + use_autokey = true; + } } else if (event_code == VIEW_CONFIRM) { - ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, false); ED_view3d_depth_tag_update(vod->rv3d); - viewops_data_free(C, op); + use_autokey = true; + ret = OPERATOR_FINISHED; + } - return OPERATOR_FINISHED; + if (use_autokey) { + ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, false); } - return OPERATOR_RUNNING_MODAL; + if (ret & OPERATOR_FINISHED) { + viewops_data_free(C, op); + } + + return ret; } +static EnumPropertyItem prop_view_roll_items[] = { + {0, "ROLLANGLE", 0, "Roll Angle", "Roll the view using an angle value"}, + {V3D_VIEW_STEPLEFT, "ROLLLEFT", 0, "Roll Left", "Roll the view around to the Left"}, + {V3D_VIEW_STEPRIGHT, "ROLLTRIGHT", 0, "Roll Right", "Roll the view around to the Right"}, + {0, NULL, 0, NULL, NULL} +}; + + static int viewroll_exec(bContext *C, wmOperator *op) { View3D *v3d; @@ -4025,12 +4093,17 @@ static int viewroll_exec(bContext *C, wmOperator *op) rv3d = ar->regiondata; if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { - const float angle = RNA_float_get(op->ptr, "angle"); + int type = RNA_enum_get(op->ptr, "type"); + float angle = (type == 0) ? RNA_float_get(op->ptr, "angle") : DEG2RADF((float)U.pad_rot_angle); float mousevec[3]; float quat_new[4]; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); + if (type == V3D_VIEW_STEPLEFT) { + angle = -angle; + } + normalize_v3_v3(mousevec, rv3d->viewinv[2]); negate_v3(mousevec); view_roll_angle(ar, quat_new, rv3d->viewquat, mousevec, angle); @@ -4052,7 +4125,9 @@ static int viewroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod; - if (RNA_struct_property_is_set(op->ptr, "angle")) { + bool use_angle = RNA_enum_get(op->ptr, "type") != 0; + + if (use_angle || RNA_struct_property_is_set(op->ptr, "angle")) { viewroll_exec(C, op); } else { @@ -4090,6 +4165,8 @@ static void viewroll_cancel(bContext *C, wmOperator *op) void VIEW3D_OT_view_roll(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "View Roll"; ot->description = "Roll the view"; @@ -4106,7 +4183,10 @@ void VIEW3D_OT_view_roll(wmOperatorType *ot) ot->flag = 0; /* properties */ - ot->prop = RNA_def_float(ot->srna, "angle", 0, -FLT_MAX, FLT_MAX, "Roll", "", -FLT_MAX, FLT_MAX); + ot->prop = prop = RNA_def_float(ot->srna, "angle", 0, -FLT_MAX, FLT_MAX, "Roll", "", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_enum(ot->srna, "type", prop_view_roll_items, 0, "Roll Angle Source", "How roll angle is calculated"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static EnumPropertyItem prop_view_pan_items[] = { @@ -4259,32 +4339,16 @@ static int background_image_add_exec(bContext *C, wmOperator *UNUSED(op)) static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { View3D *v3d = CTX_wm_view3d(C); - Image *ima = NULL; + Image *ima; BGpic *bgpic; - char name[MAX_ID_NAME - 2]; - - /* check input variables */ - if (RNA_struct_property_is_set(op->ptr, "filepath")) { - char path[FILE_MAX]; - - RNA_string_get(op->ptr, "filepath", path); - ima = BKE_image_load_exists(path); - } - else if (RNA_struct_property_is_set(op->ptr, "name")) { - RNA_string_get(op->ptr, "name", name); - ima = (Image *)BKE_libblock_find_name(ID_IM, name); - } + ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM); + /* may be NULL, continue anyway */ + bgpic = background_image_add(C); - - if (ima) { - bgpic->ima = ima; - - id_us_plus(&ima->id); - - if (!(v3d->flag & V3D_DISPBGPICS)) - v3d->flag |= V3D_DISPBGPICS; - } + bgpic->ima = ima; + + v3d->flag |= V3D_DISPBGPICS; WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); @@ -4310,7 +4374,8 @@ 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"); - RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } @@ -4360,12 +4425,16 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot) /* ********************* set clipping operator ****************** */ -static void calc_clipping_plane(float clip[6][4], const BoundBox *clipbb) +static void calc_clipping_plane(float clip[6][4], const BoundBox *clipbb, const bool is_flip) { int val; for (val = 0; val < 4; val++) { normal_tri_v3(clip[val], clipbb->vec[val], clipbb->vec[val == 3 ? 0 : val + 1], clipbb->vec[val + 4]); + if (UNLIKELY(is_flip)) { + negate_v3(clip[val]); + } + clip[val][3] = -dot_v3v3(clip[val], clipbb->vec[val]); } } @@ -4382,7 +4451,7 @@ static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float mul_v3_m4v3(clipbb_local.vec[i], imat, clipbb->vec[i]); } - calc_clipping_plane(clip_local, &clipbb_local); + calc_clipping_plane(clip_local, &clipbb_local, is_negative_m4(mat)); } void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[4][4]) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index a88724a1cdd..11ed9867e2f 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -32,12 +32,9 @@ #include <stdio.h> #include <stdlib.h> -#include "DNA_brush_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -45,8 +42,6 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_main.h" -#include "BKE_modifier.h" -#include "BKE_paint.h" #include "BKE_screen.h" #include "BKE_editmesh.h" @@ -262,7 +257,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) Object *obedit = CTX_data_edit_object(C); uiBlock *block = uiLayoutGetBlock(layout); - uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL); + UI_block_func_handle_set(block, do_view3d_header_buttons, NULL); if (obedit && (obedit->type == OB_MESH)) { BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -270,13 +265,13 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) row = uiLayoutRow(layout, true); block = uiLayoutGetBlock(row); - uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, + uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, TIP_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection")); - uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, + uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, TIP_("Edge select - Shift-Click for multiple modes, Ctrl-Click expands/contracts selection")); - uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, + uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, TIP_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection")); } @@ -302,10 +297,10 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr); block = uiLayoutGetBlock(layout); - uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL); + UI_block_func_handle_set(block, do_view3d_header_buttons, NULL); /* other buttons: */ - uiBlockSetEmboss(block, UI_EMBOSS); + UI_block_emboss_set(block, UI_EMBOSS); /* mode */ if (ob) { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 84ac4f7d02d..d3a9f5ca967 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -163,7 +163,9 @@ bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* drawmesh.c */ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, const int draw_flags); -void draw_mesh_face_select(struct RegionView3D *rv3d, struct Mesh *me, struct DerivedMesh *dm); +void draw_mesh_face_select( + struct RegionView3D *rv3d, struct Mesh *me, struct DerivedMesh *dm, + bool draw_select_edges); void draw_mesh_paint_weight_faces(struct DerivedMesh *dm, const bool do_light, void *facemask_cb, void *user_data); void draw_mesh_paint_vcolor_faces(struct DerivedMesh *dm, const bool use_light, diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 7e101fea138..5df348408df 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BKE_appdir.h" #include "BKE_blender.h" #include "BKE_context.h" #include "BKE_main.h" @@ -77,7 +78,7 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - BLI_make_file_string("/", str, BLI_temp_dir_base(), "copybuffer.blend"); + BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend"); BKE_copybuffer_save(str, op->reports); BKE_report(op->reports, RPT_INFO, "Copied selected objects to buffer"); @@ -102,7 +103,7 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op) { char str[FILE_MAX]; - BLI_make_file_string("/", str, BLI_temp_dir_base(), "copybuffer.blend"); + BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend"); if (BKE_copybuffer_paste(C, str, op->reports)) { WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -296,8 +297,8 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANUP); - RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "angle", M_PI / -12); - RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", PAD6, KM_PRESS, KM_SHIFT, 0)->ptr, "angle", M_PI / 12); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPLEFT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", PAD6, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT); @@ -309,8 +310,8 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPUP); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPDOWN); - RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "angle", M_PI / -12); - RNA_float_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "angle", M_PI / 12); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPLEFT); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); /* active aligned, replaces '*' key in 2.4x */ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 9d0a70ea9d0..eba31866f54 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -70,7 +70,7 @@ * \param r_co hit location. * \param r_no hit normal (optional). * \param co_ss Screenspace coordinate. - * \param use_depth Snap to the closest element, use when using more then one snap type. + * \param use_depth Snap to the closest element, use when using more than one snap type. * \param use_obedit Use editmode cage. * \param use_vert Snap to verts. * \param use_edge Snap to edges. @@ -122,12 +122,10 @@ static bool ED_view3d_snap_ray(bContext *C, float r_co[3], bool ret; Scene *scene = CTX_data_scene(C); - View3D *v3d = CTX_wm_view3d(C); - ARegion *ar = CTX_wm_region(C); struct Object *obedit = CTX_data_edit_object(C); /* try snap edge, then face if it fails */ - ret = snapObjectsRayEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_FACE, + ret = snapObjectsRayEx(scene, NULL, NULL, NULL, obedit, SCE_SNAP_MODE_FACE, NULL, NULL, ray_start, ray_normal, &ray_dist, NULL, &dist_px, r_co, r_no_dummy, SNAP_ALL); @@ -189,7 +187,6 @@ typedef struct RulerInfo { /* wm state */ wmWindow *win; - ScrArea *sa; ARegion *ar; void *draw_handle_pixel; } RulerInfo; @@ -552,10 +549,11 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a /* draw text (bg) */ glColor4ubv(color_back); - uiSetRoundBox(UI_CNR_ALL); - uiRoundBox(pos[0] - bg_margin, pos[1] - bg_margin, - pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1], - bg_radius); + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox( + pos[0] - bg_margin, pos[1] - bg_margin, + pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1], + bg_radius); /* draw text */ glColor3ubv(color_text); BLF_position(blf_mono_font, pos[0], pos[1], 0.0f); @@ -641,8 +639,8 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a /* draw text (bg) */ glColor4ubv(color_back); - uiSetRoundBox(UI_CNR_ALL); - uiRoundBox(pos[0] - bg_margin, pos[1] - bg_margin, + UI_draw_roundbox_corner_set(UI_CNR_ALL); + UI_draw_roundbox(pos[0] - bg_margin, pos[1] - bg_margin, pos[0] + bg_margin + numstr_size[0], pos[1] + bg_margin + numstr_size[1], bg_radius); /* draw text */ @@ -800,7 +798,6 @@ static int view3d_ruler_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE op->customdata = ruler_info; ruler_info->win = win; - ruler_info->sa = sa; ruler_info->ar = ar; ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel, ruler_info, REGION_DRAW_POST_PIXEL); @@ -827,11 +824,11 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) bool do_draw = false; int exit_code = OPERATOR_RUNNING_MODAL; RulerInfo *ruler_info = op->customdata; - ScrArea *sa = ruler_info->sa; + ScrArea *sa = CTX_wm_area(C); ARegion *ar = ruler_info->ar; RegionView3D *rv3d = ar->regiondata; - /* its possible to change spaces while running the operator [#34894] */ + /* its possible to change spaces while running the operator [#34894] */ if (UNLIKELY(ar != CTX_wm_region(C))) { exit_code = OPERATOR_FINISHED; goto exit; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index ae429289ffd..38ecbed3b5f 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -93,7 +93,6 @@ #include "ED_mball.h" #include "UI_interface.h" -#include "UI_resources.h" #include "view3d_intern.h" /* own include */ @@ -1143,7 +1142,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int const char *name = ob->id.name + 2; BLI_strncpy(object_mouse_select_menu_data[i].idname, name, MAX_ID_NAME - 2); - object_mouse_select_menu_data[i].icon = uiIconFromID(&ob->id); + object_mouse_select_menu_data[i].icon = UI_icon_from_id(&ob->id); } { @@ -1181,14 +1180,14 @@ static short selectbuffer_ret_hits_15(unsigned int *UNUSED(buffer), const short static short selectbuffer_ret_hits_9(unsigned int *buffer, const short hits15, const short hits9) { const int offs = 4 * hits15; - memcpy(buffer, buffer + offs, 4 * hits9); + memcpy(buffer, buffer + offs, 4 * hits9 * sizeof(unsigned int)); return hits9; } static short selectbuffer_ret_hits_5(unsigned int *buffer, const short hits15, const short hits9, const short hits5) { const int offs = 4 * hits15 + 4 * hits9; - memcpy(buffer, buffer + offs, 4 * hits5); + memcpy(buffer, buffer + offs, 4 * hits5 * sizeof(unsigned int)); return hits5; } diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 3f7f12d2020..f127f375a9f 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -39,7 +39,6 @@ #include "MEM_guardedalloc.h" -#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_ghash.h" @@ -118,7 +117,7 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) uiLayoutSetEnabled(pa->layout, false); /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ - uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); + UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op); view3d_panel_operator_redo_operator(C, pa, op); } @@ -151,20 +150,19 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - GHashIterator *iter = WM_operatortype_iter(); + GHashIterator iter; - for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); + for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); if (BLI_strcasestr(ot->name, str)) { if (WM_operator_poll((bContext *)C, ot)) { - if (false == uiSearchItemAdd(items, ot->name, ot, 0)) + if (false == UI_search_item_add(items, ot->name, ot, 0)) break; } } } - BLI_ghashIterator_free(iter); } @@ -180,18 +178,18 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) /* clear initial search string, then all items show */ search[0] = 0; - block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); + UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU); /* fake button, it holds space for search items */ - uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); - uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); + UI_but_func_search_set(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); - uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); - uiEndBlock(C, block); + UI_block_bounds_set_normal(block, 6); + UI_block_direction_set(block, UI_DIR_DOWN); + UI_block_end(C, block); wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 7d3f7ce282e..c0e26498af6 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -37,9 +37,7 @@ #include "BLI_math.h" #include "BLI_rect.h" -#include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLI_callbacks.h" #include "BKE_anim.h" #include "BKE_action.h" @@ -55,7 +53,6 @@ #include "BIF_gl.h" #include "BIF_glutil.h" -#include "GPU_draw.h" #include "GPU_select.h" #include "WM_api.h" @@ -64,14 +61,16 @@ #include "ED_screen.h" #include "ED_armature.h" -#include "RE_engine.h" #ifdef WITH_GAMEENGINE -#include "BL_System.h" +# include "BLI_listbase.h" +# include "BLI_callbacks.h" + +# include "GPU_draw.h" + +# include "BL_System.h" #endif -#include "RNA_access.h" -#include "RNA_define.h" #include "view3d_intern.h" /* own include */ @@ -356,6 +355,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); ED_view3d_camera_lock_sync(v3d, rv3d); + ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); } if ((rv3d->viewlock & RV3D_LOCKED) == 0) { @@ -382,6 +382,10 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; ED_view3d_camera_lock_sync(v3d, rv3d); + if (ED_screen_animation_playing(CTX_wm_manager(C))) { + ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); + } + } if (rv3d->viewlock & RV3D_BOXVIEW) @@ -1047,7 +1051,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b Scene *scene = vc->scene; View3D *v3d = vc->v3d; ARegion *ar = vc->ar; - rctf rect, selrect; + rctf rect; short hits; const bool use_obedit_skip = (scene->obedit != NULL) && (vc->obedit == NULL); const bool do_passes = do_nearest && GPU_select_query_check_active(); @@ -1064,8 +1068,6 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b else { BLI_rctf_rcti_copy(&rect, input); } - - selrect = rect; view3d_winmatrix_set(ar, v3d, &rect); mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); @@ -1079,9 +1081,9 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b ED_view3d_clipping_set(vc->rv3d); if (do_passes) - GPU_select_begin(buffer, bufsize, &selrect, GPU_SELECT_NEAREST_FIRST_PASS, 0); + GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); else - GPU_select_begin(buffer, bufsize, &selrect, GPU_SELECT_ALL, 0); + GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_ALL, 0); view3d_select_loop(vc, scene, v3d, ar, use_obedit_skip); @@ -1089,7 +1091,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b /* second pass, to get the closest object to camera */ if (do_passes) { - GPU_select_begin(buffer, bufsize, &selrect, GPU_SELECT_NEAREST_SECOND_PASS, hits); + GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); view3d_select_loop(vc, scene, v3d, ar, use_obedit_skip); @@ -1545,18 +1547,22 @@ static void game_set_commmandline_options(GameData *gm) static int game_engine_poll(bContext *C) { + bScreen *screen; /* we need a context and area to launch BGE * it's a temporary solution to avoid crash at load time * if we try to auto run the BGE. Ideally we want the * context to be set as soon as we load the file. */ if (CTX_wm_window(C) == NULL) return 0; - if (CTX_wm_screen(C) == NULL) return 0; + if ((screen = CTX_wm_screen(C)) == NULL) return 0; if (CTX_wm_area(C) == NULL) return 0; if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT) return 0; + if (!BKE_scene_uses_blender_game(screen->scene)) + return 0; + return 1; } diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index c54948b23c6..191eeb05c71 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -42,8 +42,6 @@ #include "BLF_translation.h" -#include "RNA_define.h" -#include "RNA_enum_types.h" #include "BIF_gl.h" @@ -152,6 +150,8 @@ void walk_modal_keymap(wmKeyConfig *keyconf) {WALK_MODAL_JUMP, "JUMP", 0, "Jump", "Jump when in walk mode"}, {WALK_MODAL_JUMP_STOP, "JUMP_STOP", 0, "Jump Stop", "Stop pushing jump"}, + {WALK_MODAL_TOGGLE, "GRAVITY_TOGGLE", 0, "Toggle Gravity", "Toggle gravity effect"}, + {0, NULL, 0, NULL, NULL}}; wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Walk Modal"); |