[Bf-blender-cvs] [27d0bf7] soc-2014-nurbs: C89 support (I think).

Jonathan deWerd noreply at git.blender.org
Fri Aug 22 10:59:41 CEST 2014


Commit: 27d0bf77cb88e94453b9408c5584adb3e2b25a0d
Author: Jonathan deWerd
Date:   Tue Aug 19 15:17:41 2014 -0400
Branches: soc-2014-nurbs
https://developer.blender.org/rB27d0bf77cb88e94453b9408c5584adb3e2b25a0d

C89 support (I think).

===================================================================

M	source/blender/blenkernel/intern/mesh.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/uvedit/uvedit_draw.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 445ef80..5aea5e2 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1177,10 +1177,11 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
 	MLoopUV *mloopuv = NULL;
 	MEdge *medge;
 	const float *data;
-	int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0;
-	int p1, p2, p3, p4, *index;
+	int i, a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0;
+	int p1, p2, p3, p4, *index, smooth;
 	const bool conv_polys = ((CU_DO_2DFILL(cu) == false) ||  /* 2d polys are filled with DL_INDEX3 displists */
 	                         (ob->type == OB_SURF));  /* surf polys are never filled */
+	float *nors;
 
 	/* count */
 	dl = dispbase->first;
@@ -1231,7 +1232,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
 
 	dl = dispbase->first;
 	while (dl) {
-		int smooth = dl->rt & CU_SMOOTH ? 1 : 0;
+		smooth = dl->rt & CU_SMOOTH ? 1 : 0;
 
 		if (dl->type == DL_SEGM) {
 			startvert = vertcount;
@@ -1284,7 +1285,7 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
 			startvert = vertcount;
 			a = dl->nr;
 			data = dl->verts;
-			float *nors = dl->nors;
+			nors = dl->nors;
 			while (a--) {
 				copy_v3_v3(mvert->co, data);
 				data += 3;
@@ -1307,8 +1308,6 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
 				mpoly->mat_nr = dl->col;
 
 				if (mloopuv) {
-					int i;
-
 					for (i = 0; i < 3; i++, mloopuv++) {
 						mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1);
 						mloopuv->uv[1] = 0.0f;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 2943205..9e19dbc 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -170,9 +170,9 @@ static bool nurbs_select_bpoint(Nurb *nu, BPoint *bp, int dir, bool selstatus, s
 	int pntsu = (nu->pntsu<=1)? 1 : nu->pntsu;
 	int pntsv = (nu->pntsv<=1)? 1 : nu->pntsv;
 	int idx = bp - nu->bp;
-	BLI_assert(0<=idx && idx<pntsu*pntsv);
 	int uidx = idx%pntsu;
 	int vidx = idx/pntsu;
+	BLI_assert(0<=idx && idx<pntsu*pntsv);
 	/* dir is  0:-v  1:+v  2:-u  3:+u  */
 	if (dir==2 || dir==3) {
 		for (int u=0; u<pntsu; u++) {
@@ -3825,9 +3825,11 @@ void CURVE_OT_subdivide(wmOperatorType *ot)
 static void findnearestNurbvert__doClosest(ViewContext *vc, void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2])
 {
 	struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int *dir; float dist; int hpoint, select; float mval_fl[2]; } *data = userData;
-
+	int pntsu, pntsv, idx, uidx, vidx;
+	float cos, max_cos, compass_pt[2], compass_dir[2], mouse_dir[2];
 	short flag;
 	float dist_test;
+	BPoint *Upos, *Uneg, *Vpos, *Vneg;
 
 	if (bp) {
 		flag = bp->f1;
@@ -3855,57 +3857,57 @@ static void findnearestNurbvert__doClosest(ViewContext *vc, void *userData, Nurb
 		data->nurb = nu;
 		data->hpoint = bezt ? beztindex : 0;
 		if (nu->type==CU_NURBS && data->dir) {
-			int pntsu = (nu->pntsu<=1)? 1 : nu->pntsu;
-			int pntsv = (nu->pntsu<=1)? 1 : nu->pntsv;
-			int idx = bp - nu->bp;
+			pntsu = (nu->pntsu<=1)? 1 : nu->pntsu;
+			pntsv = (nu->pntsu<=1)? 1 : nu->pntsv;
+			idx = bp - nu->bp;
 			BLI_assert(0<=idx && idx<pntsu*pntsv);
-			int uidx = idx%pntsu;
-			int vidx = idx/pntsu;
-			float max_cos = -2.0; *data->dir=-1;
-			float compass_pt[2]; /* pos of adjacent bp in {+u,-u,+v,-v} direction */
-			float compass_dir[2]; /* bp ---> bp{+u,-u,+v,-v} */
-			float mouse_dir[2]; /* bp ---> clickpt */
+			uidx = idx%pntsu;
+			vidx = idx/pntsu;
+			max_cos = -2.0; *data->dir=-1;
+			compass_pt[2]; /* pos of adjacent bp in {+u,-u,+v,-v} direction */
+			compass_dir[2]; /* bp ---> bp{+u,-u,+v,-v} */
+			mouse_dir[2]; /* bp ---> clickpt */
 			sub_v2_v2v2(mouse_dir, data->mval_fl, screen_co);
 			normalize_v2(mouse_dir);
 			*data->dir = -1;
-			BPoint *Upos = (uidx<pntsu-1)? bp+1 : NULL;
+			Upos = (uidx<pntsu-1)? bp+1 : NULL;
 			if (Upos && ED_view3d_project_float_object(vc->ar, Upos->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) {
 				sub_v2_v2v2(compass_dir, compass_pt, screen_co);
 				normalize_v2(compass_dir);
-				float cos = dot_v2v2(compass_dir, mouse_dir);
+				cos = dot_v2v2(compass_dir, mouse_dir);
 				/* data->dir for directional select (alt+click)  0:-v  1:+v  2:-u  3:+u  */
 				if (cos>max_cos) {
 					*data->dir = 3;
 					max_cos = cos;
 				}
 			}
-			BPoint *Uneg = (uidx>0)? bp-1 : NULL;
+			Uneg = (uidx>0)? bp-1 : NULL;
 			if (Uneg && ED_view3d_project_float_object(vc->ar, Uneg->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) {
 				sub_v2_v2v2(compass_dir, compass_pt, screen_co);
 				normalize_v2(compass_dir);
-				float cos = dot_v2v2(compass_dir, mouse_dir);
+				cos = dot_v2v2(compass_dir, mouse_dir);
 				/* data->dir for directional select (alt+click)  0:-v  1:+v  2:-u  3:+u  */
 				if (cos>max_cos) {
 					*data->dir = 2;
 					max_cos = cos;
 				}
 			}
-			BPoint *Vpos = (vidx<pntsv-1)? bp+pntsu : NULL;
+			Vpos = (vidx<pntsv-1)? bp+pntsu : NULL;
 			if (Vpos && ED_view3d_project_float_object(vc->ar, Vpos->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) {
 				sub_v2_v2v2(compass_dir, compass_pt, screen_co);
 				normalize_v2(compass_dir);
-				float cos = dot_v2v2(compass_dir, mouse_dir);
+				cos = dot_v2v2(compass_dir, mouse_dir);
 				/* data->dir for directional select (alt+click)  0:-v  1:+v  2:-u  3:+u  */
 				if (cos>max_cos) {
 					*data->dir = 1;
 					max_cos = cos;
 				}
 			}
-			BPoint *Vneg = (vidx>0)? bp-pntsu : NULL;
+			Vneg = (vidx>0)? bp-pntsu : NULL;
 			if (Vneg && ED_view3d_project_float_object(vc->ar, Vneg->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) {
 				sub_v2_v2v2(compass_dir, compass_pt, screen_co);
 				normalize_v2(compass_dir);
-				float cos = dot_v2v2(compass_dir, mouse_dir);
+				cos = dot_v2v2(compass_dir, mouse_dir);
 				/* data->dir for directional select (alt+click)  0:-v  1:+v  2:-u  3:+u  */
 				if (cos>max_cos) {
 					*data->dir = 0;
@@ -4757,6 +4759,7 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool
 	BPoint *bp = NULL;
 	const void *vert = BKE_curve_vert_active_get(cu);
 	int location[2];
+	int dir; /*  for directional select (alt+click)  0:-v  1:+v  2:-u  3:+u  */
 	short hand;
 	
 	view3d_operator_needs_opengl(C);
@@ -4764,7 +4767,6 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool
 	
 	location[0] = mval[0];
 	location[1] = mval[1];
-	int dir; /*  for directional select (alt+click)  0:-v  1:+v  2:-u  3:+u  */
 	hand = findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp, &dir);
 
 	if (bezt || bp) {
@@ -5650,12 +5652,12 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent
 	BezTriple *bezt;
 	BPoint *bp;
 	int a;
+	int dir;
 	const bool select = !RNA_boolean_get(op->ptr, "deselect");
 
 	view3d_operator_needs_opengl(C);
 	view3d_set_viewcontext(C, &vc);
 
-	int dir;
 	findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp, &dir);
 
 	if (bezt) {
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 6cdf7a6..d4a5c93 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -1307,6 +1307,7 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *e
 	bool extend = RNA_boolean_get(op->ptr, "extend");
 	bool deselect = RNA_boolean_get(op->ptr, "deselect");
 	bool toggle = RNA_boolean_get(op->ptr, "toggle");
+	bool b_ring = RNA_boolean_get(op->ptr, "ring");
 
 	/* NURBS surfaces have their own loop selection code. */
 	Object *obedit = CTX_data_edit_object(C);
@@ -1318,7 +1319,6 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *e
 	}
 	/* end NURBS interception code */
 
-	bool b_ring = RNA_boolean_get(op->ptr, "ring");
 	view3d_operator_needs_opengl(C);
 	if (mouse_mesh_loop(C, event->mval, extend, deselect, toggle, b_ring))
 	{
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 2ada992..f4ce552 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -937,6 +937,7 @@ static void draw_nurbuv(const struct bContext *C, ARegion *ar, Object *obedit)
 	unsigned char col1[4], col2[4];
 	float (*trim_uv_pnts)[2];
 	int grid_x_spacing, grid_y_spacing;
+	NurbEditKnot *ek;
 
 	cu = (Curve*)obedit->data;
 	BLI_assert(obedit && obedit->type == OB_SURF);
@@ -1051,7 +1052,7 @@ static void draw_nurbuv(const struct bContext *C, ARegion *ar, Object *obedit)
 	glBegin(GL_QUADS);
 	for (nu=cu->editnurb->nurbs.first; nu; nu=nu->next) {
 		if (!(nu->flag2&CU_SELECTED2)) continue;
-		NurbEditKnot *ek = BKE_nurbs_editKnot_get(nu);
+		ek = BKE_nurbs_editKnot_get(nu);
 		if (ek->breaksv) { /* This is a surf, have u and v breaks */
 			UI_view2d_view_to_region(&ar->v2d, ek->breaksu[0].loc, ek->breaksv[0].loc, &umin, &vmin);
 			UI_view2d_view_to_region(&ar->v2d, ek->breaksu[ek->num_breaksu-1].loc, ek->breaksv[ek->num_breaksv-1].loc, &umax, &vmax);




More information about the Bf-blender-cvs mailing list