[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55282] trunk/blender/source/blender/ editors/mesh/editmesh_knife.c: use floats for knife tool internal mouse coord.

Campbell Barton ideasman42 at gmail.com
Thu Mar 14 15:47:01 CET 2013


Revision: 55282
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55282
Author:   campbellbarton
Date:     2013-03-14 14:46:59 +0000 (Thu, 14 Mar 2013)
Log Message:
-----------
use floats for knife tool internal mouse coord.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_knife.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-03-14 14:05:41 UTC (rev 55281)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c	2013-03-14 14:46:59 UTC (rev 55282)
@@ -137,7 +137,8 @@
 typedef struct KnifeTool_OpData {
 	ARegion *ar;        /* region that knifetool was activated in */
 	void *draw_handle;  /* for drawing preview loop */
-	ViewContext vc;
+	ViewContext vc;     /* note: _don't_ use 'mval', instead use the one we define below */
+	float mval[2];      /* mouse value with snapping applied */
 	//bContext *C;
 
 	Object *ob;
@@ -245,8 +246,7 @@
 	kpd->vert = NULL;
 	kpd->edge = NULL;
 	kpd->bmface = NULL;
-	kpd->mval[0] = 0.0f;
-	kpd->mval[1] = 0.0f;
+	zero_v2(kpd->mval);
 }
 
 static ListBase *knife_empty_list(KnifeTool_OpData *kcd)
@@ -1747,7 +1747,7 @@
 	return NULL;
 }
 
-/* update both kcd->curr.mval and kcd->vc.mval to snap to required angle */
+/* update both kcd->curr.mval and kcd->mval to snap to required angle */
 static void knife_snap_angle(KnifeTool_OpData *kcd)
 {
 	float dx, dy;
@@ -1784,16 +1784,14 @@
 		kcd->curr.mval[0] = kcd->prev.mval[0];
 	}
 
-	kcd->vc.mval[0] = round_ftoi(kcd->curr.mval[0]);
-	kcd->vc.mval[1] = round_ftoi(kcd->curr.mval[1]);
+	copy_v2_v2(kcd->mval, kcd->curr.mval);
 }
 
 /* update active knife edge/vert pointers */
 static int knife_update_active(KnifeTool_OpData *kcd)
 {
 	knife_pos_data_clear(&kcd->curr);
-	kcd->curr.mval[0] = (float)kcd->vc.mval[0];
-	kcd->curr.mval[1] = (float)kcd->vc.mval[1];
+	copy_v2_v2(kcd->curr.mval, kcd->mval);
 	if (kcd->angle_snapping != ANGLE_FREE && kcd->mode == MODE_DRAGGING)
 		knife_snap_angle(kcd);
 
@@ -2936,17 +2934,22 @@
 	}
 }
 
-static void knifetool_update_mval(KnifeTool_OpData *kcd, const int mval_i[2])
+static void knifetool_update_mval(KnifeTool_OpData *kcd, const float mval[2])
 {
 	knife_recalc_projmat(kcd);
-	kcd->vc.mval[0] = mval_i[0];
-	kcd->vc.mval[1] = mval_i[1];
+	copy_v2_v2(kcd->mval, mval);
 
 	if (knife_update_active(kcd)) {
 		ED_region_tag_redraw(kcd->ar);
 	}
 }
 
+static void knifetool_update_mval_i(KnifeTool_OpData *kcd, const int mval_i[2])
+{
+	float mval[2] = {UNPACK2(mval_i)};
+	knifetool_update_mval(kcd, mval);
+}
+
 /* called when modal loop selection gets set up... */
 static void knifetool_init(bContext *C, KnifeTool_OpData *kcd,
                            const bool only_select, const bool cut_through)
@@ -3038,8 +3041,7 @@
 	WM_cursor_modal(CTX_wm_window(C), BC_KNIFECURSOR);
 	WM_event_add_modal_handler(C, op);
 
-	kcd = op->customdata;
-	knifetool_update_mval(kcd, event->mval);
+	knifetool_update_mval_i(kcd, event->mval);
 
 	knife_update_header(C, kcd);
 
@@ -3232,7 +3234,7 @@
 
 			case MOUSEMOVE: /* mouse moved somewhere to select another loop */
 				if (kcd->mode != MODE_PANNING) {
-					knifetool_update_mval(kcd, event->mval);
+					knifetool_update_mval_i(kcd, event->mval);
 				}
 
 				break;
@@ -3242,7 +3244,7 @@
 	if (do_refresh) {
 		/* we don't really need to update mval,
 		 * but this happens to be the best way to refresh at the moment */
-		knifetool_update_mval(kcd, event->mval);
+		knifetool_update_mval_i(kcd, event->mval);
 	}
 
 	/* keep going until the user confirms */




More information about the Bf-blender-cvs mailing list