MCPcopy Create free account
hub / github.com/defold/defold / SampleMorphWeightTrack

Function SampleMorphWeightTrack

engine/rig/src/rig.cpp:515–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513 }
514
515 static void SampleMorphWeightTrack(const dmRigDDF::MorphWeightTrack* track, float t, float sample_rate, float* out_weights)
516 {
517 uint32_t dim = track->m_MorphCount;
518 uint32_t total_floats = track->m_Weights.m_Count;
519 if (dim == 0 || total_floats == 0)
520 return;
521 uint32_t num_poses = total_floats / dim;
522 if (num_poses == 0)
523 return;
524
525 float fraction = t * sample_rate;
526 uint32_t sample = (uint32_t)fraction;
527 fraction -= sample;
528 if (sample >= num_poses - 1)
529 {
530 sample = num_poses - 1;
531 fraction = 0.0f;
532 }
533
534 const float* data = track->m_Weights.m_Data;
535 for (uint32_t d = 0; d < dim; ++d)
536 {
537 uint32_t i0 = sample * dim + d;
538 if (sample + 1 < num_poses)
539 {
540 uint32_t i1 = i0 + dim;
541 out_weights[d] = data[i0] + fraction * (data[i1] - data[i0]);
542 }
543 else
544 {
545 out_weights[d] = data[i0];
546 }
547 }
548 }
549
550 static void ApplyMorphAnimation(RigInstance* instance, RigPlayer* player, float blend_weight)
551 {

Callers 1

ApplyMorphAnimationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected