Skip to main content

wowlab_engine_domain/rotation/lower/ops/
timestamp.rs

1use super::super::super::backend::RotationBackend;
2
3pub(crate) fn ready<B>(b: &mut B, offset: usize) -> B::Bool
4where
5    B: RotationBackend,
6{
7    let ts = b.load_f64(offset);
8    let now = b.now();
9
10    b.cmp_gte_f(now, ts)
11}
12
13pub(crate) fn remaining<B>(b: &mut B, offset: usize) -> B::Float
14where
15    B: RotationBackend,
16{
17    let ts = b.load_f64(offset);
18    let now = b.now();
19    let diff = b.sub_f(ts, now);
20    let zero = b.const_f64(0.0);
21
22    b.max_f(diff, zero)
23}
24
25pub(crate) fn active<B>(b: &mut B, offset: usize) -> B::Bool
26where
27    B: RotationBackend,
28{
29    let ts = b.load_f64(offset);
30    let zero = b.const_f64(0.0);
31    let positive = b.cmp_gt_f(ts, zero);
32    let now = b.now();
33    let now_before = b.cmp_lt_f(now, ts);
34
35    b.and_b(positive, now_before)
36}
37
38pub(crate) fn inactive<B>(b: &mut B, offset: usize) -> B::Bool
39where
40    B: RotationBackend,
41{
42    let a = active(b, offset);
43
44    b.not_b(a)
45}
46
47pub(crate) fn elapsed<B>(b: &mut B, offset: usize) -> B::Float
48where
49    B: RotationBackend,
50{
51    let ts = b.load_f64(offset);
52    let now = b.now();
53
54    b.sub_f(now, ts)
55}