1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
|
/**
* $Id: poseSlide.c 23179 2009-09-13 12:34:00Z aligorith $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2009, Blender Foundation, Joshua Leung
* This is a new part of Blender
*
* Contributor(s): Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
#include "BLI_dlrbTree.h"
#include "DNA_listBase.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_context.h"
#include "BKE_report.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_types.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "BIF_gl.h"
#include "ED_anim_api.h"
#include "ED_armature.h"
#include "ED_keyframes_draw.h"
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
#include "ED_screen.h"
#include "armature_intern.h"
/* **************************************************** */
/* == POSE 'SLIDING' TOOLS ==
*
* A) Push & Relax, Breakdowner
* These tools provide the animator with various capabilities
* for interactively controlling the spacing of poses, but also
* for 'pushing' and/or 'relaxing' extremes as they see fit.
*
* B) Pose Sculpting
* This is yet to be implemented, but the idea here is to use
* sculpting techniques to make it easier to pose rigs by allowing
* rigs to be manipulated using a familiar paint-based interface.
*/
/* **************************************************** */
/* A) Push & Relax, Breakdowner */
/* Temporary data shared between these operators */
typedef struct tPoseSlideOp {
Scene *scene; /* current scene */
ARegion *ar; /* region that we're operating in (needed for */
Object *ob; /* active object that Pose Info comes from */
ListBase pfLinks; /* links between posechannels and f-curves */
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
KeyingSet *ks_loc; /* builtin KeyingSet for keyframing locations */
KeyingSet *ks_rot; /* builtin KeyingSet for keyframing rotations */
KeyingSet *ks_scale;/* builtin KeyingSet for keyframing scale */
int cframe; /* current frame number */
int prevFrame; /* frame before current frame (blend-from) */
int nextFrame; /* frame after current frame (blend-to) */
int mode; /* sliding mode (ePoseSlide_Modes) */
int flag; // unused for now, but can later get used for storing runtime settings....
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
} tPoseSlideOp;
/* Pose Sliding Modes */
typedef enum ePoseSlide_Modes {
POSESLIDE_PUSH = 0, /* exaggerate the pose... */
POSESLIDE_RELAX, /* soften the pose... */
POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */
} ePoseSlide_Modes;
/* Temporary data linking PoseChannels with the F-Curves they affect */
typedef struct tPChanFCurveLink {
struct tPChanFCurveLink *next, *prev;
ListBase fcurves; /* F-Curves for this PoseChannel */
bPoseChannel *pchan; /* Pose Channel which data is attached to */
char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */
} tPChanFCurveLink;
/* ------------------------------------ */
/* operator init */
static int pose_slide_init (bContext *C, wmOperator *op, short mode)
{
tPoseSlideOp *pso;
bAction *act= NULL;
/* init slide-op data */
pso= op->customdata= MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
/* get info from context */
pso->scene= CTX_data_scene(C);
pso->ob= CTX_data_active_object(C);
pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */
pso->cframe= pso->scene->r.cfra;
pso->mode= mode;
/* set range info from property values - these may get overridden for the invoke() */
pso->percentage= RNA_float_get(op->ptr, "percentage");
pso->prevFrame= RNA_int_get(op->ptr, "prev_frame");
pso->nextFrame= RNA_int_get(op->ptr, "next_frame");
/* check the settings from the context */
if (ELEM3(NULL, pso->ob, pso->ob->adt, pso->ob->adt->action))
return 0;
else
act= pso->ob->adt->action;
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans)
{
ListBase curves = {NULL, NULL};
int transFlags = action_get_item_transforms(act, pso->ob, pchan, &curves);
pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
/* check if any transforms found... */
if (transFlags) {
/* make new linkage data */
tPChanFCurveLink *pfl= MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink");
PointerRNA ptr;
pfl->fcurves= curves;
pfl->pchan= pchan;
/* get the RNA path to this pchan - this needs to be freed! */
RNA_pointer_create((ID *)pso->ob, &RNA_PoseChannel, pchan, &ptr);
pfl->pchan_path= RNA_path_from_ID_to_struct(&ptr);
/* add linkage data to operator data */
BLI_addtail(&pso->pfLinks, pfl);
/* set pchan's transform flags */
if (transFlags & ACT_TRANS_LOC)
pchan->flag |= POSE_LOC;
if (transFlags & ACT_TRANS_ROT)
pchan->flag |= POSE_ROT;
if (transFlags & ACT_TRANS_SCALE)
pchan->flag |= POSE_SIZE;
}
}
CTX_DATA_END;
/* do basic initialise of RB-BST used for finding keyframes, but leave the filling of it up
* to the caller of this (usually only invoke() will do it, to make things more efficient).
*/
BLI_dlrbTree_init(&pso->keys);
/* get builtin KeyingSets */
pso->ks_loc= ANIM_builtin_keyingset_get_named(NULL, "Location");
pso->ks_rot= ANIM_builtin_keyingset_get_named(NULL, "Rotation");
pso->ks_scale= ANIM_builtin_keyingset_get_named(NULL, "Scale");
/* return status is whether we've got all the data we were requested to get */
return 1;
}
/* exiting the operator - free data */
static void pose_slide_exit (bContext *C, wmOperator *op)
{
tPoseSlideOp *pso= op->customdata;
/* if data exists, clear its data and exit */
if (pso) {
tPChanFCurveLink *pfl, *pfln=NULL;
/* free the temp pchan links and their data */
for (pfl= pso->pfLinks.first; pfl; pfl= pfln) {
pfln= pfl->next;
/* free list of F-Curve reference links */
BLI_freelistN(&pfl->fcurves);
/* free pchan RNA Path */
MEM_freeN(pfl->pchan_path);
/* free link itself */
BLI_freelinkN(&pso->pfLinks, pfl);
}
/* free RB-BST for keyframes (if it contained data) */
BLI_dlrbTree_free(&pso->keys);
/* free data itself */
MEM_freeN(pso);
}
/* cleanup */
op->customdata= NULL;
}
/* ------------------------------------ */
/* helper for apply() callabcks - find the next F-Curve with matching path... */
static LinkData *find_next_fcurve_link (ListBase *fcuLinks, LinkData *prev, char *path)
{
LinkData *first= (prev)? prev->next : (fcuLinks)? fcuLinks->first : NULL;
LinkData *ld;
/* check each link to see if the linked F-Curve has a matching path */
for (ld= first; ld; ld= ld->next) {
FCurve *fcu= (FCurve *)ld->data;
/* check if paths match */
if (strcmp(path, fcu->rna_path) == 0)
return ld;
}
/* none found */
return NULL;
}
/* helper for apply() - perform sliding for some 3-element vector */
static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], char *propName)
{
LinkData *ld=NULL;
char *path=NULL;
float cframe;
/* get the path to use... */
path= BLI_sprintfN("%s.%s", pfl->pchan_path, propName);
/* get the current frame number */
cframe= (float)pso->cframe;
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld= find_next_fcurve_link(&pfl->fcurves, ld, path)) ) {
FCurve *fcu= (FCurve *)ld->data;
float w1, w2, wtot, ctrl, ictrl;
float sVal, eVal;
int ch;
/* get keyframe values for endpoint poses to blend with */
/* previous/start */
sVal= evaluate_fcurve(fcu, (float)pso->prevFrame);
/* next/end */
eVal= evaluate_fcurve(fcu, (float)pso->nextFrame);
/* get channel index */
ch= fcu->array_index;
/* get the influence of the control */
ctrl= pso->percentage;
ictrl= 1.0f - pso->percentage;
/* calculate the relative weights of the endpoints
* - these weights are derived from the relative distance of these
* poses from the current frame
* - they then get normalised, with the results of these normalised
*/
w1 = cframe - (float)pso->prevFrame;
w2 = (float)pso->nextFrame - cframe;
wtot = w1 + w2;
w1 = w1/wtot;
w2 = w2/wtot;
/* depending on the mode, */
switch (pso->mode) {
case POSESLIDE_PUSH: /* make the current pose more pronounced */
// TODO: this is not interactively modifiable!
vec[ch]= ( -((sVal * w2) + (eVal * w1)) + (vec[ch] * 6.0f) ) / 5.0f;
break;
case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */
/* apply the value with a hard coded 6th */
// TODO: this is not interactively modifiable!
vec[ch]= ( ((sVal * w2) + (eVal * w1)) + (vec[ch] * 5.0f) ) / 6.0f;
break;
case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */
// NOTE: just linear interpolation for now, but could add small component of our key if necessary...
// TODO: this doesn't work at all
w2= 1.0f - w1;
vec[ch]= ((sVal * w1) + (eVal * w2));
break;
}
}
/* free the temp path we got */
MEM_freeN(path);
}
/* helper for apply() - perform sliding for quaternion rotations (using quat blending) */
static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
{
// TODO: this is quite evil stuff...
#if 0 // XXX port...
/* get 2 quats */
quat_prev[0] = eval_icu(icu_w, frame_prev);
quat_prev[1] = eval_icu(icu_x, frame_prev);
quat_prev[2] = eval_icu(icu_y, frame_prev);
quat_prev[3] = eval_icu(icu_z, frame_prev);
quat_next[0] = eval_icu(icu_w, frame_next);
quat_next[1] = eval_icu(icu_x, frame_next);
quat_next[2] = eval_icu(icu_y, frame_next);
quat_next[3] = eval_icu(icu_z, frame_next);
#if 0
/* apply the setting, completely smooth */
QuatInterpol(pchan->quat, quat_prev, quat_next, (framef-frame_prev) / (frame_next-frame_prev) );
#else
/* tricky interpolation */
QuatInterpol(quat_interp, quat_prev, quat_next, (framef-frame_prev) / (frame_next-frame_prev) );
QUATCOPY(quat_orig, pchan->quat);
QuatInterpol(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f);
/* done */
#endif
#endif
}
/* helper for apply() - perform autokeyframing */
static void pose_slide_autoKeyframe (bContext *C, tPoseSlideOp *pso, bPoseChannel *pchan, KeyingSet *ks)
{
/* insert keyframes as necessary if autokeyframing */
if (autokeyframe_cfra_can_key(pso->scene, &pso->ob->id)) {
bCommonKeySrc cks;
ListBase dsources = {&cks, &cks};
/* init common-key-source for use by KeyingSets */
// TODO: for now, we don't clear it out, since it should be safe to do so...
//memset(&cks, 0, sizeof(bCommonKeySrc));
cks.id= &pso->ob->id;
/* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */
cks.pchan= pchan;
/* insert keyframes */
modify_keyframes(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)pso->cframe);
}
}
/* apply() - perform the pose sliding based on weighting various poses */
static void pose_slide_apply (bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
/* sanitise the frame ranges */
if (pso->prevFrame == pso->nextFrame) {
/* move out one step either side */
pso->prevFrame--;
pso->nextFrame++;
}
/* for each link, handle each set of transforms */
for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) {
/* valid transforms for each PoseChannel should have been noted already
* - sliding the pose should be a straightforward exercise for location+rotation,
* but rotations get more complicated since we may want to use quaternion blending
* for quaternions instead...
*/
bPoseChannel *pchan= pfl->pchan;
if (pchan->flag & POSE_LOC) {
/* calculate these for the 'location' vector, and use location curves */
pose_slide_apply_vec3(pso, pfl, pchan->loc, "location");
/* insert keyframes if needed */
pose_slide_autoKeyframe(C, pso, pchan, pso->ks_loc);
}
if (pchan->flag & POSE_SIZE) {
/* calculate these for the 'scale' vector, and use scale curves */
pose_slide_apply_vec3(pso, pfl, pchan->size, "scale");
/* insert keyframes if needed */
pose_slide_autoKeyframe(C, pso, pchan, pso->ks_scale);
}
if (pchan->flag & POSE_ROT) {
/* everything depends on the rotation mode */
if (pchan->rotmode > 0) {
/* eulers - so calculate these for the 'eul' vector, and use euler_rotation curves */
pose_slide_apply_vec3(pso, pfl, pchan->eul, "euler_rotation");
}
else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
// TODO: need to figure out how to do this!
}
else {
/* quaternions - use quaternion blending */
pose_slide_apply_quat(pso, pfl);
}
/* insert keyframes if needed */
pose_slide_autoKeyframe(C, pso, pchan, pso->ks_rot);
}
}
/* funky depsgraph flags - are these still needed? */
pso->ob->pose->flag |= (POSE_LOCKED|POSE_DO_UNLOCK);
/* do depsgraph flush */
DAG_id_flush_update(&pso->ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
//WM_event_add_notifier(C, NC_OBJECT|ND_POSE, pso->ob);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, pso->ob);
}
/* ------------------------------------ */
/* common code for invoke() methods */
static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
AnimData *adt= pso->ob->adt;
/* for each link, add all its keyframes to the search tree */
for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) {
LinkData *ld;
/* do this for each F-Curve */
for (ld= pfl->fcurves.first; ld; ld= ld->next) {
FCurve *fcu= (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &pso->keys, NULL);
}
}
/* consolidate these keyframes, and figure out the nearest ones */
BLI_dlrbTree_linkedlist_sync(&pso->keys);
/* cancel if no keyframes found... */
if (pso->keys.root) {
ActKeyColumn *ak;
/* firstly, check if the current frame is a keyframe... */
ak= cfra_find_actkeycolumn(pso->keys.root, pso->cframe);
if (ak == NULL) {
/* current frame is not a keyframe, so search */
/* prev frame */
ak= cfra_find_nearest_next_ak(pso->keys.root, pso->cframe, 0);
pso->prevFrame= (ak)? (ak->cfra) : (pso->cframe - 1);
RNA_int_set(op->ptr, "prev_frame", pso->prevFrame);
/* next frame */
ak= cfra_find_nearest_next_ak(pso->keys.root, pso->cframe, 1);
pso->nextFrame= (ak)? (ak->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->prevFrame);
}
else {
/* current frame itself is a keyframe, so just take keyframes on either side */
/* prev frame */
pso->prevFrame= (ak->prev)? (ak->prev->cfra) : (pso->cframe - 1);
RNA_int_set(op->ptr, "prev_frame", pso->prevFrame);
/* next frame */
pso->nextFrame= (ak->next)? (ak->next->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
}
}
else {
BKE_report(op->reports, RPT_ERROR, "No keyframes to slide between.");
return OPERATOR_CANCELLED;
}
// TODO -----------------------------------
// from here on, we should just invoke the modal operator, but for now, just do static...
/* temp static operator code... */
pose_slide_apply(C, op, pso);
pose_slide_exit(C, op);
return OPERATOR_FINISHED;
}
// TODO: common modal + cancel
/* common code for exec() methods */
static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
/* settings should have been set up ok for applying, so just apply! */
pose_slide_apply(C, op, pso);
/* cleanup and done */
pose_slide_exit(C, op);
return OPERATOR_FINISHED;
}
/* common code for defining RNA properties */
static void pose_slide_opdef_properties (wmOperatorType *ot)
{
RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame.", 0, 50);
RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame.", 0, 50);
RNA_def_float_percentage(ot->srna, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Weighting factor for the sliding operation", 0.3, 0.7);
}
/* ------------------------------------ */
/* invoke() - for 'push' mode */
static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *evt)
{
tPoseSlideOp *pso;
/* initialise data */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
else
pso= op->customdata;
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
/* exec() - for push */
static int pose_slide_push_exec (bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
/* initialise data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
else
pso= op->customdata;
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
void POSE_OT_push (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Push Pose";
ot->idname= "POSE_OT_push";
ot->description= "Exaggerate the current pose";
/* callbacks */
ot->exec= pose_slide_push_exec;
ot->invoke= pose_slide_push_invoke;
//ot->modal= pose_slide_modal;
//ot->cancel= pose_slide_cancel;
ot->poll= ED_operator_posemode;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;//|OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
}
/* ........................ */
/* invoke() - for 'relax' mode */
static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *evt)
{
tPoseSlideOp *pso;
/* initialise data */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
else
pso= op->customdata;
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
/* exec() - for relax */
static int pose_slide_relax_exec (bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
/* initialise data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
else
pso= op->customdata;
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
void POSE_OT_relax (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Relax Pose";
ot->idname= "POSE_OT_relax";
ot->description= "Make the current pose more similar to its surrounding ones.";
/* callbacks */
ot->exec= pose_slide_relax_exec;
ot->invoke= pose_slide_relax_invoke;
//ot->modal= pose_slide_modal;
//ot->cancel= pose_slide_cancel;
ot->poll= ED_operator_posemode;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;//|OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
}
/* ........................ */
/* invoke() - for 'breakdown' mode */
static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *evt)
{
tPoseSlideOp *pso;
/* initialise data */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
else
pso= op->customdata;
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
/* exec() - for breakdown */
static int pose_slide_breakdown_exec (bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
/* initialise data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
else
pso= op->customdata;
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
void POSE_OT_breakdown (wmOperatorType *ot)
{
/* identifiers */
ot->name= "Pose Breakdowner";
ot->idname= "POSE_OT_breakdown";
ot->description= "Create a suitable breakdown pose on the current frame.";
/* callbacks */
ot->exec= pose_slide_breakdown_exec;
ot->invoke= pose_slide_breakdown_invoke;
//ot->modal= pose_slide_modal;
//ot->cancel= pose_slide_cancel;
ot->poll= ED_operator_posemode;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;//|OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
}
/* **************************************************** */
|