diff options
Diffstat (limited to 'anim/src/cursor.zig')
| -rw-r--r-- | anim/src/cursor.zig | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig index 2f7be1a..6e3a5b7 100644 --- a/anim/src/cursor.zig +++ b/anim/src/cursor.zig @@ -109,6 +109,8 @@ pub const Cursor = struct { /// cannot be read at that pace is veiled. hurried: anim.Value, veil: anim.Value, + /// The veil over what a sprint also cannot show: the source and the band's view. + sprint_veil: anim.Value, /// Steps taken. count: anim.Value, /// The levels the scene shows: set before the first step. @@ -130,6 +132,7 @@ pub const Cursor = struct { .marks = .{ s.value(here), s.value(here) }, .hurried = s.value(0), .veil = s.value(0), + .sprint_veil = s.value(0), .count = s.value(0), .first = start, .last = start, @@ -202,8 +205,13 @@ pub const Cursor = struct { pub fn reading(c: Cursor, from: u64, to: u64) Plan { const rec = c.rec; const regs: f32 = @floatFromInt(@popCount(rec.registersChanged(from, to) & ~quiet)); - const wrote: f32 = @floatFromInt(rec.written(from, to).len); - const touched = wrote > 0 or rec.read(from, to).len > 0; + // Memory gives up its slot when nothing it touched is drawn. + var wrote_n: usize = 0; + for (rec.written(from, to)) |span| wrote_n += @intFromBool(rec.drawn(span, from, to)); + var read_n: usize = 0; + for (rec.read(from, to)) |span| read_n += @intFromBool(rec.drawn(span, from, to)); + const wrote: f32 = @floatFromInt(wrote_n); + const touched = wrote_n > 0 or read_n > 0; const deeper = rec.depths[to] > rec.depths[from]; const back = rec.depths[to] < rec.depths[from]; const levels = [3]bool{ @@ -221,8 +229,8 @@ pub const Cursor = struct { // A drawing made of the bytes reacts when the projection from // them arrives: its bracket and its line after their strike, and // for a write its own arm. - const projected = level == 2 and is and levels[1] and c.levels.idea == .data; - if (projected) slot += time.project.bracket + time.project.draw + @as(f32, if (wrote > 0) time.strike.arm else 0) else if (is) slot += time.cascade; + const projected = level == 2 and is and levels[1] and (c.levels.idea == .data or deeper); + if (projected) slot += time.project.bracket + @as(f32, if (c.levels.idea == .data) time.project.draw else time.project.far) + @as(f32, if (wrote > 0 and c.levels.idea == .data) time.strike.arm else 0) else if (is) slot += time.cascade; strikes.* = @max(slot, time.cascade); } // The writes of one step strike 6 f apart: the last is later. @@ -288,9 +296,10 @@ pub const Cursor = struct { const n: f32 = @floatFromInt(c.steps(by, here, until)); if (n == 0) return; // Anticipation: the veil and the counter come with the first shortened step. - const veiled = options.veil orelse (options.pace < time.run); + // What changes faster than it can be read is veiled at a run too. + const veiled = options.veil orelse true; const start = s.cursor; - s.play(.{ c.hurried.to(1), c.veil.to(if (veiled) 1 else 0) }, .{ .seconds = time.veil, .ease = anim.ease.linear }); + s.play(.{ c.hurried.to(1), c.veil.to(if (veiled) 1 else 0), c.sprint_veil.to(if (options.pace < time.run) 1 else 0) }, .{ .seconds = time.veil, .ease = anim.ease.linear }); s.cursor = start; var k: f32 = 0; while (here < until) : (k += 1) { @@ -306,7 +315,7 @@ pub const Cursor = struct { here = next; } if (!options.settle) return; - s.play(.{ c.hurried.to(0), c.veil.to(0) }, .{ .seconds = time.veil, .ease = anim.ease.linear }); + s.play(.{ c.hurried.to(0), c.veil.to(0), c.sprint_veil.to(0) }, .{ .seconds = time.veil, .ease = anim.ease.linear }); s.wait(time.beat); } @@ -337,6 +346,7 @@ pub const Cursor = struct { .marks = .{ whole(rec, placed.value(c.marks[0])), whole(rec, placed.value(c.marks[1])) }, .hurried = placed.value(c.hurried), .veil = placed.value(c.veil), + .sprint_veil = placed.value(c.sprint_veil), .count = @intFromFloat(@max(placed.value(c.count), 0)), .of = c.of, .place = 0, @@ -385,6 +395,7 @@ pub const Now = struct { /// 0 to 1: steps are hurried; what cannot be read is veiled. hurried: f32, veil: f32, + sprint_veil: f32 = 0, /// Steps taken, of how many in the scene (0: not told). count: u32, of: u32, |
