Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_nla.c
| Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | static void applyTransformNLA_translation(PointerRNA *strip_rna_ptr, const TransDataNla *transdata) | ||||
| */ | */ | ||||
| RNA_float_set(strip_rna_ptr, "frame_start", transdata->h1[0]); | RNA_float_set(strip_rna_ptr, "frame_start", transdata->h1[0]); | ||||
| RNA_float_set(strip_rna_ptr, "frame_end", transdata->h2[0]); | RNA_float_set(strip_rna_ptr, "frame_end", transdata->h2[0]); | ||||
| RNA_float_set(strip_rna_ptr, "frame_start", transdata->h1[0]); | RNA_float_set(strip_rna_ptr, "frame_start", transdata->h1[0]); | ||||
| RNA_float_set(strip_rna_ptr, "frame_end", transdata->h2[0]); | RNA_float_set(strip_rna_ptr, "frame_end", transdata->h2[0]); | ||||
| } | } | ||||
| static void applyTransformNLA_timeScale(PointerRNA *strip_rna_ptr, const float value) | |||||
| { | |||||
| RNA_float_set(strip_rna_ptr, "scale", value); | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name NLA Transform Creation | /** \name NLA Transform Creation | ||||
| * \{ */ | * \{ */ | ||||
| static void createTransNlaData(bContext *C, TransInfo *t) | static void createTransNlaData(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | if (ale->type == ANIMTYPE_NLATRACK) { | ||||
| tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt); | tdn->trackIndex = BLI_findindex(&adt->nla_tracks, nlt); | ||||
| yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla)); | yval = (float)(tdn->trackIndex * NLACHANNEL_STEP(snla)); | ||||
| tdn->h1[0] = strip->start; | tdn->h1[0] = strip->start; | ||||
| tdn->h1[1] = yval; | tdn->h1[1] = yval; | ||||
| tdn->h2[0] = strip->end; | tdn->h2[0] = strip->end; | ||||
| tdn->h2[1] = yval; | tdn->h2[1] = yval; | ||||
| tdn->h1[2] = tdn->h2[2] = strip->scale; | |||||
| center[0] = (float)scene->r.cfra; | center[0] = (float)scene->r.cfra; | ||||
| center[1] = yval; | center[1] = yval; | ||||
| center[2] = 0.0f; | center[2] = 0.0f; | ||||
| /* 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)scene->r.cfra)) { | if (FrameOnMouseSide(t->frame_side, strip->start, (float)scene->r.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 */ | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | if (t->state == TRANS_CANCEL) { | ||||
| /* end */ | /* end */ | ||||
| strip->end = tdn->h2[0]; | strip->end = tdn->h2[0]; | ||||
| if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) { | if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) { | ||||
| strip->next->start = tdn->h2[0]; | strip->next->start = tdn->h2[0]; | ||||
| } | } | ||||
| strip->scale = tdn->h1[2]; | |||||
| /* flush transforms to child strips (since this should be a meta) */ | /* flush transforms to child strips (since this should be a meta) */ | ||||
| BKE_nlameta_flush_transforms(strip); | BKE_nlameta_flush_transforms(strip); | ||||
| /* restore to original track (if needed) */ | /* restore to original track (if needed) */ | ||||
| if (tdn->oldTrack != tdn->nlt) { | if (tdn->oldTrack != tdn->nlt) { | ||||
| /* Just append to end of list for now, | /* Just append to end of list for now, | ||||
| * since strips get sorted in special_aftertrans_update(). */ | * since strips get sorted in special_aftertrans_update(). */ | ||||
| BLI_remlink(&tdn->nlt->strips, strip); | BLI_remlink(&tdn->nlt->strips, strip); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | for (short iter = 0; iter < 5; iter++) { | ||||
| } | } | ||||
| } | } | ||||
| /* Use RNA to write the values to ensure that constraints on these are obeyed | /* Use RNA to write the values to ensure that constraints on these are obeyed | ||||
| * (e.g. for transition strips, the values are taken from the neighbors) | * (e.g. for transition strips, the values are taken from the neighbors) | ||||
| */ | */ | ||||
| RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr); | RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr); | ||||
| switch (t->mode) { | |||||
| case TFM_TIME_EXTEND: | |||||
| case TFM_TIME_SCALE: { | |||||
| /* The final scale is the product of the original strip scale (from before the transform | |||||
| * operation started) and the current scale value of this transform operation. */ | |||||
| const float originalStripScale = tdn->h1[2]; | |||||
| const float newStripScale = originalStripScale * t->values_final[0]; | |||||
| applyTransformNLA_timeScale(&strip_ptr, newStripScale); | |||||
| applyTransformNLA_translation(&strip_ptr, tdn); | |||||
| break; | |||||
| } | |||||
| case TFM_TRANSLATION: | |||||
| applyTransformNLA_translation(&strip_ptr, tdn); | applyTransformNLA_translation(&strip_ptr, tdn); | ||||
| break; | |||||
| default: | |||||
| printf("recalcData_nla: unsupported NLA transformation mode %d\n", t->mode); | |||||
| continue; | |||||
| } | |||||
| /* flush transforms to child strips (since this should be a meta) */ | /* flush transforms to child strips (since this should be a meta) */ | ||||
| BKE_nlameta_flush_transforms(strip); | BKE_nlameta_flush_transforms(strip); | ||||
| /* Now, check if we need to try and move track: | /* Now, check if we need to try and move track: | ||||
| * - we need to calculate both, | * - we need to calculate both, | ||||
| * as only one may have been altered by transform if only 1 handle moved. | * as only one may have been altered by transform if only 1 handle moved. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines | |||||