diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-03-14 15:48:44 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-03-14 15:48:44 +0300 |
commit | ed75af586e8d6d8349bd4220accf7e7980d01c11 (patch) | |
tree | 6ecdbc42376f1900a8099d7560868c26477ce876 /source/blender/editors | |
parent | dfdb657427608d2c403c1f3984aa6ae4961849e9 (diff) | |
parent | 3824e0f1243798fc580f18c7948a5fc473baa58c (diff) |
Merge branch 'master' into alembic_pointcache
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 13 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_2d.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 74 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 40 |
10 files changed, 88 insertions, 61 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 8eb7fdf0c40..ccf97221112 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -256,7 +256,7 @@ void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int cou void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int count); void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count); -void ED_mesh_calc_tessface(struct Mesh *mesh); +void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly); void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface); void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 5bf077b6293..5fc5738c88f 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -241,6 +241,7 @@ void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, bool ED_view3d_calc_render_border(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, struct rcti *rect); +void ED_view3d_clipping_calc_from_boundbox(float clip[6][4], const struct BoundBox *clipbb, const bool is_flip); void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[4][4]); bool ED_view3d_clipping_test(struct RegionView3D *rv3d, const float co[3], const bool is_local); @@ -325,6 +326,7 @@ void ED_view3d_update_viewmat(struct Scene *scene, struct View3D *v3d, struct AR bool ED_view3d_quat_from_axis_view(const char view, float quat[4]); char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon); char ED_view3d_lock_view_from_index(int index); +char ED_view3d_axis_view_opposite(char view); bool ED_view3d_lock(struct RegionView3D *rv3d); uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 30e9a85d083..86991d7dfeb 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -1235,7 +1235,7 @@ void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) mesh_add_polys(mesh, count); } -void ED_mesh_calc_tessface(Mesh *mesh) +void ED_mesh_calc_tessface(Mesh *mesh, bool free_mpoly) { if (mesh->edit_btmesh) { BKE_editmesh_tessface_calc(mesh->edit_btmesh); @@ -1243,6 +1243,17 @@ void ED_mesh_calc_tessface(Mesh *mesh) else { BKE_mesh_tessface_calc(mesh); } + if (free_mpoly) { + CustomData_free(&mesh->ldata, mesh->totloop); + CustomData_free(&mesh->pdata, mesh->totpoly); + mesh->totloop = 0; + mesh->totpoly = 0; + mesh->mloop = NULL; + mesh->mloopcol = NULL; + mesh->mloopuv = NULL; + mesh->mpoly = NULL; + mesh->mtpoly = NULL; + } } void ED_mesh_report_mirror_ex(wmOperator *op, int totmirr, int totfail, diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index db7cd991338..99b351561c7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1700,11 +1700,10 @@ static int convert_exec(bContext *C, wmOperator *op) dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH); // dm = mesh_create_derived_no_deform(ob1, NULL); /* this was called original (instead of get_derived). man o man why! (ton) */ - DM_to_mesh(dm, newob->data, newob, CD_MASK_MESH); + DM_to_mesh(dm, newob->data, newob, CD_MASK_MESH, true); /* re-tessellation is called by DM_to_mesh */ - dm->release(dm); BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_FONT) { diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index bed85444101..710cf2dbdd2 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -614,9 +614,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, return 0; } - DM_to_mesh(dm, me, ob, CD_MASK_MESH); - - dm->release(dm); + DM_to_mesh(dm, me, ob, CD_MASK_MESH, true); if (md->type == eModifierType_Multires) multires_customdata_delete(me); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index b0fd6a9fa6b..eb96d1d20d5 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -345,8 +345,8 @@ static unsigned short *brush_painter_curve_mask_new(BrushPainter *painter, int d { Brush *brush = painter->brush; - int xoff = -diameter * 0.5f + 0.5f; - int yoff = -diameter * 0.5f + 0.5f; + int xoff = -radius; + int yoff = -radius; unsigned short *mask, *m; int x, y; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 2d8a0a3da29..a5c04ce2cb4 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -908,7 +908,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) glPointSize(7.0); glBegin(GL_POINTS); - glVertex2f(x, y); + glVertex2f(x, y); glEnd(); /* inner frame */ @@ -916,7 +916,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) glPointSize(3.0); glBegin(GL_POINTS); - glVertex2f(x, y); + glVertex2f(x, y); glEnd(); glPointSize(1.0f); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 7169fa95763..51915e05a9e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3703,22 +3703,6 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, } if (align_active == false) { - /* normal operation */ - if (rv3d->viewlock & RV3D_LOCKED) { - /* only pass on if */ - - /* nice confusing if-block */ - if (!((rv3d->view == RV3D_VIEW_FRONT && view == RV3D_VIEW_BACK) || - (rv3d->view == RV3D_VIEW_BACK && view == RV3D_VIEW_FRONT) || - (rv3d->view == RV3D_VIEW_RIGHT && view == RV3D_VIEW_LEFT) || - (rv3d->view == RV3D_VIEW_LEFT && view == RV3D_VIEW_RIGHT) || - (rv3d->view == RV3D_VIEW_BOTTOM && view == RV3D_VIEW_TOP) || - (rv3d->view == RV3D_VIEW_TOP && view == RV3D_VIEW_BOTTOM))) - { - return; - } - } - rv3d->view = view; } @@ -3765,10 +3749,6 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) viewnum = RNA_enum_get(op->ptr, "type"); align_active = RNA_boolean_get(op->ptr, "align_active"); - /* set this to zero, gets handled in axis_set_view */ - if (rv3d->viewlock & RV3D_LOCKED) - align_active = false; - /* Use this to test if we started out with a camera */ if (rv3d->persp == RV3D_CAMOB) { @@ -3894,23 +3874,37 @@ static int vieworbit_exec(bContext *C, wmOperator *op) ARegion *ar; RegionView3D *rv3d; int orbitdir; + char view_opposite; + PropertyRNA *prop_angle = RNA_struct_find_property(op->ptr, "angle"); + float angle = RNA_property_is_set(op->ptr, prop_angle) ? + RNA_property_float_get(op->ptr, prop_angle) : DEG2RADF((float)U.pad_rot_angle); /* no NULL check is needed, poll checks */ - ED_view3d_context_user_region(C, &v3d, &ar); + v3d = CTX_wm_view3d(C); + ar = CTX_wm_region(C); rv3d = ar->regiondata; + /* support for switching to the opposite view (even when in locked views) */ + view_opposite = (fabsf(angle) == (float)M_PI) ? ED_view3d_axis_view_opposite(rv3d->view) : RV3D_VIEW_USER; orbitdir = RNA_enum_get(op->ptr, "type"); - if ((rv3d->viewlock & RV3D_LOCKED) == 0) { + if ((rv3d->viewlock & RV3D_LOCKED) && (view_opposite == RV3D_VIEW_USER)) { + /* no NULL check is needed, poll checks */ + ED_view3d_context_user_region(C, &v3d, &ar); + rv3d = ar->regiondata; + } + + if ((rv3d->viewlock & RV3D_LOCKED) == 0 || (view_opposite != RV3D_VIEW_USER)) { if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) { int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - float angle = DEG2RADF((float)U.pad_rot_angle); float quat_mul[4]; float quat_new[4]; float ofs_new[3]; float *ofs_new_pt = NULL; - view3d_ensure_persp(v3d, ar); + if (view_opposite == RV3D_VIEW_USER) { + view3d_ensure_persp(v3d, ar); + } if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) { const float zvec[3] = {0.0f, 0.0f, 1.0f}; @@ -3933,7 +3927,15 @@ static int vieworbit_exec(bContext *C, wmOperator *op) } mul_qt_qtqt(quat_new, rv3d->viewquat, quat_mul); - rv3d->view = RV3D_VIEW_USER; + + if (view_opposite != RV3D_VIEW_USER) { + rv3d->view = view_opposite; + /* avoid float in-precision, just get a new orientation */ + ED_view3d_quat_from_axis_view(view_opposite, quat_new); + } + else { + rv3d->view = RV3D_VIEW_USER; + } if (U.uiflag & USER_ORBIT_SELECTION) { float dyn_ofs[3]; @@ -3964,6 +3966,8 @@ static int vieworbit_exec(bContext *C, wmOperator *op) void VIEW3D_OT_view_orbit(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "View Orbit"; ot->description = "Orbit the view"; @@ -3977,7 +3981,11 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot) ot->flag = 0; /* properties */ + 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); + ot->prop = RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit"); + } @@ -4429,20 +4437,6 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot) /* ********************* set clipping operator ****************** */ -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]); - } -} - static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float mat[4][4]) { BoundBox clipbb_local; @@ -4455,7 +4449,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, is_negative_m4(mat)); + ED_view3d_clipping_calc_from_boundbox(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_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 0457f5f2d52..8c668b2b8e0 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -299,6 +299,9 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANUP); 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); + kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD9, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "type", V3D_VIEW_STEPRIGHT); + RNA_float_set(kmi->ptr, "angle", (float)M_PI); 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); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 5a3893f733f..4888c6846d2 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -609,6 +609,20 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) /* ********************************** */ +void ED_view3d_clipping_calc_from_boundbox(float clip[4][4], const BoundBox *bb, const bool is_flip) +{ + int val; + + for (val = 0; val < 4; val++) { + normal_tri_v3(clip[val], bb->vec[val], bb->vec[val == 3 ? 0 : val + 1], bb->vec[val + 4]); + if (UNLIKELY(is_flip)) { + negate_v3(clip[val]); + } + + clip[val][3] = -dot_v3v3(clip[val], bb->vec[val]); + } +} + void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect) { float modelview[4][4]; @@ -644,16 +658,7 @@ void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, co ((float *)modelview)[a] = mats->modelview[a]; flip_sign = is_negative_m4(modelview); - /* then plane equations */ - for (val = 0; val < 4; val++) { - - normal_tri_v3(planes[val], bb->vec[val], bb->vec[val == 3 ? 0 : val + 1], bb->vec[val + 4]); - - if (flip_sign) - negate_v3(planes[val]); - - planes[val][3] = -dot_v3v3(planes[val], bb->vec[val]); - } + ED_view3d_clipping_calc_from_boundbox(planes, bb, flip_sign); } static bool view3d_boundbox_clip_m4(const BoundBox *bb, float persmatob[4][4]) @@ -891,6 +896,21 @@ char ED_view3d_lock_view_from_index(int index) } +char ED_view3d_axis_view_opposite(char view) +{ + switch (view) { + case RV3D_VIEW_FRONT: return RV3D_VIEW_BACK; + case RV3D_VIEW_BACK: return RV3D_VIEW_FRONT; + case RV3D_VIEW_LEFT: return RV3D_VIEW_RIGHT; + case RV3D_VIEW_RIGHT: return RV3D_VIEW_LEFT; + case RV3D_VIEW_TOP: return RV3D_VIEW_BOTTOM; + case RV3D_VIEW_BOTTOM: return RV3D_VIEW_TOP; + } + + return RV3D_VIEW_USER; +} + + bool ED_view3d_lock(RegionView3D *rv3d) { return ED_view3d_quat_from_axis_view(rv3d->view, rv3d->viewquat); |