Blender V2.61 - r43446

BLI_editVert.h

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