fix for error loading ruler info back from greasepencil.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 10 Mar 2013 12:06:24 +0000 (12:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 10 Mar 2013 12:06:24 +0000 (12:06 +0000)
source/blender/editors/space_view3d/view3d_ruler.c

index 3021932..8545f82 100644 (file)
@@ -368,7 +368,7 @@ static bool view3d_ruler_from_gpencil(bContext *C, RulerInfo *ruler_info)
                                        }
                                        else if (gps->totpoints == 2) {
                                                RulerItem *ruler_item = ruler_item_add(ruler_info);
                                        }
                                        else if (gps->totpoints == 2) {
                                                RulerItem *ruler_item = ruler_item_add(ruler_info);
-                                               for (j = 0; j < 3; j++) {
+                                               for (j = 0; j < 3; j += 2) {
                                                        copy_v3_v3(ruler_item->co[j], &pt->x);
                                                        pt++;
                                                }
                                                        copy_v3_v3(ruler_item->co[j], &pt->x);
                                                        pt++;
                                                }
@@ -732,7 +732,8 @@ static int view3d_ruler_invoke(bContext *C, wmOperator *op, wmEvent *event)
        op->customdata = ruler_info;
 
        ruler_info->ar = ar;
        op->customdata = ruler_info;
 
        ruler_info->ar = ar;
-       ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel, ruler_info, REGION_DRAW_POST_PIXEL);
+       ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel,
+                                                                  ruler_info, REGION_DRAW_POST_PIXEL);
 
        view3d_ruler_header_update(sa);
 
 
        view3d_ruler_header_update(sa);
 
@@ -794,7 +795,6 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                                                negate_v3_v3(ruler_item->co[0], rv3d->ofs);
                                                view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval);
 
                                                negate_v3_v3(ruler_item->co[0], rv3d->ofs);
                                                view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval);
-                                               copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
 
                                                /* snap the first point added, not essential but handy */
                                                {
 
                                                /* snap the first point added, not essential but handy */
                                                {
@@ -802,6 +802,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, wmEvent *event)
                                                        view3d_ruler_item_mousemove(C, ruler_info, event->mval, true);
                                                }
 
                                                        view3d_ruler_item_mousemove(C, ruler_info, event->mval, true);
                                                }
 
+                                               copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);
                                                ruler_item->co_index = 2;
 
                                                do_draw = true;
                                                ruler_item->co_index = 2;
 
                                                do_draw = true;