MCPcopy Create free account
hub / github.com/crownengine/crown / evaluate

Function evaluate

src/world/sprite_animation_player.cpp:51–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 }
50
51 void evaluate(SpriteAnimationPlayer &p, AnimationId anim_id, f32 time, UnitId unit, EventStream &events)
52 {
53 SpriteAnimationPlayer::Index &index = p._indices[anim_id & ANIMATION_INDEX_MASK];
54 SpriteAnimationPlayer::Animation &a = p._animations[index.index];
55
56 CE_ENSURE(time <= a.time_total);
57 const f32 frame_ratio = time / a.time_total;
58 const u32 frame_unclamped = u32(frame_ratio * f32(a.num_frames));
59 const u32 frame_index = min(frame_unclamped, a.num_frames - 1);
60
61 SpriteFrameChangeEvent ev;
62 ev.unit = unit;
63 ev.frame_num = a.frames[frame_index];
64 event_stream::write(events, 0, ev);
65 }
66
67} // namespace sprite_animation_player
68

Callers

nothing calls this directly

Calls 2

minFunction · 0.50
writeFunction · 0.50

Tested by

no test coverage detected