Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_nla.c
| Show All 31 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_convert.h" | #include "transform_convert.h" | ||||
| #include "transform_data.h" | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name NLA Transform Creation | /** \name NLA Transform Creation | ||||
| * | * | ||||
| * \{ */ | * \{ */ | ||||
| void createTransNlaData(bContext *C, TransInfo *t) | void createTransNlaData(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| SpaceNla *snla = NULL; | SpaceNla *snla = NULL; | ||||
| TransData *td = NULL; | |||||
| TransDataNla *tdn = NULL; | TransDataNla *tdn = NULL; | ||||
| bAnimContext ac; | bAnimContext ac; | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| int count = 0; | int count = 0; | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | if (count == 0) { | ||||
| /* cleanup temp list */ | /* cleanup temp list */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| return; | return; | ||||
| } | } | ||||
| /* allocate memory for data */ | /* allocate memory for data */ | ||||
| tc->data_len = count; | tc->data_len = count; | ||||
| TransData *td = tc->data = transform_data_alloc(tc->data_len, TD_BASIC_COMP); | |||||
| int tdi = 0; | |||||
| tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransData(NLA Editor)"); | |||||
| td = tc->data; | |||||
| tc->custom.type.data = tdn = MEM_callocN(tc->data_len * sizeof(TransDataNla), | tc->custom.type.data = tdn = MEM_callocN(tc->data_len * sizeof(TransDataNla), | ||||
| "TransDataNla (NLA Editor)"); | "TransDataNla (NLA Editor)"); | ||||
| tc->custom.type.use_free = true; | tc->custom.type.use_free = true; | ||||
| /* loop 2: build transdata array */ | /* loop 2: build transdata array */ | ||||
| for (ale = anim_data.first; ale; ale = ale->next) { | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| /* only if a real NLA-track */ | /* only if a real NLA-track */ | ||||
| if (ale->type == ANIMTYPE_NLATRACK) { | if (ale->type == ANIMTYPE_NLATRACK) { | ||||
| Show All 37 Lines | if (ale->type == ANIMTYPE_NLATRACK) { | ||||
| /* set td's based on which handles are applicable */ | /* set td's based on which handles are applicable */ | ||||
| if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) { | if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) { | ||||
| /* just set tdn to assume that it only has one handle for now */ | /* just set tdn to assume that it only has one handle for now */ | ||||
| tdn->handle = -1; | tdn->handle = -1; | ||||
| /* now, link the transform data up to this data */ | /* now, link the transform data up to this data */ | ||||
| if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { | if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { | ||||
| td->loc = tdn->h1; | td->basic[tdi].loc = tdn->h1; | ||||
| copy_v3_v3(td->iloc, tdn->h1); | copy_v3_v3(td->basic[tdi].iloc, tdn->h1); | ||||
| /* store all the other gunk that is required by transform */ | /* store all the other gunk that is required by transform */ | ||||
| copy_v3_v3(td->center, center); | copy_v3_v3(td->center[tdi], center); | ||||
| memset(td->axismtx, 0, sizeof(td->axismtx)); | const float axismtx[3][3] = { | ||||
| td->axismtx[2][2] = 1.0f; | {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}}; | ||||
| copy_m3_m3(td->space[tdi].axismtx, axismtx); | |||||
| td->ext = NULL; | td->special[tdi].val = NULL; | ||||
| td->val = NULL; | |||||
| td->flag |= TD_SELECTED; | td->basic[tdi].flag |= TD_SELECTED; | ||||
| td->dist = 0.0f; | td->prop[tdi].dist = 0.0f; | ||||
| unit_m3(td->mtx); | unit_m3(td->space[tdi].mtx); | ||||
| unit_m3(td->smtx); | unit_m3(td->space[tdi].smtx); | ||||
| } | } | ||||
| else { | else { | ||||
| /* time scaling only needs single value */ | /* time scaling only needs single value */ | ||||
| td->val = &tdn->h1[0]; | td->special[tdi].val = &tdn->h1[0]; | ||||
| td->ival = tdn->h1[0]; | td->special[tdi].ival = tdn->h1[0]; | ||||
| } | } | ||||
| td->extra = tdn; | td->basic[tdi].extra = tdn; | ||||
| td++; | tdi++; | ||||
| } | } | ||||
| if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) { | if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) { | ||||
| /* if tdn is already holding the start handle, | /* if tdn is already holding the start handle, | ||||
| * then we're doing both, otherwise, only end */ | * then we're doing both, otherwise, only end */ | ||||
| tdn->handle = (tdn->handle) ? 2 : 1; | tdn->handle = (tdn->handle) ? 2 : 1; | ||||
| /* now, link the transform data up to this data */ | /* now, link the transform data up to this data */ | ||||
| if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { | if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) { | ||||
| td->loc = tdn->h2; | td->basic[tdi].loc = tdn->h2; | ||||
| copy_v3_v3(td->iloc, tdn->h2); | copy_v3_v3(td->basic[tdi].iloc, tdn->h2); | ||||
| /* store all the other gunk that is required by transform */ | /* store all the other gunk that is required by transform */ | ||||
| copy_v3_v3(td->center, center); | copy_v3_v3(td->center[tdi], center); | ||||
| memset(td->axismtx, 0, sizeof(td->axismtx)); | const float axismtx[3][3] = { | ||||
| td->axismtx[2][2] = 1.0f; | {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f}}; | ||||
| copy_m3_m3(td->space[tdi].axismtx, axismtx); | |||||
| td->ext = NULL; | td->special[tdi].val = NULL; | ||||
| td->val = NULL; | |||||
| td->flag |= TD_SELECTED; | td->basic[tdi].flag |= TD_SELECTED; | ||||
| td->dist = 0.0f; | td->prop[tdi].dist = 0.0f; | ||||
| unit_m3(td->mtx); | unit_m3(td->space[tdi].mtx); | ||||
| unit_m3(td->smtx); | unit_m3(td->space[tdi].smtx); | ||||
| } | } | ||||
| else { | else { | ||||
| /* time scaling only needs single value */ | /* time scaling only needs single value */ | ||||
| td->val = &tdn->h2[0]; | td->special[tdi].val = &tdn->h2[0]; | ||||
| td->ival = tdn->h2[0]; | td->special[tdi].ival = tdn->h2[0]; | ||||
| } | } | ||||
| td->extra = tdn; | td->basic[tdi].extra = tdn; | ||||
| td++; | tdi++; | ||||
| } | } | ||||
| /* If both handles were used, skip the next tdn (i.e. leave it blank) | /* If both handles were used, skip the next tdn (i.e. leave it blank) | ||||
| * since the counting code is dumb. | * since the counting code is dumb. | ||||
| * Otherwise, just advance to the next one. | * Otherwise, just advance to the next one. | ||||
| */ | */ | ||||
| if (tdn->handle == 2) { | if (tdn->handle == 2) { | ||||
| tdn += 2; | tdn += 2; | ||||
| Show All 15 Lines | |||||