1ba6dd453454556fdf65fb752c70b803bb6bba0c
[blender.git] / source / blender / src / transform_generics.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <string.h>
34 #include <math.h>
35
36 #include "MEM_guardedalloc.h"
37
38 #include "DNA_action_types.h"
39 #include "DNA_armature_types.h"
40 #include "DNA_curve_types.h"
41 #include "DNA_lattice_types.h"
42 #include "DNA_scene_types.h"
43 #include "DNA_view3d_types.h"
44 #include "DNA_userdef_types.h"
45 #include "DNA_constraint_types.h"
46
47 #include "BIF_screen.h"
48 #include "BIF_resources.h"
49 #include "BIF_mywindow.h"
50 #include "BIF_gl.h"
51 #include "BIF_editarmature.h"
52 #include "BIF_editmesh.h"
53
54 #include "BKE_action.h"
55 #include "BKE_anim.h"
56 #include "BKE_armature.h"
57 #include "BKE_curve.h"
58 #include "BKE_depsgraph.h"
59 #include "BKE_displist.h"
60 #include "BKE_depsgraph.h"
61 #include "BKE_global.h"
62 #include "BKE_ipo.h"
63 #include "BKE_lattice.h"
64 #include "BKE_object.h"
65 #include "BKE_utildefines.h"
66
67 #include "BSE_view.h"
68
69 #include "BLI_arithb.h"
70 #include "BLI_blenlib.h"
71
72 #include "blendef.h"
73
74 #include "mydevice.h"
75
76 #include "transform.h"
77
78 extern ListBase editNurb;
79 extern ListBase editelems;
80
81 extern TransInfo Trans; /* From transform.c */
82
83 /* ************************** Functions *************************** */
84
85
86 void getViewVector(float coord[3], float vec[3]) {
87         if (G.vd->persp)
88         {
89                 float p1[4], p2[4];
90
91                 VECCOPY(p1, coord);
92                 p1[3] = 1.0f;
93                 VECCOPY(p2, p1);
94                 p2[3] = 1.0f;
95                 Mat4MulVec4fl(G.vd->viewmat, p2);
96
97                 p2[0] = 2.0f * p2[0];
98                 p2[1] = 2.0f * p2[1];
99                 p2[2] = 2.0f * p2[2];
100
101                 Mat4MulVec4fl(G.vd->viewinv, p2);
102
103                 VecSubf(vec, p1, p2);
104         }
105         else {
106                 VECCOPY(vec, G.vd->viewinv[2]);
107         }
108         Normalise(vec);
109 }
110
111 /* ************************** GENERICS **************************** */
112
113 /* if editbone (partial) selected, copy data */
114 /* context; editmode armature, with mirror editing enabled */
115 static void transform_armature_mirror_update(void)
116 {
117         EditBone *ebo, *eboflip;
118         
119         for (ebo=G.edbo.first; ebo; ebo=ebo->next) {
120                 if(ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) {
121                         
122                         eboflip= armature_bone_get_mirrored(ebo);
123                         
124                         if(eboflip) {
125                                 /* we assume X-axis flipping for now */
126                                 if(ebo->flag & BONE_TIPSEL) {
127                                         eboflip->tail[0]= -ebo->tail[0];
128                                         eboflip->tail[1]= ebo->tail[1];
129                                         eboflip->tail[2]= ebo->tail[2];
130                                         eboflip->rad_tail= ebo->rad_tail;
131                                 }
132                                 if(ebo->flag & BONE_ROOTSEL) {
133                                         eboflip->head[0]= -ebo->head[0];
134                                         eboflip->head[1]= ebo->head[1];
135                                         eboflip->head[2]= ebo->head[2];
136                                         eboflip->rad_head= ebo->rad_head;
137                                 }
138                                 if(ebo->flag & BONE_SELECTED)
139                                         eboflip->dist= ebo->dist;
140                         }
141                 }
142         }
143 }
144
145
146 /* called for objects updating while transform acts, once per redraw */
147 void recalcData(TransInfo *t)
148 {
149         
150         if (G.obedit) {
151                 if (G.obedit->type == OB_MESH) {
152                         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);  /* sets recalc flags */
153                         
154                         recalc_editnormals();
155                 }
156                 else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
157                         Nurb *nu= editNurb.first;
158                         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);  /* sets recalc flags */
159                         
160                         while(nu) {
161                                 test2DNurb(nu);
162                                 testhandlesNurb(nu); /* test for bezier too */
163                                 nu= nu->next;
164                         }
165                 }
166                 else if(G.obedit->type==OB_ARMATURE){   /* no recalc flag, does pose */
167                         bArmature *arm= G.obedit->data;
168                         EditBone *ebo;
169                         
170                         /* Ensure all bones are correctly adjusted */
171                         for (ebo=G.edbo.first; ebo; ebo=ebo->next){
172                                 
173                                 if ((ebo->flag & BONE_IK_TOPARENT) && ebo->parent){
174                                         /* If this bone has a parent tip that has been moved */
175                                         if (ebo->parent->flag & BONE_TIPSEL){
176                                                 VECCOPY (ebo->head, ebo->parent->tail);
177                                                 if(t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail;
178                                         }
179                                         /* If this bone has a parent tip that has NOT been moved */
180                                         else{
181                                                 VECCOPY (ebo->parent->tail, ebo->head);
182                                                 if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
183                                         }
184                                 }
185                                 
186                                 /* on extrude bones, oldlength==0.0f, so we scale radius of points */
187                                 if(ebo->oldlength==0.0f) {
188                                         ebo->rad_head= 0.25f*ebo->length;
189                                         ebo->rad_tail= 0.10f*ebo->length;
190                                         ebo->dist= 0.25f*ebo->length;
191                                         if(ebo->parent) {
192                                                 if(ebo->rad_head > ebo->parent->rad_tail)
193                                                         ebo->rad_head= ebo->parent->rad_tail;
194                                         }
195                                 }
196                                 else if(t->mode!=TFM_BONE_ENVELOPE) {
197                                         /* if bones change length, lets do that for the deform distance as well */
198                                         ebo->dist*= ebo->length/ebo->oldlength;
199                                         ebo->rad_head*= ebo->length/ebo->oldlength;
200                                         ebo->rad_tail*= ebo->length/ebo->oldlength;
201                                         ebo->oldlength= ebo->length;
202                                 }
203                         }
204                         if(arm->flag & ARM_MIRROR_EDIT) 
205                                 transform_armature_mirror_update();
206                         
207                 }
208                 else if(G.obedit->type==OB_LATTICE) {
209                         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);  /* sets recalc flags */
210                         
211                         if(editLatt->flag & LT_OUTSIDE) outside_lattice(editLatt);
212                 }
213                 else {
214                         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);  /* sets recalc flags */
215                 }
216         }
217         else if( (t->flag & T_POSE) && t->poseobj) {
218                 Object *ob= t->poseobj;
219                 bArmature *arm= ob->data;
220                 
221                 /* old optimize trick... this enforces to bypass the depgraph */
222                 if (!(arm->flag & ARM_DELAYDEFORM)) 
223                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);  /* sets recalc flags */
224                 else
225                         where_is_pose(ob);
226         }
227         else {
228                 Base *base;
229                 
230                 base= FIRSTBASE;
231                 while(base) {
232                         /* this flag is from depgraph, was stored in nitialize phase, handled in drawview.c */
233                         if(base->flag & BA_HAS_RECALC_OB)
234                                 base->object->recalc |= OB_RECALC_OB;
235                         if(base->flag & BA_HAS_RECALC_DATA)
236                                 base->object->recalc |= OB_RECALC_DATA;
237                         
238                         /* thanks to ob->ctime usage, ipos are not called in where_is_object,
239                            unless we edit ipokeys */
240                         if(base->flag & BA_DO_IPO) {
241                                 if(base->object->ipo) {
242                                         IpoCurve *icu;
243                                         
244                                         base->object->ctime= -1234567.0;
245                                         
246                                         icu= base->object->ipo->curve.first;
247                                         while(icu) {
248                                                 calchandles_ipocurve(icu);
249                                                 icu= icu->next;
250                                         }
251                                 }                               
252                         }
253                         
254                         base= base->next;
255                 } 
256         }
257         
258         /* update shaded drawmode while transform */
259         if(G.vd->drawtype == OB_SHADED) reshadeall_displist();
260         
261 }
262
263 void initTransModeFlags(TransInfo *t, int mode) 
264 {
265         t->mode = mode;
266         t->num.flag = 0;
267
268         /* REMOVING RESTRICTIONS FLAGS */
269         t->flag &= ~T_ALL_RESTRICTIONS;
270         
271         switch (mode) {
272         case TFM_RESIZE:
273                 t->flag |= T_NULL_ONE;
274                 t->num.flag |= NUM_NULL_ONE;
275                 t->num.flag |= NUM_AFFECT_ALL;
276                 if (!G.obedit) {
277                         t->flag |= T_NO_ZERO;
278                         t->num.flag |= NUM_NO_ZERO;
279                 }
280                 break;
281         case TFM_TOSPHERE:
282                 t->num.flag |= NUM_NULL_ONE;
283                 t->num.flag |= NUM_NO_NEGATIVE;
284                 t->flag |= T_NO_CONSTRAINT;
285                 break;
286         case TFM_SHEAR:
287         case TFM_CREASE:
288         case TFM_BONE_ENVELOPE:
289                 t->flag |= T_NO_CONSTRAINT;
290                 break;
291         }
292 }
293
294 void drawLine(float *center, float *dir, char axis, short options)
295 {
296         extern void make_axis_color(char *col, char *col2, char axis);  // drawview.c
297         float v1[3], v2[3], v3[3];
298         char col[3], col2[3];
299         
300         //if(G.obedit) mymultmatrix(G.obedit->obmat);   // sets opengl viewing
301
302         VecCopyf(v3, dir);
303         VecMulf(v3, G.vd->far);
304         
305         VecSubf(v2, center, v3);
306         VecAddf(v1, center, v3);
307
308         if (options & DRAWLIGHT) {
309                 col[0] = col[1] = col[2] = 220;
310         }
311         else {
312                 BIF_GetThemeColor3ubv(TH_GRID, col);
313         }
314         make_axis_color(col, col2, axis);
315         glColor3ubv(col2);
316
317         setlinestyle(0);
318         glBegin(GL_LINE_STRIP); 
319                 glVertex3fv(v1); 
320                 glVertex3fv(v2); 
321         glEnd();
322         
323         myloadmatrix(G.vd->viewmat);
324 }
325
326 void initTrans (TransInfo *t)
327 {
328         
329         /* moving: is shown in drawobject() (transform color) */
330         if(G.obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT;
331         else G.moving= G_TRANSFORM_OBJ;
332
333         t->data = NULL;
334         t->ext = NULL;
335
336         t->flag = 0;
337
338         /* setting PET flag */
339         if ((t->context & CTX_NO_PET) == 0 && (G.scene->proportional)) {
340                 t->flag |= T_PROP_EDIT;
341                 if(G.scene->proportional==2) t->flag |= T_PROP_CONNECTED;       // yes i know, has to become define
342         }
343
344         getmouseco_areawin(t->imval);
345         t->con.imval[0] = t->imval[0];
346         t->con.imval[1] = t->imval[1];
347
348         t->transform            = NULL;
349
350         t->total                        =
351                 t->num.idx              =
352                 t->num.idx_max  =
353                 t->num.ctrl[0]  = 
354                 t->num.ctrl[1]  = 
355                 t->num.ctrl[2]  = 0;
356
357         t->val = 0.0f;
358
359         t->num.val[0]           = 
360                 t->num.val[1]   = 
361                 t->num.val[2]   = 0.0f;
362
363         t->vec[0]                       =
364                 t->vec[1]               =
365                 t->vec[2]               = 0.0f;
366         
367         Mat3One(t->mat);
368         
369         Mat4CpyMat4(t->viewmat, G.vd->viewmat);
370         Mat4CpyMat4(t->viewinv, G.vd->viewinv);
371         Mat4CpyMat4(t->persinv, G.vd->persinv);
372 }
373
374 /* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
375 void postTrans (TransInfo *t) 
376 {
377         G.moving = 0; // Set moving flag off (display as usual)
378
379         stopConstraint(t);
380         
381         /* postTrans can be called when nothing is selected, so data is NULL already */
382         if (t->data) {
383                 TransData *td;
384                 int a;
385
386                 /* since ipokeys are optional on objects, we mallocced them per trans-data */
387                 for(a=0, td= t->data; a<t->total; a++, td++) {
388                         if(td->tdi) MEM_freeN(td->tdi);
389                 }
390                 MEM_freeN(t->data);
391         }
392
393         if (t->ext) MEM_freeN(t->ext);
394         
395 }
396
397 static void apply_grid3(float *val, int max_index, float fac1, float fac2, float fac3)
398 {
399         /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
400         int invert = U.flag & USER_AUTOGRABGRID;
401         int ctrl;
402         int i;
403
404         for (i=0; i<=max_index; i++) {
405
406                 if(invert) {
407                         if(G.qual & LR_CTRLKEY) ctrl= 0;
408                         else ctrl= 1;
409                 }
410                 else ctrl= (G.qual & LR_CTRLKEY);
411
412                 if(ctrl && (G.qual & LR_SHIFTKEY)) {
413                         if(fac3!= 0.0) {
414                                 for (i=0; i<=max_index; i++) {
415                                         val[i]= fac3*(float)floor(val[i]/fac3 +.5);
416                                 }
417                         }
418                 }
419                 else if(ctrl) {
420                         if(fac2!= 0.0) {
421                                 for (i=0; i<=max_index; i++) {
422                                         val[i]= fac2*(float)floor(val[i]/fac2 +.5);
423                                 }
424                         }
425                 }
426                 else {
427                         if(fac1!= 0.0) {
428                                 for (i=0; i<=max_index; i++) {
429                                         val[i]= fac1*(float)floor(val[i]/fac1 +.5);
430                                 }
431                         }
432                 }
433         }
434 }
435
436 void snapGrid(TransInfo *t, float *val) {
437         apply_grid3(val, t->idx_max, t->snap[0], t->snap[1], t->snap[2]);
438 }
439
440 void applyTransObjects(TransInfo *t)
441 {
442         TransData *td;
443         
444         for (td = t->data; td < t->data + t->total; td++) {
445                 VECCOPY(td->iloc, td->loc);
446                 if (td->ext->rot) {
447                         VECCOPY(td->ext->irot, td->ext->rot);
448                 }
449                 if (td->ext->size) {
450                         VECCOPY(td->ext->isize, td->ext->size);
451                 }
452         }       
453         recalcData(t);
454
455
456 /* helper for below */
457 static void restore_ipokey(float *poin, float *old)
458 {
459         if(poin) {
460                 poin[0]= old[0];
461                 poin[-3]= old[3];
462                 poin[3]= old[6];
463         }
464 }
465
466 static void restoreElement(TransData *td) {
467         /* TransData for crease has no loc */
468         if (td->loc) {
469                 VECCOPY(td->loc, td->iloc);
470         }
471         if (td->val) {
472                 *td->val = td->ival;
473         }
474         if (td->ext) {
475                 if (td->ext->rot) {
476                         VECCOPY(td->ext->rot, td->ext->irot);
477                 }
478                 if (td->ext->size) {
479                         VECCOPY(td->ext->size, td->ext->isize);
480                 }
481                 if(td->flag & TD_USEQUAT) {
482                         if (td->ext->quat) {
483                                 QUATCOPY(td->ext->quat, td->ext->iquat);
484                         }
485                 }
486         }
487         if(td->tdi) {
488                 TransDataIpokey *tdi= td->tdi;
489                 
490                 restore_ipokey(tdi->locx, tdi->oldloc);
491                 restore_ipokey(tdi->locy, tdi->oldloc+1);
492                 restore_ipokey(tdi->locz, tdi->oldloc+2);
493
494                 restore_ipokey(tdi->rotx, tdi->oldrot);
495                 restore_ipokey(tdi->roty, tdi->oldrot+1);
496                 restore_ipokey(tdi->rotz, tdi->oldrot+2);
497                 
498                 restore_ipokey(tdi->sizex, tdi->oldsize);
499                 restore_ipokey(tdi->sizey, tdi->oldsize+1);
500                 restore_ipokey(tdi->sizez, tdi->oldsize+2);
501         }
502 }
503
504 void restoreTransObjects(TransInfo *t)
505 {
506         TransData *td;
507         
508         for (td = t->data; td < t->data + t->total; td++) {
509                 restoreElement(td);
510         }       
511         recalcData(t);
512
513
514 void calculateCenterCursor(TransInfo *t)
515 {
516         float *cursor;
517
518         cursor = give_cursor();
519         VECCOPY(t->center, cursor);
520
521         if(t->flag & (T_EDIT|T_POSE)) {
522                 Object *ob= G.obedit?G.obedit:t->poseobj;
523                 float mat[3][3], imat[3][3];
524                 float vec[3];
525                 
526                 VecSubf(t->center, t->center, ob->obmat[3]);
527                 Mat3CpyMat4(mat, ob->obmat);
528                 Mat3Inv(imat, mat);
529                 Mat3MulVecfl(imat, t->center);
530                 
531                 VECCOPY(vec, t->center);
532                 Mat4MulVecfl(ob->obmat, vec);
533                 project_int(vec, t->center2d);
534         }
535         else {
536                 project_int(t->center, t->center2d);
537         }
538 }
539
540 void calculateCenterMedian(TransInfo *t)
541 {
542         float partial[3] = {0.0f, 0.0f, 0.0f};
543         int i;
544         for(i = 0; i < t->total; i++) {
545                 if (t->data[i].flag & TD_SELECTED) {
546                         VecAddf(partial, partial, t->data[i].center);
547                 }
548                 else {
549                         /* 
550                            All the selected elements are at the head of the array 
551                            which means we can stop when it finds unselected data
552                         */
553                         break;
554                 }
555         }
556         VecMulf(partial, 1.0f / i);
557         VECCOPY(t->center, partial);
558
559         if (t->flag & (T_EDIT|T_POSE)) {
560                 Object *ob= G.obedit?G.obedit:t->poseobj;
561                 float vec[3];
562                 
563                 VECCOPY(vec, t->center);
564                 Mat4MulVecfl(ob->obmat, vec);
565                 project_int(vec, t->center2d);
566         }
567         else {
568                 project_int(t->center, t->center2d);
569         }
570 }
571
572 void calculateCenterBound(TransInfo *t)
573 {
574         float max[3];
575         float min[3];
576         int i;
577         for(i = 0; i < t->total; i++) {
578                 if (i) {
579                         if (t->data[i].flag & TD_SELECTED) {
580                                 MinMax3(min, max, t->data[i].center);
581                         }
582                         else {
583                                 /* 
584                                    All the selected elements are at the head of the array 
585                                    which means we can stop when it finds unselected data
586                                 */
587                                 break;
588                         }
589                 }
590                 else {
591                         VECCOPY(max, t->data[i].center);
592                         VECCOPY(min, t->data[i].center);
593                 }
594         }
595         VecAddf(t->center, min, max);
596         VecMulf(t->center, 0.5);
597
598         if (t->flag & (T_EDIT|T_POSE)) {
599                 Object *ob= G.obedit?G.obedit:t->poseobj;
600                 float vec[3];
601                 
602                 VECCOPY(vec, t->center);
603                 Mat4MulVecfl(ob->obmat, vec);
604                 project_int(vec, t->center2d);
605         }
606         else {
607                 project_int(t->center, t->center2d);
608         }
609 }
610
611 void calculateCenter(TransInfo *t) 
612 {
613         switch(G.vd->around) {
614         case V3D_CENTRE:
615                 calculateCenterBound(t);
616                 break;
617         case V3D_CENTROID:
618                 calculateCenterMedian(t);
619                 break;
620         case V3D_CURSOR:
621                 calculateCenterCursor(t);
622                 break;
623         case V3D_LOCAL:
624                 /* Individual element center uses median center for helpline and such */
625                 calculateCenterMedian(t);
626                 break;
627         case V3D_ACTIVE:
628                 /* set median, and if if if... do object center */
629                 calculateCenterMedian(t);
630                 if((t->flag & (T_EDIT|T_POSE))==0) {
631                         Object *ob= OBACT;
632                         if(ob) {
633                                 VECCOPY(t->center, ob->obmat[3]);
634                                 project_int(t->center, t->center2d);
635                         }
636                 }
637                 
638         }
639
640         /* setting constraint center */
641         VECCOPY(t->con.center, t->center);
642         if(t->flag & (T_EDIT|T_POSE)) {
643                 Object *ob= G.obedit?G.obedit:t->poseobj;
644                 Mat4MulVecfl(ob->obmat, t->con.center);
645         }
646
647         /* voor panning from cameraview */
648         if(t->flag & T_OBJECT) {
649                 if( G.vd->camera==OBACT && G.vd->persp>1) {
650                         float axis[3];
651                         /* persinv is nasty, use viewinv instead, always right */
652                         VECCOPY(axis, G.vd->viewinv[2]);
653                         Normalise(axis);
654
655                         /* 6.0 = 6 grid units */
656                         axis[0]= t->center[0]- 6.0f*axis[0];
657                         axis[1]= t->center[1]- 6.0f*axis[1];
658                         axis[2]= t->center[2]- 6.0f*axis[2];
659                         
660                         project_int(axis, t->center2d);
661                         
662                         /* rotate only needs correct 2d center, grab needs initgrabz() value */
663                         if(t->mode==TFM_TRANSLATION) VECCOPY(t->center, axis);
664                 }
665         }       
666         initgrabz(t->center[0], t->center[1], t->center[2]);
667 }
668
669 void calculatePropRatio(TransInfo *t)
670 {
671         TransData *td = t->data;
672         int i;
673         float dist;
674         short connected = t->flag & T_PROP_CONNECTED;
675
676         if (t->flag & T_PROP_EDIT) {
677                 for(i = 0 ; i < t->total; i++, td++) {
678                         if (td->flag & TD_SELECTED) {
679                                 td->factor = 1.0f;
680                         }
681                         else if ((connected && 
682                                                 (td->flag & TD_NOTCONNECTED || td->dist > t->propsize))
683                                 ||
684                                         (connected == 0 &&
685                                                 td->rdist > t->propsize)) {
686                                 /* 
687                                    The elements are sorted according to their dist member in the array,
688                                    that means we can stop when it finds one element outside of the propsize.
689                                 */
690                                 td->flag |= TD_NOACTION;
691                                 td->factor = 0.0f;
692                                 restoreElement(td);
693                         }
694                         else {
695                                 /* Use rdist for falloff calculations, it is the real distance */
696                                 td->flag &= ~TD_NOACTION;
697                                 dist= (t->propsize-td->rdist)/t->propsize;
698                                 switch(G.scene->prop_mode) {
699                                 case PROP_SHARP:
700                                         td->factor= dist*dist;
701                                         break;
702                                 case PROP_SMOOTH:
703                                         td->factor= 3.0f*dist*dist - 2.0f*dist*dist*dist;
704                                         break;
705                                 case PROP_ROOT:
706                                         td->factor = (float)sqrt(dist);
707                                         break;
708                                 case PROP_LIN:
709                                         td->factor = dist;
710                                         break;
711                                 case PROP_CONST:
712                                         td->factor = 1.0f;
713                                         break;
714                                 case PROP_SPHERE:
715                                         td->factor = (float)sqrt(2*dist - dist * dist);
716                                         break;
717                                 default:
718                                         td->factor = 1;
719                                 }
720                         }
721                 }
722                 switch(G.scene->prop_mode) {
723                 case PROP_SHARP:
724                         strcpy(t->proptext, "(Sharp)");
725                         break;
726                 case PROP_SMOOTH:
727                         strcpy(t->proptext, "(Smooth)");
728                         break;
729                 case PROP_ROOT:
730                         strcpy(t->proptext, "(Root)");
731                         break;
732                 case PROP_LIN:
733                         strcpy(t->proptext, "(Linear)");
734                         break;
735                 case PROP_CONST:
736                         strcpy(t->proptext, "(Constant)");
737                         break;
738                 case PROP_SPHERE:
739                         strcpy(t->proptext, "(Sphere)");
740                         break;
741                 default:
742                         strcpy(t->proptext, "");
743                 }
744         }
745         else {
746                 for(i = 0 ; i < t->total; i++, td++) {
747                         td->factor = 1.0;
748                 }
749                 strcpy(t->proptext, "");
750         }
751 }
752
753 TransInfo * BIF_GetTransInfo() {
754         return &Trans;
755 }
756