Blender  V2.59
BLI_editVert.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BLI_editVert.h 35793 2011-03-26 08:28:24Z blendix $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00030 #ifndef BLI_EDITVERT_H
00031 #define BLI_EDITVERT_H
00032 
00041 #include "DNA_customdata_types.h"
00042 #include "DNA_mesh_types.h"
00043 
00044 #include "BLO_sys_types.h" // for intptr_t support
00045 
00046 struct DerivedMesh;
00047 struct RetopoPaintData;
00048 
00049 /* note; changing this also might affect the undo copy in editmesh.c */
00050 typedef struct EditVert
00051 {
00052         struct EditVert *next, *prev;
00053         union {
00054                 /* some lean storage for temporary usage 
00055                  * in editmesh routines
00056                  */
00057                 struct EditVert *v;
00058                 struct EditEdge *e;
00059                 struct EditFace *f;
00060                 void            *p;
00061                 intptr_t         l;
00062                 float            fp;
00063                 int                              t;
00064         } tmp;
00065         float no[3]; /*vertex normal */
00066         float co[3]; /*vertex location */
00067         short xs, ys; /* used to store a screenspace 2d projection of the verts */
00068         
00069         /* f stores selection eg. if (eve->f & SELECT) {...
00070         h for hidden. if (!eve->h) {...
00071         f1 and f2 can be used for temp data, clear them first*/
00072         unsigned char f, h, f1, f2; 
00073         float bweight;
00074         short fast;     /* only 0 or 1, for editmesh_fastmalloc, do not store temp data here! */
00075         int hash;     /* internal editmesh.c use only, don't touch! */
00076         int keyindex; /* original index #, for restoring  key information */
00077 
00078         void *data;             /* custom vertex data */
00079 } EditVert;
00080 
00081 struct EditEdge;
00082 
00083 typedef struct HashEdge {
00084         struct EditEdge *eed;
00085         struct HashEdge *next;
00086 } HashEdge;
00087 
00088 /* note; changing this also might affect the undo copy in editmesh.c */
00089 typedef struct EditEdge
00090 {
00091         struct EditEdge *next, *prev;
00092         struct EditVert *v1, *v2;
00093         union {
00094                 /* some lean storage for temporary usage 
00095                  * in editmesh routines
00096                  */
00097                 struct EditVert *v;
00098                 struct EditEdge *e;
00099                 struct EditFace *f;
00100                 void            *p;
00101                 intptr_t         l;
00102                 float                   fp;
00103         } tmp;
00104         short f1, f2;   /* short, f1 is (ab)used in subdiv */
00105         unsigned char f, h, dir, seam, sharp;
00106         float crease;
00107         float bweight;
00108         short fast;             /* only 0 or 1, for editmesh_fastmalloc */
00109         short fgoni;            /* index for fgon, for search */
00110         HashEdge hash;
00111         void *data;                     /*custom edge data*/
00112 } EditEdge;
00113 
00114 /* note; changing this also might affect the undo copy in editmesh.c */
00115 typedef struct EditFace
00116 {
00117         struct EditFace *next, *prev;
00118         struct EditVert *v1, *v2, *v3, *v4;
00119         struct EditEdge *e1, *e2, *e3, *e4;
00120         union {
00121                 /* some lean storage for temporary usage 
00122                  * in editmesh routines
00123                  */
00124                 struct EditVert *v;
00125                 struct EditEdge *e;
00126                 struct EditFace *f;
00127                 void            *p;
00128                 intptr_t         l;
00129                 float                   fp;
00130         } tmp;
00131         float n[3], cent[3];
00132         unsigned char flag;
00133         unsigned char f, f1, h;
00134         unsigned char fast;                     /* only 0 or 1, for editmesh_fastmalloc */
00135         unsigned char fgonf;            /* flag for fgon options */
00136         short mat_nr;
00137         void *data;             /* custom face data */
00138 } EditFace;
00139 
00140 
00141 /*selection types*/
00142 #define EDITVERT 0
00143 #define EDITEDGE 1
00144 #define EDITFACE 2
00145 
00146 typedef struct EditSelection
00147 {
00148         struct EditSelection *next, *prev;
00149         short type;
00150         void *data;
00151 } EditSelection;
00152 
00153 
00154 typedef struct EditMesh
00155 {
00156         ListBase verts, edges, faces;
00157         ListBase selected; /*EditSelections. Used to store the order in which things are selected.*/
00158         HashEdge *hashedgetab;
00159         
00160         /* this is for the editmesh_fastmalloc */
00161         EditVert *allverts, *curvert;
00162         EditEdge *alledges, *curedge;
00163         EditFace *allfaces, *curface;
00164                 /* DerivedMesh caches... note that derived cage can be equivalent
00165                  * to derived final, care should be taken on release.
00166                  */
00167         
00168         /* used for keeping track of the last clicked on face - so the space image
00169          * when using the last selected face - (EditSelection) the space image flickered too much
00170          * 
00171          * never access this directly, use EM_set_actFace and EM_get_actFace */
00172         EditFace *act_face; 
00173         
00174         /* copy from scene */
00175         short selectmode;
00176         /* copy from object actcol */
00177         short mat_nr;
00178         /* stats */
00179         int totvert, totedge, totface, totvertsel, totedgesel, totfacesel;
00180         /* shape key being edited */
00181         int shapenr;
00182         
00183         struct DerivedMesh *derivedCage, *derivedFinal;
00184         /* the custom data layer mask that was last used to calculate
00185          * derivedCage and derivedFinal
00186          */
00187         int lastDataMask;
00188 
00189         struct RetopoPaintData *retopo_paint_data;
00190 
00191         CustomData vdata, edata, fdata;
00192 
00193 } EditMesh;
00194 
00195 #endif
00196