diff options
author | Ton Roosendaal <ton@blender.org> | 2005-08-14 14:58:17 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-08-14 14:58:17 +0400 |
commit | f47f8d94185cfcd0a7e8eda0544910012f8ea3ac (patch) | |
tree | b33bc304b54e8ff7a5ad513188cf2070144b9a95 /source/blender | |
parent | 524d3493f7b58ba6bf9f695b354e4e54378a1891 (diff) |
Patch provided by Campbell Barton; this makes the editmode Mesh CTRL+T
"convert to triangles" check for shortest diagonal to decide how the
triangles will be made.
Fun todo for another occasion; check on facenormals too...
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/src/editmesh_tools.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 77e7f6a68b8..32e0f5c4723 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -146,19 +146,44 @@ void convert_to_triface(int all) next= efa->prev; if(efa->v4) { if(all || (efa->f & SELECT) ) { - - efan= addfacelist(efa->v1, efa->v2, efa->v3, 0, efa, NULL); - if(efa->f & SELECT) EM_select_face(efan, 1); - efan= addfacelist(efa->v1, efa->v3, efa->v4, 0, efa, NULL); - if(efa->f & SELECT) EM_select_face(efan, 1); - - efan->tf.uv[1][0]= efan->tf.uv[2][0]; - efan->tf.uv[1][1]= efan->tf.uv[2][1]; - efan->tf.uv[2][0]= efan->tf.uv[3][0]; - efan->tf.uv[2][1]= efan->tf.uv[3][1]; - - efan->tf.col[1]= efan->tf.col[2]; - efan->tf.col[2]= efan->tf.col[3]; + /* choose shortest diagonal for split */ + if(VecLenf(efa->v1->co, efa->v3->co) <= VecLenf(efa->v2->co, efa->v4->co)) { + + efan= addfacelist(efa->v1, efa->v2, efa->v3, 0, efa, NULL); + if(efa->f & SELECT) EM_select_face(efan, 1); + efan= addfacelist(efa->v1, efa->v3, efa->v4, 0, efa, NULL); + if(efa->f & SELECT) EM_select_face(efan, 1); + + efan->tf.uv[1][0]= efan->tf.uv[2][0]; + efan->tf.uv[1][1]= efan->tf.uv[2][1]; + efan->tf.uv[2][0]= efan->tf.uv[3][0]; + efan->tf.uv[2][1]= efan->tf.uv[3][1]; + + efan->tf.col[1]= efan->tf.col[2]; + efan->tf.col[2]= efan->tf.col[3]; + } + else { + efan= addfacelist(efa->v1, efa->v2, efa->v4, 0, efa, NULL); + if(efa->f & SELECT) EM_select_face(efan, 1); + + efan->tf.uv[2][0]= efan->tf.uv[3][0]; + efan->tf.uv[2][1]= efan->tf.uv[3][1]; + efan->tf.col[2]= efan->tf.col[3]; + + efan= addfacelist(efa->v2, efa->v3, efa->v4, 0, efa, NULL); + if(efa->f & SELECT) EM_select_face(efan, 1); + + efan->tf.uv[0][0]= efan->tf.uv[1][0]; + efan->tf.uv[0][1]= efan->tf.uv[1][1]; + efan->tf.uv[1][0]= efan->tf.uv[2][0]; + efan->tf.uv[1][1]= efan->tf.uv[2][1]; + efan->tf.uv[2][0]= efan->tf.uv[3][0]; + efan->tf.uv[2][1]= efan->tf.uv[3][1]; + + efan->tf.col[0]= efan->tf.col[1]; + efan->tf.col[1]= efan->tf.col[2]; + efan->tf.col[2]= efan->tf.col[3]; + } BLI_remlink(&em->faces, efa); free_editface(efa); |