Merge pull request #496 from 94xhn/fix/aabb-sphere-below-min-face-selection

box/aabb2d: fix wrong face selected below AABB min bound in sphere/circle test
This commit is contained in:
Recep Aslantas
2026-07-18 18:32:22 +03:00
committed by GitHub
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -235,8 +235,8 @@ glm_aabb2d_circle(vec2 aabb[2], vec3 c) {
a = (c[0] < aabb[0][0]) + (c[0] > aabb[1][0]);
b = (c[1] < aabb[0][1]) + (c[1] > aabb[1][1]);
dmin = glm_pow2((c[0] - aabb[!(a - 1)][0]) * (a != 0))
+ glm_pow2((c[1] - aabb[!(b - 1)][1]) * (b != 0));
dmin = glm_pow2((c[0] - aabb[c[0] > aabb[1][0]][0]) * (a != 0))
+ glm_pow2((c[1] - aabb[c[1] > aabb[1][1]][1]) * (b != 0));
return dmin <= glm_pow2(c[2]);
}
+3 -3
View File
@@ -243,9 +243,9 @@ glm_aabb_sphere(vec3 box[2], vec4 s) {
b = (s[1] < box[0][1]) + (s[1] > box[1][1]);
c = (s[2] < box[0][2]) + (s[2] > box[1][2]);
dmin = glm_pow2((s[0] - box[!(a - 1)][0]) * (a != 0))
+ glm_pow2((s[1] - box[!(b - 1)][1]) * (b != 0))
+ glm_pow2((s[2] - box[!(c - 1)][2]) * (c != 0));
dmin = glm_pow2((s[0] - box[s[0] > box[1][0]][0]) * (a != 0))
+ glm_pow2((s[1] - box[s[1] > box[1][1]][1]) * (b != 0))
+ glm_pow2((s[2] - box[s[2] > box[1][2]][2]) * (c != 0));
return dmin <= glm_pow2(s[3]);
}