A couple of smaller fixes;
[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                         }
197                         if(arm->flag & ARM_MIRROR_EDIT) 
198                                 transform_armature_mirror_update();
199                         
200                 }
201                 else if(G.obedit->type==OB_LATTICE) {
202                         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);  /* sets recalc flags */
203                         
204                         if(editLatt->flag & LT_OUTSIDE) outside_lattice(editLatt);
205                 }
206                 else {
207                         DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);  /* sets recalc flags */
208                 }
209         }
210         else if( (t->flag & T_POSE) && t->poseobj) {
211                 Object *ob= t->poseobj;
212                 bArmature *arm= ob->data;
213                 
214                 /* old optimize trick... this enforces to bypass the depgraph */
215                 if (!(arm->flag & ARM_DELAYDEFORM)) 
216                         DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);  /* sets recalc flags */
217                 else
218                         where_is_pose(ob);
219         }
220         else {
221                 Base *base;
222                 
223                 base= FIRSTBASE;
224                 while(base) {
225                         /* this flag is from depgraph, was stored in nitialize phase, handled in drawview.c */
226                         if(base->flag & BA_HAS_RECALC_OB)
227                                 base->object->recalc |= OB_RECALC_OB;
228                         if(base->flag & BA_HAS_RECALC_DATA)
229                                 base->object->recalc |= OB_RECALC_DATA;
230                         
231                         /* thanks to ob->ctime usage, ipos are not called in where_is_object,
232                            unless we edit ipokeys */
233                         if(base->flag & BA_DO_IPO) {
234                                 if(base->object->ipo) {
235                                         IpoCurve *icu;
236                                         
237                                         base->object->ctime= -1234567.0;
238                                         
239                                         icu= base->object->ipo->curve.first;
240                                         while(icu) {
241                                                 calchandles_ipocurve(icu);
242                                                 icu= icu->next;
243                                         }
244                                 }                               
245                         }
246                         
247                         base= base->next;
248                 } 
249         }
250         
251         /* update shaded drawmode while transform */
252         if(G.vd->drawtype == OB_SHADED) reshadeall_displist();
253         
254 }
255
256 void initTransModeFlags(TransInfo *t, int mode) 
257 {
258         t->mode = mode;
259         t->num.flag = 0;
260
261         /* REMOVING RESTRICTIONS FLAGS */
262         t->flag &= ~T_ALL_RESTRICTIONS;
263         
264         switch (mode) {
265         case TFM_RESIZE:
266                 t->flag |= T_NULL_ONE;
267                 t->num.flag |= NUM_NULL_ONE;
268                 t->num.flag |= NUM_AFFECT_ALL;
269                 if (!G.obedit) {
270                         t->flag |= T_NO_ZERO;
271                         t->num.flag |= NUM_NO_ZERO;
272                 }
273                 break;
274         case TFM_TOSPHERE:
275                 t->num.flag |= NUM_NULL_ONE;
276                 t->num.flag |= NUM_NO_NEGATIVE;
277                 t->flag |= T_NO_CONSTRAINT;
278                 break;
279         case TFM_SHEAR:
280         case TFM_CREASE:
281         case TFM_BONE_ENVELOPE:
282                 t->flag |= T_NO_CONSTRAINT;
283                 break;
284         }
285 }
286
287 void drawLine(float *center, float *dir, char axis, short options)
288 {
289         extern void make_axis_color(char *col, char *col2, char axis);  // drawview.c
290         float v1[3], v2[3], v3[3];
291         char col[3], col2[3];
292         
293         //if(G.obedit) mymultmatrix(G.obedit->obmat);   // sets opengl viewing
294
295         VecCopyf(v3, dir);
296         VecMulf(v3, G.vd->far);
297         
298         VecSubf(v2, center, v3);
299         VecAddf(v1, center, v3);
300
301         if (options & DRAWLIGHT) {
302                 col[0] = col[1] = col[2] = 220;
303         }
304         else {
305                 BIF_GetThemeColor3ubv(TH_GRID, col);
306         }
307         make_axis_color(col, col2, axis);
308         glColor3ubv(col2);
309
310         setlinestyle(0);
311         glBegin(GL_LINE_STRIP); 
312                 glVertex3fv(v1); 
313                 glVertex3fv(v2); 
314         glEnd();
315         
316         myloadmatrix(G.vd->viewmat);
317 }
318
319 void initTrans (TransInfo *t)
320 {
321         
322         /* moving: is shown in drawobject() (transform color) */
323         if(G.obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT;
324         else G.moving= G_TRANSFORM_OBJ;
325
326         t->data = NULL;
327         t->ext = NULL;
328
329         t->flag = 0;
330
331         /* setting PET flag */
332         if ((t->context & CTX_NO_PET) == 0 && (G.scene->proportional)) {
333                 t->flag |= T_PROP_EDIT;
334                 if(G.scene->proportional==2) t->flag |= T_PROP_CONNECTED;       // yes i know, has to become define
335         }
336
337         getmouseco_areawin(t->imval);
338         t->con.imval[0] = t->imval[0];
339         t->con.imval[1] = t->imval[1];
340
341         t->transform            = NULL;
342
343         t->total                        =
344                 t->num.idx              =
345                 t->num.idx_max  =
346                 t->num.ctrl[0]  = 
347                 t->num.ctrl[1]  = 
348                 t->num.ctrl[2]  = 0;
349
350         t->val = 0.0f;
351
352         t->num.val[0]           = 
353                 t->num.val[1]   = 
354                 t->num.val[2]   = 0.0f;
355
356         t->vec[0]                       =
357                 t->vec[1]               =
358                 t->vec[2]               = 0.0f;
359         
360         Mat3One(t->mat);
361         
362         Mat4CpyMat4(t->viewmat, G.vd->viewmat);
363         Mat4CpyMat4(t->viewinv, G.vd->viewinv);
364         Mat4CpyMat4(t->persinv, G.vd->persinv);
365 }
366
367 /* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
368 void postTrans (TransInfo *t) 
369 {
370         G.moving = 0; // Set moving flag off (display as usual)
371
372         stopConstraint(t);
373         
374         /* postTrans can be called when nothing is selected, so data is NULL already */
375         if (t->data) {
376                 TransData *td;
377                 int a;
378
379                 /* since ipokeys are optional on objects, we mallocced them per trans-data */
380                 for(a=0, td= t->data; a<t->total; a++, td++) {
381                         if(td->tdi) MEM_freeN(td->tdi);
382                 }
383                 MEM_freeN(t->data);
384         }
385
386         if (t->ext) MEM_freeN(t->ext);
387         
388 }
389
390 static void apply_grid3(float *val, int max_index, float fac1, float fac2, float fac3)
391 {
392         /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
393         int invert = U.flag & USER_AUTOGRABGRID;
394         int ctrl;
395         int i;
396
397         for (i=0; i<=max_index; i++) {
398
399                 if(invert) {
400                         if(G.qual & LR_CTRLKEY) ctrl= 0;
401                         else ctrl= 1;
402                 }
403                 else ctrl= (G.qual & LR_CTRLKEY);
404
405                 if(ctrl && (G.qual & LR_SHIFTKEY)) {
406                         if(fac3!= 0.0) {
407                                 for (i=0; i<=max_index; i++) {
408                                         val[i]= fac3*(float)floor(val[i]/fac3 +.5);
409                                 }
410                         }
411                 }
412                 else if(ctrl) {
413                         if(fac2!= 0.0) {
414                                 for (i=0; i<=max_index; i++) {
415                                         val[i]= fac2*(float)floor(val[i]/fac2 +.5);
416                                 }
417                         }
418                 }
419                 else {
420                         if(fac1!= 0.0) {
421                                 for (i=0; i<=max_index; i++) {
422                                         val[i]= fac1*(float)floor(val[i]/fac1 +.5);
423                                 }
424                         }
425                 }
426         }
427 }
428
429 void snapGrid(TransInfo *t, float *val) {
430         apply_grid3(val, t->idx_max, t->snap[0], t->snap[1], t->snap[2]);
431 }
432
433 void applyTransObjects(TransInfo *t)
434 {
435         TransData *td;
436         
437         for (td = t->data; td < t->data + t->total; td++) {
438                 VECCOPY(td->iloc, td->loc);
439                 if (td->ext->rot) {
440                         VECCOPY(td->ext->irot, td->ext->rot);
441                 }
442                 if (td->ext->size) {
443                         VECCOPY(td->ext->isize, td->ext->size);
444                 }
445         }       
446         recalcData(t);
447
448
449 /* helper for below */
450 static void restore_ipokey(float *poin, float *old)
451 {
452         if(poin) {
453                 poin[0]= old[0];
454                 poin[-3]= old[3];
455                 poin[3]= old[6];
456         }
457 }
458
459 static void restoreElement(TransData *td) {
460         /* TransData for crease has no loc */
461         if (td->loc) {
462                 VECCOPY(td->loc, td->iloc);
463         }
464         if (td->val) {
465                 *td->val = td->ival;
466         }
467         if (td->ext) {
468                 if (td->ext->rot) {
469                         VECCOPY(td->ext->rot, td->ext->irot);
470                 }
471                 if (td->ext->size) {
472                         VECCOPY(td->ext->size, td->ext->isize);
473                 }
474                 if(td->flag & TD_USEQUAT) {
475                         if (td->ext->quat) {
476                                 QUATCOPY(td->ext->quat, td->ext->iquat);
477                         }
478                 }
479         }
480         if(td->tdi) {
481                 TransDataIpokey *tdi= td->tdi;
482                 
483                 restore_ipokey(tdi->locx, tdi->oldloc);
484                 restore_ipokey(tdi->locy, tdi->oldloc+1);
485                 restore_ipokey(tdi->locz, tdi->oldloc+2);
486
487                 restore_ipokey(tdi->rotx, tdi->oldrot);
488                 restore_ipokey(tdi->roty, tdi->oldrot+1);
489                 restore_ipokey(tdi->rotz, tdi->oldrot+2);
490                 
491                 restore_ipokey(tdi->sizex, tdi->oldsize);
492                 restore_ipokey(tdi->sizey, tdi->oldsize+1);
493                 restore_ipokey(tdi->sizez, tdi->oldsize+2);
494         }
495 }
496
497 void restoreTransObjects(TransInfo *t)
498 {
499         TransData *td;
500         
501         for (td = t->data; td < t->data + t->total; td++) {
502                 restoreElement(td);
503         }       
504         recalcData(t);
505
506
507 void calculateCenterCursor(TransInfo *t)
508 {
509         float *cursor;
510
511         cursor = give_cursor();
512         VECCOPY(t->center, cursor);
513
514         if(t->flag & (T_EDIT|T_POSE)) {
515                 Object *ob= G.obedit?G.obedit:t->poseobj;
516                 float mat[3][3], imat[3][3];
517                 float vec[3];
518                 
519                 VecSubf(t->center, t->center, ob->obmat[3]);
520                 Mat3CpyMat4(mat, ob->obmat);
521                 Mat3Inv(imat, mat);
522                 Mat3MulVecfl(imat, t->center);
523                 
524                 VECCOPY(vec, t->center);
525                 Mat4MulVecfl(ob->obmat, vec);
526                 project_int(vec, t->center2d);
527         }
528         else {
529                 project_int(t->center, t->center2d);
530         }
531 }
532
533 void calculateCenterMedian(TransInfo *t)
534 {
535         float partial[3] = {0.0f, 0.0f, 0.0f};
536         int i;
537         for(i = 0; i < t->total; i++) {
538                 if (t->data[i].flag & TD_SELECTED) {
539                         VecAddf(partial, partial, t->data[i].center);
540                 }
541                 else {
542                         /* 
543                            All the selected elements are at the head of the array 
544                            which means we can stop when it finds unselected data
545                         */
546                         break;
547                 }
548         }
549         VecMulf(partial, 1.0f / i);
550         VECCOPY(t->center, partial);
551
552         if (t->flag & (T_EDIT|T_POSE)) {
553                 Object *ob= G.obedit?G.obedit:t->poseobj;
554                 float vec[3];
555                 
556                 VECCOPY(vec, t->center);
557                 Mat4MulVecfl(ob->obmat, vec);
558                 project_int(vec, t->center2d);
559         }
560         else {
561                 project_int(t->center, t->center2d);
562         }
563 }
564
565 void calculateCenterBound(TransInfo *t)
566 {
567         float max[3];
568         float min[3];
569         int i;
570         for(i = 0; i < t->total; i++) {
571                 if (i) {
572                         if (t->data[i].flag & TD_SELECTED) {
573                                 MinMax3(min, max, t->data[i].center);
574                         }
575                         else {
576                                 /* 
577                                    All the selected elements are at the head of the array 
578                                    which means we can stop when it finds unselected data
579                                 */
580                                 break;
581                         }
582                 }
583                 else {
584                         VECCOPY(max, t->data[i].center);
585                         VECCOPY(min, t->data[i].center);
586                 }
587         }
588         VecAddf(t->center, min, max);
589         VecMulf(t->center, 0.5);
590
591         if (t->flag & (T_EDIT|T_POSE)) {
592                 Object *ob= G.obedit?G.obedit:t->poseobj;
593                 float vec[3];
594                 
595                 VECCOPY(vec, t->center);
596                 Mat4MulVecfl(ob->obmat, vec);
597                 project_int(vec, t->center2d);
598         }
599         else {
600                 project_int(t->center, t->center2d);
601         }
602 }
603
604 void calculateCenter(TransInfo *t) 
605 {
606         switch(G.vd->around) {
607         case V3D_CENTRE:
608                 calculateCenterBound(t);
609                 break;
610         case V3D_CENTROID:
611                 calculateCenterMedian(t);
612                 break;
613         case V3D_CURSOR:
614                 calculateCenterCursor(t);
615                 break;
616         case V3D_LOCAL:
617                 /* Individual element center uses median center for helpline and such */
618                 calculateCenterMedian(t);
619                 break;
620         case V3D_ACTIVE:
621                 /* set median, and if if if... do object center */
622                 calculateCenterMedian(t);
623                 if((t->flag & (T_EDIT|T_POSE))==0) {
624                         Object *ob= OBACT;
625                         if(ob) {
626                                 VECCOPY(t->center, ob->obmat[3]);
627                                 project_int(t->center, t->center2d);
628                         }
629                 }
630                 
631         }
632
633         /* setting constraint center */
634         VECCOPY(t->con.center, t->center);
635         if(t->flag & (T_EDIT|T_POSE)) {
636                 Object *ob= G.obedit?G.obedit:t->poseobj;
637                 Mat4MulVecfl(ob->obmat, t->con.center);
638         }
639
640         /* voor panning from cameraview */
641         if(t->flag & T_OBJECT) {
642                 if( G.vd->camera==OBACT && G.vd->persp>1) {
643                         float axis[3];
644                         /* persinv is nasty, use viewinv instead, always right */
645                         VECCOPY(axis, G.vd->viewinv[2]);
646                         Normalise(axis);
647
648                         /* 6.0 = 6 grid units */
649                         axis[0]= t->center[0]- 6.0f*axis[0];
650                         axis[1]= t->center[1]- 6.0f*axis[1];
651                         axis[2]= t->center[2]- 6.0f*axis[2];
652                         
653                         project_int(axis, t->center2d);
654                         
655                         /* rotate only needs correct 2d center, grab needs initgrabz() value */
656                         if(t->mode==TFM_TRANSLATION) VECCOPY(t->center, axis);
657                 }
658         }       
659         initgrabz(t->center[0], t->center[1], t->center[2]);
660 }
661
662 void calculatePropRatio(TransInfo *t)
663 {
664         TransData *td = t->data;
665         int i;
666         float dist;
667         short connected = t->flag & T_PROP_CONNECTED;
668
669         if (t->flag & T_PROP_EDIT) {
670                 for(i = 0 ; i < t->total; i++, td++) {
671                         if (td->flag & TD_SELECTED) {
672                                 td->factor = 1.0f;
673                         }
674                         else if ((connected && 
675                                                 (td->flag & TD_NOTCONNECTED || td->dist > t->propsize))
676                                 ||
677                                         (connected == 0 &&
678                                                 td->rdist > t->propsize)) {
679                                 /* 
680                                    The elements are sorted according to their dist member in the array,
681                                    that means we can stop when it finds one element outside of the propsize.
682                                 */
683                                 td->flag |= TD_NOACTION;
684                                 td->factor = 0.0f;
685                                 restoreElement(td);
686                         }
687                         else {
688                                 /* Use rdist for falloff calculations, it is the real distance */
689                                 td->flag &= ~TD_NOACTION;
690                                 dist= (t->propsize-td->rdist)/t->propsize;
691                                 switch(G.scene->prop_mode) {
692                                 case PROP_SHARP:
693                                         td->factor= dist*dist;
694                                         break;
695                                 case PROP_SMOOTH:
696                                         td->factor= 3.0f*dist*dist - 2.0f*dist*dist*dist;
697                                         break;
698                                 case PROP_ROOT:
699                                         td->factor = (float)sqrt(dist);
700                                         break;
701                                 case PROP_LIN:
702                                         td->factor = dist;
703                                         break;
704                                 case PROP_CONST:
705                                         td->factor = 1.0f;
706                                         break;
707                                 case PROP_SPHERE:
708                                         td->factor = (float)sqrt(2*dist - dist * dist);
709                                         break;
710                                 default:
711                                         td->factor = 1;
712                                 }
713                         }
714                 }
715                 switch(G.scene->prop_mode) {
716                 case PROP_SHARP:
717                         strcpy(t->proptext, "(Sharp)");
718                         break;
719                 case PROP_SMOOTH:
720                         strcpy(t->proptext, "(Smooth)");
721                         break;
722                 case PROP_ROOT:
723                         strcpy(t->proptext, "(Root)");
724                         break;
725                 case PROP_LIN:
726                         strcpy(t->proptext, "(Linear)");
727                         break;
728                 case PROP_CONST:
729                         strcpy(t->proptext, "(Constant)");
730                         break;
731                 case PROP_SPHERE:
732                         strcpy(t->proptext, "(Sphere)");
733                         break;
734                 default:
735                         strcpy(t->proptext, "");
736                 }
737         }
738         else {
739                 for(i = 0 ; i < t->total; i++, td++) {
740                         td->factor = 1.0;
741                 }
742                 strcpy(t->proptext, "");
743         }
744 }
745
746 TransInfo * BIF_GetTransInfo() {
747         return &Trans;
748 }
749