Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2004-07-13 15:48:52 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2004-07-13 15:48:52 +0400
commite0773281220c5af56585b0e07ccdbfc6ee485b4f (patch)
tree4b06de628461f5822cb31c59eb6c6768ae06cc6f /source/blender/blenkernel/intern/subsurf.c
parent4f1c674ee02e07a6986a54a312d7fb9e2547e950 (diff)
Added LSCM UV Unwrapping:
http://www.loria.fr/~levy/Galleries/LSCM/index.html http://www.loria.fr/~levy/Papers/2002/s2002_lscm.pdf Implementation Least Squares Conformal Maps parameterization, based on chapter 2 of: Bruno Levy, Sylvain Petitjean, Nicolas Ray, Jerome Maillot. Least Squares Conformal Maps for Automatic Texture Atlas Generation. In Siggraph 2002, July 2002. Seams: Stored as a flag (ME_SEAM) in the new MEdge struct, these seams define where a mesh will be cut when executing LSCM unwrapping. Seams can be marked and cleared in Edit Mode. Ctrl+EKEY will pop up a menu allowing to Clear or Mark the selected edges as seams. Select Linked in Face Select Mode now only selects linked faces if no seams separate them. So if seams are defined, this will now select the 'face group' defined by the seams. Hotkey is still LKEY. LSCM Unwrap: unwrap UV's by calculating a conformal mapping (preserving local angles). Based on seams, the selected faces will be 'cut'. If multiple 'face groups' are selected, they will be unwrapped separately and packed in the image rectangle in the UV Editor. Packing uses a simple and fast algorithm, only designed to avoid having overlapping faces. LSCM can be found in the Unwrap menu (UKEY), and the UV Calculation panel. Pinning: UV's can be pinned in the UV Editor. When LSCM Unwrap is then executed, these UV's will stay in place, allowing to tweak the solution. PKEY and ALT+PKEY will respectively pin and unpin selected UV's. Face Select Mode Drawing Changes: - Draw Seams option to enable disable drawing of seams - Draw Faces option to enable drawing of selected faces in transparent purple - Draw Hidden Edges option to enable drawing of edges of hidden faces - Draw Edges option to enable drawing of edges of visible faces The colors for these seams, faces and edges are themeable.
Diffstat (limited to 'source/blender/blenkernel/intern/subsurf.c')
-rw-r--r--source/blender/blenkernel/intern/subsurf.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/subsurf.c b/source/blender/blenkernel/intern/subsurf.c
index 6b069782336..4a8724272b7 100644
--- a/source/blender/blenkernel/intern/subsurf.c
+++ b/source/blender/blenkernel/intern/subsurf.c
@@ -176,8 +176,9 @@ struct _HyperVert {
LinkNode *edges, *faces;
};
-/* hyper edge flag */
+/* hyper edge flags */
#define DR_OPTIM 1
+#define HE_SEAM 2
struct _HyperEdge {
HyperEdge *next;
@@ -200,6 +201,7 @@ struct _HyperFace {
unsigned char (*vcol)[4];
float (*uvco)[2];
+ short unwrap;
/* for getting back tface, matnr, etc */
union {
@@ -342,7 +344,7 @@ static HyperMesh *hypermesh_from_mesh(Mesh *me, float *extverts, int subdivLevel
MFace *mface= me->mface;
MEdge *medge= me->medge;
float creasefac= ((float)subdivLevels)/255.0; // in Mesh sharpness is byte
- int i, j;
+ int i, j, flag;
hme->orig_me= me;
if (me->tface)
@@ -362,8 +364,11 @@ static HyperMesh *hypermesh_from_mesh(Mesh *me, float *extverts, int subdivLevel
if(medge) {
for (i=0; i<me->totedge; i++) {
MEdge *med= &medge[i];
+
+ flag= DR_OPTIM;
+ if(med->flag & ME_SEAM) flag |= HE_SEAM;
- hypermesh_add_edge(hme, vert_tbl[med->v1], vert_tbl[med->v2], DR_OPTIM,
+ hypermesh_add_edge(hme, vert_tbl[med->v1], vert_tbl[med->v2], flag,
creasefac*((float)med->crease) );
}
}
@@ -395,6 +400,8 @@ static HyperMesh *hypermesh_from_mesh(Mesh *me, float *extverts, int subdivLevel
f->vcol= BLI_memarena_alloc(hme->arena, sizeof(*f->vcol)*nverts);
for (j=0; j<nverts; j++)
*((unsigned int*) f->vcol[j])= tf->col[j];
+
+ f->unwrap= tf->unwrap;
} else if (hme->hasvcol) {
MCol *mcol= &me->mcol[i*4];
@@ -418,6 +425,7 @@ static HyperMesh *hypermesh_from_editmesh(EditMesh *em, int subdivLevels) {
EditEdge *ee;
EditVlak *ef;
float creasefac= (float)subdivLevels;
+ int flag;
/* we only add vertices with edges, 'f1' is a free flag */
/* added: check for hide flag in vertices */
@@ -437,8 +445,10 @@ static HyperMesh *hypermesh_from_editmesh(EditMesh *em, int subdivLevels) {
ee->v2->prev= (EditVert*) hypermesh_add_vert(hme, ee->v2->co, ee->v2->co);
ee->v2->f1= 0;
}
-
- hypermesh_add_edge(hme, (HyperVert*) ee->v1->prev, (HyperVert*) ee->v2->prev, DR_OPTIM,
+
+ flag= DR_OPTIM;
+ if(ee->seam) flag |= HE_SEAM;
+ hypermesh_add_edge(hme, (HyperVert*) ee->v1->prev, (HyperVert*) ee->v2->prev, flag,
creasefac*ee->crease);
}
}
@@ -743,6 +753,13 @@ static void hypermesh_subdivide(HyperMesh *me, HyperMesh *nme) {
Vec2Cpy(nf->uvco[1], uvco_edge[j]);
Vec2Cpy(nf->uvco[2], uvco_mid);
Vec2Cpy(nf->uvco[3], uvco_edge[last]);
+
+ if(j==0 && (f->unwrap & ((f->nverts==4)?TF_PIN4:TF_PIN3)))
+ nf->unwrap= TF_PIN1;
+ else if(j==1 && f->unwrap & TF_PIN1) nf->unwrap= TF_PIN1;
+ else if(j==2 && f->unwrap & TF_PIN2) nf->unwrap= TF_PIN1;
+ else if(j==3 && f->unwrap & TF_PIN3) nf->unwrap= TF_PIN1;
+ else nf->unwrap= 0;
}
}
}
@@ -956,8 +973,8 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) {
med->v1= (int) e->v[0]->nmv;
med->v2= (int) e->v[1]->nmv;
- /* flag only for optimal */
- if(e->flag) med->flag = ME_EDGEDRAW;
+ if(e->flag & DR_OPTIM) med->flag |= ME_EDGEDRAW;
+ if(e->flag & HE_SEAM) med->flag |= ME_SEAM;
}
/* and we add the handles (med is re-used) */
@@ -1036,6 +1053,7 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) {
tf->transp= origtf->transp;
tf->mode= origtf->mode;
tf->tile= origtf->tile;
+ tf->unwrap= f->unwrap;
} else if (hme->hasvcol) {
MCol *mcolbase= &dlm->mcol[i*4];