Text3d: selection in editmode now follows rotated text along path

This commit is contained in:
Campbell Barton 2014-01-05 22:12:21 +11:00
parent 42bd5d7c80
commit 99d050f88b
6 changed files with 57 additions and 5 deletions

View File

@ -55,6 +55,7 @@ struct CharTrans {
typedef struct SelBox {
float x, y, w, h;
float rot;
} SelBox;
typedef struct EditFont {

View File

@ -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;

View File

@ -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]);

View File

@ -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])
{

View File

@ -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);

View File

@ -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);
}
}