Fixed build with MSVC.

This commit is contained in:
Relintai 2024-01-19 14:09:27 +00:00
parent 61ceb39736
commit 2de9d4d9dc
2 changed files with 8 additions and 14 deletions

View File

@ -117,8 +117,9 @@ AABB AABB::intersection(const AABB &p_aabb) const {
bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const { bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
Vector3 c1, c2; Vector3 c1, c2;
Vector3 end = position + size; Vector3 end = position + size;
real_t near = -1e20; //<windows.h> has a far and near macro defined, and we can't undo it here in the amalgamation
real_t far = 1e20; real_t aabb_near = -1e20;
real_t aabb_far = 1e20;
int axis = 0; int axis = 0;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -133,14 +134,14 @@ bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *
if (c1[i] > c2[i]) { if (c1[i] > c2[i]) {
SWAP(c1, c2); SWAP(c1, c2);
} }
if (c1[i] > near) { if (c1[i] > aabb_near) {
near = c1[i]; aabb_near = c1[i];
axis = i; axis = i;
} }
if (c2[i] < far) { if (c2[i] < aabb_far) {
far = c2[i]; aabb_far = c2[i];
} }
if ((near > far) || (far < 0)) { if ((aabb_near > aabb_far) || (aabb_far < 0)) {
return false; return false;
} }
} }

View File

@ -56,13 +56,6 @@
#undef ONLY_GLAD #undef ONLY_GLAD
#include "sfw_3rd.m" #include "sfw_3rd.m"
#if defined(_WIN64) || defined(_WIN32)
#undef far
#undef near
#undef FAR
#undef NEAR
#endif
#undef CursorShape #undef CursorShape
#if defined(__linux__) #if defined(__linux__)