MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / find_keyframe_pair

Function find_keyframe_pair

native/shared/src/models.rs:669–689  ·  view source on GitHub ↗
(timestamps: &[f32], time: f32)

Source from the content-addressed store, hash-verified

667}
668
669fn find_keyframe_pair(timestamps: &[f32], time: f32) -> (usize, usize, f32) {
670 if timestamps.len() <= 1 {
671 return (0, 0, 0.0);
672 }
673 if time <= timestamps[0] {
674 return (0, 0, 0.0);
675 }
676 if time >= timestamps[timestamps.len() - 1] {
677 let last = timestamps.len() - 1;
678 return (last, last, 0.0);
679 }
680 for i in 0..timestamps.len() - 1 {
681 if time >= timestamps[i] && time < timestamps[i + 1] {
682 let dt = timestamps[i + 1] - timestamps[i];
683 let t = if dt > 0.0 { (time - timestamps[i]) / dt } else { 0.0 };
684 return (i, i + 1, t);
685 }
686 }
687 let last = timestamps.len() - 1;
688 (last, last, 0.0)
689}
690
691fn sample_vec3(timestamps: &[f32], values: &[[f32; 3]], time: f32) -> [f32; 3] {
692 if values.is_empty() { return [0.0; 3]; }

Callers 2

sample_vec3Function · 0.85
sample_quatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected