From: cilix42 Date: Wed, 26 Dec 2007 22:35:54 +0000 (+0000) Subject: Recompute box corners relative to new perspective when merging persps (to prevent... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e2d40573e3eece043a9e2607f851ed1d32251242;p=inkscape.git Recompute box corners relative to new perspective when merging persps (to prevent boxes from jumping randomly) --- diff --git a/src/box3d.cpp b/src/box3d.cpp index 0f9f8defe..3397cd6b0 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -1428,7 +1428,19 @@ box3d_get_perspective(SPBox3D const *box) { } void -box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp) { +box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners) { + if (recompute_corners) { + box->orig_corner0.normalize(); + box->orig_corner7.normalize(); + double z0 = box->orig_corner0[Proj::Z]; + double z7 = box->orig_corner7[Proj::Z]; + NR::Point corner0_screen = box3d_get_corner_screen(box, 0); + NR::Point corner7_screen = box3d_get_corner_screen(box, 7); + + box->orig_corner0 = new_persp->tmat.preimage(corner0_screen, z0, Proj::Z); + box->orig_corner7 = new_persp->tmat.preimage(corner7_screen, z7, Proj::Z); + } + persp3d_remove_box (old_persp, box); persp3d_add_box (new_persp, box); diff --git a/src/box3d.h b/src/box3d.h index d6243d5e0..d80cf038b 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -79,7 +79,7 @@ void box3d_remove_from_selection(SPBox3D *box); void box3d_mark_transformed(SPBox3D *box); Persp3D *box3d_get_perspective(SPBox3D const *box); -void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp); +void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners = false); #endif /* __SP_BOX3D_H__ */ diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 05a699446..1029516f7 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -529,16 +529,10 @@ persp3d_absorb(Persp3D *persp1, Persp3D *persp2) { // otherwise the loop below gets confused when perspectives are reattached. std::list boxes_of_persp2 = persp3d_list_of_boxes(persp2); - Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(persp1); - const gchar *persp_id = persp_repr->attribute("id"); - gchar *href = g_strdup_printf("#%s", persp_id); - for (std::list::iterator i = boxes_of_persp2.begin(); i != boxes_of_persp2.end(); ++i) { - SP_OBJECT_REPR(*i)->setAttribute("inkscape:perspectiveID", href); + box3d_switch_perspectives((*i), persp2, persp1, true); + SP_OBJECT(*i)->updateRepr(SP_OBJECT_WRITE_EXT); // so that undo/redo can do its job properly } - g_free(href); - - persp1->boxes.insert(persp1->boxes.begin(), persp2->boxes.begin(), persp2->boxes.end()); } static void