diff options
author | Chris Want <cwant@ualberta.ca> | 2008-01-26 02:21:22 +0300 |
---|---|---|
committer | Chris Want <cwant@ualberta.ca> | 2008-01-26 02:21:22 +0300 |
commit | 40413c9a4a3f8f5128c7d0a05d1b1fe45f396b2a (patch) | |
tree | 2a368d627fa136956a8e3c55fa9eab99455209cf | |
parent | a4c8a5b670fe759d136ca843b91b5e3a93ec5313 (diff) |
== Mirror Modifier & Subdivide ==
Vertices that are newly created by a subdivision of a mesh object
with mirror modifiers (with clipping option set) are projected to
the plane of symmetry when they are created on edges that lie on
that plane.
For regular subdivide this is trivial by linearity, so this mainly
effects subdivide smooth, loopcut smooth, and subdivide fractal.
This commit basically prevents nasty seam rips on the mirror when
doing these operations.
-rw-r--r-- | source/blender/src/editmesh_tools.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 1992ea8468a..9fc6f1896ea 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -51,6 +51,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise #include "DNA_mesh_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -1283,6 +1284,19 @@ static EditVert *subdivide_edge_addvert(EditEdge *edge, float rad, int beauty, f /* offset for smooth or sphere or fractal */ alter_co(co, edge, rad, beauty, percent); + /* clip if needed by mirror modifier */ + if (edge->v1->f2) { + if ( edge->v1->f2 & edge->v2->f2 & 1) { + co[0]= 0.0f; + } + if ( edge->v1->f2 & edge->v2->f2 & 2) { + co[1]= 0.0f; + } + if ( edge->v1->f2 & edge->v2->f2 & 4) { + co[2]= 0.0f; + } + } + ev = addvertlist(co, NULL); /* vert data (vgroups, ..) */ @@ -2403,12 +2417,39 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype) EditMesh *em = G.editMesh; EditFace *ef; EditEdge *eed, *cedge, *sort[4]; - EditVert **templist; + EditVert *eve, **templist; struct GHash *gh; float length[4], v1mat[3], v2mat[3], v3mat[3], v4mat[3]; int i, j, edgecount, touchcount, facetype,hold; + ModifierData *md= G.obedit->modifiers.first; if(multires_test()) return; + + for (; md; md=md->next) { + if (md->type==eModifierType_Mirror) { + MirrorModifierData *mmd = (MirrorModifierData*) md; + + if(mmd->flag & MOD_MIR_CLIPPING) { + for (eve= em->verts.first; eve; eve= eve->next) { + eve->f2= 0; + switch(mmd->axis){ + case 0: + if (fabs(eve->co[0]) < mmd->tolerance) + eve->f2 |= 1; + break; + case 1: + if (fabs(eve->co[1]) < mmd->tolerance) + eve->f2 |= 2; + break; + case 2: + if (fabs(eve->co[2]) < mmd->tolerance) + eve->f2 |= 4; + break; + } + } + } + } + } //Set faces f1 to 0 cause we need it later for(ef=em->faces.first;ef;ef = ef->next) { |