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.
2004-07-13 11:48:52 +00:00
|
|
|
/**
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
2005-12-01 02:09:21 +00:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_utildefines.h"
|
2007-09-10 12:26:36 +00:00
|
|
|
#include "BKE_customdata.h"
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
|
|
|
|
|
#include "BLI_arithb.h"
|
2005-08-21 21:39:44 +00:00
|
|
|
#include "BLI_edgehash.h"
|
2007-09-10 12:26:36 +00:00
|
|
|
#include "BLI_editVert.h"
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
#include "BIF_editsima.h"
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
#include "BIF_space.h"
|
2005-12-01 02:09:21 +00:00
|
|
|
#include "BIF_screen.h"
|
2007-09-12 01:14:31 +00:00
|
|
|
#include "BIF_editmesh.h"
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
|
|
|
|
|
#include "blendef.h"
|
|
|
|
|
#include "mydevice.h"
|
|
|
|
|
|
|
|
|
|
#include "BDR_unwrapper.h"
|
|
|
|
|
|
2005-12-01 02:09:21 +00:00
|
|
|
#include "PIL_time.h"
|
|
|
|
|
|
|
|
|
|
#include "parametrizer.h"
|
|
|
|
|
|
2006-02-08 21:01:00 +00:00
|
|
|
/* Set tface seams based on edge data, uses hash table to find seam edges. */
|
2004-09-06 14:30:28 +00:00
|
|
|
|
2005-08-21 21:39:44 +00:00
|
|
|
static void hash_add_face(EdgeHash *ehash, MFace *mf)
|
2005-04-23 01:36:08 +00:00
|
|
|
{
|
2005-08-21 21:39:44 +00:00
|
|
|
BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL);
|
|
|
|
|
BLI_edgehash_insert(ehash, mf->v2, mf->v3, NULL);
|
|
|
|
|
if(mf->v4) {
|
|
|
|
|
BLI_edgehash_insert(ehash, mf->v3, mf->v4, NULL);
|
|
|
|
|
BLI_edgehash_insert(ehash, mf->v4, mf->v1, NULL);
|
2005-04-23 01:36:08 +00:00
|
|
|
}
|
|
|
|
|
else
|
2005-08-21 21:39:44 +00:00
|
|
|
BLI_edgehash_insert(ehash, mf->v3, mf->v1, NULL);
|
2004-09-06 14:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-23 01:36:08 +00:00
|
|
|
void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
|
2004-09-06 14:30:28 +00:00
|
|
|
{
|
2005-04-23 01:36:08 +00:00
|
|
|
MFace *mf;
|
2004-09-06 14:30:28 +00:00
|
|
|
int a, doit=1, mark=0;
|
2005-04-23 01:36:08 +00:00
|
|
|
char *linkflag;
|
2006-02-08 21:01:00 +00:00
|
|
|
EdgeHash *ehash, *seamhash;
|
|
|
|
|
MEdge *med;
|
2005-04-23 01:36:08 +00:00
|
|
|
|
2005-08-21 21:39:44 +00:00
|
|
|
ehash= BLI_edgehash_new();
|
2006-02-08 21:01:00 +00:00
|
|
|
seamhash = BLI_edgehash_new();
|
2005-04-23 01:36:08 +00:00
|
|
|
linkflag= MEM_callocN(sizeof(char)*me->totface, "linkflaguv");
|
|
|
|
|
|
2006-02-08 21:01:00 +00:00
|
|
|
for(med=me->medge, a=0; a < me->totedge; a++, med++)
|
|
|
|
|
if(med->flag & ME_SEAM)
|
|
|
|
|
BLI_edgehash_insert(seamhash, med->v1, med->v2, NULL);
|
|
|
|
|
|
2005-04-23 01:36:08 +00:00
|
|
|
if (mode==0 || mode==1) {
|
|
|
|
|
/* only put face under cursor in array */
|
|
|
|
|
mf= ((MFace*)me->mface) + index;
|
2005-08-21 21:39:44 +00:00
|
|
|
hash_add_face(ehash, mf);
|
2005-04-23 01:36:08 +00:00
|
|
|
linkflag[index]= 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* fill array by selection */
|
|
|
|
|
mf= me->mface;
|
2007-04-29 13:39:46 +00:00
|
|
|
for(a=0; a<me->totface; a++, mf++) {
|
|
|
|
|
if(mf->flag & ME_HIDE);
|
|
|
|
|
else if(mf->flag & ME_FACE_SEL) {
|
2005-08-21 21:39:44 +00:00
|
|
|
hash_add_face(ehash, mf);
|
2005-04-23 01:36:08 +00:00
|
|
|
linkflag[a]= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-09-06 14:30:28 +00:00
|
|
|
|
|
|
|
|
while(doit) {
|
|
|
|
|
doit= 0;
|
|
|
|
|
|
2005-04-23 01:36:08 +00:00
|
|
|
/* expand selection */
|
|
|
|
|
mf= me->mface;
|
2007-04-29 13:39:46 +00:00
|
|
|
for(a=0; a<me->totface; a++, mf++) {
|
|
|
|
|
if(mf->flag & ME_HIDE)
|
2006-02-08 21:01:00 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if(!linkflag[a]) {
|
2004-09-06 14:30:28 +00:00
|
|
|
mark= 0;
|
|
|
|
|
|
2006-02-08 21:01:00 +00:00
|
|
|
if(!BLI_edgehash_haskey(seamhash, mf->v1, mf->v2))
|
2005-08-21 21:39:44 +00:00
|
|
|
if(BLI_edgehash_haskey(ehash, mf->v1, mf->v2))
|
2004-09-06 14:30:28 +00:00
|
|
|
mark= 1;
|
2006-02-08 21:01:00 +00:00
|
|
|
if(!BLI_edgehash_haskey(seamhash, mf->v2, mf->v3))
|
2005-08-21 21:39:44 +00:00
|
|
|
if(BLI_edgehash_haskey(ehash, mf->v2, mf->v3))
|
2004-09-06 14:30:28 +00:00
|
|
|
mark= 1;
|
2006-02-08 21:01:00 +00:00
|
|
|
if(mf->v4) {
|
|
|
|
|
if(!BLI_edgehash_haskey(seamhash, mf->v3, mf->v4))
|
2005-08-21 21:39:44 +00:00
|
|
|
if(BLI_edgehash_haskey(ehash, mf->v3, mf->v4))
|
2004-09-06 14:30:28 +00:00
|
|
|
mark= 1;
|
2006-02-08 21:01:00 +00:00
|
|
|
if(!BLI_edgehash_haskey(seamhash, mf->v4, mf->v1))
|
|
|
|
|
if(BLI_edgehash_haskey(ehash, mf->v4, mf->v1))
|
|
|
|
|
mark= 1;
|
2004-09-06 14:30:28 +00:00
|
|
|
}
|
2006-02-08 21:01:00 +00:00
|
|
|
else if(!BLI_edgehash_haskey(seamhash, mf->v3, mf->v1))
|
|
|
|
|
if(BLI_edgehash_haskey(ehash, mf->v3, mf->v1))
|
|
|
|
|
mark = 1;
|
2004-09-06 14:30:28 +00:00
|
|
|
|
|
|
|
|
if(mark) {
|
2005-04-23 01:36:08 +00:00
|
|
|
linkflag[a]= 1;
|
2005-08-21 21:39:44 +00:00
|
|
|
hash_add_face(ehash, mf);
|
2004-09-06 14:30:28 +00:00
|
|
|
doit= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2005-04-23 01:36:08 +00:00
|
|
|
|
2006-02-08 21:01:00 +00:00
|
|
|
BLI_edgehash_free(ehash, NULL);
|
|
|
|
|
BLI_edgehash_free(seamhash, NULL);
|
|
|
|
|
|
2005-04-23 01:36:08 +00:00
|
|
|
if(mode==0 || mode==2) {
|
2007-04-29 13:39:46 +00:00
|
|
|
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
|
2005-04-23 01:36:08 +00:00
|
|
|
if(linkflag[a])
|
2007-04-29 13:39:46 +00:00
|
|
|
mf->flag |= ME_FACE_SEL;
|
2005-04-23 01:36:08 +00:00
|
|
|
else
|
2007-04-29 13:39:46 +00:00
|
|
|
mf->flag &= ~ME_FACE_SEL;
|
2005-04-23 01:36:08 +00:00
|
|
|
}
|
|
|
|
|
else if(mode==1) {
|
2007-04-29 13:39:46 +00:00
|
|
|
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
|
|
|
|
|
if(linkflag[a] && (mf->flag & ME_FACE_SEL))
|
2005-04-23 01:36:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (a<me->totface) {
|
2007-04-29 13:39:46 +00:00
|
|
|
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
|
2005-04-23 01:36:08 +00:00
|
|
|
if(linkflag[a])
|
2007-04-29 13:39:46 +00:00
|
|
|
mf->flag &= ~ME_FACE_SEL;
|
2005-04-23 01:36:08 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-04-29 13:39:46 +00:00
|
|
|
for(a=0, mf=me->mface; a<me->totface; a++, mf++)
|
2005-04-23 01:36:08 +00:00
|
|
|
if(linkflag[a])
|
2007-04-29 13:39:46 +00:00
|
|
|
mf->flag |= ME_FACE_SEL;
|
2005-04-23 01:36:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(linkflag);
|
2004-09-06 14:30:28 +00:00
|
|
|
|
2004-11-07 13:15:04 +00:00
|
|
|
BIF_undo_push("Select linked UV face");
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
object_tface_flags_changed(OBACT, 0);
|
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.
2004-07-13 11:48:52 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-01 02:09:21 +00:00
|
|
|
/* Parametrizer */
|
2007-09-10 12:26:36 +00:00
|
|
|
ParamHandle *construct_param_handle(EditMesh *em, short implicit, short fill, short sel)
|
2005-12-01 02:09:21 +00:00
|
|
|
{
|
|
|
|
|
int a;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MTFace *tf;
|
2007-09-10 12:26:36 +00:00
|
|
|
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
EditEdge *eed;
|
|
|
|
|
EditVert *ev;
|
|
|
|
|
|
2005-12-01 02:09:21 +00:00
|
|
|
ParamHandle *handle;
|
|
|
|
|
|
|
|
|
|
handle = param_construct_begin();
|
2008-05-08 20:38:38 +00:00
|
|
|
|
|
|
|
|
if ((G.scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT)==0) {
|
2008-09-29 17:08:11 +00:00
|
|
|
efa = EM_get_actFace(1);
|
2008-05-08 20:38:38 +00:00
|
|
|
if (efa) {
|
|
|
|
|
float aspx, aspy;
|
|
|
|
|
MTFace *tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
|
|
|
|
image_final_aspect(tface->tpage, &aspx, &aspy);
|
|
|
|
|
|
|
|
|
|
if (aspx!=aspy)
|
|
|
|
|
param_aspect_ratio(handle, aspx, aspy);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-17 18:22:06 +00:00
|
|
|
/* we need the vert indicies */
|
2007-09-10 12:26:36 +00:00
|
|
|
for (ev= em->verts.first, a=0; ev; ev= ev->next, a++)
|
|
|
|
|
ev->tmp.l = a;
|
|
|
|
|
|
|
|
|
|
for (efa= em->faces.first; efa; efa= efa->next) {
|
2005-12-01 02:09:21 +00:00
|
|
|
ParamKey key, vkeys[4];
|
|
|
|
|
ParamBool pin[4], select[4];
|
|
|
|
|
float *co[4];
|
|
|
|
|
float *uv[4];
|
|
|
|
|
int nverts;
|
2007-09-10 12:26:36 +00:00
|
|
|
|
2007-09-18 02:59:57 +00:00
|
|
|
if ((efa->h) || (sel && (efa->f & SELECT)==0))
|
2006-02-08 21:01:00 +00:00
|
|
|
continue;
|
|
|
|
|
|
2007-09-17 18:22:06 +00:00
|
|
|
tf= (MTFace *)CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
|
|
|
|
|
|
|
|
|
if (implicit &&
|
2007-11-25 13:43:14 +00:00
|
|
|
!( simaUVSel_Check(efa, tf, 0) ||
|
|
|
|
|
simaUVSel_Check(efa, tf, 1) ||
|
|
|
|
|
simaUVSel_Check(efa, tf, 2) ||
|
|
|
|
|
(efa->v4 && simaUVSel_Check(efa, tf, 3)) )
|
2007-09-17 18:22:06 +00:00
|
|
|
) {
|
2005-12-01 02:09:21 +00:00
|
|
|
continue;
|
2007-09-17 18:22:06 +00:00
|
|
|
}
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
key = (ParamKey)efa;
|
|
|
|
|
vkeys[0] = (ParamKey)efa->v1->tmp.l;
|
|
|
|
|
vkeys[1] = (ParamKey)efa->v2->tmp.l;
|
|
|
|
|
vkeys[2] = (ParamKey)efa->v3->tmp.l;
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
co[0] = efa->v1->co;
|
|
|
|
|
co[1] = efa->v2->co;
|
|
|
|
|
co[2] = efa->v3->co;
|
2005-12-01 02:09:21 +00:00
|
|
|
|
|
|
|
|
uv[0] = tf->uv[0];
|
|
|
|
|
uv[1] = tf->uv[1];
|
|
|
|
|
uv[2] = tf->uv[2];
|
|
|
|
|
|
2005-12-03 23:22:31 +00:00
|
|
|
pin[0] = ((tf->unwrap & TF_PIN1) != 0);
|
|
|
|
|
pin[1] = ((tf->unwrap & TF_PIN2) != 0);
|
|
|
|
|
pin[2] = ((tf->unwrap & TF_PIN3) != 0);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-11-25 13:43:14 +00:00
|
|
|
select[0] = ((simaUVSel_Check(efa, tf, 0)) != 0);
|
|
|
|
|
select[1] = ((simaUVSel_Check(efa, tf, 1)) != 0);
|
|
|
|
|
select[2] = ((simaUVSel_Check(efa, tf, 2)) != 0);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
if (efa->v4) {
|
|
|
|
|
vkeys[3] = (ParamKey)efa->v4->tmp.l;
|
|
|
|
|
co[3] = efa->v4->co;
|
2005-12-01 02:09:21 +00:00
|
|
|
uv[3] = tf->uv[3];
|
2005-12-03 23:22:31 +00:00
|
|
|
pin[3] = ((tf->unwrap & TF_PIN4) != 0);
|
2007-11-25 13:43:14 +00:00
|
|
|
select[3] = (simaUVSel_Check(efa, tf, 3) != 0);
|
2005-12-01 02:09:21 +00:00
|
|
|
nverts = 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nverts = 3;
|
|
|
|
|
|
|
|
|
|
param_face_add(handle, key, nverts, vkeys, co, uv, pin, select);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!implicit) {
|
2007-09-10 12:26:36 +00:00
|
|
|
for (eed= em->edges.first; eed; eed= eed->next) {
|
|
|
|
|
if(eed->seam) {
|
2005-12-01 02:09:21 +00:00
|
|
|
ParamKey vkeys[2];
|
2007-09-10 12:26:36 +00:00
|
|
|
vkeys[0] = (ParamKey)eed->v1->tmp.l;
|
|
|
|
|
vkeys[1] = (ParamKey)eed->v2->tmp.l;
|
2005-12-01 02:09:21 +00:00
|
|
|
param_edge_set_seam(handle, vkeys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
param_construct_end(handle, fill, implicit);
|
|
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
|
2007-09-18 02:59:57 +00:00
|
|
|
extern int EM_texFaceCheck(void);
|
2007-09-10 12:26:36 +00:00
|
|
|
|
2006-02-08 21:01:00 +00:00
|
|
|
void unwrap_lscm(short seamcut)
|
2005-12-01 02:09:21 +00:00
|
|
|
{
|
2007-09-10 12:26:36 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
2005-12-01 02:09:21 +00:00
|
|
|
ParamHandle *handle;
|
2006-02-05 14:12:45 +00:00
|
|
|
short abf = G.scene->toolsettings->unwrapper == 1;
|
2008-03-26 14:50:29 +00:00
|
|
|
short fillholes = G.scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES;
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 19:32:44 +00:00
|
|
|
/* add uvs if there not here */
|
|
|
|
|
if (!EM_texFaceCheck()) {
|
|
|
|
|
if (em && em->faces.first)
|
|
|
|
|
EM_add_data_layer(&em->fdata, CD_MTFACE);
|
|
|
|
|
|
|
|
|
|
if (!EM_texFaceCheck())
|
|
|
|
|
return;
|
2007-09-18 02:59:57 +00:00
|
|
|
|
2008-03-26 11:56:41 +00:00
|
|
|
if (G.sima && G.sima->image) /* this is a bit of a kludge, but assume they want the image on their mesh when UVs are added */
|
|
|
|
|
image_changed(G.sima, G.sima->image);
|
|
|
|
|
|
2007-09-18 02:59:57 +00:00
|
|
|
/* select new UV's */
|
2007-09-21 14:34:29 +00:00
|
|
|
if ((G.sima==0 || G.sima->flag & SI_SYNC_UVSEL)==0) {
|
2007-09-18 02:59:57 +00:00
|
|
|
EditFace *efa;
|
|
|
|
|
MTFace *tf;
|
|
|
|
|
for(efa=em->faces.first; efa; efa=efa->next) {
|
|
|
|
|
tf= (MTFace *)CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
|
2007-11-25 13:43:14 +00:00
|
|
|
simaFaceSel_Set(efa, tf);
|
2007-09-18 02:59:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-09-10 19:32:44 +00:00
|
|
|
}
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
handle = construct_param_handle(em, 0, fillholes, seamcut == 0);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2006-02-05 14:12:45 +00:00
|
|
|
param_lscm_begin(handle, PARAM_FALSE, abf);
|
2005-12-01 02:09:21 +00:00
|
|
|
param_lscm_solve(handle);
|
|
|
|
|
param_lscm_end(handle);
|
2008-03-26 14:50:29 +00:00
|
|
|
|
2005-12-01 02:09:21 +00:00
|
|
|
param_pack(handle);
|
2006-02-05 14:12:45 +00:00
|
|
|
|
2005-12-03 23:22:31 +00:00
|
|
|
param_flush(handle);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
|
|
|
|
param_delete(handle);
|
|
|
|
|
|
2006-02-08 21:01:00 +00:00
|
|
|
if (!seamcut)
|
|
|
|
|
BIF_undo_push("UV unwrap");
|
2005-12-01 02:09:21 +00:00
|
|
|
|
|
|
|
|
object_uvs_changed(OBACT);
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWIMAGE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void minimize_stretch_tface_uv(void)
|
|
|
|
|
{
|
2007-09-10 12:26:36 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
2005-12-01 02:09:21 +00:00
|
|
|
ParamHandle *handle;
|
|
|
|
|
double lasttime;
|
2005-12-01 12:45:17 +00:00
|
|
|
short doit = 1, escape = 0, val, blend = 0;
|
2005-12-01 02:09:21 +00:00
|
|
|
unsigned short event = 0;
|
2008-03-26 14:50:29 +00:00
|
|
|
short fillholes = G.scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES;
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
if(!EM_texFaceCheck()) return;
|
2005-12-01 02:09:21 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
handle = construct_param_handle(em, 1, fillholes, 1);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
|
|
|
|
lasttime = PIL_check_seconds_timer();
|
|
|
|
|
|
|
|
|
|
param_stretch_begin(handle);
|
|
|
|
|
|
|
|
|
|
while (doit) {
|
|
|
|
|
param_stretch_iter(handle);
|
|
|
|
|
|
|
|
|
|
while (qtest()) {
|
|
|
|
|
event= extern_qread(&val);
|
2005-12-01 12:45:17 +00:00
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
|
switch (event) {
|
|
|
|
|
case ESCKEY:
|
|
|
|
|
escape = 1;
|
|
|
|
|
case RETKEY:
|
|
|
|
|
case PADENTER:
|
|
|
|
|
doit = 0;
|
|
|
|
|
break;
|
|
|
|
|
case PADPLUSKEY:
|
|
|
|
|
case WHEELUPMOUSE:
|
|
|
|
|
if (blend < 10) {
|
|
|
|
|
blend++;
|
|
|
|
|
param_stretch_blend(handle, blend*0.1f);
|
2005-12-03 23:22:31 +00:00
|
|
|
param_flush(handle);
|
2005-12-01 12:45:17 +00:00
|
|
|
lasttime = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case PADMINUS:
|
|
|
|
|
case WHEELDOWNMOUSE:
|
|
|
|
|
if (blend > 0) {
|
|
|
|
|
blend--;
|
|
|
|
|
param_stretch_blend(handle, blend*0.1f);
|
2005-12-03 23:22:31 +00:00
|
|
|
param_flush(handle);
|
2005-12-01 12:45:17 +00:00
|
|
|
lasttime = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((event == LEFTMOUSE) || (event == RIGHTMOUSE)) {
|
|
|
|
|
escape = (event == RIGHTMOUSE);
|
|
|
|
|
doit = 0;
|
|
|
|
|
}
|
2005-12-01 02:09:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!doit)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (PIL_check_seconds_timer() - lasttime > 0.5) {
|
2005-12-01 12:45:17 +00:00
|
|
|
char str[100];
|
|
|
|
|
|
2005-12-03 23:22:31 +00:00
|
|
|
param_flush(handle);
|
|
|
|
|
|
2005-12-01 12:45:17 +00:00
|
|
|
sprintf(str, "Stretch minimize. Blend %.2f.", blend*0.1f);
|
|
|
|
|
headerprint(str);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
|
|
|
|
lasttime = PIL_check_seconds_timer();
|
2006-02-05 14:12:45 +00:00
|
|
|
object_uvs_changed(OBACT);
|
2005-12-01 02:09:21 +00:00
|
|
|
if(G.sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
|
|
|
|
|
else force_draw(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-03 23:22:31 +00:00
|
|
|
if (escape)
|
|
|
|
|
param_flush_restore(handle);
|
|
|
|
|
else
|
|
|
|
|
param_flush(handle);
|
|
|
|
|
|
|
|
|
|
param_stretch_end(handle);
|
2005-12-01 02:09:21 +00:00
|
|
|
|
|
|
|
|
param_delete(handle);
|
|
|
|
|
|
|
|
|
|
BIF_undo_push("UV stretch minimize");
|
|
|
|
|
|
|
|
|
|
object_uvs_changed(OBACT);
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWIMAGE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-22 20:32:20 +00:00
|
|
|
void pack_charts_tface_uv(void)
|
|
|
|
|
{
|
2007-09-10 12:26:36 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
2007-03-22 20:32:20 +00:00
|
|
|
ParamHandle *handle;
|
|
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
if(!EM_texFaceCheck()) return;
|
2007-03-22 20:32:20 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
handle = construct_param_handle(em, 1, 0, 1);
|
2007-03-22 20:32:20 +00:00
|
|
|
param_pack(handle);
|
|
|
|
|
param_flush(handle);
|
|
|
|
|
param_delete(handle);
|
|
|
|
|
|
2008-03-03 01:44:35 +00:00
|
|
|
BIF_undo_push("UV pack islands");
|
|
|
|
|
|
|
|
|
|
object_uvs_changed(OBACT);
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWIMAGE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void average_charts_tface_uv(void)
|
|
|
|
|
{
|
|
|
|
|
EditMesh *em = G.editMesh;
|
|
|
|
|
ParamHandle *handle;
|
|
|
|
|
|
|
|
|
|
if(!EM_texFaceCheck()) return;
|
|
|
|
|
|
|
|
|
|
handle = construct_param_handle(em, 1, 0, 1);
|
|
|
|
|
param_average(handle);
|
|
|
|
|
param_flush(handle);
|
|
|
|
|
param_delete(handle);
|
|
|
|
|
|
|
|
|
|
BIF_undo_push("UV average island scale");
|
2007-03-22 20:32:20 +00:00
|
|
|
|
|
|
|
|
object_uvs_changed(OBACT);
|
|
|
|
|
|
|
|
|
|
allqueue(REDRAWVIEW3D, 0);
|
|
|
|
|
allqueue(REDRAWIMAGE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-03 23:22:31 +00:00
|
|
|
/* LSCM live mode */
|
|
|
|
|
|
|
|
|
|
static ParamHandle *liveHandle = NULL;
|
|
|
|
|
|
|
|
|
|
void unwrap_lscm_live_begin(void)
|
|
|
|
|
{
|
2007-09-10 12:26:36 +00:00
|
|
|
EditMesh *em = G.editMesh;
|
2006-02-05 14:12:45 +00:00
|
|
|
short abf = G.scene->toolsettings->unwrapper == 1;
|
2008-03-26 14:50:29 +00:00
|
|
|
short fillholes = G.scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES;
|
2005-12-03 23:22:31 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
if(!EM_texFaceCheck()) return;
|
2005-12-03 23:22:31 +00:00
|
|
|
|
2007-09-10 12:26:36 +00:00
|
|
|
liveHandle = construct_param_handle(em, 0, fillholes, 1);
|
2005-12-03 23:22:31 +00:00
|
|
|
|
2006-02-05 14:12:45 +00:00
|
|
|
param_lscm_begin(liveHandle, PARAM_TRUE, abf);
|
2005-12-03 23:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void unwrap_lscm_live_re_solve(void)
|
|
|
|
|
{
|
|
|
|
|
if (liveHandle) {
|
|
|
|
|
param_lscm_solve(liveHandle);
|
|
|
|
|
param_flush(liveHandle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-05 14:12:45 +00:00
|
|
|
void unwrap_lscm_live_end(short cancel)
|
2005-12-03 23:22:31 +00:00
|
|
|
{
|
|
|
|
|
if (liveHandle) {
|
|
|
|
|
param_lscm_end(liveHandle);
|
2006-02-05 14:12:45 +00:00
|
|
|
if (cancel)
|
|
|
|
|
param_flush_restore(liveHandle);
|
2005-12-03 23:22:31 +00:00
|
|
|
param_delete(liveHandle);
|
|
|
|
|
liveHandle = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|