this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

moved to alibs interval

Altagos 9ac7d611 c85cda01

+4 -141
+1 -1
src/hittable.zig
··· 2 2 3 3 const zm = @import("zmath"); 4 4 5 - const IntervalF32 = @import("interval.zig").IntervalF32; 5 + const IntervalF32 = @import("a").interval.IntervalF32; 6 6 const Material = @import("material.zig").Material; 7 7 const Ray = @import("ray.zig"); 8 8
+1 -1
src/hittable/sphere.zig
··· 1 1 const zm = @import("zmath"); 2 2 3 - const IntervalF32 = @import("../interval.zig").IntervalF32; 3 + const IntervalF32 = @import("a").interval.IntervalF32; 4 4 const Ray = @import("../ray.zig"); 5 5 const HitRecord = @import("../hittable.zig").HitRecord; 6 6 const Material = @import("../material.zig").Material;
-136
src/interval.zig
··· 1 - const std = @import("std"); 2 - 3 - pub const IntervalU8 = Interval(u8); 4 - pub const IntervalU16 = Interval(u16); 5 - pub const IntervalU32 = Interval(u32); 6 - pub const IntervalU64 = Interval(u64); 7 - pub const IntervalUsize = Interval(usize); 8 - 9 - pub const IntervalI8 = Interval(i8); 10 - pub const IntervalI16 = Interval(i16); 11 - pub const IntervalI32 = Interval(i32); 12 - pub const IntervalI64 = Interval(i64); 13 - pub const IntervalIsize = Interval(isize); 14 - 15 - pub const IntervalF32 = Interval(f32); 16 - pub const IntervalF64 = Interval(f64); 17 - 18 - pub const IntervalIteratorType = enum { 19 - inclusive, 20 - exclusive, 21 - }; 22 - 23 - pub fn Interval(comptime T: type) type { 24 - if (@typeInfo(T) == .Int) { 25 - return IntInterval(T); 26 - } else if (@typeInfo(T) == .Float) { 27 - return FloatInterval(T); 28 - } else { 29 - @compileError("Interval only supports Int and Float Types!"); 30 - } 31 - } 32 - 33 - fn IntInterval(comptime T: type) type { 34 - return struct { 35 - const Self = @This(); 36 - 37 - pub const empty: Self = .{ .min = std.math.inf(T), .max = -std.math.inf(T) }; 38 - pub const universe: Self = .{ .min = -std.math.inf(T), .max = std.math.inf(T) }; 39 - 40 - pub const Iterator = struct { 41 - interval: Self, 42 - current: T, 43 - 44 - lower_boundry: IntervalIteratorType = .inclusive, 45 - upper_boundry: IntervalIteratorType = .exclusive, 46 - 47 - pub fn init( 48 - interval: Self, 49 - lower_boundry: IntervalIteratorType, 50 - upper_boundry: IntervalIteratorType, 51 - ) Iterator { 52 - return .{ 53 - .interval = interval, 54 - .current = if (lower_boundry == .inclusive) interval.min else interval.min + 1, 55 - .lower_boundry = lower_boundry, 56 - .upper_boundry = upper_boundry, 57 - }; 58 - } 59 - 60 - pub fn next(self: *Iterator) ?T { 61 - self.current += 1; 62 - if (self.current < self.interval.max or (self.current == self.interval.max and self.upper_boundry == .inclusive)) { 63 - return self.current; 64 - } else return null; 65 - } 66 - 67 - pub fn nextInc(self: *Iterator) ?T { 68 - self.current += 1; 69 - return if (self.current <= self.interval.max) self.current else null; 70 - } 71 - 72 - pub fn nextExc(self: *Iterator) ?T { 73 - self.current += 1; 74 - return if (self.current < self.interval.max) self.current else null; 75 - } 76 - }; 77 - 78 - min: T, 79 - max: T, 80 - 81 - pub fn init(min: T, max: T) Interval { 82 - return .{ .min = min, .max = max }; 83 - } 84 - 85 - pub fn contains(self: *const Self, x: T) bool { 86 - return self.min <= x and x <= self.max; 87 - } 88 - 89 - pub fn surrounds(self: *const Self, x: T) bool { 90 - return self.min < x and x < self.max; 91 - } 92 - 93 - pub fn clamp(self: *const Self, x: T) T { 94 - if (x < self.min) return self.min; 95 - if (x > self.max) return self.max; 96 - return x; 97 - } 98 - 99 - pub fn iter(self: *const Self) Iterator { 100 - return Iterator{ 101 - .interval = self.*, 102 - .current = self.min, 103 - }; 104 - } 105 - }; 106 - } 107 - 108 - fn FloatInterval(comptime T: type) type { 109 - return struct { 110 - pub const empty: @This() = .{ .min = std.math.inf(T), .max = -std.math.inf(T) }; 111 - pub const universe: @This() = .{ .min = -std.math.inf(T), .max = std.math.inf(T) }; 112 - 113 - const Self = @This(); 114 - 115 - min: T, 116 - max: T, 117 - 118 - pub fn init(min: T, max: T) Self { 119 - return .{ .min = min, .max = max }; 120 - } 121 - 122 - pub fn contains(self: *const Self, x: T) bool { 123 - return self.min <= x and x <= self.max; 124 - } 125 - 126 - pub fn surrounds(self: *const Self, x: T) bool { 127 - return self.min < x and x < self.max; 128 - } 129 - 130 - pub fn clamp(self: *const Self, x: T) T { 131 - if (x < self.min) return self.min; 132 - if (x > self.max) return self.max; 133 - return x; 134 - } 135 - }; 136 - }
+1 -2
src/rayray.zig
··· 6 6 7 7 pub const Camera = @import("camera.zig"); 8 8 pub const hittable = @import("hittable.zig"); 9 - pub const interval = @import("interval.zig"); 10 9 pub const material = @import("material.zig"); 11 10 pub const renderer = @import("renderer.zig"); 12 11 13 - const IntervalUsize = @import("interval.zig").IntervalUsize; 12 + const IntervalUsize = @import("a").interval.IntervalUsize; 14 13 15 14 const log = std.log.scoped(.rayray); 16 15
+1 -1
src/renderer.zig
··· 10 10 const Ray = @import("ray.zig"); 11 11 const util = @import("util.zig"); 12 12 13 - const interval = @import("interval.zig"); 13 + const interval = @import("a").interval; 14 14 const IntervalUsize = interval.IntervalUsize; 15 15 const IntervalF32 = interval.IntervalF32; 16 16