summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-12-26 22:35:54 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-12-26 22:35:54 +0000
commitda9c97afb1d035ac4d716d5d365dc527e4ee732b (patch)
treefef96db4b84a5d1f23263ade3dedbd8d09fd4a67 /src
parentcheck for cairo version (diff)
downloadinkscape-da9c97afb1d035ac4d716d5d365dc527e4ee732b.tar.gz
inkscape-da9c97afb1d035ac4d716d5d365dc527e4ee732b.zip
Recompute box corners relative to new perspective when merging persps (to prevent boxes from jumping randomly)
(bzr r4311)
Diffstat (limited to 'src')
-rw-r--r--src/box3d.cpp14
-rw-r--r--src/box3d.h2
-rw-r--r--src/persp3d.cpp10
3 files changed, 16 insertions, 10 deletions
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<SPBox3D *> 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<SPBox3D *>::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