Code

Store a global list of existing perspectives; for each perspective hold a list of...
[inkscape.git] / src / box3d-context.cpp
index d5d367d818b1e75473a8105d49ed182741e938e1..25f6f78f11768e85c5cc20982278452d46bea4f5 100644 (file)
@@ -90,7 +90,7 @@ static void sp_3dbox_context_class_init(SP3DBoxContextClass *klass)
     event_context_class->item_handler  = sp_3dbox_context_item_handler;
 }
 
-Box3D::Perspective3D * SP3DBoxContext::current_perspective = NULL;
+Box3D::Perspective3D * Box3D::Perspective3D::current_perspective = NULL;
 guint SP3DBoxContext::number_of_handles = 3;
 
 static void sp_3dbox_context_init(SP3DBoxContext *box3d_context)
@@ -116,20 +116,6 @@ static void sp_3dbox_context_init(SP3DBoxContext *box3d_context)
 
     box3d_context->ctrl_dragged = false;
     box3d_context->extruded = false;
-
-    /* create an initial perspective */
-    if (!SP3DBoxContext::current_perspective) {
-        SP3DBoxContext::current_perspective = new Box3D::Perspective3D (
-                                              // VP in x-direction
-                                              Box3D::VanishingPoint( NR::Point( 50.0, 600.0),
-                                                                     NR::Point( -1.0,   0.0), Box3D::VP_INFINITE),
-                                              // VP in y-direction
-                                              Box3D::VanishingPoint( NR::Point(500.0,1000.0),
-                                                                     NR::Point(  0.0,   1.0), Box3D::VP_INFINITE),
-                                              // VP in z-direction
-                                              Box3D::VanishingPoint( NR::Point(700.0, 500.0),
-                                                                     NR::Point(sqrt(3.0),1.0), Box3D::VP_INFINITE));
-    }
     
     new (&box3d_context->sel_changed_connection) sigc::connection();
 }
@@ -371,18 +357,18 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven
                 // Without Ctrl, motion of the extruded corner is constrained to the
                 // perspective line from drag_ptB to vanishing point Y.
                 if (!rc->ctrl_dragged) {
-                       rc->drag_ptC = Box3D::perspective_line_snap (rc->drag_ptB, Box3D::Z, motion_dt);
+                       rc->drag_ptC = Box3D::perspective_line_snap (rc->drag_ptB, Box3D::Z, motion_dt, Box3D::Perspective3D::current_perspective);
                 } else {
                     rc->drag_ptC = motion_dt;
                 }
                 rc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_BBOX | Inkscape::Snapper::SNAPPOINT_NODE, rc->drag_ptC, rc->item).getPoint();
                 if (rc->ctrl_dragged) {
-                       Box3D::PerspectiveLine pl1 (NR::Point (event_context->xp, event_context->yp), Box3D::Y);
-                       Box3D::PerspectiveLine pl2 (rc->drag_ptB, Box3D::X);
+                       Box3D::PerspectiveLine pl1 (NR::Point (event_context->xp, event_context->yp), Box3D::Y, Box3D::Perspective3D::current_perspective);
+                       Box3D::PerspectiveLine pl2 (rc->drag_ptB, Box3D::X, Box3D::Perspective3D::current_perspective);
                        NR::Point corner1 = pl1.meet(pl2);
                        
-                       Box3D::PerspectiveLine pl3 (corner1, Box3D::X);
-                       Box3D::PerspectiveLine pl4 (rc->drag_ptC, Box3D::Z);
+                       Box3D::PerspectiveLine pl3 (corner1, Box3D::X, Box3D::Perspective3D::current_perspective);
+                       Box3D::PerspectiveLine pl4 (rc->drag_ptC, Box3D::Z, Box3D::Perspective3D::current_perspective);
                        rc->drag_ptB = pl3.meet(pl4);
                 }
             }