diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e0743c5cb..d92b7379b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,19 +127,23 @@ endif() # Global configuration types ################################################################################ if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") -set(CMAKE_C_FLAGS_DEBUG "-g -ffast-math -DDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-g -ffast-math -DDEBUG") -set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") +set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG") +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") else() set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG") endif() -# IEEE 754 compliant floating-point rounding on arm64 macOS -if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - add_compile_options(-Xarch_arm64 -ffp-contract=off) -endif() + +# Enforce strict, deterministic IEEE-754 floating-point to match N64 (MIPS) semantics. +# Never enable fast-math, and disable FMA contraction: the R4300 CPU and RSP have no +# fused multiply-add, so contracting mul+add into an FMA produces extra precision. +add_compile_options($<$:-fno-fast-math>) +add_compile_options($<$:-ffp-contract=off>) +add_compile_options($<$:/fp:precise>) +add_compile_options($<$:/fp:except->) if(NOT CMAKE_BUILD_TYPE ) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) diff --git a/soh/src/code/z_bgcheck.c b/soh/src/code/z_bgcheck.c index f0ad28568b..e98e66e44d 100644 --- a/soh/src/code/z_bgcheck.c +++ b/soh/src/code/z_bgcheck.c @@ -399,16 +399,6 @@ s32 CollisionPoly_LineVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* posA, V (poly->normal.x * posB->x + poly->normal.y * posB->y + poly->normal.z * posB->z) * COLPOLY_NORMAL_FRAC + plane.originDist; -#if defined(__SWITCH__) || defined(__WIIU__) - // on some platforms this ends up as very small numbers due to rounding issues - if (IS_ZERO(planeDistA)) { - planeDistA = 0.0f; - } - if (IS_ZERO(planeDistB)) { - planeDistB = 0.0f; - } -#endif - planeDistDelta = planeDistA - planeDistB; if ((planeDistA >= 0.0f && planeDistB >= 0.0f) || (planeDistA < 0.0f && planeDistB < 0.0f) || (chkOneFace && planeDistA < 0.0f && planeDistB > 0.0f) || IS_ZERO(planeDistDelta)) {