[Bf-blender-cvs] [99d050f] master: Text3d: selection in editmode now follows rotated text along path

Campbell Barton noreply at git.blender.org
Sun Jan 5 12:20:53 CET 2014


Commit: 99d050f88b57f4eb616542f064da8f47594559f1
Author: Campbell Barton
Date:   Sun Jan 5 22:12:21 2014 +1100
https://developer.blender.org/rB99d050f88b57f4eb616542f064da8f47594559f1

Text3d: selection in editmode now follows rotated text along path

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

M	source/blender/blenkernel/BKE_font.h
M	source/blender/blenkernel/intern/font.c
M	source/blender/blenlib/BLI_math_matrix.h
M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/uvedit/uvedit_parametrizer.c

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

diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index 16cbcde..85aaafd 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -55,6 +55,7 @@ struct CharTrans {
 
 typedef struct SelBox {
 	float x, y, w, h;
+	float rot;
 } SelBox;
 
 typedef struct EditFont {	
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index a85ddb8..556e9dc 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -926,6 +926,12 @@ makebreak:
 				
 				ct->xof = vec[0] + si * yof;
 				ct->yof = vec[1] + co * yof;
+
+				if (cu->selboxes && (i >= selstart) && (i <= selend)) {
+					SelBox *sb;
+					sb = &(cu->selboxes[i - selstart]);
+					sb->rot = -ct->rot;
+				}
 				
 			}
 			cucu->flag = oldflag;
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index c834947..af25148 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -91,6 +91,7 @@ void mul_m4_v3(float M[4][4], float r[3]);
 void mul_v3_m4v3(float r[3], float M[4][4], const float v[3]);
 void mul_v2_m4v3(float r[2], float M[4][4], const float v[3]);
 void mul_v2_m2v2(float r[2], float M[2][2], const float v[2]);
+void mul_m2v2(float M[2][2], float v[2]);
 void mul_mat3_m4_v3(float M[4][4], float r[3]);
 void mul_m4_v4(float M[4][4], float r[4]);
 void mul_v4_m4v4(float r[4], float M[4][4], const float v[4]);
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index a4ea406..c185fe1a 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -398,6 +398,11 @@ void mul_v2_m2v2(float r[2], float mat[2][2], const float vec[2])
 	r[1] = mat[0][1] * x + mat[1][1] * vec[1];
 }
 
+void mul_m2v2(float mat[2][2], float vec[2])
+{
+	mul_v2_m2v2(vec, mat, vec);
+}
+
 /* same as mul_m4_v3() but doesnt apply translation component */
 void mul_mat3_m4_v3(float mat[4][4], float vec[3])
 {
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index c26a8b0..93106ea 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -6873,6 +6873,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
 						set_inverted_drawing(1);
 						for (i = 0; i <= (selend - selstart); i++) {
 							SelBox *sb = &(cu->selboxes[i]);
+							float tvec[3];
 
 							if (i < (selend - selstart)) {
 								if (cu->selboxes[i + 1].y == sb->y)
@@ -6883,11 +6884,49 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
 							else {
 								selboxw = sb->w;
 							}
+
+							/* fill in xy below */
+							tvec[2] = 0.001;
+
 							glBegin(GL_QUADS);
-							glVertex3f(sb->x, sb->y, 0.001);
-							glVertex3f(sb->x + selboxw, sb->y, 0.001);
-							glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
-							glVertex3f(sb->x, sb->y + sb->h, 0.001);
+
+							if (sb->rot == 0.0f) {
+								copy_v2_fl2(tvec, sb->x, sb->y);
+								glVertex3fv(tvec);
+
+								copy_v2_fl2(tvec, sb->x + selboxw, sb->y);
+								glVertex3fv(tvec);
+
+								copy_v2_fl2(tvec, sb->x + selboxw, sb->y + sb->h);
+								glVertex3fv(tvec);
+
+								copy_v2_fl2(tvec, sb->x, sb->y + sb->h);
+								glVertex3fv(tvec);
+							}
+							else {
+								float mat[2][2];
+
+								angle_to_mat2(mat, sb->rot);
+
+								copy_v2_fl2(tvec, sb->x, sb->y);
+								glVertex3fv(tvec);
+
+								copy_v2_fl2(tvec, selboxw, 0.0f);
+								mul_m2v2(mat, tvec);
+								add_v2_v2(tvec, &sb->x);
+								glVertex3fv(tvec);
+
+								copy_v2_fl2(tvec, selboxw, sb->h);
+								mul_m2v2(mat, tvec);
+								add_v2_v2(tvec, &sb->x);
+								glVertex3fv(tvec);
+
+								copy_v2_fl2(tvec, 0.0f, sb->h);
+								mul_m2v2(mat, tvec);
+								add_v2_v2(tvec, &sb->x);
+								glVertex3fv(tvec);
+							}
+
 							glEnd();
 						}
 						set_inverted_drawing(0);
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 34c4418..66e4c01 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -493,7 +493,7 @@ static void p_chart_uv_transform(PChart *chart, float mat[2][2])
 	PVert *v;
 
 	for (v = chart->verts; v; v = v->nextlink) {
-		mul_v2_m2v2(v->uv, mat, v->uv);
+		mul_m2v2(mat, v->uv);
 	}
 }




More information about the Bf-blender-cvs mailing list