Skip to content

Commit

Permalink
feat(glsl): add compare utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan committed Dec 2, 2024
1 parent 69b700e commit 9471c90
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions assets/shaders/math/math.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ float length_sqr(vec3 v) { return pow2(v.x) + pow2(v.y) + pow2(v.z); }
float units_to_meters(float units) { return units * 0.025; }
float meters_to_units(float meters) { return meters / 0.025; }

bool compare(float a, float b) { return abs(a - b) < FLT_EPSILON; }
bool compare(vec3 a, vec3 b) { return compare(a.x, b.x) && compare(a.y, b.y) && compare(a.z, b.z); }

float atan2(in float y, in float x)
{
// Source: https://stackoverflow.com/a/27228836
Expand Down

0 comments on commit 9471c90

Please sign in to comment.