Skip to content

Commit

Permalink
update to zig 0.12.0-dev.1607+f8b38a174
Browse files Browse the repository at this point in the history
  • Loading branch information
kdchambers committed Nov 15, 2023
1 parent ef9a7e6 commit d7fbf97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/geometry.zig
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn quadraticBezierPlaneIntersections(bezier: BezierQuadratic, horizontal_axi

pub fn triangleArea(p1: Point(f64), p2: Point(f64), p3: Point(f64)) f64 {
if (p1.x == p2.x and p2.x == p3.x) return 0.0;
return @fabs((p1.x * (p2.y - p3.y)) + (p2.x * (p3.y - p1.y)) + (p3.x * (p1.y - p2.y))) / 2.0;
return @abs((p1.x * (p2.y - p3.y)) + (p2.x * (p3.y - p1.y)) + (p3.x * (p1.y - p2.y))) / 2.0;
}

/// Given two points, one that lies inside a normalized boundry and one that lies outside
Expand Down
10 changes: 5 additions & 5 deletions src/rasterizer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const IntersectionList = struct {
std.debug.assert(dist_forward >= 0.0);
std.debug.assert(dist_forward < max_t);

const dist_reverse = @mod(@fabs(base_t + (max_t - candidate_t)), max_t);
const dist_reverse: f64 = @mod(@abs(base_t + (max_t - candidate_t)), max_t);
std.debug.assert(dist_reverse >= 0.0);
std.debug.assert(dist_reverse < max_t);

Expand All @@ -174,7 +174,7 @@ const IntersectionList = struct {
if (other.t == base_t or other.t == candidate_t) continue;
if (other_i == candidate_index or other_i == base_index) continue;
if (other.outline_index != base_outline_index) continue;
const dist_other = @mod(@fabs(base_t + (max_t - other.t)), max_t);
const dist_other = @mod(@abs(base_t + (max_t - other.t)), max_t);
if (dist_other < dist_reverse) {
return false;
}
Expand Down Expand Up @@ -458,7 +458,7 @@ const OutlineSamplerUnbounded = struct {
//
const t_per_pixel = current_segment.t_per_pixel;
self.t_increment = self.t_direction * (t_per_pixel / self.samples_per_pixel);
std.debug.assert(@fabs(self.t_increment) < 1.0);
std.debug.assert(@abs(self.t_increment) < 1.0);
if (self.t_direction == 1.0) {
self.t_current = @floor(self.t_current);
std.debug.assert(old_segment.to.x == current_segment.from.x);
Expand Down Expand Up @@ -968,7 +968,7 @@ fn combineIntersectionLists(
const is_t_connected = intersections.isTConnected(intersection_i, other_i, outline_max_t);
if (is_t_connected) {
// TODO: This doesn't take into account wrapping
const t_diff = @fabs(intersection.t - other_intersection.t);
const t_diff = @abs(intersection.t - other_intersection.t);
if (t_diff < smallest_t_diff) {
smallest_t_diff = t_diff;
best_match_index = other_i;
Expand Down Expand Up @@ -1138,7 +1138,7 @@ fn calculateHorizontalLineIntersections(scanline_y: f64, outlines: []Outline) !Y
}
if (optional_intersection_points[1]) |second_intersection| {
const x_diff_threshold = 0.001;
if (@fabs(second_intersection.x - first_intersection.x) > x_diff_threshold) {
if (@abs(second_intersection.x - first_intersection.x) > x_diff_threshold) {
const t_second = @mod(@as(f64, @floatFromInt(segment_i)) + second_intersection.t, max_t);
const intersection = YIntersection{
.outline_index = @as(u32, @intCast(outline_i)),
Expand Down

0 comments on commit d7fbf97

Please sign in to comment.