From: cilix42 Date: Sun, 26 Aug 2007 17:56:46 +0000 (+0000) Subject: Various small cleanups X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=315c94766449a5049ab19ccaf3b3c9dc9517bc0d;p=inkscape.git Various small cleanups --- diff --git a/src/axis-manip.h b/src/axis-manip.h index 32c1e6137..4ebdb5aab 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -68,7 +68,7 @@ inline gint face_to_int (guint face_id) { } } -inline guint opposite_face (guint face_id) { +inline gint opposite_face (guint face_id) { return face_id + ((face_id % 2 == 0) ? 1 : -1); } @@ -92,7 +92,7 @@ inline bool is_single_axis_direction (Box3D::Axis dir) { // Warning: We don't check that axis really unambiguously specifies a plane. // Make sure this is the case when calling this function. -inline guint face_containing_corner (Box3D::Axis axis, guint corner) { +inline gint face_containing_corner (Box3D::Axis axis, guint corner) { if (!is_single_axis_direction (axis)) { axis = (Box3D::Axis) (axis ^ Box3D::XYZ); } diff --git a/src/box3d.cpp b/src/box3d.cpp index 0f672aab2..8df5c3b52 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -439,7 +439,7 @@ sp_3dbox_corner_angle_to_VP (SP3DBox *box, Box3D::Axis axis, guint extreme_corne bool sp_3dbox_recompute_z_orders (SP3DBox *box) { - guint new_z_orders[6]; + gint new_z_orders[6]; // TODO: Determine the front corner depending on the distance from VPs and/or the user presets guint front_corner = sp_3dbox_get_front_corner_id (box); @@ -636,13 +636,9 @@ static void sp_3dbox_corner_configuration (SP3DBox *box, std::vector &on_h /* returns true if there was a change in the z-orders (which triggers an update of the repr) */ static bool sp_3dbox_recompute_z_orders_by_corner_configuration (SP3DBox *box) { - guint new_z_orders[6]; + gint new_z_orders[6]; Box3D::Axis front_rear_axis = Box3D::Z; - Box3D::Axis axis1 = Box3D::get_remaining_axes (front_rear_axis).first; - Box3D::Axis axis2 = Box3D::get_remaining_axes (front_rear_axis).second; - Box3D::Axis front_plane = Box3D::orth_plane_or_axis (front_rear_axis); - std::vector on_hull; std::vector inside_hull; std::vector visible_faces; diff --git a/src/box3d.h b/src/box3d.h index 57c4f0e9b..27e734193 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -36,7 +36,7 @@ struct SP3DBox : public SPGroup { NR::Point corners[8]; Box3DFace *faces[6]; - guint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) + gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) std::vector currently_visible_faces; diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index 000da8a07..549defb2e 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -121,9 +121,14 @@ bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const & return (coords.first >= 0 and coords.second >= 0); } -static double pos_angle (NR::Point A, NR::Point B) +bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt) { - return fabs (NR::atan2 (A) - NR::atan2 (B)); + return (lies_in_sector (D - A, B - A, pt - A) && lies_in_sector (D - C, B - C, pt - C)); +} + +static double pos_angle (NR::Point v, NR::Point w) +{ + return fabs (NR::atan2 (v) - NR::atan2 (w)); } /* diff --git a/src/line-geometry.h b/src/line-geometry.h index 72e0ae794..fc8f157e9 100644 --- a/src/line-geometry.h +++ b/src/line-geometry.h @@ -31,7 +31,7 @@ public: virtual ~Line() {} Line &operator=(Line const &line); virtual NR::Maybe intersect(Line const &line); - void set_direction(NR::Point const &dir); // FIXME: Can we avoid this explicit assignment? + inline NR::Point direction () { return v_dir; } NR::Point closest_to(NR::Point const &pt); // returns the point on the line closest to pt @@ -43,6 +43,7 @@ public: return (pt + lambda * NR::unit_vector (v_dir)); } protected: + void set_direction(NR::Point const &dir); inline static bool pts_coincide (NR::Point const pt1, NR::Point const pt2) { return (NR::L2 (pt2 - pt1) < epsilon); @@ -56,6 +57,7 @@ protected: std::pair coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w); bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w); +bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt); std::pair side_of_intersection (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt, NR::Point const &dir); diff --git a/src/perspective3d.cpp b/src/perspective3d.cpp index 9f79d25bd..8b1b3863d 100644 --- a/src/perspective3d.cpp +++ b/src/perspective3d.cpp @@ -331,6 +331,17 @@ Perspective3D::update_z_orders () } } +/* the direction from a point pt towards the specified vanishing point of the perspective */ +NR::Point +Perspective3D::direction (NR::Point pt, Box3D::Axis axis) +{ + Box3D::VanishingPoint *vp = this->get_vanishing_point (axis); + if (!vp->is_finite()) { + return vp->v_dir; + } + return (vp->get_pos() - pt); +} + // swallow the list of boxes from the other perspective and delete it void Perspective3D::absorb (Perspective3D *other) @@ -385,9 +396,11 @@ Perspective3D::print_debugging_info () if (j != NULL) { g_print ("%d", SP_3DBOX (j->data)->my_counter); } + g_print ("\n"); } + g_print ("\n"); } - g_print ("\n====================================================\n"); + g_print ("====================================================\n"); } } // namespace Box3D diff --git a/src/perspective3d.h b/src/perspective3d.h index a56003393..8c63cf42e 100644 --- a/src/perspective3d.h +++ b/src/perspective3d.h @@ -44,6 +44,8 @@ public: void update_box_reprs (); void update_z_orders (); + NR::Point direction (NR::Point pt, Box3D::Axis axis); + /* convenience functions for interaction with dragging machinery: */ bool all_boxes_occur_in_list (GSList *boxes_to_do); GSList * boxes_occurring_in_list (GSList * list_of_boxes);