diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-04-20 19:45:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-04-20 19:45:36 +0900 |
| commit | 76657dddd4f37f55a3912ac44d2ba8722645b1b6 (patch) | |
| tree | 936903feec51b0f6f6f1f97b5b83fcdb452ebf69 /src/rtw/texture.zig | |
| parent | daff2a6d02ca5e7683156551cc1b9b146fa4121d (diff) | |
| download | RayTracingInOneWeekend.zig-76657dddd4f37f55a3912ac44d2ba8722645b1b6.tar.gz RayTracingInOneWeekend.zig-76657dddd4f37f55a3912ac44d2ba8722645b1b6.tar.zst RayTracingInOneWeekend.zig-76657dddd4f37f55a3912ac44d2ba8722645b1b6.zip | |
refactor: use anonymous enum for tagged-union
Diffstat (limited to 'src/rtw/texture.zig')
| -rw-r--r-- | src/rtw/texture.zig | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/rtw/texture.zig b/src/rtw/texture.zig index ff17579..402fb1a 100644 --- a/src/rtw/texture.zig +++ b/src/rtw/texture.zig @@ -7,14 +7,7 @@ const rgb = @import("vec.zig").rgb; const Random = @import("rand.zig").Random; const Perlin = @import("perlin.zig").Perlin; -const TextureTag = enum { - solid, - checker, - noise, - image, -}; - -pub const Texture = union(TextureTag) { +pub const Texture = union(enum) { solid: SolidTexture, checker: CheckerTexture, noise: NoiseTexture, @@ -42,10 +35,10 @@ pub const Texture = union(TextureTag) { pub fn value(tx: Texture, u: f64, v: f64, p: Vec3) Color { return switch (tx) { - TextureTag.solid => |solid_tx| solid_tx.value(u, v, p), - TextureTag.checker => |checker_tx| checker_tx.value(u, v, p), - TextureTag.noise => |noise_tx| noise_tx.value(u, v, p), - TextureTag.image => |image_tx| image_tx.value(u, v, p), + .solid => |solid_tx| solid_tx.value(u, v, p), + .checker => |checker_tx| checker_tx.value(u, v, p), + .noise => |noise_tx| noise_tx.value(u, v, p), + .image => |image_tx| image_tx.value(u, v, p), }; } }; |
