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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: editipo.c,v 1.24 2004/04/20 18:27:09 ton Exp $
 
2
 * $Id: editipo.c,v 1.54 2005/05/11 20:01:42 ton Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
51
51
#include <unistd.h>
52
52
#else
53
53
#include <io.h>
54
 
#include "BLI_winstuff.h"
55
54
#endif   
56
55
#include "MEM_guardedalloc.h"
57
56
#include "PIL_time.h"
62
61
#include "DNA_constraint_types.h"
63
62
#include "DNA_action_types.h"
64
63
#include "DNA_armature_types.h"
65
 
#include "DNA_object_types.h"
 
64
#include "DNA_camera_types.h"
 
65
#include "DNA_curve_types.h"
 
66
#include "DNA_group_types.h"
 
67
#include "DNA_ika_types.h"
 
68
#include "DNA_ipo_types.h"
 
69
#include "DNA_key_types.h"
66
70
#include "DNA_lamp_types.h"
67
 
#include "DNA_sequence_types.h"
68
 
#include "DNA_sound_types.h"
69
 
#include "DNA_camera_types.h"
70
71
#include "DNA_material_types.h"
71
 
#include "DNA_key_types.h"
 
72
#include "DNA_object_types.h"
72
73
#include "DNA_screen_types.h"
73
74
#include "DNA_scene_types.h"
74
 
#include "DNA_ipo_types.h"
75
 
#include "DNA_curve_types.h"
76
75
#include "DNA_space_types.h"
 
76
#include "DNA_sequence_types.h"
 
77
#include "DNA_sound_types.h"
 
78
#include "DNA_texture_types.h"
77
79
#include "DNA_userdef_types.h"
78
80
#include "DNA_view3d_types.h"
79
 
#include "DNA_group_types.h"
80
 
#include "DNA_ika_types.h"
 
81
#include "DNA_world_types.h"
81
82
 
82
83
#include "BKE_utildefines.h"
83
84
#include "BKE_action.h"
84
85
#include "BKE_anim.h"
85
86
#include "BKE_material.h"
 
87
#include "BKE_texture.h"
86
88
#include "BKE_ipo.h"
87
89
#include "BKE_key.h"
88
90
#include "BKE_ika.h"
116
118
 
117
119
#include "blendef.h"
118
120
#include "mydevice.h"
119
 
#include "render.h"
120
121
 
121
122
/* forwards */
122
123
#define BEZSELECTED(bezt)   (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
137
138
extern int snd_ar[];
138
139
extern int ac_ar[];
139
140
extern int co_ar[];
140
 
 
141
 
void getname_ac_ei(int nr, char *str)
142
 
{
 
141
extern int te_ar[];
 
142
 
 
143
char *ob_ic_names[OB_TOTNAM] = { "LocX", "LocY", "LocZ", "dLocX", "dLocY", "dLocZ",
 
144
                                                 "RotX", "RotY", "RotZ", "dRotX", "dRotY", "dRotZ",
 
145
                                                 "SizeX", "SizeY", "SizeZ", "dSizeX", "dSizeY", "dSizeZ",
 
146
                                                 "Layer", "Time", "ColR", "ColG", "ColB", "ColA",
 
147
                                                 "FStreng", "FFall", "RDamp", "Damping", "Perm" };
 
148
char *obeff_ic_names[3] = { "EffX", "EffY", "EffZ" };
 
149
char *co_ic_names[CO_TOTNAM] = { "Inf" };
 
150
char *mtex_ic_names[TEX_TOTNAM] = { "OfsX", "OfsY", "OfsZ", "SizeX", "SizeY", "SizeZ",
 
151
                                                  "texR", "texG", "texB", "DefVar", "Col", "Nor", "Var",
 
152
                                                  "Disp" };
 
153
char *tex_ic_names[TE_TOTNAM] = { "NSize", "NDepth", "NType", "Turb", "Vnw1", "Vnw2",
 
154
                                                                   "Vnw3", "Vnw4", "MinkMExp", "DistM", "ColT", "iScale",
 
155
                                                                   "DistA", "MgType", "MgH", "Lacu", "Oct", "MgOff",
 
156
                                                                   "MgGain", "NBase1", "NBase2" };
 
157
char *ma_ic_names[MA_TOTNAM] = { "R", "G", "B", "SpecR", "SpecG", "SpecB", "MirR",
 
158
                                                 "MirG", "MirB", "Ref", "Alpha", "Emit", "Amb", "Spec",
 
159
                                                 "Hard", "SpTra", "Ior", "Mode", "HaSize", "Translu",
 
160
                                                 "RayMir", "FresMir", "FresMirI", "FresTra", "FresTraI",
 
161
                                                 "TraGlow" };
 
162
char *seq_ic_names[SEQ_TOTNAM] = { "Fac" };
 
163
char *cu_ic_names[CU_TOTNAM] = { "Speed" };
 
164
char *key_ic_names[KEY_TOTNAM] = { "Speed", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5",
 
165
                                                                        "Key 6", "Key 7", "Key 8", "Key 9", "Key 10",
 
166
                                                                        "Key 11", "Key 12", "Key 13", "Key 14", "Key 15",
 
167
                                                                        "Key 16", "Key 17", "Key 18", "Key 19", "Key 20",
 
168
                                                                        "Key 21", "Key 22", "Key 23", "Key 24", "Key 25",
 
169
                                                                        "Key 26", "Key 27", "Key 28", "Key 29", "Key 30",
 
170
                                                                        "Key 31", "Key 32", "Key 33", "Key 34", "Key 35",
 
171
                                                                        "Key 36", "Key 37", "Key 38", "Key 39", "Key 40",
 
172
                                                                        "Key 41", "Key 42", "Key 43", "Key 44", "Key 45",
 
173
                                                                        "Key 46", "Key 47", "Key 48", "Key 49", "Key 50",
 
174
                                                                        "Key 51", "Key 52", "Key 53", "Key 54", "Key 55",
 
175
                                                                        "Key 56", "Key 57", "Key 58", "Key 59", "Key 60",
 
176
                                                                        "Key 61", "Key 62", "Key 63"};
 
177
char *wo_ic_names[WO_TOTNAM] = { "HorR", "HorG", "HorB", "ZenR", "ZenG", "ZenB", "Expos",
 
178
                                                 "Misi", "MisDi", "MisSta", "MisHi", "StarR", "StarB",
 
179
                                                 "StarG", "StarDi", "StarSi" };
 
180
char *la_ic_names[LA_TOTNAM] = { "Energ", "R", "G", "B", "Dist", "SpoSi", "SpoBl",
 
181
                                                                  "Quad1", "Quad2", "HaInt" };
 
182
/* yafray: two curve names added, 'Apert' for aperture, and 'FDist' for focal distance */
 
183
char *cam_ic_names[CAM_TOTNAM] = { "Lens", "ClSta", "ClEnd", "Apert", "FDist" };
 
184
char *snd_ic_names[SND_TOTNAM] = { "Vol", "Pitch", "Pan", "Atten" };
 
185
char *ac_ic_names[AC_TOTNAM] = {"LocX", "LocY", "LocZ", "SizeX", "SizeY",
 
186
                                                  "SizeZ", "QuatW", "QuatX", "QuatY", "QuatZ"};
 
187
char *ic_name_empty[1] ={ "" };
 
188
 
 
189
char *getname_ac_ei(int nr) {
143
190
        switch(nr) {
144
191
        case AC_LOC_X:
145
 
                strcpy(str, "LocX"); break;
146
192
        case AC_LOC_Y:
147
 
                strcpy(str, "LocY"); break;
148
193
        case AC_LOC_Z:
149
 
                strcpy(str, "LocZ"); break;
 
194
                return ac_ic_names[nr-1];
150
195
        case AC_SIZE_X:
151
 
                strcpy(str, "SizeX"); break;
152
196
        case AC_SIZE_Y:
153
 
                strcpy(str, "SizeY"); break;
154
197
        case AC_SIZE_Z:
155
 
                strcpy(str, "SizeZ"); break;
 
198
                return ac_ic_names[nr-10];
156
199
        case AC_QUAT_X:
157
 
                strcpy(str, "QuatX"); break;
158
200
        case AC_QUAT_Y:
159
 
                strcpy(str, "QuatY"); break;
160
201
        case AC_QUAT_Z:
161
 
                strcpy(str, "QuatZ"); break;
162
202
        case AC_QUAT_W:
163
 
                strcpy(str, "QuatW"); break;
 
203
                return ac_ic_names[nr-19];
164
204
        default:
165
 
                str[0]= 0;
166
 
        }       
 
205
                return ic_name_empty[0]; /* empty */
 
206
        }
167
207
}
168
208
 
169
 
void getname_co_ei(int nr, char *str)
 
209
char *getname_co_ei(int nr)
170
210
{
171
211
        switch(nr){
172
212
        case CO_ENFORCE:
173
 
                strcpy(str, "Inf"); break;
174
 
        }
175
 
}
176
 
 
177
 
void getname_ob_ei(int nr, char *str, int colipo)
178
 
{
179
 
        switch(nr) {
180
 
        case OB_LOC_X:
181
 
                strcpy(str, "LocX"); break;
182
 
        case OB_LOC_Y:
183
 
                strcpy(str, "LocY"); break;
184
 
        case OB_LOC_Z:
185
 
                strcpy(str, "LocZ"); break;
186
 
        case OB_DLOC_X:
187
 
                strcpy(str, "dLocX"); break;
188
 
        case OB_DLOC_Y:
189
 
                strcpy(str, "dLocY"); break;
190
 
        case OB_DLOC_Z:
191
 
                strcpy(str, "dLocZ"); break;
192
 
 
193
 
        case OB_ROT_X:
194
 
                strcpy(str, "RotX"); break;
195
 
        case OB_ROT_Y:
196
 
                strcpy(str, "RotY"); break;
197
 
        case OB_ROT_Z:
198
 
                strcpy(str, "RotZ"); break;
199
 
        case OB_DROT_X:
200
 
                strcpy(str, "dRotX"); break;
201
 
        case OB_DROT_Y:
202
 
                strcpy(str, "dRotY"); break;
203
 
        case OB_DROT_Z:
204
 
                strcpy(str, "dRotZ"); break;
205
 
                
206
 
        case OB_SIZE_X:
207
 
                strcpy(str, "SizeX"); break;
208
 
        case OB_SIZE_Y:
209
 
                strcpy(str, "SizeY"); break;
210
 
        case OB_SIZE_Z:
211
 
                strcpy(str, "SizeZ"); break;
212
 
        case OB_DSIZE_X:
213
 
                strcpy(str, "dSizeX"); break;
214
 
        case OB_DSIZE_Y:
215
 
                strcpy(str, "dSizeY"); break;
216
 
        case OB_DSIZE_Z:
217
 
                strcpy(str, "dSizeZ"); break;
 
213
                return co_ic_names[nr-1];
 
214
        }
 
215
        return ic_name_empty[0];
 
216
}
 
217
 
 
218
char *getname_ob_ei(int nr, int colipo)
 
219
{
 
220
        if(!colipo && (nr>=OB_EFF_X && nr <=OB_EFF_Z)) {
 
221
                return obeff_ic_names[nr-OB_EFF_X];
 
222
        } else {
 
223
                if(nr>=OB_LOC_X && nr <= OB_PD_PERM) return ob_ic_names[nr-1];
 
224
        }
 
225
        return ic_name_empty[0];
 
226
}
 
227
 
 
228
char *getname_tex_ei(int nr)
 
229
{
 
230
        if(nr>=TE_NSIZE && nr<=TE_N_BAS2) return tex_ic_names[nr-1];
 
231
 
 
232
        return ic_name_empty[0];
 
233
}
 
234
 
 
235
char *getname_mtex_ei(int nr)
 
236
{
 
237
        if(nr>=MAP_OFS_X && nr<=MAP_DISP) return mtex_ic_names[nr-1];
218
238
        
219
 
        case OB_LAY:
220
 
                strcpy(str, "Layer"); break;
221
 
 
222
 
        case OB_TIME:
223
 
                strcpy(str, "Time"); break;
224
 
        case OB_EFF_X:
225
 
                if(colipo) strcpy(str, "ColR");
226
 
                else strcpy(str, "EffX");
227
 
                break;
228
 
        case OB_EFF_Y:
229
 
                if(colipo) strcpy(str, "ColG");
230
 
                else strcpy(str, "EffY");
231
 
                break;
232
 
        case OB_EFF_Z:
233
 
                if(colipo) strcpy(str, "ColB");
234
 
                else strcpy(str, "EffZ");
235
 
                break;
236
 
        case OB_COL_A:
237
 
                strcpy(str, "ColA");
238
 
                break;
239
 
        default:
240
 
                str[0]= 0;
241
 
        }       
242
 
}
243
 
 
244
 
void getname_tex_ei(int nr, char *str)
245
 
{
246
 
        switch(nr) {
247
 
        case MAP_OFS_X:
248
 
                strcpy(str, "OfsX"); break;
249
 
        case MAP_OFS_Y:
250
 
                strcpy(str, "OfsY"); break;
251
 
        case MAP_OFS_Z:
252
 
                strcpy(str, "OfsZ"); break;
253
 
        case MAP_SIZE_X:
254
 
                strcpy(str, "SizeX"); break;
255
 
        case MAP_SIZE_Y:
256
 
                strcpy(str, "SizeY"); break;
257
 
        case MAP_SIZE_Z:
258
 
                strcpy(str, "SizeZ"); break;
259
 
        case MAP_R:
260
 
                strcpy(str, "texR"); break;
261
 
        case MAP_G:
262
 
                strcpy(str, "texG"); break;
263
 
        case MAP_B:
264
 
                strcpy(str, "texB"); break;
265
 
        case MAP_DVAR:
266
 
                strcpy(str, "DefVar"); break;
267
 
        case MAP_COLF:
268
 
                strcpy(str, "Col"); break;
269
 
        case MAP_NORF:
270
 
                strcpy(str, "Nor"); break;
271
 
        case MAP_VARF:
272
 
                strcpy(str, "Var"); break;
273
 
        default:
274
 
                str[0]= 0;
275
 
        }
276
 
}
277
 
 
278
 
void getname_mat_ei(int nr, char *str)
279
 
{
280
 
        if(nr>=MA_MAP1) getname_tex_ei((nr & (MA_MAP1-1)), str);
281
 
        else {
282
 
                switch(nr) {
283
 
                case MA_COL_R:
284
 
                        strcpy(str, "R"); break;
285
 
                case MA_COL_G:
286
 
                        strcpy(str, "G"); break;
287
 
                case MA_COL_B:
288
 
                        strcpy(str, "B"); break;
289
 
                case MA_SPEC_R:
290
 
                        strcpy(str, "SpecR"); break;
291
 
                case MA_SPEC_G:
292
 
                        strcpy(str, "SpecG"); break;
293
 
                case MA_SPEC_B:
294
 
                        strcpy(str, "SpecB"); break;
295
 
                case MA_MIR_R:
296
 
                        strcpy(str, "MirR"); break;
297
 
                case MA_MIR_G:
298
 
                        strcpy(str, "MirG"); break;
299
 
                case MA_MIR_B:
300
 
                        strcpy(str, "MirB"); break;
301
 
                case MA_REF:
302
 
                        strcpy(str, "Ref"); break;
303
 
                case MA_ALPHA:
304
 
                        strcpy(str, "Alpha"); break;
305
 
                case MA_EMIT:
306
 
                        strcpy(str, "Emit"); break;
307
 
                case MA_AMB:
308
 
                        strcpy(str, "Amb"); break;
309
 
                case MA_SPEC:
310
 
                        strcpy(str, "Spec"); break;
311
 
                case MA_HARD:
312
 
                        strcpy(str, "Hard"); break;
313
 
                case MA_SPTR:
314
 
                        strcpy(str, "SpTra"); break;
315
 
                case MA_ANG:
316
 
                        strcpy(str, "Ang"); break;
317
 
                case MA_MODE:
318
 
                        strcpy(str, "Mode"); break;
319
 
                case MA_HASIZE:
320
 
                        strcpy(str, "HaSize"); break;
321
 
                default:
322
 
                        str[0]= 0;
323
 
                }
324
 
        }
325
 
}
326
 
 
327
 
void getname_world_ei(int nr, char *str)
328
 
{
329
 
        if(nr>=MA_MAP1) getname_tex_ei((nr & (MA_MAP1-1)), str);
330
 
        else {
331
 
                switch(nr) {
332
 
                case WO_HOR_R:
333
 
                        strcpy(str, "HorR"); break;
334
 
                case WO_HOR_G:
335
 
                        strcpy(str, "HorG"); break;
336
 
                case WO_HOR_B:
337
 
                        strcpy(str, "HorB"); break;
338
 
                case WO_ZEN_R:
339
 
                        strcpy(str, "ZenR"); break;
340
 
                case WO_ZEN_G:
341
 
                        strcpy(str, "ZenG"); break;
342
 
                case WO_ZEN_B:
343
 
                        strcpy(str, "ZenB"); break;
344
 
 
345
 
                case WO_EXPOS:
346
 
                        strcpy(str, "Expos"); break;
347
 
 
348
 
                case WO_MISI:
349
 
                        strcpy(str, "Misi"); break;
350
 
                case WO_MISTDI:
351
 
                        strcpy(str, "MisDi"); break;
352
 
                case WO_MISTSTA:
353
 
                        strcpy(str, "MisSta"); break;
354
 
                case WO_MISTHI:
355
 
                        strcpy(str, "MisHi"); break;
356
 
 
357
 
                case WO_STAR_R:
358
 
                        strcpy(str, "StarR"); break;
359
 
                case WO_STAR_G:
360
 
                        strcpy(str, "StarB"); break;
361
 
                case WO_STAR_B:
362
 
                        strcpy(str, "StarG"); break;
363
 
 
364
 
                case WO_STARDIST:
365
 
                        strcpy(str, "StarDi"); break;
366
 
                case WO_STARSIZE:
367
 
                        strcpy(str, "StarSi"); break;
368
 
                default:
369
 
                        str[0]= 0;
370
 
                }
371
 
        }
372
 
}
373
 
 
374
 
void getname_seq_ei(int nr, char *str)
375
 
{
376
 
        switch(nr) {
377
 
        case SEQ_FAC1:
378
 
                strcpy(str, "Fac"); break;
379
 
        default:
380
 
                str[0]= 0;
381
 
        }
382
 
}
383
 
 
384
 
void getname_cu_ei(int nr, char *str)
385
 
{
386
 
 
387
 
        switch(nr) {
388
 
        case CU_SPEED:
389
 
                strcpy(str, "Speed"); break;
390
 
        default:
391
 
                str[0]= 0;
392
 
        }
393
 
}
394
 
 
395
 
void getname_key_ei(int nr, char *str)
396
 
{
397
 
        if(nr==KEY_SPEED) strcpy(str, "Speed");
398
 
        else sprintf(str, "Key %d", nr);
399
 
}
400
 
 
401
 
void getname_la_ei(int nr, char *str)
402
 
{
403
 
        if(nr>=MA_MAP1) getname_tex_ei((nr & (MA_MAP1-1)), str);
404
 
        else {
405
 
                switch(nr) {
406
 
                case LA_ENERGY:
407
 
                        strcpy(str, "Energ"); break;
408
 
                case LA_COL_R:
409
 
                        strcpy(str, "R"); break;
410
 
                case LA_COL_G:
411
 
                        strcpy(str, "G"); break;
412
 
                case LA_COL_B:
413
 
                        strcpy(str, "B"); break;
414
 
                case LA_DIST:
415
 
                        strcpy(str, "Dist"); break;
416
 
                case LA_SPOTSI:
417
 
                        strcpy(str, "SpoSi"); break;
418
 
                case LA_SPOTBL:
419
 
                        strcpy(str, "SpoBl"); break;
420
 
                case LA_QUAD1:
421
 
                        strcpy(str, "Quad1"); break;
422
 
                case LA_QUAD2:
423
 
                        strcpy(str, "Quad2"); break;
424
 
                case LA_HALOINT:
425
 
                        strcpy(str, "HaInt"); break;
426
 
                default:
427
 
                        str[0]= 0;
428
 
                }
429
 
        }
430
 
}
431
 
 
432
 
void getname_cam_ei(int nr, char *str)
433
 
{
434
 
        switch(nr) {
435
 
        case CAM_LENS:
436
 
                strcpy(str, "Lens"); break;
437
 
        case CAM_STA:
438
 
                strcpy(str, "ClSta"); break;
439
 
        case CAM_END:
440
 
                strcpy(str, "ClEnd"); break;
441
 
        default:
442
 
                str[0]= 0;
443
 
        }
444
 
}
445
 
 
446
 
void getname_snd_ei(int nr, char *str)
447
 
{
448
 
        switch(nr) {
449
 
        case SND_VOLUME:
450
 
                strcpy(str, "Vol"); break;
451
 
        case SND_PITCH:
452
 
                strcpy(str, "Pitch"); break;
453
 
        case SND_PANNING:
454
 
                strcpy(str, "Pan"); break;
455
 
        case SND_ATTEN:
456
 
                strcpy(str, "Atten"); break;
457
 
        default:
458
 
                str[0]= 0;
459
 
        }
460
 
}
461
 
 
 
239
        return ic_name_empty[0];
 
240
}
 
241
 
 
242
char *getname_mat_ei(int nr)
 
243
{
 
244
        if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
 
245
        else {
 
246
                if(nr>=MA_COL_R && nr<=MA_ADD) return ma_ic_names[nr-1];
 
247
        }
 
248
        return ic_name_empty[0];
 
249
}
 
250
 
 
251
char *getname_world_ei(int nr)
 
252
{
 
253
        if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
 
254
        else {
 
255
                if(nr>=WO_HOR_R && nr<=WO_STARSIZE) return wo_ic_names[nr-1];
 
256
        }
 
257
        return ic_name_empty[0];
 
258
}
 
259
 
 
260
char *getname_seq_ei(int nr)
 
261
{
 
262
        if(nr == SEQ_FAC1) return seq_ic_names[nr-1];
 
263
        return ic_name_empty[0];
 
264
}
 
265
 
 
266
char *getname_cu_ei(int nr)
 
267
{
 
268
        if(nr==CU_SPEED) return cu_ic_names[nr-1];
 
269
        return ic_name_empty[0];
 
270
}
 
271
 
 
272
char *getname_key_ei(int nr)
 
273
{
 
274
        if(nr>=KEY_SPEED && nr<KEY_TOTNAM) return key_ic_names[nr];
 
275
        return ic_name_empty[0];
 
276
}
 
277
 
 
278
char *getname_la_ei(int nr)
 
279
{
 
280
        if(nr>=MA_MAP1) return getname_mtex_ei((nr & (MA_MAP1-1)));
 
281
        else {
 
282
                if(nr>=LA_ENERGY && nr<=LA_HALOINT) return la_ic_names[nr-1];
 
283
        }
 
284
        return ic_name_empty[0];
 
285
}
 
286
 
 
287
char *getname_cam_ei(int nr)
 
288
{
 
289
        /* yafray: curves extended to CAM_YF_FDIST */
 
290
        //if(nr>=CAM_LENS && nr<=CAM_END) return cam_ic_names[nr-1];
 
291
        if(nr>=CAM_LENS && nr<=CAM_YF_FDIST) return cam_ic_names[nr-1];
 
292
        return ic_name_empty[0];
 
293
}
 
294
 
 
295
char *getname_snd_ei(int nr)
 
296
{
 
297
        if(nr>=SND_VOLUME && nr<=SND_ATTEN) return snd_ic_names[nr-1];
 
298
        return ic_name_empty[0];
 
299
}
462
300
 
463
301
IpoCurve *find_ipocurve(Ipo *ipo, int adrcode)
464
302
{
552
390
        KeyBlock *kb;
553
391
        int a, first=1;
554
392
 
555
 
 
556
393
        ei= si->editipo;
557
394
        if(ei==0)
558
395
                return;
 
396
        
559
397
 
560
398
        for(a=0; a<si->totipo; a++, ei++) {
561
399
                
577
415
                        }
578
416
                }
579
417
        }
 
418
        
580
419
 
581
420
        v2d= &(si->v2d);        
582
421
 
591
430
                }
592
431
        }
593
432
        
594
 
        
595
433
        /* is there no curve? */
596
434
        if(first) {
597
435
                v2d->tot.xmin= 0.0;
635
473
                }
636
474
 
637
475
                else if(si->blocktype==ID_MA) allqueue(REDRAWBUTSSHADING, 0);
 
476
                else if(si->blocktype==ID_TE) allqueue(REDRAWBUTSSHADING, 0);
638
477
                else if(si->blocktype==ID_WO) allqueue(REDRAWBUTSSHADING, 0);
639
478
                else if(si->blocktype==ID_LA) allqueue(REDRAWBUTSSHADING, 0);
640
479
//              else if(si->blocktype==ID_SO) allqueue(REDRAWBUTSSOUND, 0);
644
483
                }
645
484
                else if(si->blocktype==ID_SEQ) clear_last_seq();
646
485
                else if(si->blocktype==ID_AC){
647
 
                        do_all_actions();
 
486
                        do_all_actions(NULL);
648
487
                        allqueue(REDRAWACTION, 0);
649
488
                        allqueue(REDRAWNLA, 0);
650
489
                }
693
532
                        }
694
533
                }
695
534
        }
 
535
 
696
536
        editipo_changed(G.sipo, 1);
 
537
 
 
538
        BIF_undo_push("Scale Edit Ipo");
697
539
        allqueue(REDRAWNLA, 0);
698
540
        allqueue (REDRAWACTION, 0);
699
541
        allqueue(REDRAWIPO, 0);
749
591
                        return ob->ipo;
750
592
                }
751
593
        }
 
594
        else if(G.sipo->blocktype==ID_TE) {
 
595
                if(ob) {
 
596
                        Tex *tex= give_current_texture(ob, ob->actcol);
 
597
                        *from= (ID *)tex;
 
598
                        if(tex) return tex->ipo;
 
599
                }
 
600
        }
752
601
        else if(G.sipo->blocktype==ID_MA) {
753
602
                if(ob) {
754
603
                        Material *ma= give_current_material(ob, ob->actcol);
816
665
{
817
666
        EditIpo *ei;
818
667
        int a, len, colipo=0;
 
668
        char *name;
819
669
        
820
670
        if(ob->type==OB_MESH) colipo= 1;
821
671
 
824
674
        si->totipo= OB_TOTIPO;
825
675
        
826
676
        for(a=0; a<OB_TOTIPO; a++) {
827
 
                getname_ob_ei(ob_ar[a], ei->name, colipo);
 
677
                name = getname_ob_ei(ob_ar[a], colipo);
 
678
                strcpy(ei->name, name);
828
679
                ei->adrcode= ob_ar[a];
829
680
                
830
681
                if ELEM6(ei->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z, OB_DROT_X, OB_DROT_Y, OB_DROT_Z) ei->disptype= IPO_DISPDEGR;
847
698
                        ei->flag= ei->icu->flag;
848
699
                }
849
700
                
 
701
                
850
702
                ei++;
851
703
        }
852
704
}
856
708
{
857
709
        EditIpo *ei;
858
710
        int a;
 
711
        char *name;
859
712
        
860
713
        ei= si->editipo= MEM_callocN(SEQ_TOTIPO*sizeof(EditIpo), "editipo");
861
714
        
863
716
        
864
717
        
865
718
        for(a=0; a<SEQ_TOTIPO; a++) {
866
 
                getname_seq_ei(seq_ar[a], ei->name);
 
719
                name = getname_seq_ei(seq_ar[a]);
 
720
                strcpy(ei->name, name);
867
721
                ei->adrcode= seq_ar[a];
868
722
                
869
723
                ei->col= ipo_rainbow(a, SEQ_TOTIPO);
882
736
{
883
737
        EditIpo *ei;
884
738
        int a;
 
739
        char *name;
885
740
        
886
741
        ei= si->editipo= MEM_callocN(CU_TOTIPO*sizeof(EditIpo), "editipo");
887
742
        
889
744
        
890
745
        
891
746
        for(a=0; a<CU_TOTIPO; a++) {
892
 
                getname_cu_ei(cu_ar[a], ei->name);
 
747
                name = getname_cu_ei(cu_ar[a]);
 
748
                strcpy(ei->name, name);
893
749
                ei->adrcode= cu_ar[a];
894
750
                
895
751
                ei->col= ipo_rainbow(a, CU_TOTIPO);
910
766
        KeyBlock *kb=NULL;
911
767
        EditIpo *ei;
912
768
        int a;
 
769
        char *name;
913
770
        
914
771
        ei= si->editipo= MEM_callocN(KEY_TOTIPO*sizeof(EditIpo), "editipo");
915
772
        
920
777
        
921
778
        for(a=0; a<KEY_TOTIPO; a++, ei++) {
922
779
                if(kb && kb->name[0] != 0) strncpy(ei->name, kb->name, 32);     // length both same
923
 
                else getname_key_ei(key_ar[a], ei->name);
 
780
                else {
 
781
                        name = getname_key_ei(key_ar[a]);
 
782
                        strcpy(ei->name, name);
 
783
                }
924
784
                ei->adrcode= key_ar[a];
925
785
                
926
786
                ei->col= ipo_rainbow(a, KEY_TOTIPO);
954
814
                case 5: return MA_MAP6; 
955
815
                case 6: return MA_MAP7; 
956
816
                case 7: return MA_MAP8; 
 
817
                case 8: return MA_MAP9; 
 
818
                case 9: return MA_MAP10; 
957
819
                default: return 0;
958
820
        }
959
821
}
962
824
{
963
825
        EditIpo *ei;
964
826
        int a, len;
 
827
        char *name;
965
828
        
966
829
        if(si->from==0) return;
967
830
        
970
833
        si->totipo= MA_TOTIPO;
971
834
        
972
835
        for(a=0; a<MA_TOTIPO; a++) {
973
 
                getname_mat_ei(ma_ar[a], ei->name);
 
836
                name = getname_mat_ei(ma_ar[a]);
 
837
                strcpy(ei->name, name);
974
838
                ei->adrcode= ma_ar[a];
975
839
                
976
840
                if(ei->adrcode & MA_MAP1) {
981
845
                        if(ei->adrcode==MA_MODE) ei->disptype= IPO_DISPBITS;
982
846
                }
983
847
                
984
 
                ei->col= ipo_rainbow(a, WO_TOTIPO);
 
848
                ei->col= ipo_rainbow(a, MA_TOTIPO);
985
849
                
986
850
                len= strlen(ei->name);
987
851
                if(len) {
999
863
        }
1000
864
}
1001
865
 
 
866
void make_texture_editipo(SpaceIpo *si)
 
867
{
 
868
        EditIpo *ei;
 
869
        int a;
 
870
        char *name;
 
871
        
 
872
        if(si->from==0) return;    
 
873
        
 
874
        ei= si->editipo= MEM_callocN(TE_TOTIPO*sizeof(EditIpo), "editipo");
 
875
        
 
876
        si->totipo= TE_TOTIPO;
 
877
        
 
878
        for(a=0; a<TE_TOTIPO; a++) {
 
879
                name = getname_tex_ei(te_ar[a]);
 
880
                strcpy(ei->name, name);
 
881
                        ei->adrcode= te_ar[a];
 
882
 
 
883
                ei->col= ipo_rainbow(a, TE_TOTIPO);
 
884
                
 
885
                ei->icu= find_ipocurve(si->ipo, ei->adrcode);
 
886
                if(ei->icu) {
 
887
                        ei->flag= ei->icu->flag;
 
888
                }
 
889
                
 
890
                ei++;
 
891
        }
 
892
}
 
893
 
1002
894
void make_world_editipo(SpaceIpo *si)
1003
895
{
1004
896
        EditIpo *ei;
1005
897
        int a, len;
 
898
        char *name;
1006
899
        
1007
900
        if(si->from==0) return;
1008
901
        
1011
904
        si->totipo= WO_TOTIPO;
1012
905
        
1013
906
        for(a=0; a<WO_TOTIPO; a++) {
1014
 
                getname_world_ei(wo_ar[a], ei->name);
 
907
                name = getname_world_ei(wo_ar[a]);
 
908
                
 
909
                strcpy(ei->name, name); 
1015
910
                ei->adrcode= wo_ar[a];
1016
911
                
1017
912
                if(ei->adrcode & MA_MAP1) {
1022
917
                        if(ei->adrcode==MA_MODE) ei->disptype= IPO_DISPBITS;
1023
918
                }
1024
919
                
1025
 
                ei->col= ipo_rainbow(a, MA_TOTIPO);
 
920
                ei->col= ipo_rainbow(a, WO_TOTIPO);
1026
921
                
1027
922
                len= strlen(ei->name);
1028
923
                if(len) {
1044
939
{
1045
940
        EditIpo *ei;
1046
941
        int a;
 
942
        char *name;
1047
943
        
1048
944
        ei= si->editipo= MEM_callocN(LA_TOTIPO*sizeof(EditIpo), "editipo");
1049
945
        
1051
947
        
1052
948
        
1053
949
        for(a=0; a<LA_TOTIPO; a++) {
1054
 
                getname_la_ei(la_ar[a], ei->name);
 
950
                name = getname_la_ei(la_ar[a]);
 
951
                strcpy(ei->name, name);
1055
952
                ei->adrcode= la_ar[a];
1056
953
 
1057
954
                if(ei->adrcode & MA_MAP1) {
1074
971
{
1075
972
        EditIpo *ei;
1076
973
        int a;
 
974
        char *name;
1077
975
        
1078
976
        ei= si->editipo= MEM_callocN(CAM_TOTIPO*sizeof(EditIpo), "editipo");
1079
977
        
1081
979
        
1082
980
        
1083
981
        for(a=0; a<CAM_TOTIPO; a++) {
1084
 
                getname_cam_ei(cam_ar[a], ei->name);
 
982
                name = getname_cam_ei(cam_ar[a]);
 
983
                strcpy(ei->name, name);
1085
984
                ei->adrcode= cam_ar[a];
1086
985
 
1087
986
                ei->col= ipo_rainbow(a, CAM_TOTIPO);
1099
998
{
1100
999
        EditIpo *ei;
1101
1000
        int a;
 
1001
        char *name;
1102
1002
        
1103
1003
        ei= *si= MEM_callocN(CO_TOTIPO*sizeof(EditIpo), "editipo");
1104
1004
        
1105
1005
        for(a=0; a<CO_TOTIPO; a++) {
1106
 
                getname_co_ei(co_ar[a], ei->name);
 
1006
                name = getname_co_ei(co_ar[a]);
 
1007
                strcpy(ei->name, name);
1107
1008
                ei->adrcode= co_ar[a];
1108
1009
 
1109
1010
                ei->col= ipo_rainbow(a, CO_TOTIPO);
1122
1023
{
1123
1024
        EditIpo *ei;
1124
1025
        int a;
 
1026
        char *name;
1125
1027
        
1126
1028
        ei= *si= MEM_callocN(AC_TOTIPO*sizeof(EditIpo), "editipo");
1127
1029
        
1128
1030
        for(a=0; a<AC_TOTIPO; a++) {
1129
 
                getname_ac_ei(ac_ar[a], ei->name);
 
1031
                name = getname_ac_ei(ac_ar[a]);
 
1032
                strcpy(ei->name, name);
1130
1033
                ei->adrcode= ac_ar[a];
1131
1034
 
1132
1035
                ei->col= ipo_rainbow(a, AC_TOTIPO);
1146
1049
{
1147
1050
        EditIpo *ei;
1148
1051
        int a;
 
1052
        char *name;
1149
1053
        
1150
1054
        ei= si->editipo= MEM_callocN(SND_TOTIPO*sizeof(EditIpo), "editipo");
1151
1055
        
1153
1057
        
1154
1058
        
1155
1059
        for(a=0; a<SND_TOTIPO; a++) {
1156
 
                getname_snd_ei(snd_ar[a], ei->name);
 
1060
                name = getname_snd_ei(snd_ar[a]);
 
1061
                strcpy(ei->name, name);
1157
1062
                ei->adrcode= snd_ar[a];
1158
1063
 
1159
1064
                ei->col= ipo_rainbow(a, SND_TOTIPO);
1222
1127
                        make_lamp_editipo(G.sipo);
1223
1128
                }
1224
1129
        }
 
1130
        else if(G.sipo->blocktype==ID_TE) {
 
1131
                if (ob) {
 
1132
                        ob->ipowin= ID_TE;
 
1133
                        make_texture_editipo(G.sipo);
 
1134
                }
 
1135
        }
1225
1136
        else if(G.sipo->blocktype==ID_CA) {
1226
1137
                if (ob) {
1227
1138
                        ob->ipowin= ID_CA;
1250
1161
 
1251
1162
        if(G.sipo->editipo==0) return;
1252
1163
        
1253
 
        /* rowbut for VISIBLE select */
1254
 
        G.sipo->rowbut= 0;
1255
1164
        ei= G.sipo->editipo;
1256
1165
        for(a=0; a<G.sipo->totipo; a++, ei++) {
1257
 
                
1258
 
                if(ei->flag & IPO_VISIBLE) G.sipo->rowbut |= (1<<a);
1259
 
                
1260
1166
                if(ei->icu) ei->icu->flag= ei->flag;
1261
1167
        }
1262
1168
        editipo_changed(G.sipo, 0);
1290
1196
                        G.v2d->cur.ymin= (float)-0.1;
1291
1197
                        G.v2d->cur.ymax= (float)+1.1;
1292
1198
                }
 
1199
                else if(G.sipo->blocktype==ID_TE) {
 
1200
                        G.v2d->cur.xmin= (float)-0.1;
 
1201
                        G.v2d->cur.xmax= EFRA;
 
1202
                        G.v2d->cur.ymin= (float)-0.1;
 
1203
                        G.v2d->cur.ymax= (float)+1.1;
 
1204
                }
1293
1205
                else if(G.sipo->blocktype==ID_SEQ) {
1294
1206
                        G.v2d->cur.xmin= -5.0;
1295
1207
                        G.v2d->cur.xmax= 105.0;
1396
1308
        }
1397
1309
}
1398
1310
 
1399
 
 
1400
 
 
1401
1311
void update_editipo_flags()
1402
1312
{
1403
1313
        EditIpo *ei;
1404
1314
        IpoKey *ik;
1405
 
        unsigned int flag;
1406
1315
        int a;
1407
1316
        
1408
1317
        ei= G.sipo->editipo;
1409
1318
        if(ei) {
1410
1319
                for(a=0; a<G.sipo->totipo; a++, ei++) {
1411
 
                        ei->flag &= ~IPO_VISIBLE;
1412
 
                        flag= (1<<a);
1413
 
                        if( G.sipo->rowbut & flag ) ei->flag |= IPO_VISIBLE;
1414
 
                        
1415
1320
                        if(ei->icu) ei->icu->flag= ei->flag;
1416
 
                        
1417
1321
                }
1418
1322
        }
1419
1323
        if(G.sipo->showkey) {
1490
1394
        else G.sipo->showkey= 1;
1491
1395
        free_ipokey(&G.sipo->ipokey);
1492
1396
        if(G.sipo->ipo) G.sipo->ipo->showkey= G.sipo->showkey;
 
1397
 
 
1398
        BIF_undo_push("Toggle show key Ipo");
1493
1399
}
1494
1400
 
1495
1401
void swap_selectall_editipo()
1500
1406
        BezTriple *bezt;
1501
1407
        int a, b; /*  , sel=0; */
1502
1408
        
1503
 
        
1504
1409
        deselectall_key();
1505
1410
 
1506
1411
        get_status_editipo();
1507
 
        
1508
 
 
1509
1412
 
1510
1413
        if(G.sipo->showkey) {
1511
1414
                ik= G.sipo->ipokey.first;
1533
1436
                        }
1534
1437
                        update_editipo_flags();
1535
1438
                }
 
1439
                get_status_editipo();
1536
1440
        }
1537
1441
        else {
1538
1442
                ei= G.sipo->editipo;
1557
1461
                
1558
1462
        }
1559
1463
        
 
1464
        BIF_undo_push("Swap select all Ipo");
1560
1465
        scrarea_queue_winredraw(curarea);
1561
1466
        
1562
1467
}
1569
1474
        
1570
1475
        get_status_editipo();
1571
1476
        
1572
 
        G.sipo->rowbut= 0;
1573
1477
        
1574
1478
        ei= G.sipo->editipo;
1575
1479
        for(a=0; a<G.sipo->totipo; a++) {
1576
1480
                if(totipo_vis==0) {
1577
1481
                        if(ei->icu) {
1578
1482
                                ei->flag |= IPO_VISIBLE;
1579
 
                                G.sipo->rowbut |= (1<<a);
 
1483
                                ei->flag |= IPO_SELECT;
1580
1484
                        }
1581
1485
                }
1582
1486
                else ei->flag &= ~IPO_VISIBLE;
1594
1498
        }
1595
1499
 
1596
1500
        scrarea_queue_winredraw(curarea);
1597
 
        
 
1501
        BIF_undo_push("Swap Visible Ipo");      
1598
1502
}
1599
1503
 
1600
1504
void deselectall_editipo()
1645
1549
                }
1646
1550
        }
1647
1551
        
 
1552
        BIF_undo_push("(De)select all Ipo");
1648
1553
        scrarea_queue_winredraw(curarea);
1649
1554
}
1650
1555
 
1655
1560
        /* return 0 1 2: handlepunt */
1656
1561
        EditIpo *ei;
1657
1562
        BezTriple *bezt1;
1658
 
        int a, b;
1659
 
        short dist= 100, temp, mval[2], hpoint=0;
 
1563
        int dist= 100, temp, a, b;
 
1564
        short mval[2], hpoint=0;
1660
1565
 
1661
1566
        *icu= 0;
1662
1567
        *bezt= 0;
1764
1669
                        }
1765
1670
                }
1766
1671
        }
 
1672
        BIF_undo_push("Set frame to selected Ipo vertex");
1767
1673
}
1768
1674
 
1769
1675
/* *********************************** */
1770
1676
 
 
1677
/* handling of right-hand channel/curve buttons in ipo window */
1771
1678
void do_ipowin_buts(short event)
1772
1679
{
 
1680
        EditIpo *ei = 0;
 
1681
        int a;
 
1682
 
 
1683
        /* without shift, all other channels are made invisible */
1773
1684
        if((G.qual & LR_SHIFTKEY)==0) {
1774
 
                G.sipo->rowbut= (1<<event);
 
1685
                if(event>G.sipo->totipo) return;
 
1686
                ei = G.sipo->editipo;
 
1687
                for(a=0; a<G.sipo->totipo; a++) {
 
1688
                        if(a!=event) ei->flag &= ~IPO_VISIBLE;
 
1689
                        else ei->flag |= IPO_VISIBLE;
 
1690
                        ei++;
 
1691
                }
1775
1692
        }
1776
1693
        scrarea_queue_winredraw(curarea);
1777
1694
        
1784
1701
 
1785
1702
}
1786
1703
 
 
1704
/* the fake buttons to the left of channel names, for select/deselect curves */
1787
1705
void do_ipo_selectbuttons()
1788
1706
{
1789
1707
        EditIpo *ei, *ei1;
1808
1726
                
1809
1727
                if(ei->icu) {
1810
1728
                        if((ei->flag & IPO_VISIBLE)==0) {
1811
 
                                ei->flag |= IPO_VISIBLE;
1812
 
                                G.sipo->rowbut |= (1<<nr);
 
1729
                                ei->flag |= IPO_VISIBLE|IPO_SELECT;
1813
1730
                        }
1814
1731
        
1815
1732
                        if((G.qual & LR_SHIFTKEY)==0) {
1826
1743
                        else {
1827
1744
                                ei->flag |= IPO_SELECT;
1828
1745
                        }
1829
 
 
 
1746
                        
1830
1747
                        update_editipo_flags();
1831
1748
                        scrarea_queue_winredraw(curarea);
1832
1749
                }
1833
1750
        }
 
1751
        BIF_undo_push("Select Ipo curve");
1834
1752
}
1835
1753
 
1836
1754
/* ******************************************* */
1867
1785
{
1868
1786
        Object *ob;
1869
1787
        Material *ma;
 
1788
        Tex *tex;
1870
1789
        Curve *cu;
1871
1790
        Sequence *seq;
1872
1791
        Key *key;
1908
1827
                
1909
1828
                if(make && ipo==0) ipo= ma->ipo= add_ipo("MatIpo", ID_MA);
1910
1829
        }
1911
 
 
 
1830
        else if( type==ID_TE) {
 
1831
                tex= (Tex *)from;
 
1832
                if(tex->id.lib) return 0;
 
1833
                ipo= tex->ipo;
 
1834
                
 
1835
                if(make && ipo==0) ipo= tex->ipo= add_ipo("TexIpo", ID_TE);
 
1836
        }
1912
1837
        else if( type==ID_SEQ) {
1913
1838
                seq= (Sequence *)from;
1914
1839
 
2025
1950
        int a = 0, h1, h2;
2026
1951
        
2027
1952
        memset(&beztr, 0, sizeof(BezTriple));
 
1953
        beztr.vec[0][0]= x; // set all three points, for nicer start position
 
1954
        beztr.vec[0][1]= y;
2028
1955
        beztr.vec[1][0]= x;
2029
1956
        beztr.vec[1][1]= y;
 
1957
        beztr.vec[2][0]= x;
 
1958
        beztr.vec[2][1]= y;
2030
1959
        beztr.hide= IPO_BEZ;
2031
1960
        beztr.f1= beztr.f2= beztr.f3= SELECT;
2032
1961
        beztr.h1= beztr.h2= HD_AUTO;
2105
2034
        
2106
2035
        ei= get_editipo();
2107
2036
        if(ei==0) {
2108
 
                error("Too many editipo's");
 
2037
                error("Too many (or no) EditIpos");
2109
2038
                return;
2110
2039
        }
2111
2040
        
2129
2058
        /* to be sure: if icu was 0, or only 1 curve visible */
2130
2059
        ei->flag |= IPO_SELECT;
2131
2060
        ei->icu->flag= ei->flag;
2132
 
 
 
2061
        
2133
2062
        editipo_changed(G.sipo, 1);
 
2063
        BIF_undo_push("Add Ipo vertex");
2134
2064
}
2135
2065
 
2136
2066
void add_duplicate_editipo()
2190
2120
                        if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
2191
2121
                }
2192
2122
        }
 
2123
        BIF_undo_push("Duplicate Ipo");
2193
2124
        transform_ipo('g');
2194
2125
}
2195
2126
 
2410
2341
                }
2411
2342
        }
2412
2343
        deselectall_editipo();
 
2344
        BIF_undo_push("Join Ipo");
2413
2345
}
2414
2346
 
2415
2347
void ipo_snap_menu(void)
2505
2437
                }
2506
2438
        }
2507
2439
        editipo_changed(G.sipo, 1);
 
2440
        BIF_undo_push("Snap Ipo");
2508
2441
}
2509
2442
 
2510
2443
 
2621
2554
                                if(actkb) {
2622
2555
                                        ok= TRUE;
2623
2556
                                        if(G.obedit && (actkb->flag & 1)==0) {
2624
 
                                                ok= okee("Copy Key after leaving EditMode");
 
2557
                                                ok= okee("Copy key after leaving Edit Mode");
2625
2558
                                        }
2626
2559
                                        if(ok) {
2627
2560
                                                /* also does all keypos */
2669
2602
        
2670
2603
        update_editipo_flags();
2671
2604
        
2672
 
        force_draw();
 
2605
        force_draw(0);
 
2606
        BIF_undo_push("Select Ipo");
2673
2607
        
2674
2608
        if(G.sipo->showkey && G.sipo->blocktype==ID_OB) {
2675
2609
                ob= OBACT;
2676
 
                if(ob && (ob->ipoflag & OB_DRAWKEY)) draw_object_ext(BASACT);
 
2610
                if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
2677
2611
        }
2678
2612
        
2679
2613
        getmouseco_areawin(mval);
2693
2627
        }
2694
2628
}
2695
2629
 
2696
 
int icu_keys_bezier_loop(IpoCurve *icu,
 
2630
static int icu_keys_bezier_loop(IpoCurve *icu,
2697
2631
                         int (*bezier_function)(BezTriple *),
2698
2632
                         void (ipocurve_function)(struct IpoCurve *icu)) 
2699
2633
{
2736
2670
 
2737
2671
}
2738
2672
 
2739
 
int ipo_keys_bezier_loop(Ipo *ipo,
 
2673
static int ipo_keys_bezier_loop(Ipo *ipo,
2740
2674
                         int (*bezier_function)(BezTriple *),
2741
2675
                         void (ipocurve_function)(struct IpoCurve *icu))
2742
2676
{
2759
2693
    return 0;
2760
2694
}
2761
2695
 
2762
 
int selected_bezier_loop(int (*looptest)(EditIpo *),
 
2696
static int selected_bezier_loop(int (*looptest)(EditIpo *),
2763
2697
                         int (*bezier_function)(BezTriple *),
2764
2698
                         void (ipocurve_function)(struct IpoCurve *icu))
2765
2699
{
2851
2785
  return 0;
2852
2786
}
2853
2787
 
2854
 
int set_bezier_auto(BezTriple *bezt) 
 
2788
static int set_bezier_auto(BezTriple *bezt) 
2855
2789
{
2856
2790
        /* Sets the selected bezier handles to type 'auto' 
2857
2791
         */
2874
2808
        return 0;
2875
2809
}
2876
2810
 
2877
 
int set_bezier_vector(BezTriple *bezt) 
 
2811
static int set_bezier_vector(BezTriple *bezt) 
2878
2812
{
2879
2813
        /* Sets the selected bezier handles to type 'vector' 
2880
2814
         */
2897
2831
        return 0;
2898
2832
}
2899
2833
 
2900
 
int bezier_isfree(BezTriple *bezt) 
 
2834
static int bezier_isfree(BezTriple *bezt) 
2901
2835
{
2902
2836
        /* queries whether the handle should be set
2903
2837
         * to type 'free' (I think)
2907
2841
        return 0;
2908
2842
}
2909
2843
 
2910
 
int set_bezier_free(BezTriple *bezt) 
 
2844
static int set_bezier_free(BezTriple *bezt) 
2911
2845
{
2912
2846
        /* Sets selected bezier handles to type 'free' 
2913
2847
         */
2916
2850
        return 0;
2917
2851
}
2918
2852
 
2919
 
int set_bezier_align(BezTriple *bezt) 
 
2853
static int set_bezier_align(BezTriple *bezt) 
2920
2854
{
2921
2855
        /* Sets selected bezier handles to type 'align' 
2922
2856
         */
2925
2859
        return 0;
2926
2860
}
2927
2861
 
2928
 
int vis_edit_icu_bez(EditIpo *ei) {
 
2862
static int vis_edit_icu_bez(EditIpo *ei) {
2929
2863
        /* A 4 part test for an EditIpo :
2930
2864
         *   is it a) visible
2931
2865
         *         b) in edit mode
3035
2969
        }
3036
2970
 
3037
2971
        editipo_changed(G.sipo, 1);
 
2972
        BIF_undo_push("Set handles Ipo");
3038
2973
}
3039
2974
 
3040
2975
 
3041
 
void set_ipocurve_constant(struct IpoCurve *icu) {
 
2976
static void set_ipocurve_constant(struct IpoCurve *icu) {
3042
2977
        /* Sets the type of the IPO curve to constant
3043
2978
         */
3044
2979
        icu->ipo= IPO_CONST;
3045
2980
}
3046
2981
 
3047
 
void set_ipocurve_linear(struct IpoCurve *icu) {
 
2982
static void set_ipocurve_linear(struct IpoCurve *icu) {
3048
2983
        /* Sets the type of the IPO curve to linear
3049
2984
         */
3050
2985
        icu->ipo= IPO_LIN;
3051
2986
}
3052
2987
 
3053
 
void set_ipocurve_bezier(struct IpoCurve *icu) {
 
2988
static void set_ipocurve_bezier(struct IpoCurve *icu) {
3054
2989
        /* Sets the type of the IPO curve to bezier
3055
2990
         */
3056
2991
        icu->ipo= IPO_BEZ;
3091
3026
                key= (Key *)G.sipo->from;
3092
3027
                if(key==0) return;
3093
3028
                
3094
 
                event= pupmenu("Key Type %t|Linear %x1|Cardinal %x2|B spline %x3");
 
3029
                event= pupmenu("Key Type %t|Linear %x1|Cardinal %x2|B Spline %x3");
3095
3030
                if(event < 1) return;
3096
3031
                
3097
3032
                kb= key->block.first;
3118
3053
                        }
3119
3054
                }
3120
3055
        }
 
3056
        BIF_undo_push("Set ipo type");
3121
3057
        scrarea_queue_winredraw(curarea);
3122
3058
}
3123
3059
 
3182
3118
                                }
3183
3119
                        }
3184
3120
                }
 
3121
                BIF_undo_push("Border select Ipo");
3185
3122
                scrarea_queue_winredraw(curarea);
3186
3123
        }
3187
3124
}
3188
3125
 
3189
 
 
3190
 
 
 
3126
/*
 
3127
 * When deleting an IPO curve from Python, check if the IPO is being
 
3128
 * edited and if so clear the pointer to the old curve.
 
3129
 */
 
3130
 
 
3131
void del_ipoCurve ( IpoCurve * icu )
 
3132
{
 
3133
        int i;
 
3134
        EditIpo *ei= G.sipo->editipo;
 
3135
        if (!ei) return;
 
3136
 
 
3137
        for(i=0; i<G.sipo->totipo; i++, ei++) {
 
3138
                if ( ei->icu == icu ) {
 
3139
                        ei->flag &= ~(IPO_SELECT | IPO_EDIT);
 
3140
                        ei->icu= 0;
 
3141
                        return;
 
3142
                }
 
3143
        }
 
3144
}
3191
3145
 
3192
3146
void del_ipo()
3193
3147
{
3277
3231
                }
3278
3232
        }
3279
3233
        
 
3234
        BIF_undo_push("Delete Ipo");
3280
3235
        allqueue(REDRAWNLA, 0);
3281
3236
        allqueue (REDRAWACTION, 0);
3282
3237
        allqueue(REDRAWIPO, 0);
3327
3282
                }
3328
3283
        }
3329
3284
        
3330
 
        if(totipocopybuf==0) error("Copybuf is empty");
 
3285
        if(totipocopybuf==0) error("Copy buffer is empty");
3331
3286
}
3332
3287
 
3333
3288
void paste_editipo()
3388
3343
                        }
3389
3344
                }
3390
3345
                editipo_changed(G.sipo, 1);
 
3346
                BIF_undo_push("Paste Ipo curves");
3391
3347
        }
3392
3348
}
3393
3349
 
3407
3363
                        }
3408
3364
                }
3409
3365
        }
 
3366
 
3410
3367
        editipo_changed(G.sipo, 1);
 
3368
        BIF_undo_push("Set extrapolation Ipo");
3411
3369
}
3412
3370
 
3413
3371
int find_other_handles(EditIpo *eicur, float ctime, BezTriple **beztar)
3502
3460
        if(didit==0) error("Did not set speed");
3503
3461
        
3504
3462
        editipo_changed(G.sipo, 1);
 
3463
        BIF_undo_push("Set speed IPO");
3505
3464
        allqueue(REDRAWNLA, 0);
3506
3465
        allqueue (REDRAWACTION, 0);
3507
3466
        allqueue(REDRAWIPO, 0);
3556
3515
        short event;
3557
3516
        
3558
3517
        if(G.sipo->showkey)
3559
 
                event= pupmenu("Insert KeyVertices %t|Current frame %x1|Selected Keys %x2");
 
3518
                event= pupmenu("Insert Key Vertices %t|Current Frame %x1|Selected Keys %x2");
3560
3519
        else 
3561
 
                event= pupmenu("Insert KeyVertices %t|Current frame %x1");
 
3520
                event= pupmenu("Insert Key Vertices %t|Current Frame %x1");
3562
3521
        
3563
3522
        if(event<1) return;
3564
3523
        
3634
3593
                        }
3635
3594
                }
3636
3595
        }
 
3596
        BIF_undo_push("Insert Key Ipo");
3637
3597
        allqueue (REDRAWACTION, 0);
3638
3598
        allqueue(REDRAWNLA, 0);
3639
3599
        allqueue(REDRAWIPO, 0);
3664
3624
                                id= G.buts->lockpoin;
3665
3625
                                ma= G.buts->lockpoin;
3666
3626
                                if(id) {
3667
 
                                        event= pupmenu("Insert Key %t|RGB%x0|Alpha%x1|HaSize%x2|Mode %x3|All Color%x10|Ofs%x12|Size%x13|All Mapping%x11");
 
3627
                                        event= pupmenu("Insert Key %t|RGB%x0|Alpha%x1|Halo Size%x2|Mode %x3|All Color%x10|All Mirror%x14|Ofs%x12|Size%x13|All Mapping%x11");
3668
3628
                                        if(event== -1) return;
3669
3629
                                        
3670
3630
                                        map= texchannel_to_adrcode(ma->texact);
3693
3653
                                                insertkey(id, MA_SPEC);
3694
3654
                                                insertkey(id, MA_HARD);
3695
3655
                                                insertkey(id, MA_MODE);
 
3656
                                                insertkey(id, MA_TRANSLU);
 
3657
                                                insertkey(id, MA_ADD);
 
3658
                                        }
 
3659
                                        if(event==14) {
 
3660
                                                insertkey(id, MA_RAYM);
 
3661
                                                insertkey(id, MA_FRESMIR);
 
3662
                                                insertkey(id, MA_FRESMIRI);
 
3663
                                                insertkey(id, MA_FRESTRA);
 
3664
                                                insertkey(id, MA_FRESTRAI);
3696
3665
                                        }
3697
3666
                                        if(event==12 || event==11) {
3698
3667
                                                insertkey(id, map+MAP_OFS_X);
3712
3681
                                                insertkey(id, map+MAP_COLF);
3713
3682
                                                insertkey(id, map+MAP_NORF);
3714
3683
                                                insertkey(id, map+MAP_VARF);
 
3684
                                                insertkey(id, map+MAP_DISP);
3715
3685
                                        }
3716
3686
                                }
3717
3687
                        }
3719
3689
                                id= G.buts->lockpoin;
3720
3690
                                wo= G.buts->lockpoin;
3721
3691
                                if(id) {
3722
 
                                        event= pupmenu("Insert Key %t|ZenRGB%x0|HorRGB%x1|Mist%x2|stars %x3|Ofs%x12|Size%x13");
 
3692
                                        event= pupmenu("Insert Key %t|Zenith RGB%x0|Horizon RGB%x1|Mist%x2|Stars %x3|Offset%x12|Size%x13");
3723
3693
                                        if(event== -1) return;
3724
3694
                                        
3725
3695
                                        map= texchannel_to_adrcode(wo->texact);
3763
3733
                                id= G.buts->lockpoin;
3764
3734
                                la= G.buts->lockpoin;
3765
3735
                                if(id) {
3766
 
                                        event= pupmenu("Insert Key %t|RGB%x0|Energy%x1|Spotsi%x2|Ofs%x12|Size%x13");
 
3736
                                        event= pupmenu("Insert Key %t|RGB%x0|Energy%x1|Spot Size%x2|Offset%x12|Size%x13");
3767
3737
                                        if(event== -1) return;
3768
3738
                                        
3769
3739
                                        map= texchannel_to_adrcode(la->texact);
3789
3759
                                                insertkey(id, map+MAP_SIZE_Y);
3790
3760
                                                insertkey(id, map+MAP_SIZE_Z);
3791
3761
                                        }
3792
 
                                        
 
3762
 
 
3763
                                }
 
3764
                        }
 
3765
                }
 
3766
                else if(G.buts->mainb==CONTEXT_OBJECT) {
 
3767
                        ob= OBACT;
 
3768
                        if(ob && ob->type==OB_MESH) {
 
3769
                                id= (ID *) (ob);
 
3770
                                if(id) {
 
3771
                                        event= pupmenu("Insert Key %t|Surface Damping%x0|Random Damping%x1|Permeability%x2|Force Strength%x3|Force Falloff%x4");
 
3772
                                        if(event== -1) return;
 
3773
 
 
3774
                                        if(event==0) {
 
3775
                                                insertkey(id, OB_PD_SDAMP);
 
3776
                                        }
 
3777
                                        if(event==1) {
 
3778
                                                insertkey(id, OB_PD_RDAMP);
 
3779
                                        }
 
3780
                                        if(event==2) {
 
3781
                                                insertkey(id, OB_PD_PERM);
 
3782
                                        }
 
3783
                                        if(event==3) {
 
3784
                                                insertkey(id, OB_PD_FSTR);
 
3785
                                        }
 
3786
                                        if(event==4) {
 
3787
                                                insertkey(id, OB_PD_FFALL);
 
3788
                                        }
 
3789
 
3793
3790
                                }
3794
3791
                        }
3795
3792
                }
3798
3795
                        if(ob && ob->type==OB_CAMERA) {
3799
3796
                                id= G.buts->lockpoin;
3800
3797
                                if(id) {
3801
 
                                        event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1");
 
3798
                                        /* yafray: insert key extended with aperture and focal distance */
 
3799
                                        if (G.scene->r.renderer==R_INTERN)
 
3800
                                                event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1");
 
3801
                                        else
 
3802
                                                event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1|Aperture%x2|FocalDistance%x3");
3802
3803
                                        if(event== -1) return;
3803
3804
 
3804
3805
                                        if(event==0) {
3805
3806
                                                insertkey(id, CAM_LENS);
3806
3807
                                        }
3807
 
                                        if(event==1) {
 
3808
                                        else if(event==1) {
3808
3809
                                                insertkey(id, CAM_STA);
3809
3810
                                                insertkey(id, CAM_END);
3810
3811
                                        }
 
3812
                                        else if(event==2) {
 
3813
                                                insertkey(id, CAM_YF_APERT);
 
3814
                                        }
 
3815
                                        else if(event==3) {
 
3816
                                                insertkey(id, CAM_YF_FDIST);
 
3817
                                        }
3811
3818
                                }
3812
3819
                        }
3813
3820
                }
3834
3841
                        }
3835
3842
                }
3836
3843
                
 
3844
                BIF_undo_push("Insert Key Buttons");
 
3845
 
3837
3846
                allqueue(REDRAWACTION, 0);
3838
3847
                allqueue(REDRAWNLA, 0);
3839
3848
                allqueue(REDRAWIPO, 0);
3843
3852
        else if(curarea->spacetype==SPACE_VIEW3D) {
3844
3853
                
3845
3854
 
3846
 
                base= FIRSTBASE;
3847
 
                while(base) {
3848
 
                        if TESTBASELIB(base) break;
3849
 
                        base= base->next;
3850
 
                }
3851
 
                if(base==0) return;
3852
 
                
3853
 
                if (G.obpose)
 
3855
                if (G.obpose) {
3854
3856
                        strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Avail%x9");
3855
 
                else
 
3857
                }
 
3858
                else {
 
3859
                        base= FIRSTBASE;
 
3860
                        while(base) {
 
3861
                                if TESTBASELIB(base) break;
 
3862
                                base= base->next;
 
3863
                        }
 
3864
                        if(base==0) return;
 
3865
                
3856
3866
                        strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Layer%x5|Avail%x9");
3857
 
 
 
3867
                }
3858
3868
                
3859
3869
                if( (ob = OBACT)) {
3860
3870
                        if(ob->type==OB_MESH) strcat(menustr, "| %x6|Mesh%x7");
3956
3966
 
3957
3967
                                remake_action_ipos(act);
3958
3968
                        }
 
3969
 
3959
3970
                        allqueue(REDRAWIPO, 0);
3960
3971
                        allqueue(REDRAWACTION, 0);
3961
3972
                        allqueue(REDRAWNLA, 0);
3962
 
                        
3963
3973
                }
3964
 
                else
3965
 
                {
 
3974
                else {
3966
3975
                        while(base) {
3967
3976
                                if TESTBASELIB(base) {
3968
3977
                                        id= (ID *)(base->object);
4012
4021
                                base= base->next;
4013
4022
                        }
4014
4023
                }
 
4024
 
 
4025
                if(event==0) BIF_undo_push("Insert Loc Key");
 
4026
                else if(event==1) BIF_undo_push("Insert Rot Key");
 
4027
                else if(event==2) BIF_undo_push("Insert Size Key");
 
4028
                else if(event==3) BIF_undo_push("Insert LocRot Key");
 
4029
                else if(event==4) BIF_undo_push("Insert LocRotSize Key");
 
4030
                else if(event==5) BIF_undo_push("Insert Layer Key");
 
4031
                else if(event==7) BIF_undo_push("Insert Vertex Key");
 
4032
                else if(event==9) BIF_undo_push("Insert Avail Key");
 
4033
 
4015
4034
                allspace(REMAKEIPO, 0);
4016
4035
                allqueue(REDRAWIPO, 0);
4017
4036
                allqueue(REDRAWVIEW3D, 0);
4365
4384
 
4366
4385
static int float_to_frame (float frame) 
4367
4386
{
4368
 
        int to= (int) frame;
4369
 
        
4370
 
        if (frame-to>0.5) to++;
 
4387
        int to= (int) floor(0.5 + frame/G.scene->r.framelen );
4371
4388
        
4372
4389
        return to;      
4373
4390
}
4401
4418
                update_for_newframe();
4402
4419
        }
4403
4420
        
 
4421
        BIF_undo_push("Move Key");
4404
4422
        allqueue(REDRAWNLA, 0);
4405
4423
        allqueue(REDRAWACTION, 0);
4406
4424
        allqueue(REDRAWVIEW3D, 0);
4456
4474
                update_for_newframe();
4457
4475
        }
4458
4476
        
 
4477
        BIF_undo_push("Move Key");
4459
4478
        allqueue(REDRAWNLA, 0);
4460
4479
        allqueue(REDRAWACTION, 0);
4461
4480
        allqueue(REDRAWVIEW3D, 0);
4825
4844
                        /* update realtime */
4826
4845
                        if(G.sipo->lock) {
4827
4846
                                if(G.sipo->blocktype==ID_MA) {
4828
 
                                        force_draw_plus(SPACE_BUTS);
 
4847
                                        force_draw_plus(SPACE_BUTS, 0);
4829
4848
                                }
4830
4849
                                else if(G.sipo->blocktype==ID_KE) {
4831
4850
                                        do_ob_key(OBACT);
4832
4851
                                        makeDispList(OBACT);
4833
 
                                        force_draw_plus(SPACE_VIEW3D);
 
4852
                                        force_draw_plus(SPACE_VIEW3D, 0);
4834
4853
                                }
4835
4854
                                else if(G.sipo->blocktype==ID_AC) {
4836
 
                                        do_all_actions();
4837
 
                                        force_draw_all();
 
4855
                                        do_all_actions(NULL);
 
4856
                                        force_draw_all(0);
4838
4857
                                }
4839
4858
                                else if(G.sipo->blocktype==ID_OB) {
4840
4859
                                        Base *base= FIRSTBASE;
4843
4862
                                                if(base->object->ipo==G.sipo->ipo) do_ob_ipo(base->object);
4844
4863
                                                base= base->next;
4845
4864
                                        }
4846
 
                                        force_draw_plus(SPACE_VIEW3D);
 
4865
                                        force_draw_plus(SPACE_VIEW3D, 0);
4847
4866
                                }
4848
 
                                else force_draw();
 
4867
                                else force_draw(0);
4849
4868
                        }
4850
4869
                        else {
4851
 
                                force_draw();
 
4870
                                force_draw(0);
4852
4871
                        }
4853
4872
                        firsttime= 0;
4854
4873
                }
4934
4953
                }
4935
4954
                calc_ipo(G.sipo->ipo, (float)CFRA);
4936
4955
        }
4937
 
        
 
4956
        else BIF_undo_push("Transform Ipo");
 
4957
 
4938
4958
        editipo_changed(G.sipo, 1);
4939
4959
 
4940
4960
        MEM_freeN(transmain);
5011
5031
        if(G.sipo->from==0) return;
5012
5032
        if(SFRA>=EFRA) return;
5013
5033
        
5014
 
        anim= pupmenu("Record Mouse %t|Still %x1|Play anim %x2");
 
5034
        anim= pupmenu("Record Mouse %t|Still %x1|Play Animation %x2");
5015
5035
        if(anim < 1) return;
5016
5036
        if(anim!=2) anim= 0;
5017
5037
 
5027
5047
                        if(ei1==0) ei1= ei;
5028
5048
                        else if(ei2==0) ei2= ei;
5029
5049
                        else {
5030
 
                                error("Max 2 visible curves");
 
5050
                                error("Maximum 2 visible curves");
5031
5051
                                return;
5032
5052
                        }
5033
5053
                }
5085
5105
        waitcursor(1);
5086
5106
        
5087
5107
        tottime= 0.0;
5088
 
        swaptime= speed_to_swaptime(G.animspeed);
 
5108
        swaptime= G.scene->r.framelen;
5089
5109
        cfrao= CFRA;
5090
5110
        cfra=efra= SFRA;
5091
5111
        sfra= EFRA;
5120
5140
                                sfra= MIN2(sfra, cfra);
5121
5141
                                efra= MAX2(efra, cfra);
5122
5142
                        }
5123
 
                        else sprintf(str, "Mouse Recording. Use CTRL to start. LeftMouse or Space to end");
 
5143
                        else sprintf(str, "Mouse Recording. Use Ctrl to start. LeftMouse or Space to end");
5124
5144
                        
5125
5145
                        do_ob_key(OBACT);
5126
5146
 
5194
5214
        editipo_changed(G.sipo, 0);
5195
5215
        do_ipo(G.sipo->ipo);
5196
5216
        waitcursor(0);
 
5217
 
5197
5218
        allqueue(REDRAWVIEW3D, 0);
5198
5219
        if(sa) scrarea_queue_headredraw(sa);    /* headerprint */
5199
5220
        scrarea_queue_redraw(oldarea);
5201
5222
        
5202
5223
        /* for the time being? */
5203
5224
        update_for_newframe();
 
5225
        BIF_undo_push("Ipo Record");
5204
5226
        
5205
5227
        MEM_freeN(data1);
5206
5228
        MEM_freeN(data2);