~ubuntu-branches/ubuntu/lucid/blender/lucid

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/BKE_bmesh.h

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-08-06 22:32:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806223219-8z4eej1u8levu4pz
Tags: 2.49a+dfsg-0ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: Build-depend on python-2.6 rather than python-2.5.
  - debian/misc/*.desktop: Add Spanish translation to .desktop 
    files.
  - debian/pyversions: 2.6.
  - debian/rules: Clean *.o of source/blender/python/api2_2x/
* New upstream release (LP: #382153).
* Refreshed patches:
  - 01_sanitize_sys.patch
  - 02_tmp_in_HOME
  - 10_use_systemwide_ftgl
  - 70_portability_platform_detection
* Removed patches merged upstream:
  - 30_fix_python_syntax_warning
  - 90_ubuntu_ffmpeg_52_changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * BKE_bmesh.h    jan 2007
3
 
 *
4
 
 *      BMesh modeler structure and functions.
5
 
 *
6
 
 * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $
7
 
 *
8
 
 * ***** BEGIN GPL LICENSE BLOCK *****
9
 
 *
10
 
 * This program is free software; you can redistribute it and/or
11
 
 * modify it under the terms of the GNU General Public License
12
 
 * as published by the Free Software Foundation; either version 2
13
 
 * of the License, or (at your option) any later version. The Blender
14
 
 * Foundation also sells licenses for use in proprietary software under
15
 
 * the Blender License.  See http://www.blender.org/BL/ for information
16
 
 * about this.  
17
 
 *
18
 
 * This program is distributed in the hope that it will be useful,
19
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
 * GNU General Public License for more details.
22
 
 *
23
 
 * You should have received a copy of the GNU General Public License
24
 
 * along with this program; if not, write to the Free Software Foundation,
25
 
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26
 
 *
27
 
 * The Original Code is Copyright (C) 2004 Blender Foundation.
28
 
 * All rights reserved.
29
 
 *
30
 
 * The Original Code is: all of this file.
31
 
 *
32
 
 * Contributor(s): Geoffrey Bantle.
33
 
 *
34
 
 * ***** END GPL LICENSE BLOCK *****
35
 
 */
36
 
 
37
 
#ifndef BKE_BMESH_H
38
 
#define BKE_BMESH_H
39
 
 
40
 
#include "DNA_listBase.h"
41
 
#include "BLI_ghash.h"
42
 
#include "BLI_mempool.h"
43
 
#include "BLI_memarena.h"
44
 
#include "DNA_image_types.h"
45
 
#include "BLI_editVert.h"
46
 
#include "BKE_DerivedMesh.h"
47
 
#include "transform.h"
48
 
 
49
 
/*forward declerations*/
50
 
struct BME_Vert;
51
 
struct BME_Edge;
52
 
struct BME_Poly;
53
 
struct BME_Loop;
54
 
 
55
 
 
56
 
/*Notes on further structure Cleanup:
57
 
        -Remove the tflags, they belong in custom data layers
58
 
        -Remove the eflags completely, they are mostly not used
59
 
        -Remove the selection/vis/bevel weight flag/values ect and move them to custom data
60
 
        -Remove EID member and move to custom data
61
 
        -Add a radial cycle length, disk cycle length and loop cycle lenght attributes to custom data and have eulers maintain/use them if present.
62
 
        -Move data such as vertex coordinates/normals to custom data and leave pointers in structures to active layer data.
63
 
        -Remove BME_CycleNode structure?
64
 
*/
65
 
typedef struct BME_CycleNode{
66
 
        struct BME_CycleNode *next, *prev;
67
 
        void *data;
68
 
} BME_CycleNode;
69
 
 
70
 
typedef struct BME_Mesh
71
 
{
72
 
        ListBase verts, edges, polys;
73
 
        /*memory pools used for storing mesh elements*/
74
 
        struct BLI_mempool *vpool;
75
 
        struct BLI_mempool *epool;
76
 
        struct BLI_mempool *ppool;
77
 
        struct BLI_mempool *lpool;
78
 
        /*some scratch arrays used by eulers*/
79
 
        struct BME_Vert **vtar;
80
 
        struct BME_Edge **edar;
81
 
        struct BME_Loop **lpar;
82
 
        struct BME_Poly **plar;
83
 
        int vtarlen, edarlen, lparlen, plarlen;
84
 
        int totvert, totedge, totpoly, totloop;                         /*record keeping*/
85
 
        int nextv, nexte, nextp, nextl;                                         /*Next element ID for verts/edges/faces/loops. Never reused*/
86
 
        struct CustomData vdata, edata, pdata, ldata;   /*Custom Data Layer information*/
87
 
} BME_Mesh;
88
 
 
89
 
typedef struct BME_Vert
90
 
{
91
 
        struct BME_Vert *next, *prev;
92
 
        int     EID;
93
 
        float co[3];                                                                    
94
 
        float no[3];                                                                    
95
 
        struct BME_Edge *edge;                                                  /*first edge in the disk cycle for this vertex*/
96
 
        void *data;                                                                             /*custom vertex data*/
97
 
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
98
 
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
99
 
        unsigned short flag, h;
100
 
        float bweight;
101
 
} BME_Vert;
102
 
 
103
 
typedef struct BME_Edge
104
 
{
105
 
        struct BME_Edge *next, *prev;
106
 
        int EID;
107
 
        struct BME_Vert *v1, *v2;                                               /*note that order of vertex pointers means nothing to eulers*/
108
 
        struct BME_CycleNode d1, d2;                                    /*disk cycle nodes for v1 and v2 respectivley*/
109
 
        struct BME_Loop *loop;                                                  /*first BME_Loop in the radial cycle around this edge*/
110
 
        void *data;                                                                             /*custom edge data*/
111
 
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
112
 
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
113
 
        unsigned short flag, h;
114
 
        float crease, bweight;
115
 
} BME_Edge;
116
 
 
117
 
typedef struct BME_Loop 
118
 
{       
119
 
        struct BME_Loop *next, *prev;                                   /*circularly linked list around face*/
120
 
        int EID;
121
 
        struct BME_CycleNode radial;                                    /*circularly linked list used to find faces around an edge*/
122
 
        struct BME_Vert *v;                                                             /*vertex that this loop starts at.*/
123
 
        struct BME_Edge *e;                                                             /*edge this loop belongs to*/
124
 
        struct BME_Poly *f;                                                             /*face this loop belongs to*/   
125
 
        void *data;                                                                             /*custom per face vertex data*/
126
 
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
127
 
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
128
 
        unsigned short flag, h;
129
 
} BME_Loop;
130
 
 
131
 
typedef struct BME_Poly
132
 
{
133
 
        struct BME_Poly *next, *prev;
134
 
        int EID;
135
 
        struct BME_Loop *loopbase;                                              /*First editloop around Polygon.*/
136
 
        unsigned int len;                                                               /*total length of the face. Eulers should preserve this data*/
137
 
        void *data;                                                                             /*custom face data*/
138
 
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
139
 
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
140
 
        unsigned short flag, h, mat_nr;
141
 
} BME_Poly;
142
 
 
143
 
/*EDGE UTILITIES*/
144
 
int BME_verts_in_edge(struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *e);
145
 
int BME_vert_in_edge(struct BME_Edge *e, BME_Vert *v);
146
 
struct BME_Vert *BME_edge_getothervert(struct BME_Edge *e, struct BME_Vert *v);
147
 
 
148
 
/*GENERAL CYCLE*/
149
 
int BME_cycle_length(void *h);
150
 
 
151
 
/*DISK CYCLE*/
152
 
struct BME_Edge *BME_disk_nextedge(struct BME_Edge *e, struct BME_Vert *v); 
153
 
struct BME_CycleNode *BME_disk_getpointer(struct BME_Edge *e, struct BME_Vert *v);
154
 
struct BME_Edge *BME_disk_next_edgeflag(struct BME_Edge *e, struct BME_Vert *v, int eflag, int tflag);
155
 
int BME_disk_count_edgeflag(struct BME_Vert *v, int eflag, int tflag);
156
 
 
157
 
/*RADIAL CYCLE*/
158
 
struct BME_Loop *BME_radial_nextloop(struct BME_Loop *l);
159
 
int BME_radial_find_face(struct BME_Edge *e,struct BME_Poly *f);
160
 
 
161
 
/*LOOP CYCLE*/
162
 
struct BME_Loop *BME_loop_find_loop(struct BME_Poly *f, struct BME_Vert *v);
163
 
 
164
 
/*MESH CREATION/DESTRUCTION*/
165
 
struct BME_Mesh *BME_make_mesh(int allocsize[4]);
166
 
void BME_free_mesh(struct BME_Mesh *bm);
167
 
/*FULL MESH VALIDATION*/
168
 
int BME_validate_mesh(struct BME_Mesh *bm, int halt);
169
 
/*ENTER/EXIT MODELLING LOOP*/
170
 
int BME_model_begin(struct BME_Mesh *bm);
171
 
void BME_model_end(struct BME_Mesh *bm);
172
 
 
173
 
/*MESH CONSTRUCTION API.*/
174
 
/*MAKE*/
175
 
struct BME_Vert *BME_MV(struct BME_Mesh *bm, float *vec);
176
 
struct BME_Edge *BME_ME(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2);
177
 
struct BME_Poly *BME_MF(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge **elist, int len);
178
 
/*KILL*/
179
 
int BME_KV(struct BME_Mesh *bm, struct BME_Vert *v);
180
 
int BME_KE(struct BME_Mesh *bm, struct BME_Edge *e);
181
 
int BME_KF(struct BME_Mesh *bm, struct BME_Poly *bply);
182
 
/*SPLIT*/
183
 
struct BME_Vert *BME_SEMV(struct BME_Mesh *bm, struct BME_Vert *tv, struct BME_Edge *e, struct BME_Edge **re);
184
 
struct BME_Poly *BME_SFME(struct BME_Mesh *bm, struct BME_Poly *f, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Loop **rl);
185
 
/*JOIN*/
186
 
int BME_JEKV(struct BME_Mesh *bm, struct BME_Edge *ke, struct BME_Vert *kv);
187
 
struct BME_Poly *BME_JFKE(struct BME_Mesh *bm, struct BME_Poly *f1, struct BME_Poly *f2,struct BME_Edge *e); /*no reason to return BME_Poly pointer?*/
188
 
/*NORMAL FLIP(Is its own inverse)*/
189
 
int BME_loop_reverse(struct BME_Mesh *bm, struct BME_Poly *f);
190
 
 
191
 
/* bevel tool defines */
192
 
/* element flags */
193
 
#define BME_BEVEL_ORIG                  1
194
 
#define BME_BEVEL_BEVEL                 (1<<1)
195
 
#define BME_BEVEL_NONMAN                (1<<2)
196
 
#define BME_BEVEL_WIRE                  (1<<3)
197
 
 
198
 
/* tool options */
199
 
#define BME_BEVEL_SELECT                1
200
 
#define BME_BEVEL_VERT                  (1<<1)
201
 
#define BME_BEVEL_RADIUS                (1<<2)
202
 
#define BME_BEVEL_ANGLE                 (1<<3)
203
 
#define BME_BEVEL_WEIGHT                (1<<4)
204
 
//~ #define BME_BEVEL_EWEIGHT           (1<<4)
205
 
//~ #define BME_BEVEL_VWEIGHT           (1<<5)
206
 
#define BME_BEVEL_PERCENT               (1<<6)
207
 
#define BME_BEVEL_EMIN                  (1<<7)
208
 
#define BME_BEVEL_EMAX                  (1<<8)
209
 
#define BME_BEVEL_RUNNING               (1<<9)
210
 
#define BME_BEVEL_RES                   (1<<10)
211
 
 
212
 
typedef struct BME_TransData {
213
 
        BME_Mesh *bm; /* the bmesh the vert belongs to */
214
 
        BME_Vert *v;  /* pointer to the vert this tdata applies to */
215
 
        float co[3];  /* the original coordinate */
216
 
        float org[3]; /* the origin */
217
 
        float vec[3]; /* a directional vector; always, always normalize! */
218
 
        void *loc;    /* a pointer to the data to transform (likely the vert's cos) */
219
 
        float factor; /* primary scaling factor; also accumulates number of weighted edges for beveling tool */
220
 
        float weight; /* another scaling factor; used primarily for propogating vertex weights to transforms; */
221
 
                      /* weight is also used across recursive bevels to help with the math */
222
 
        float maxfactor; /* the unscaled, original factor (used only by "edge verts" in recursive beveling) */
223
 
        float *max;   /* the maximum distance this vert can be transformed; negative is infinite
224
 
                       * it points to the "parent" maxfactor (where maxfactor makes little sense)
225
 
                       * where the max limit is stored (limits are stored per-corner) */
226
 
} BME_TransData;
227
 
 
228
 
typedef struct BME_TransData_Head {
229
 
        GHash *gh;       /* the hash structure for element lookup */
230
 
        MemArena *ma;    /* the memory "pool" we will be drawing individual elements from */
231
 
        int len;
232
 
} BME_TransData_Head;
233
 
 
234
 
typedef struct BME_Glob { /* stored in Global G for Transform() purposes */
235
 
        BME_Mesh *bm;
236
 
        BME_TransData_Head *td;
237
 
        struct TransInfo *Trans; /* a pointer to the global Trans struct */
238
 
        int imval[2]; /* for restoring original mouse co when initTransform() is called multiple times */
239
 
        int options;
240
 
        int res;
241
 
} BME_Glob;
242
 
 
243
 
struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BME_Vert *v);
244
 
void BME_free_transdata(struct BME_TransData_Head *td);
245
 
float *BME_bevel_calc_polynormal(struct BME_Poly *f, struct BME_TransData_Head *td);
246
 
struct BME_Mesh *BME_bevel(struct BME_Mesh *bm, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd);
247
 
 
248
 
/*CONVERSION FUNCTIONS*/
249
 
struct BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em);
250
 
struct EditMesh *BME_bmesh_to_editmesh(struct BME_Mesh *bm, BME_TransData_Head *td);
251
 
struct BME_Mesh *BME_derivedmesh_to_bmesh(struct DerivedMesh *dm);
252
 
struct DerivedMesh *BME_bmesh_to_derivedmesh(struct BME_Mesh *bm, struct DerivedMesh *dm);
253
 
#endif
 
1
/**
 
2
 * BKE_bmesh.h    jan 2007
 
3
 *
 
4
 *      BMesh modeler structure and functions.
 
5
 *
 
6
 * $Id: BKE_bmesh.h 19485 2009-03-31 22:34:34Z gsrb3d $
 
7
 *
 
8
 * ***** BEGIN GPL LICENSE BLOCK *****
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU General Public License
 
12
 * as published by the Free Software Foundation; either version 2
 
13
 * of the License, or (at your option) any later version. The Blender
 
14
 * Foundation also sells licenses for use in proprietary software under
 
15
 * the Blender License.  See http://www.blender.org/BL/ for information
 
16
 * about this.  
 
17
 *
 
18
 * This program is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
 * GNU General Public License for more details.
 
22
 *
 
23
 * You should have received a copy of the GNU General Public License
 
24
 * along with this program; if not, write to the Free Software Foundation,
 
25
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
26
 *
 
27
 * The Original Code is Copyright (C) 2004 Blender Foundation.
 
28
 * All rights reserved.
 
29
 *
 
30
 * The Original Code is: all of this file.
 
31
 *
 
32
 * Contributor(s): Geoffrey Bantle.
 
33
 *
 
34
 * ***** END GPL LICENSE BLOCK *****
 
35
 */
 
36
 
 
37
#ifndef BKE_BMESH_H
 
38
#define BKE_BMESH_H
 
39
 
 
40
#include "DNA_listBase.h"
 
41
#include "BLI_ghash.h"
 
42
#include "BLI_mempool.h"
 
43
#include "BLI_memarena.h"
 
44
#include "DNA_image_types.h"
 
45
#include "BLI_editVert.h"
 
46
#include "BKE_DerivedMesh.h"
 
47
#include "transform.h"
 
48
 
 
49
/*forward declerations*/
 
50
struct BME_Vert;
 
51
struct BME_Edge;
 
52
struct BME_Poly;
 
53
struct BME_Loop;
 
54
 
 
55
 
 
56
/*Notes on further structure Cleanup:
 
57
        -Remove the tflags, they belong in custom data layers
 
58
        -Remove the eflags completely, they are mostly not used
 
59
        -Remove the selection/vis/bevel weight flag/values ect and move them to custom data
 
60
        -Remove EID member and move to custom data
 
61
        -Add a radial cycle length, disk cycle length and loop cycle lenght attributes to custom data and have eulers maintain/use them if present.
 
62
        -Move data such as vertex coordinates/normals to custom data and leave pointers in structures to active layer data.
 
63
        -Remove BME_CycleNode structure?
 
64
*/
 
65
typedef struct BME_CycleNode{
 
66
        struct BME_CycleNode *next, *prev;
 
67
        void *data;
 
68
} BME_CycleNode;
 
69
 
 
70
typedef struct BME_Mesh
 
71
{
 
72
        ListBase verts, edges, polys;
 
73
        /*memory pools used for storing mesh elements*/
 
74
        struct BLI_mempool *vpool;
 
75
        struct BLI_mempool *epool;
 
76
        struct BLI_mempool *ppool;
 
77
        struct BLI_mempool *lpool;
 
78
        /*some scratch arrays used by eulers*/
 
79
        struct BME_Vert **vtar;
 
80
        struct BME_Edge **edar;
 
81
        struct BME_Loop **lpar;
 
82
        struct BME_Poly **plar;
 
83
        int vtarlen, edarlen, lparlen, plarlen;
 
84
        int totvert, totedge, totpoly, totloop;                         /*record keeping*/
 
85
        int nextv, nexte, nextp, nextl;                                         /*Next element ID for verts/edges/faces/loops. Never reused*/
 
86
        struct CustomData vdata, edata, pdata, ldata;   /*Custom Data Layer information*/
 
87
} BME_Mesh;
 
88
 
 
89
typedef struct BME_Vert
 
90
{
 
91
        struct BME_Vert *next, *prev;
 
92
        int     EID;
 
93
        float co[3];                                                                    
 
94
        float no[3];                                                                    
 
95
        struct BME_Edge *edge;                                                  /*first edge in the disk cycle for this vertex*/
 
96
        void *data;                                                                             /*custom vertex data*/
 
97
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
 
98
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
 
99
        unsigned short flag, h;
 
100
        float bweight;
 
101
} BME_Vert;
 
102
 
 
103
typedef struct BME_Edge
 
104
{
 
105
        struct BME_Edge *next, *prev;
 
106
        int EID;
 
107
        struct BME_Vert *v1, *v2;                                               /*note that order of vertex pointers means nothing to eulers*/
 
108
        struct BME_CycleNode d1, d2;                                    /*disk cycle nodes for v1 and v2 respectivley*/
 
109
        struct BME_Loop *loop;                                                  /*first BME_Loop in the radial cycle around this edge*/
 
110
        void *data;                                                                             /*custom edge data*/
 
111
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
 
112
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
 
113
        unsigned short flag, h;
 
114
        float crease, bweight;
 
115
} BME_Edge;
 
116
 
 
117
typedef struct BME_Loop 
 
118
{       
 
119
        struct BME_Loop *next, *prev;                                   /*circularly linked list around face*/
 
120
        int EID;
 
121
        struct BME_CycleNode radial;                                    /*circularly linked list used to find faces around an edge*/
 
122
        struct BME_Vert *v;                                                             /*vertex that this loop starts at.*/
 
123
        struct BME_Edge *e;                                                             /*edge this loop belongs to*/
 
124
        struct BME_Poly *f;                                                             /*face this loop belongs to*/   
 
125
        void *data;                                                                             /*custom per face vertex data*/
 
126
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
 
127
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
 
128
        unsigned short flag, h;
 
129
} BME_Loop;
 
130
 
 
131
typedef struct BME_Poly
 
132
{
 
133
        struct BME_Poly *next, *prev;
 
134
        int EID;
 
135
        struct BME_Loop *loopbase;                                              /*First editloop around Polygon.*/
 
136
        unsigned int len;                                                               /*total length of the face. Eulers should preserve this data*/
 
137
        void *data;                                                                             /*custom face data*/
 
138
        int eflag1, eflag2;                                                             /*reserved for use by eulers*/
 
139
        int tflag1, tflag2;                                                             /*reserved for use by tools*/
 
140
        unsigned short flag, h, mat_nr;
 
141
} BME_Poly;
 
142
 
 
143
/*EDGE UTILITIES*/
 
144
int BME_verts_in_edge(struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge *e);
 
145
int BME_vert_in_edge(struct BME_Edge *e, BME_Vert *v);
 
146
struct BME_Vert *BME_edge_getothervert(struct BME_Edge *e, struct BME_Vert *v);
 
147
 
 
148
/*GENERAL CYCLE*/
 
149
int BME_cycle_length(void *h);
 
150
 
 
151
/*DISK CYCLE*/
 
152
struct BME_Edge *BME_disk_nextedge(struct BME_Edge *e, struct BME_Vert *v); 
 
153
struct BME_CycleNode *BME_disk_getpointer(struct BME_Edge *e, struct BME_Vert *v);
 
154
struct BME_Edge *BME_disk_next_edgeflag(struct BME_Edge *e, struct BME_Vert *v, int eflag, int tflag);
 
155
int BME_disk_count_edgeflag(struct BME_Vert *v, int eflag, int tflag);
 
156
 
 
157
/*RADIAL CYCLE*/
 
158
struct BME_Loop *BME_radial_nextloop(struct BME_Loop *l);
 
159
int BME_radial_find_face(struct BME_Edge *e,struct BME_Poly *f);
 
160
 
 
161
/*LOOP CYCLE*/
 
162
struct BME_Loop *BME_loop_find_loop(struct BME_Poly *f, struct BME_Vert *v);
 
163
 
 
164
/*MESH CREATION/DESTRUCTION*/
 
165
struct BME_Mesh *BME_make_mesh(int allocsize[4]);
 
166
void BME_free_mesh(struct BME_Mesh *bm);
 
167
/*FULL MESH VALIDATION*/
 
168
int BME_validate_mesh(struct BME_Mesh *bm, int halt);
 
169
/*ENTER/EXIT MODELLING LOOP*/
 
170
int BME_model_begin(struct BME_Mesh *bm);
 
171
void BME_model_end(struct BME_Mesh *bm);
 
172
 
 
173
/*MESH CONSTRUCTION API.*/
 
174
/*MAKE*/
 
175
struct BME_Vert *BME_MV(struct BME_Mesh *bm, float *vec);
 
176
struct BME_Edge *BME_ME(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2);
 
177
struct BME_Poly *BME_MF(struct BME_Mesh *bm, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Edge **elist, int len);
 
178
/*KILL*/
 
179
int BME_KV(struct BME_Mesh *bm, struct BME_Vert *v);
 
180
int BME_KE(struct BME_Mesh *bm, struct BME_Edge *e);
 
181
int BME_KF(struct BME_Mesh *bm, struct BME_Poly *bply);
 
182
/*SPLIT*/
 
183
struct BME_Vert *BME_SEMV(struct BME_Mesh *bm, struct BME_Vert *tv, struct BME_Edge *e, struct BME_Edge **re);
 
184
struct BME_Poly *BME_SFME(struct BME_Mesh *bm, struct BME_Poly *f, struct BME_Vert *v1, struct BME_Vert *v2, struct BME_Loop **rl);
 
185
/*JOIN*/
 
186
int BME_JEKV(struct BME_Mesh *bm, struct BME_Edge *ke, struct BME_Vert *kv);
 
187
struct BME_Poly *BME_JFKE(struct BME_Mesh *bm, struct BME_Poly *f1, struct BME_Poly *f2,struct BME_Edge *e); /*no reason to return BME_Poly pointer?*/
 
188
/*NORMAL FLIP(Is its own inverse)*/
 
189
int BME_loop_reverse(struct BME_Mesh *bm, struct BME_Poly *f);
 
190
 
 
191
/* bevel tool defines */
 
192
/* element flags */
 
193
#define BME_BEVEL_ORIG                  1
 
194
#define BME_BEVEL_BEVEL                 (1<<1)
 
195
#define BME_BEVEL_NONMAN                (1<<2)
 
196
#define BME_BEVEL_WIRE                  (1<<3)
 
197
 
 
198
/* tool options */
 
199
#define BME_BEVEL_SELECT                1
 
200
#define BME_BEVEL_VERT                  (1<<1)
 
201
#define BME_BEVEL_RADIUS                (1<<2)
 
202
#define BME_BEVEL_ANGLE                 (1<<3)
 
203
#define BME_BEVEL_WEIGHT                (1<<4)
 
204
//~ #define BME_BEVEL_EWEIGHT           (1<<4)
 
205
//~ #define BME_BEVEL_VWEIGHT           (1<<5)
 
206
#define BME_BEVEL_PERCENT               (1<<6)
 
207
#define BME_BEVEL_EMIN                  (1<<7)
 
208
#define BME_BEVEL_EMAX                  (1<<8)
 
209
#define BME_BEVEL_RUNNING               (1<<9)
 
210
#define BME_BEVEL_RES                   (1<<10)
 
211
 
 
212
typedef struct BME_TransData {
 
213
        BME_Mesh *bm; /* the bmesh the vert belongs to */
 
214
        BME_Vert *v;  /* pointer to the vert this tdata applies to */
 
215
        float co[3];  /* the original coordinate */
 
216
        float org[3]; /* the origin */
 
217
        float vec[3]; /* a directional vector; always, always normalize! */
 
218
        void *loc;    /* a pointer to the data to transform (likely the vert's cos) */
 
219
        float factor; /* primary scaling factor; also accumulates number of weighted edges for beveling tool */
 
220
        float weight; /* another scaling factor; used primarily for propogating vertex weights to transforms; */
 
221
                      /* weight is also used across recursive bevels to help with the math */
 
222
        float maxfactor; /* the unscaled, original factor (used only by "edge verts" in recursive beveling) */
 
223
        float *max;   /* the maximum distance this vert can be transformed; negative is infinite
 
224
                       * it points to the "parent" maxfactor (where maxfactor makes little sense)
 
225
                       * where the max limit is stored (limits are stored per-corner) */
 
226
} BME_TransData;
 
227
 
 
228
typedef struct BME_TransData_Head {
 
229
        GHash *gh;       /* the hash structure for element lookup */
 
230
        MemArena *ma;    /* the memory "pool" we will be drawing individual elements from */
 
231
        int len;
 
232
} BME_TransData_Head;
 
233
 
 
234
typedef struct BME_Glob { /* stored in Global G for Transform() purposes */
 
235
        BME_Mesh *bm;
 
236
        BME_TransData_Head *td;
 
237
        struct TransInfo *Trans; /* a pointer to the global Trans struct */
 
238
        int imval[2]; /* for restoring original mouse co when initTransform() is called multiple times */
 
239
        int options;
 
240
        int res;
 
241
} BME_Glob;
 
242
 
 
243
struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BME_Vert *v);
 
244
void BME_free_transdata(struct BME_TransData_Head *td);
 
245
float *BME_bevel_calc_polynormal(struct BME_Poly *f, struct BME_TransData_Head *td);
 
246
struct BME_Mesh *BME_bevel(struct BME_Mesh *bm, float value, int res, int options, int defgrp_index, float angle, BME_TransData_Head **rtd);
 
247
 
 
248
/*CONVERSION FUNCTIONS*/
 
249
struct BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em);
 
250
struct EditMesh *BME_bmesh_to_editmesh(struct BME_Mesh *bm, BME_TransData_Head *td);
 
251
struct BME_Mesh *BME_derivedmesh_to_bmesh(struct DerivedMesh *dm);
 
252
struct DerivedMesh *BME_bmesh_to_derivedmesh(struct BME_Mesh *bm, struct DerivedMesh *dm);
 
253
#endif