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

« back to all changes in this revision

Viewing changes to source/blender/src/transform_manipulator.c

  • 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:
75
75
#include "BIF_screen.h"
76
76
#include "BIF_space.h"
77
77
#include "BIF_transform.h"
 
78
#include "BIF_editmesh.h"
78
79
 
79
80
#include "BSE_edit.h"
80
81
#include "BSE_view.h"
148
149
        if(protectflag & OB_LOCK_ROTZ)
149
150
                *drawflags &= ~MAN_ROT_Z;
150
151
 
151
 
        if(protectflag & OB_LOCK_SIZEX)
 
152
        if(protectflag & OB_LOCK_SCALEX)
152
153
                *drawflags &= ~MAN_SCALE_X;
153
 
        if(protectflag & OB_LOCK_SIZEY)
 
154
        if(protectflag & OB_LOCK_SCALEY)
154
155
                *drawflags &= ~MAN_SCALE_Y;
155
 
        if(protectflag & OB_LOCK_SIZEZ)
 
156
        if(protectflag & OB_LOCK_SCALEZ)
156
157
                *drawflags &= ~MAN_SCALE_Z;
157
158
}
158
159
 
172
173
        }
173
174
}
174
175
 
 
176
/* only counts the parent selection, and tags transform flag */
 
177
/* bad call... should re-use method from transform_conversion once */
 
178
static void count_bone_select(TransInfo *t, bArmature *arm, ListBase *lb, int do_it) 
 
179
{
 
180
        Bone *bone;
 
181
        int do_next;
 
182
        
 
183
        for(bone= lb->first; bone; bone= bone->next) {
 
184
                bone->flag &= ~BONE_TRANSFORM;
 
185
                do_next= do_it;
 
186
                if(do_it) {
 
187
                        if(bone->layer & arm->layer) {
 
188
                                if (bone->flag & BONE_SELECTED) {
 
189
                                        /* We don't let connected children get "grabbed" */
 
190
                                        if ( (t->mode!=TFM_TRANSLATION) || (bone->flag & BONE_CONNECTED)==0 ) {
 
191
                                                bone->flag |= BONE_TRANSFORM;
 
192
                                                t->total++;
 
193
                                                do_next= 0;     // no transform on children if one parent bone is selected
 
194
                                        }
 
195
                                }
 
196
                        }
 
197
                }
 
198
                count_bone_select(t, arm, &bone->childbase, do_next);
 
199
        }
 
200
}
 
201
 
175
202
/* centroid, boundbox, of selection */
176
203
/* returns total items selected */
177
204
int calc_manipulator_stats(ScrArea *sa)
203
230
                if(G.obedit->type==OB_MESH) {
204
231
                        EditMesh *em = G.editMesh;
205
232
                        EditVert *eve;
206
 
                        float vec[3];
 
233
                        float vec[3]= {0,0,0};
207
234
                        int no_faces= 1;
208
235
                        
209
 
                        if(v3d->twmode == V3D_MANIP_NORMAL) {
210
 
                                EditFace *efa;
211
 
                                
212
 
                                for(efa= em->faces.first; efa; efa= efa->next) {
213
 
                                        if(efa->f & SELECT) {
214
 
                                                no_faces= 0;
215
 
                                                VECADD(normal, normal, efa->n);
216
 
                                                VecSubf(vec, efa->v2->co, efa->v1->co);
217
 
                                                VECADD(plane, plane, vec);
218
 
                                        }
219
 
                                }
220
 
                        }
221
 
                        
222
 
                        /* do vertices for center, and if still no normal found, use vertex normals */
223
 
                        for(eve= em->verts.first; eve; eve= eve->next) {
224
 
                                if(eve->f & SELECT) {
225
 
                                        if(no_faces) VECADD(normal, normal, eve->no);
226
 
                                        
227
 
                                        totsel++;
228
 
                                        calc_tw_center(eve->co);
229
 
                                }
230
 
                        }
231
 
                        /* the edge case... */
232
 
                        if(no_faces && v3d->twmode == V3D_MANIP_NORMAL) {
233
 
                                EditEdge *eed;
234
 
                                
235
 
                                for(eed= em->edges.first; eed; eed= eed->next) {
236
 
                                        if(eed->f & SELECT) {
237
 
                                                /* ok we got an edge, only use one, and as normal */
238
 
                                                VECCOPY(plane, normal);
239
 
                                                VecSubf(normal, eed->v2->co, eed->v1->co);
240
 
                                                break;
241
 
                                        }
242
 
                                }
243
 
                        }
244
 
                }
 
236
                        /* USE LAST SELECTE WITH ACTIVE */
 
237
                        if (G.vd->around==V3D_ACTIVE && em->selected.last) {
 
238
                                EM_editselection_center(vec, em->selected.last);
 
239
                                calc_tw_center(vec);
 
240
                                totsel= 1;
 
241
                                if (v3d->twmode == V3D_MANIP_NORMAL) {
 
242
                                        EM_editselection_normal(normal, em->selected.last);
 
243
                                        EM_editselection_plane(plane, em->selected.last);
 
244
                                } /* NORMAL OPERATION */
 
245
                        } else {
 
246
                                if(v3d->twmode == V3D_MANIP_NORMAL) {
 
247
                                        EditFace *efa;
 
248
                                        
 
249
                                        for(efa= em->faces.first; efa; efa= efa->next) {
 
250
                                                if(efa->f & SELECT) {
 
251
                                                        no_faces= 0;
 
252
                                                        VECADD(normal, normal, efa->n);
 
253
                                                        VecSubf(vec, efa->v2->co, efa->v1->co);
 
254
                                                        VECADD(plane, plane, vec);
 
255
                                                }
 
256
                                        }
 
257
                                }
 
258
                                
 
259
                                /* do vertices for center, and if still no normal found, use vertex normals */
 
260
                                for(eve= em->verts.first; eve; eve= eve->next) {
 
261
                                        if(eve->f & SELECT) {
 
262
                                                if(no_faces) VECADD(normal, normal, eve->no);
 
263
                                                
 
264
                                                totsel++;
 
265
                                                calc_tw_center(eve->co);
 
266
                                        }
 
267
                                }
 
268
                                /* the edge case... */
 
269
                                if(no_faces && v3d->twmode == V3D_MANIP_NORMAL) {
 
270
                                        EditEdge *eed;
 
271
                                        
 
272
                                        for(eed= em->edges.first; eed; eed= eed->next) {
 
273
                                                if(eed->f & SELECT) {
 
274
                                                        /* ok we got an edge, only use one, and as normal */
 
275
                                                        VECCOPY(plane, normal);
 
276
                                                        VecSubf(normal, eed->v2->co, eed->v1->co);
 
277
                                                        break;
 
278
                                                }
 
279
                                        }
 
280
                                }
 
281
                        }
 
282
                } /* end editmesh */
245
283
                else if (G.obedit->type==OB_ARMATURE){
 
284
                        bArmature *arm= G.obedit->data;
246
285
                        EditBone *ebo;
247
286
                        for (ebo=G.edbo.first;ebo;ebo=ebo->next){
248
 
                                if (ebo->flag & BONE_TIPSEL) {
249
 
                                        calc_tw_center(ebo->tail);
250
 
                                        totsel++;
251
 
                                }
252
 
                                if (ebo->flag & BONE_ROOTSEL) {
253
 
                                        calc_tw_center(ebo->head);
254
 
                                        totsel++;
 
287
                                if(ebo->layer & arm->layer) {
 
288
                                        if (ebo->flag & BONE_TIPSEL) {
 
289
                                                calc_tw_center(ebo->tail);
 
290
                                                totsel++;
 
291
                                        }
 
292
                                        if (ebo->flag & BONE_ROOTSEL) {
 
293
                                                calc_tw_center(ebo->head);
 
294
                                                totsel++;
 
295
                                        }
255
296
                                }
256
297
                        }
257
298
                }
366
407
                
367
408
                /* count total, we use same method as transform will do */
368
409
                Trans.total= 0;
369
 
                count_bone_select(&Trans, &arm->bonebase, 1);
 
410
                count_bone_select(&Trans, arm, &arm->bonebase, 1);
370
411
                totsel= Trans.total;
371
412
                if(totsel) {
372
413
                        /* use channels to get stats */
1459
1500
        /* get rid of overlay button matrix */
1460
1501
        persp(PERSP_VIEW);
1461
1502
        
1462
 
        setwinmatrixview3d(&rect);
 
1503
        setwinmatrixview3d(sa->winx, sa->winy, &rect);
1463
1504
        Mat4MulMat4(v3d->persmat, v3d->viewmat, sa->winmat);
1464
1505
        
1465
1506
        glSelectBuffer( 64, buffer);
1481
1522
        hits= glRenderMode(GL_RENDER);
1482
1523
        
1483
1524
        G.f &= ~G_PICKSEL;
1484
 
        setwinmatrixview3d(0);
 
1525
        setwinmatrixview3d(sa->winx, sa->winy, NULL);
1485
1526
        Mat4MulMat4(v3d->persmat, v3d->viewmat, sa->winmat);
1486
1527
        
1487
1528
        persp(PERSP_WIN);