X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fbox3d.cpp;h=ff00a795c57505d50c8475fa83ed835cd16e4740;hb=b7d95f994b4858eeab9ce480b04933b5e94d40eb;hp=0cf0743dbc6568f4218e1cb9aae1400be3635c29;hpb=492de225e9b11f35d98b6b75efa58e115ee688fa;p=inkscape.git diff --git a/src/box3d.cpp b/src/box3d.cpp index 0cf0743db..ff00a795c 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -234,7 +234,15 @@ sp_3dbox_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SP3DBox *box = SP_3DBOX(object); - sp_3dbox_link_to_existing_paths (box, SP_OBJECT_REPR(object)); + Inkscape::XML::Node *repr = SP_OBJECT_REPR(object); + sp_3dbox_link_to_existing_paths (box, repr); + SPEventContext *ec = inkscape_active_event_context(); + if (SP_IS_3DBOX_CONTEXT (ec)) { + SP_3DBOX_CONTEXT (ec)->_vpdrag->updateDraggers(); + // FIXME: Should we update the corners here, too? Maybe this is the reason why the handles + // are off after an undo/redo! On the other hand, if we do so we get warnings about + // updates occuring while other updats are in progress ... + } } /* Invoke parent method */ @@ -798,6 +806,23 @@ sp_3dbox_link_to_existing_paths (SP3DBox *box, Inkscape::XML::Node *repr) { } } +void +sp_3dbox_reshape_after_VP_rotation (SP3DBox *box, Box3D::Axis axis) +{ + Box3D::Perspective3D *persp = inkscape_active_document()->get_persp_of_box (box); + Box3D::VanishingPoint *vp = persp->get_vanishing_point (axis); + + guint c1 = (axis == Box3D::Z) ? 1 : sp_3dbox_get_front_corner_id (box); // hack + guint c2 = c1 ^ axis; + NR::Point v = box->corners[c1] - box->corners[c2]; + double dist = NR::L2 (v) * ((NR::dot (v, vp->v_dir) < 0) ? 1 : -1); // "directed" distance + + Box3D::PerspectiveLine pline (box->corners[c1], axis, persp); + NR::Point pt = pline.point_from_lambda (dist); + + sp_3dbox_move_corner_in_Z_direction (box, c2, pt, axis == Box3D::Z); +} + void sp_3dbox_move_corner_in_XY_plane (SP3DBox *box, guint id, NR::Point pt, Box3D::Axis axes) { @@ -1019,6 +1044,9 @@ sp_3dbox_new_midpoints (Box3D::Perspective3D *persp, Box3D::Axis axis, NR::Point // FIXME: cr == 1 is a degenerate case; how should we deal with it? return std::make_pair (NR::Point (0,0), NR::Point (0,0)); } + if (cr1 == NR_HUGE) { + return std::make_pair (A, B); + } Box3D::PerspectiveLine pl (M0, axis, persp); NR::Point B_new = pl.pt_with_given_cross_ratio (M0, M, cr1 / (cr1 - 1)); NR::Point A_new = pl.pt_with_given_cross_ratio (M0, M, 1 - cr2);