Skip to content

Commit

Permalink
perf: pre-calculate inverses
Browse files Browse the repository at this point in the history
william-silversmith committed Feb 21, 2024
1 parent 53b3b61 commit ffd2059
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/xs3d.hpp
Original file line number Diff line number Diff line change
@@ -277,6 +277,13 @@ void check_intersections(
khat.dot(normal)
};

float inv_projections[3];
for (int i = 0; i < 3; i++) {
inv_projections[i] = (projections[i] == 0)
? 0
: 1.0 / projections[i];
}

const Vec3 pipe_points[4] = {
c[0], c[3], c[5], c[6]
};
@@ -329,7 +336,7 @@ void check_intersections(
continue;
}

float t = proj / proj2;
float t = proj * inv_projections[i >> 2];
if (std::abs(t) > 1 + epsilon) {
continue;
}

0 comments on commit ffd2059

Please sign in to comment.