From d72ce4a2d5fa62c6e897fbb173c0f4d45de087b9 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Fri, 23 Apr 2021 01:06:53 -0400 Subject: [PATCH] Fixed assert on macOS when -D_DEBUG defined, assertion guarding atan2f in Math.h not needed --- neo/CMakeLists.txt | 13 +++---------- neo/idlib/math/Math.h | 4 +++- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 6a25e62a..c3ccff8c 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -188,16 +188,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_CO endif() endif() - #SRS - some #ifdef _DEBUG code can cause game to crash on OSX, remove -D_DEBUG for now and fix later - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0") - #set(CMAKE_C_FLAGS_DEBUGALL "${CMAKE_C_FLAGS_DEBUGALL} -g -ggdb") - #set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -g -ggdb -O1 -fno-omit-frame-pointer") - else() - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -D_DEBUG -O0") - #set(CMAKE_C_FLAGS_DEBUGALL "${CMAKE_C_FLAGS_DEBUGALL} -g -ggdb -D_DEBUG") - #set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer") - endif() + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -D_DEBUG -O0") + #set(CMAKE_C_FLAGS_DEBUGALL "${CMAKE_C_FLAGS_DEBUGALL} -g -ggdb -D_DEBUG") + #set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") diff --git a/neo/idlib/math/Math.h b/neo/idlib/math/Math.h index ebaf8326..fa37b4e3 100644 --- a/neo/idlib/math/Math.h +++ b/neo/idlib/math/Math.h @@ -963,7 +963,9 @@ idMath::ATan */ ID_INLINE float idMath::ATan( float y, float x ) { - assert( fabs( y ) > idMath::FLT_SMALLEST_NON_DENORMAL || fabs( x ) > idMath::FLT_SMALLEST_NON_DENORMAL ); + // SRS - Don't need this assertion since atan2f(y,x) handles x=0, y=0 and x=0, y>0 or y<0 cases properly + // SRS - This assertion can cause game to stop prematurely when _DEBUG is defined and asserts are enabled + //assert( fabs( y ) > idMath::FLT_SMALLEST_NON_DENORMAL || fabs( x ) > idMath::FLT_SMALLEST_NON_DENORMAL ); return atan2f( y, x ); }