Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/anim_sys.c
| Show First 20 Lines • Show All 1,651 Lines • ▼ Show 20 Lines | static bool nla_combine_quaternion_get_inverted_strip_values(const float lower_values[4], | ||||
| invert_qt_normalized(tmp_lower); | invert_qt_normalized(tmp_lower); | ||||
| mul_qt_qtqt(r_strip_values, tmp_lower, tmp_blended); | mul_qt_qtqt(r_strip_values, tmp_lower, tmp_blended); | ||||
| pow_qt_fl_normalized(r_strip_values, 1.0f / influence); | pow_qt_fl_normalized(r_strip_values, 1.0f / influence); | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* Blend the specified snapshots into the target, and free the input snapshots. */ | |||||
| static void nlaeval_snapshot_mix_and_free(NlaEvalData *nlaeval, | |||||
| NlaEvalSnapshot *out, | |||||
| NlaEvalSnapshot *in1, | |||||
| NlaEvalSnapshot *in2, | |||||
| float alpha) | |||||
| { | |||||
| BLI_assert(in1->base == out && in2->base == out); | |||||
| nlaeval_snapshot_ensure_size(out, nlaeval->num_channels); | |||||
| for (int i = 0; i < nlaeval->num_channels; i++) { | |||||
| NlaEvalChannelSnapshot *c_in1 = nlaeval_snapshot_get(in1, i); | |||||
| NlaEvalChannelSnapshot *c_in2 = nlaeval_snapshot_get(in2, i); | |||||
| if (c_in1 || c_in2) { | |||||
| NlaEvalChannelSnapshot *c_out = out->channels[i]; | |||||
| /* Steal the entry from one of the input snapshots. */ | |||||
| if (c_out == NULL) { | |||||
| if (c_in1 != NULL) { | |||||
| c_out = c_in1; | |||||
| in1->channels[i] = NULL; | |||||
| } | |||||
| else { | |||||
| c_out = c_in2; | |||||
| in2->channels[i] = NULL; | |||||
| } | |||||
| } | |||||
| if (c_in1 == NULL) { | |||||
| c_in1 = nlaeval_snapshot_find_channel(in1->base, c_out->channel); | |||||
| } | |||||
| if (c_in2 == NULL) { | |||||
| c_in2 = nlaeval_snapshot_find_channel(in2->base, c_out->channel); | |||||
| } | |||||
| out->channels[i] = c_out; | |||||
| for (int j = 0; j < c_out->length; j++) { | |||||
| c_out->values[j] = c_in1->values[j] * (1.0f - alpha) + c_in2->values[j] * alpha; | |||||
| } | |||||
| } | |||||
| } | |||||
| nlaeval_snapshot_free_data(in1); | |||||
| nlaeval_snapshot_free_data(in2); | |||||
| } | |||||
| /* ---------------------- */ | /* ---------------------- */ | ||||
| /* F-Modifier stack joining/separation utilities - | /* F-Modifier stack joining/separation utilities - | ||||
| * should we generalize these for BLI_listbase.h interface? */ | * should we generalize these for BLI_listbase.h interface? */ | ||||
| /* Temporarily join two lists of modifiers together, storing the result in a third list */ | /* Temporarily join two lists of modifiers together, storing the result in a third list */ | ||||
| static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, ListBase *list2) | static void nlaeval_fmodifiers_join_stacks(ListBase *result, ListBase *list1, ListBase *list2) | ||||
| { | { | ||||
| FModifier *fcm1, *fcm2; | FModifier *fcm1, *fcm2; | ||||
| ▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | static void nlastrip_evaluate_transition(PointerRNA *ptr, | ||||
| /* second strip */ | /* second strip */ | ||||
| tmp_nes.strip_mode = NES_TIME_TRANSITION_END; | tmp_nes.strip_mode = NES_TIME_TRANSITION_END; | ||||
| tmp_nes.strip = s2; | tmp_nes.strip = s2; | ||||
| tmp_nes.strip_time = s2->strip_time; | tmp_nes.strip_time = s2->strip_time; | ||||
| nlaeval_snapshot_init(&snapshot2, channels, snapshot); | nlaeval_snapshot_init(&snapshot2, channels, snapshot); | ||||
| nlastrip_evaluate( | nlastrip_evaluate( | ||||
| ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot2, anim_eval_context, flush_to_original); | ptr, channels, &tmp_modifiers, &tmp_nes, &snapshot2, anim_eval_context, flush_to_original); | ||||
| /* accumulate temp-buffer and full-buffer, using the 'real' strip */ | /** Replace \a snapshot2 NULL channels with base or default values so all channels blend. */ | ||||
| nlaeval_snapshot_mix_and_free(channels, snapshot, &snapshot1, &snapshot2, nes->strip_time); | nlasnapshot_ensure_channels(channels, &snapshot2); | ||||
| nlasnapshot_blend( | |||||
| channels, &snapshot1, &snapshot2, NLASTRIP_MODE_REPLACE, nes->strip_time, snapshot); | |||||
| nlaeval_snapshot_free_data(&snapshot1); | |||||
| nlaeval_snapshot_free_data(&snapshot2); | |||||
| /* unlink this strip's modifiers from the parent's modifiers again */ | /* unlink this strip's modifiers from the parent's modifiers again */ | ||||
| nlaeval_fmodifiers_split_stacks(&nes->strip->modifiers, modifiers); | nlaeval_fmodifiers_split_stacks(&nes->strip->modifiers, modifiers); | ||||
| } | } | ||||
| /* evaluate meta-strip */ | /* evaluate meta-strip */ | ||||
| static void nlastrip_evaluate_meta(PointerRNA *ptr, | static void nlastrip_evaluate_meta(PointerRNA *ptr, | ||||
| NlaEvalData *channels, | NlaEvalData *channels, | ||||
| ▲ Show 20 Lines • Show All 587 Lines • ▼ Show 20 Lines | static void animsys_calculate_nla(PointerRNA *ptr, | ||||
| } | } | ||||
| /* free temp data */ | /* free temp data */ | ||||
| nlaeval_free(&echannels); | nlaeval_free(&echannels); | ||||
| } | } | ||||
| /* ---------------------- */ | /* ---------------------- */ | ||||
| void nlasnapshot_ensure_channels(NlaEvalData *eval_data, NlaEvalSnapshot *snapshot) | |||||
| { | |||||
| LISTBASE_FOREACH (NlaEvalChannel *, nec, &eval_data->channels) { | |||||
| nlaeval_snapshot_ensure_channel(snapshot, nec); | |||||
| } | |||||
| } | |||||
| /** Blends the \a lower_snapshot with the \a upper_snapshot into \a r_blended_snapshot according | /** Blends the \a lower_snapshot with the \a upper_snapshot into \a r_blended_snapshot according | ||||
| * to the given \a upper_blendmode and \a upper_influence. */ | * to the given \a upper_blendmode and \a upper_influence. */ | ||||
| void nlasnapshot_blend(NlaEvalData *eval_data, | void nlasnapshot_blend(NlaEvalData *eval_data, | ||||
| NlaEvalSnapshot *lower_snapshot, | NlaEvalSnapshot *lower_snapshot, | ||||
| NlaEvalSnapshot *upper_snapshot, | NlaEvalSnapshot *upper_snapshot, | ||||
| const short upper_blendmode, | const short upper_blendmode, | ||||
| const float upper_influence, | const float upper_influence, | ||||
| NlaEvalSnapshot *r_blended_snapshot) | NlaEvalSnapshot *r_blended_snapshot) | ||||
| ▲ Show 20 Lines • Show All 610 Lines • Show Last 20 Lines | |||||