136
155
MirrorModifierData *mmd = (MirrorModifierData*) md;
138
157
if(mmd->flag & MOD_MIR_CLIPPING) {
142
tolerance[0] = mmd->tolerance;
146
tolerance[1] = mmd->tolerance;
150
tolerance[2] = mmd->tolerance;
156
TransData *td = t->data;
159
if(mmd->flag & MOD_MIR_AXIS_X) {
161
tolerance[0] = mmd->tolerance;
163
if(mmd->flag & MOD_MIR_AXIS_Y) {
165
tolerance[1] = mmd->tolerance;
167
if(mmd->flag & MOD_MIR_AXIS_Z) {
169
tolerance[2] = mmd->tolerance;
172
float mtx[4][4], imtx[4][4];
174
TransData *td = t->data;
159
for(i = 0 ; i < t->total; i++, td++) {
160
if (td->flag & TD_NOACTION)
166
if(fabs(td->iloc[0])<=tolerance[0] || td->loc[0]*td->iloc[0]<0.0f) td->loc[0]= 0.0f;
170
if(fabs(td->iloc[1])<=tolerance[1] || td->loc[1]*td->iloc[1]<0.0f) td->loc[1]= 0.0f;
173
if(fabs(td->iloc[2])<=tolerance[2] || td->loc[2]*td->iloc[2]<0.0f) td->loc[2]= 0.0f;
176
if (mmd->mirror_ob) {
179
Mat4Invert(obinv, mmd->mirror_ob->obmat);
180
Mat4MulMat4(mtx, ob->obmat, obinv);
181
Mat4Invert(imtx, mtx);
184
for(i = 0 ; i < t->total; i++, td++) {
186
float loc[3], iloc[3];
188
if (td->flag & TD_NOACTION)
193
if (td->flag & TD_SKIP)
196
VecCopyf(loc, td->loc);
197
VecCopyf(iloc, td->iloc);
199
if (mmd->mirror_ob) {
200
VecMat4MulVecfl(loc, mtx, loc);
201
VecMat4MulVecfl(iloc, mtx, iloc);
206
if(fabs(iloc[0])<=tolerance[0] ||
207
loc[0]*iloc[0]<0.0f) {
214
if(fabs(iloc[1])<=tolerance[1] ||
215
loc[1]*iloc[1]<0.0f) {
221
if(fabs(iloc[2])<=tolerance[2] ||
222
loc[2]*iloc[2]<0.0f) {
228
if (mmd->mirror_ob) {
229
VecMat4MulVecfl(loc, imtx, loc);
231
VecCopyf(td->loc, loc);
202
266
void recalcData(TransInfo *t)
270
struct TransData *td;
273
if (t->spacetype == SPACE_ACTION) {
278
/* determine what type of data we are operating on */
279
data = get_action_context(&context);
280
if (data == NULL) return;
282
if (G.saction->lock) {
283
if (context == ACTCONT_ACTION) {
285
ob->ctime= -1234567.0f;
286
if(ob->pose || ob_get_key(ob))
287
DAG_object_flush_update(G.scene, ob, OB_RECALC);
289
DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
292
else if (context == ACTCONT_SHAPEKEY) {
293
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_OB|OB_RECALC_DATA);
297
else if (t->spacetype == SPACE_NLA) {
299
for (base=G.scene->base.first; base; base=base->next) {
300
if (base->flag & BA_HAS_RECALC_OB)
301
base->object->recalc |= OB_RECALC_OB;
302
if (base->flag & BA_HAS_RECALC_DATA)
303
base->object->recalc |= OB_RECALC_DATA;
305
if (base->object->recalc)
306
base->object->ctime= -1234567.0f; // eveil!
308
/* recalculate scale of selected nla-strips */
309
if (base->object->nlastrips.first) {
310
Object *bob= base->object;
313
for (strip= bob->nlastrips.first; strip; strip= strip->next) {
314
if (strip->flag & ACTSTRIP_SELECT) {
315
float actlen= strip->actend - strip->actstart;
316
float len= strip->end - strip->start;
318
strip->scale= len / (actlen * strip->repeat);
324
DAG_scene_flush_update(G.scene, screen_view3d_layers(), 0);
327
for (base=G.scene->base.first; base; base=base->next) {
328
/* recalculate scale of selected nla-strips */
329
if (base->object->nlastrips.first) {
330
Object *bob= base->object;
333
for (strip= bob->nlastrips.first; strip; strip= strip->next) {
334
if (strip->flag & ACTSTRIP_SELECT) {
335
float actlen= strip->actend - strip->actstart;
336
float len= strip->end - strip->start;
338
/* prevent 'negative' scaling */
340
SWAP(float, strip->start, strip->end);
344
/* calculate new scale */
345
strip->scale= len / (actlen * strip->repeat);
352
else if (t->spacetype == SPACE_IPO) {
357
/* do the flush first */
358
flushTransIpoData(t);
360
/* now test if there is a need to re-sort */
362
for (a=0; a<G.sipo->totipo; a++, ei++) {
363
if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
365
/* watch it: if the time is wrong: do not correct handles */
366
if (test_time_ipocurve(ei->icu)) {
369
calchandles_ipocurve(ei->icu);
374
/* do resort and other updates? */
375
if (dosort) remake_ipo_transdata(t);
376
if (G.sipo->showkey) update_ipokey_val();
378
calc_ipo(G.sipo->ipo, (float)CFRA);
380
/* update realtime - not working? */
382
if (G.sipo->blocktype==ID_MA || G.sipo->blocktype==ID_TE) {
385
else if(G.sipo->blocktype==ID_CA) {
388
else if(G.sipo->blocktype==ID_KE) {
391
ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
392
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
395
else if(G.sipo->blocktype==ID_PO) {
398
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
401
else if(G.sipo->blocktype==ID_OB) {
402
Base *base= FIRSTBASE;
405
if(base->object->ipo==G.sipo->ipo) {
406
do_ob_ipo(base->object);
407
base->object->recalc |= OB_RECALC_OB;
411
DAG_scene_flush_update(G.scene, screen_view3d_layers(), 0);
207
416
if (G.obedit->type == OB_MESH) {
209
/* mirror modifier clipping? */
210
if(t->state != TRANS_CANCEL)
211
clipMirrorModifier(t, G.obedit);
213
if(G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR)
214
editmesh_apply_to_mirror(t);
216
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
218
recalc_editnormals();
417
if(t->spacetype==SPACE_IMAGE) {
419
if (G.sima->flag & SI_LIVE_UNWRAP)
420
unwrap_lscm_live_re_solve();
422
/* mirror modifier clipping? */
423
if(t->state != TRANS_CANCEL) {
424
if ((G.qual & LR_CTRLKEY)==0) {
425
/* Only retopo if not snapping, Note, this is the only case of G.qual being used, but we have no T_SHIFT_MOD - Campbell */
428
clipMirrorModifier(t, G.obedit);
430
if((t->context & CTX_NO_MIRROR) == 0 && (G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR))
431
editmesh_apply_to_mirror(t);
433
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
435
recalc_editnormals();
220
438
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
221
439
Nurb *nu= editNurb.first;
222
440
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); /* sets recalc flags */
226
testhandlesNurb(nu); /* test for bezier too */
442
if (t->state == TRANS_CANCEL) {
444
calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
448
/* Normal updating */
230
457
else if(G.obedit->type==OB_ARMATURE){ /* no recalc flag, does pose */
286
513
/* old optimize trick... this enforces to bypass the depgraph */
287
514
if (!(arm->flag & ARM_DELAYDEFORM)) {
288
515
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); /* sets recalc flags */
290
/* bah, softbody exception... recalcdata doesnt reset */
291
for(base= FIRSTBASE; base; base= base->next) {
292
if(base->object->recalc & OB_RECALC_DATA)
293
if(modifiers_isSoftbodyEnabled(base->object)) {
294
base->object->softflag |= OB_SB_REDO;
299
518
where_is_pose(ob);
301
else if(t->spacetype==SPACE_IMAGE) {
303
if (G.sima->flag & SI_LIVE_UNWRAP)
304
unwrap_lscm_live_re_solve();
520
else if(G.f & G_PARTICLEEDIT) {
521
flushTransParticles(t);
307
524
for(base= FIRSTBASE; base; base= base->next) {
308
/* this flag is from depgraph, was stored in nitialize phase, handled in drawview.c */
525
Object *ob= base->object;
527
/* this flag is from depgraph, was stored in initialize phase, handled in drawview.c */
309
528
if(base->flag & BA_HAS_RECALC_OB)
310
base->object->recalc |= OB_RECALC_OB;
529
ob->recalc |= OB_RECALC_OB;
311
530
if(base->flag & BA_HAS_RECALC_DATA)
312
base->object->recalc |= OB_RECALC_DATA;
531
ob->recalc |= OB_RECALC_DATA;
314
533
/* thanks to ob->ctime usage, ipos are not called in where_is_object,
315
534
unless we edit ipokeys */
316
535
if(base->flag & BA_DO_IPO) {
317
if(base->object->ipo) {
320
base->object->ctime= -1234567.0;
539
ob->ctime= -1234567.0;
322
icu= base->object->ipo->curve.first;
541
icu= ob->ipo->curve.first;
324
543
calchandles_ipocurve(icu);
446
679
t->vec[2] = 0.0f;
450
687
t->spacetype = curarea->spacetype;
451
688
if(t->spacetype==SPACE_VIEW3D) {
452
689
if(G.vd->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
453
690
t->around = G.vd->around;
691
} else if(t->spacetype==SPACE_IMAGE) {
692
t->around = G.v2d->around;
456
t->around = V3D_CENTRE;
695
t->around = V3D_CENTER;
458
697
setTransformViewMatrices(t);
698
initNDofInput(&(t->ndof));
461
701
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
462
702
void postTrans (TransInfo *t)
464
706
G.moving = 0; // Set moving flag off (display as usual)
709
for (td = t->data; td < t->data + t->total; td++) {
710
if(td->flag & TD_VERSE_VERT) {
711
if(td->verse) send_versevert_pos((VerseVert*)td->verse);
713
else if(td->flag & TD_VERSE_OBJECT) {
716
vnode = (VNode*)((Object*)td->verse)->vnode;
717
((VObjectData*)vnode->data)->flag |= POS_SEND_READY;
718
((VObjectData*)vnode->data)->flag |= ROT_SEND_READY;
719
((VObjectData*)vnode->data)->flag |= SCALE_SEND_READY;
720
b_verse_send_transformation((Object*)td->verse);
466
726
stopConstraint(t);
468
728
/* postTrans can be called when nothing is selected, so data is NULL already */
473
732
/* since ipokeys are optional on objects, we mallocced them per trans-data */
474
733
for(a=0, td= t->data; a<t->total; a++, td++) {
475
734
if(td->tdi) MEM_freeN(td->tdi);
735
if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->hdata);
477
737
MEM_freeN(t->data);
492
static void apply_grid3(TransInfo *t, float *val, int max_index, float fac1, float fac2, float fac3)
494
/* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
500
if(t->mode==TFM_ROTATION || t->mode==TFM_WARP || t->mode==TFM_TILT || t->mode==TFM_TRACKBALL)
501
invert = U.flag & USER_AUTOROTGRID;
502
else if(t->mode==TFM_RESIZE || t->mode==TFM_SHEAR || t->mode==TFM_BONESIZE || t->mode==TFM_SHRINKFATTEN)
503
invert = U.flag & USER_AUTOSIZEGRID;
505
invert = U.flag & USER_AUTOGRABGRID;
507
for (i=0; i<=max_index; i++) {
509
/* evil hack - snapping needs to be adapted for image aspect ratio */
510
if((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
512
transform_aspect_ratio_tface_uv(&aspx, &aspy);
518
if(G.qual & LR_CTRLKEY) ctrl= 0;
521
else ctrl= (G.qual & LR_CTRLKEY);
523
if(ctrl && (G.qual & LR_SHIFTKEY)) {
525
for (i=0; i<=max_index; i++) {
526
val[i]= fac3*asp*(float)floor(val[i]/(fac3*asp) +.5);
532
for (i=0; i<=max_index; i++) {
533
val[i]= fac2*asp*(float)floor(val[i]/(fac2*asp) +.5);
539
for (i=0; i<=max_index; i++) {
540
val[i]= fac1*asp*(float)floor(val[i]/(fac1*asp) +.5);
547
void snapGrid(TransInfo *t, float *val) {
548
apply_grid3(t, val, t->idx_max, t->snap[0], t->snap[1], t->snap[2]);
551
752
void applyTransObjects(TransInfo *t)