Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/anim_sys.c
| Context not available. | |||||
| 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? */ | ||||
| Context not available. | |||||
| 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); | ||||
| Context not available. | |||||
| /* ---------------------- */ | /* ---------------------- */ | ||||
| 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, | ||||
| Context not available. | |||||