~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to release/scripts/bevel_center.py

  • Committer: Bazaar Package Importer
  • Author(s): Lukas Fittl
  • Date: 2006-09-20 01:57:27 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060920015727-gmoqlxwstx9wwqs3
Tags: 2.42a-1ubuntu1
* Merge from Debian unstable (Closes: Malone #55903). Remaining changes:
  - debian/genpot: Add python scripts from Lee June <blender@eyou.com> to
    generate a reasonable PO template from the sources. Since gettext is used
    in a highly nonstandard way, xgettext does not work for this job.
  - debian/rules: Call the scripts, generate po/blender.pot, and clean it up
    in the clean target.
  - Add a proper header to the generated PO template.
* debian/control: Build depend on libavformat-dev >= 3:0.cvs20060823-3.1,
  otherwise this package will FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
from Blender.Mathutils import *
52
52
from Blender.BGL import *
53
53
 
 
54
#PY23 NO SETS#
 
55
'''
 
56
try:
 
57
        set()
 
58
except:
 
59
        from sets import set    
 
60
'''
 
61
 
54
62
######################################################################
55
63
# Functions to handle the global structures of the script NF, NE and NC
56
64
# which contain informations about faces and corners to be created
59
67
E_selected = NMesh.EdgeFlags['SELECT']
60
68
 
61
69
def make_sel_vert(*co):
62
 
        vi= NMesh.Vert(*co)
63
 
        v.sel = 1 
 
70
        v= NMesh.Vert(*co)
 
71
        v.sel = 1
64
72
        me.verts.append(v)
65
73
        return v
66
74
 
70
78
        me.addFace(f)
71
79
 
72
80
def add_to_NV(old,dir,new):
73
 
        if old in NV.keys():            NV[old][dir] = new
74
 
        else:                                      NV[old] = {dir:new}
 
81
        try:
 
82
                NV[old][dir] = new
 
83
        except:
 
84
                NV[old] = {dir:new}        
75
85
 
76
86
def get_v(old, *neighbors):
77
 
 
78
87
        # compute the direction of the new vert
79
 
        if len(neighbors) == 1 : dir = (neighbors[0].co - old.co).normalize()
80
 
        else : dir = (neighbors[0].co - old.co).normalize() + (neighbors[1].co-old.co).normalize()
 
88
        if len(neighbors) == 1: dir = (neighbors[0].co - old.co).normalize()
 
89
                #dir
 
90
        else: dir = (neighbors[0].co - old.co).normalize() + (neighbors[1].co-old.co).normalize()
81
91
         
82
92
        # look in NV if this vert already exists
83
93
        key = tuple(dir)
122
132
                        # determine and store the face to be created
123
133
 
124
134
                        lenV = [len(x) for x in newV]
125
 
                        
126
135
                        if 2 not in lenV :                        
127
136
                                new_f = NMesh.Face(newV)
128
137
                                if sum(Esel) == nV : new_f.sel = 1
178
187
                                                NF.append(NMesh.Face([newV[ind2-2][0],newV[ind2-2][1],newV[ind2-1][0],newV[ind2-1][1]]))
179
188
                                        
180
189
                                        else:
181
 
                                                ind2 = min(((newV[i][1].co-newV[i-1][0].co).length, i) for i in enumV)[1]
 
190
                                                ind2 = min( [((newV[i][1].co-newV[i-1][0].co).length, i) for i in enumV] )
182
191
                                                NF.append(NMesh.Face([newV[ind2-1][1],newV[ind2][0],newV[ind2][1],newV[ind2-2][0]]))
183
192
                                                NF.append(NMesh.Face([newV[ind2-2][0],newV[ind2-2][1],newV[ind2-1][0],newV[ind2-1][1]]))
184
193
                                
185
194
                                # Preparing the corners
186
195
                                for i in enumV:
187
196
                                        if lenV[i] == 2 :          NC.setdefault(V[i],[]).append(newV[i])
 
197
                                
188
198
                        
189
199
                        old_faces.append(f)
190
200
                        
211
221
                        me.findEdge(*oldv).flag   |= E_selected
212
222
                        me.findEdge(*new[0]).flag |= E_selected
213
223
 
214
 
                        for v in oldv : NV_ext.add(v)
 
224
                        #PY23 NO SETS# for v in oldv : NV_ext.add(v)
 
225
                        for v in oldv : NV_ext[v]= None
215
226
                
216
227
                else:
217
228
                        make_sel_face(new[0] + new[1][::-1])
222
233
def make_corners():
223
234
        """ Make the faces corresponding to corners """
224
235
 
225
 
        for v in NV.keys():
 
236
        for v in NV.iterkeys():
226
237
                V = NV[v].values()
227
238
                nV = len(V)
228
239
                
229
240
                if nV == 1:      pass
230
241
                
231
242
                elif nV == 2 :
232
 
                        if v in NV_ext:
 
243
                        #PY23 NO SETS# if v in NV_ext:
 
244
                        if v in NV_ext.iterkeys():
233
245
                                make_sel_face(V+[v])
234
246
                                me.findEdge(*V).flag   |= E_selected
235
247
                                
236
248
                else:
237
 
                        if nV == 3 and v not in NV_ext : make_sel_face(V)
 
249
                        #PY23 NO SETS# if nV == 3 and v not in NV_ext : make_sel_face(V)
 
250
                        if nV == 3 and v not in NV_ext.iterkeys() : make_sel_face(V)
 
251
                        
238
252
                        
239
253
                        else :
240
254
                                
279
293
                                        New_V = Vector(0.0, 0.0,0.0)
280
294
                                        New_d = [0.0, 0.0,0.0]
281
295
                
282
 
                                        for x in hc.keys():              New_V += x.co
 
296
                                        for x in hc.iterkeys():          New_V += x.co
283
297
                                        for dir in NV[v] :
284
298
                                                for i in xrange(3):      New_d[i] += dir[i]
285
299
 
299
313
 
300
314
        for f in old_faces: me.removeFace(f)
301
315
        
302
 
        for v in NV.keys():
303
 
                if v not in NV_ext :  me.verts.remove(v)
 
316
        for v in NV.iterkeys():
 
317
                #PY23 NO SETS# if v not in NV_ext :  me.verts.remove(v)
 
318
                if v not in NV_ext.iterkeys() :  me.verts.remove(v)
304
319
 
305
320
        for e in me.edges:
306
321
                if e.flag & E_selected :
358
373
def bevel():
359
374
        """ The main function, which creates the bevel """
360
375
        global me,NV,NV_ext,NE,NC, old_faces,old_dist
361
 
 
 
376
        t= Blender.sys.time()
362
377
        scn = Scene.GetCurrent()
363
378
        ob = scn.getActiveObject() 
364
379
        if ob == None or ob.getType() != 'Mesh': 
373
388
        me = ob.getData()
374
389
 
375
390
        NV = {}
376
 
        NV_ext = set()
 
391
        #PY23 NO SETS# NV_ext = set()
 
392
        NV_ext= {}
377
393
        NE = {}
378
394
        NC = {}
379
395
        old_faces = []
384
400
        clear_old()
385
401
 
386
402
        old_dist = dist.val
387
 
 
 
403
        print '\tbevel in %.6f sec' % (Blender.sys.time()-t)
388
404
        me.update(1)
389
405
        if is_editmode: Window.EditMode(1)
390
406
        Window.WaitCursor(0)
398
414
        fac = dist.val - old_dist
399
415
        old_dist = dist.val
400
416
 
401
 
        for old_v in NV.keys():
402
 
                for dir in NV[old_v].keys():
 
417
        for old_v in NV.iterkeys():
 
418
                for dir in NV[old_v].iterkeys():
403
419
                        for i in range(3):
404
420
                                NV[old_v][dir].co[i] += fac*dir[i]
405
421