this repo has no description
0
fork

Configure Feed

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

smiplified object sorting

Altagos 16cfd023 86d378d6

+5 -25
+5 -25
src/BVH.zig
··· 84 84 } 85 85 86 86 const axis = ast_bbox.longestAxis(); 87 - 88 - if (axis == 0) { 89 - std.mem.sort(Hittable, objects, .{}, boxXCompare); 90 - } else if (axis == 1) { 91 - std.mem.sort(Hittable, objects, .{}, boxYCompare); 92 - } else { 93 - std.mem.sort(Hittable, objects, .{}, boxZCompare); 94 - } 87 + std.mem.sort(Hittable, objects, axis, boxCompare); 95 88 96 89 var left = try allocator.create(Node); 97 90 var right = try allocator.create(Node); ··· 133 126 switch (self.*) { 134 127 inline else => |*n| if (n.bbox.hit(r, ray_t)) { 135 128 return n.hit(r, ray_t); 136 - } else { 137 - return null; 138 129 }, 139 130 } 131 + 132 + return null; 140 133 } 141 134 }; 142 135 ··· 149 142 150 143 const root = try allocator.create(Node); 151 144 try root.init(allocator, objects.list.items, max_depth, 0); 152 - // const bbox = root.recomputeBbox(); 153 145 154 146 log.debug("Reached depth of: {}, max objects: {}", .{ reached_depth, max_objects }); 155 147 ··· 167 159 return self.root.hit(r, ray_t); 168 160 } 169 161 170 - inline fn boxCompare(a: *Hittable, b: *Hittable, axis_index: i32) bool { 171 - return a.boundingBox().axisInterval(axis_index).min < b.boundingBox().axisInterval(axis_index).min; 172 - } 173 - 174 - fn boxXCompare(_: @TypeOf(.{}), a: Hittable, b: Hittable) bool { 175 - return boxCompare(@constCast(&a), @constCast(&b), 0); 176 - } 177 - 178 - fn boxYCompare(_: @TypeOf(.{}), a: Hittable, b: Hittable) bool { 179 - return boxCompare(@constCast(&a), @constCast(&b), 1); 180 - } 181 - 182 - fn boxZCompare(_: @TypeOf(.{}), a: Hittable, b: Hittable) bool { 183 - return boxCompare(@constCast(&a), @constCast(&b), 2); 162 + fn boxCompare(axis_index: i32, a: Hittable, b: Hittable) bool { 163 + return @constCast(&a).boundingBox().axisInterval(axis_index).min < @constCast(&b).boundingBox().axisInterval(axis_index).min; 184 164 }
src/camera.zig src/Camera.zig