diff --git a/irr/include/IMeshBuffer.h b/irr/include/IMeshBuffer.h index 55c05211a..afcf28943 100644 --- a/irr/include/IMeshBuffer.h +++ b/irr/include/IMeshBuffer.h @@ -11,6 +11,7 @@ #include "IIndexBuffer.h" #include "EHardwareBufferFlags.h" #include "EPrimitiveTypes.h" +#include namespace irr { @@ -121,7 +122,7 @@ public: /** \return Pointer to indices array. */ inline const u16 *getIndices() const { - _IRR_DEBUG_BREAK_IF(getIndexBuffer()->getType() != video::EIT_16BIT); + assert(getIndexBuffer()->getType() == video::EIT_16BIT); return static_cast(getIndexBuffer()->getData()); } @@ -129,7 +130,7 @@ public: /** \return Pointer to indices array. */ inline u16 *getIndices() { - _IRR_DEBUG_BREAK_IF(getIndexBuffer()->getType() != video::EIT_16BIT); + assert(getIndexBuffer()->getType() == video::EIT_16BIT); return static_cast(getIndexBuffer()->getData()); } diff --git a/irr/include/IReferenceCounted.h b/irr/include/IReferenceCounted.h index 65c991db2..80454f9ea 100644 --- a/irr/include/IReferenceCounted.h +++ b/irr/include/IReferenceCounted.h @@ -5,6 +5,7 @@ #pragma once #include "irrTypes.h" +#include namespace irr { @@ -118,7 +119,7 @@ public: bool drop() const { // someone is doing bad reference counting. - _IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) + assert(ReferenceCounter > 0); --ReferenceCounter; if (!ReferenceCounter) { diff --git a/irr/include/ISceneNode.h b/irr/include/ISceneNode.h index c80ff4b48..f91fd6499 100644 --- a/irr/include/ISceneNode.h +++ b/irr/include/ISceneNode.h @@ -16,6 +16,7 @@ #include #include #include +#include namespace irr { @@ -268,7 +269,7 @@ public: return false; // The iterator must be set since the parent is not null. - _IRR_DEBUG_BREAK_IF(!child->ThisIterator.has_value()); + assert(child->ThisIterator.has_value()); auto it = *child->ThisIterator; child->ThisIterator = std::nullopt; child->Parent = nullptr; diff --git a/irr/include/SSkinMeshBuffer.h b/irr/include/SSkinMeshBuffer.h index eb3f7371f..8b2e26882 100644 --- a/irr/include/SSkinMeshBuffer.h +++ b/irr/include/SSkinMeshBuffer.h @@ -8,6 +8,7 @@ #include "CVertexBuffer.h" #include "CIndexBuffer.h" #include "S3DVertex.h" +#include namespace irr { @@ -200,7 +201,7 @@ public: //! append the vertices and indices to the current buffer void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override { - _IRR_DEBUG_BREAK_IF(true); + assert(false); } //! Describe what kind of primitive geometry is used by the meshbuffer diff --git a/irr/include/irrArray.h b/irr/include/irrArray.h index 834dc825c..2542d0542 100644 --- a/irr/include/irrArray.h +++ b/irr/include/irrArray.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "irrTypes.h" #include "irrMath.h" @@ -108,7 +109,7 @@ public: \param index: Where position to insert the new element. */ void insert(const T &element, u32 index = 0) { - _IRR_DEBUG_BREAK_IF(index > m_data.size()) // access violation + assert(index <= m_data.size()); auto pos = std::next(m_data.begin(), index); m_data.insert(pos, element); is_sorted = false; @@ -190,32 +191,28 @@ public: //! Direct access operator T &operator[](u32 index) { - _IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation - + assert(index < m_data.size()); return m_data[index]; } //! Direct const access operator const T &operator[](u32 index) const { - _IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation - + assert(index < m_data.size()); return m_data[index]; } //! Gets last element. T &getLast() { - _IRR_DEBUG_BREAK_IF(m_data.empty()) // access violation - + assert(!m_data.empty()); return m_data.back(); } //! Gets last element const T &getLast() const { - _IRR_DEBUG_BREAK_IF(m_data.empty()) // access violation - + assert(!m_data.empty()); return m_data.back(); } @@ -365,7 +362,7 @@ public: \param index: Index of element to be erased. */ void erase(u32 index) { - _IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation + assert(index < m_data.size()); auto it = std::next(m_data.begin(), index); m_data.erase(it); } diff --git a/irr/include/irrString.h b/irr/include/irrString.h index 76e0548d3..465664e87 100644 --- a/irr/include/irrString.h +++ b/irr/include/irrString.h @@ -11,6 +11,7 @@ #include #include #include +#include /* HACK: import these string methods from MT's util/string.h */ extern std::wstring utf8_to_wide(std::string_view input); @@ -174,9 +175,9 @@ public: } if constexpr (sizeof(T) != sizeof(B)) { - _IRR_DEBUG_BREAK_IF( - (uintptr_t)c >= (uintptr_t)(str.data()) && - (uintptr_t)c < (uintptr_t)(str.data() + str.size())); + assert( + (uintptr_t)c < (uintptr_t)(str.data()) || + (uintptr_t)c >= (uintptr_t)(str.data() + str.size())); } if ((void *)c == (void *)c_str()) diff --git a/irr/include/irrTypes.h b/irr/include/irrTypes.h index 910991689..9e71d0771 100644 --- a/irr/include/irrTypes.h +++ b/irr/include/irrTypes.h @@ -5,6 +5,7 @@ #pragma once #include +#include namespace irr { @@ -65,22 +66,6 @@ typedef char fschar_t; } // end namespace irr -//! define a break macro for debugging. -#if defined(_DEBUG) -#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) -#include -#define _IRR_DEBUG_BREAK_IF(_CONDITION_) \ - if (_CONDITION_) { \ - _CrtDbgBreak(); \ - } -#else -#include -#define _IRR_DEBUG_BREAK_IF(_CONDITION_) assert(!(_CONDITION_)); -#endif -#else -#define _IRR_DEBUG_BREAK_IF(_CONDITION_) -#endif - //! deprecated macro for virtual function override /** prefer to use the override keyword for new code */ #define _IRR_OVERRIDE_ override @@ -89,13 +74,13 @@ typedef char fschar_t; // Note: an assert(false) is included first to catch this in debug builds #if defined(__cpp_lib_unreachable) #include -#define IRR_CODE_UNREACHABLE() do { _IRR_DEBUG_BREAK_IF(1) std::unreachable(); } while(0) +#define IRR_CODE_UNREACHABLE() do { assert(false); std::unreachable(); } while(0) #elif defined(__has_builtin) #if __has_builtin(__builtin_unreachable) -#define IRR_CODE_UNREACHABLE() do { _IRR_DEBUG_BREAK_IF(1) __builtin_unreachable(); } while(0) +#define IRR_CODE_UNREACHABLE() do { assert(false); __builtin_unreachable(); } while(0) #endif #elif defined(_MSC_VER) -#define IRR_CODE_UNREACHABLE() do { _IRR_DEBUG_BREAK_IF(1) __assume(false); } while(0) +#define IRR_CODE_UNREACHABLE() do { assert(false); __assume(false); } while(0) #endif #ifndef IRR_CODE_UNREACHABLE #define IRR_CODE_UNREACHABLE() (void)0 diff --git a/irr/include/matrix4.h b/irr/include/matrix4.h index 40fb41e57..6fc8cf6f8 100644 --- a/irr/include/matrix4.h +++ b/irr/include/matrix4.h @@ -12,6 +12,7 @@ #include "aabbox3d.h" #include "rect.h" #include "IrrCompileConfig.h" // for IRRLICHT_API +#include namespace irr { @@ -1198,10 +1199,10 @@ inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveFovRH( f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) { const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); - _IRR_DEBUG_BREAK_IF(aspectRatio == 0.f); // divide by zero + assert(aspectRatio != 0.f); // divide by zero const T w = static_cast(h / aspectRatio); - _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + assert(zNear != zFar); // divide by zero M[0] = w; M[1] = 0; M[2] = 0; @@ -1240,10 +1241,10 @@ inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveFovLH( f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) { const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); - _IRR_DEBUG_BREAK_IF(aspectRatio == 0.f); // divide by zero + assert(aspectRatio != 0.f); // divide by zero const T w = static_cast(h / aspectRatio); - _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + assert(zNear != zFar); // divide by zero M[0] = w; M[1] = 0; M[2] = 0; @@ -1282,7 +1283,7 @@ inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveFovInfinityLH( f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon) { const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); - _IRR_DEBUG_BREAK_IF(aspectRatio == 0.f); // divide by zero + assert(aspectRatio != 0.f); // divide by zero const T w = static_cast(h / aspectRatio); M[0] = w; @@ -1313,9 +1314,9 @@ template inline CMatrix4 &CMatrix4::buildProjectionMatrixOrthoLH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + assert(widthOfViewVolume != 0.f); // divide by zero + assert(heightOfViewVolume != 0.f); // divide by zero + assert(zNear != zFar); // divide by zero M[0] = (T)(2 / widthOfViewVolume); M[1] = 0; M[2] = 0; @@ -1352,9 +1353,9 @@ template inline CMatrix4 &CMatrix4::buildProjectionMatrixOrthoRH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + assert(widthOfViewVolume != 0.f); // divide by zero + assert(heightOfViewVolume != 0.f); // divide by zero + assert(zNear != zFar); // divide by zero M[0] = (T)(2 / widthOfViewVolume); M[1] = 0; M[2] = 0; @@ -1391,9 +1392,9 @@ template inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveRH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + assert(widthOfViewVolume != 0.f); // divide by zero + assert(heightOfViewVolume != 0.f); // divide by zero + assert(zNear != zFar); // divide by zero M[0] = (T)(2 * zNear / widthOfViewVolume); M[1] = 0; M[2] = 0; @@ -1431,9 +1432,9 @@ template inline CMatrix4 &CMatrix4::buildProjectionMatrixPerspectiveLH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) { - _IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero - _IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero + assert(widthOfViewVolume != 0.f); // divide by zero + assert(heightOfViewVolume != 0.f); // divide by zero + assert(zNear != zFar); // divide by zero M[0] = (T)(2 * zNear / widthOfViewVolume); M[1] = 0; M[2] = 0; diff --git a/irr/include/vector2d.h b/irr/include/vector2d.h index 63be1f246..821885719 100644 --- a/irr/include/vector2d.h +++ b/irr/include/vector2d.h @@ -9,6 +9,7 @@ #include #include +#include namespace irr { diff --git a/irr/include/vector3d.h b/irr/include/vector3d.h index 780686c7a..c9c96fabf 100644 --- a/irr/include/vector3d.h +++ b/irr/include/vector3d.h @@ -8,6 +8,7 @@ #include #include +#include namespace irr { diff --git a/irr/src/CGLTFMeshFileLoader.cpp b/irr/src/CGLTFMeshFileLoader.cpp index b32ba5692..32fa4829c 100644 --- a/irr/src/CGLTFMeshFileLoader.cpp +++ b/irr/src/CGLTFMeshFileLoader.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -797,7 +798,7 @@ std::optional> SelfType::MeshExtractor::getIndices( if (index == std::numeric_limits::max()) throw std::runtime_error("invalid index"); } else { - _IRR_DEBUG_BREAK_IF(!std::holds_alternative>(accessor)); + assert(std::holds_alternative>(accessor)); u32 indexWide = std::get>(accessor).get(elemIdx); // Use >= here for consistency. if (indexWide >= std::numeric_limits::max()) diff --git a/irr/src/CImage.cpp b/irr/src/CImage.cpp index 29c115c8a..4366809ae 100644 --- a/irr/src/CImage.cpp +++ b/irr/src/CImage.cpp @@ -9,6 +9,8 @@ #include "os.h" #include "SoftwareDriver2_helper.h" +#include + namespace irr { namespace video @@ -20,7 +22,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d &size, void *d IImage(format, size, deleteMemory) { if (ownForeignMemory) { - _IRR_DEBUG_BREAK_IF(!data) + assert(data); Data = reinterpret_cast(data); if (reinterpret_cast(data) % sizeof(u32) != 0) os::Printer::log("CImage created with foreign memory that's not aligned", ELL_WARNING); diff --git a/irr/src/CIrrDeviceLinux.cpp b/irr/src/CIrrDeviceLinux.cpp index 7c5d9cf0b..f72ccc7a1 100644 --- a/irr/src/CIrrDeviceLinux.cpp +++ b/irr/src/CIrrDeviceLinux.cpp @@ -1680,10 +1680,10 @@ const c8 *CIrrDeviceLinux::getTextFromSelection(Atom selection, core::stringc &t }, (XPointer)&args); - _IRR_DEBUG_BREAK_IF(!(event_ret.type == SelectionNotify && + assert(event_ret.type == SelectionNotify && event_ret.xselection.requestor == XWindow && event_ret.xselection.selection == selection && - event_ret.xselection.target == X_ATOM_UTF8_STRING)); + event_ret.xselection.target == X_ATOM_UTF8_STRING); Atom property_set = event_ret.xselection.property; if (event_ret.xselection.property == None) { diff --git a/irr/src/CIrrDeviceSDL.cpp b/irr/src/CIrrDeviceSDL.cpp index 28a92f450..bc7627f73 100644 --- a/irr/src/CIrrDeviceSDL.cpp +++ b/irr/src/CIrrDeviceSDL.cpp @@ -16,11 +16,13 @@ #include "irrString.h" #include "Keycodes.h" #include "COSOperator.h" -#include -#include #include "SIrrCreationParameters.h" #include +#include +#include +#include + #ifdef _IRR_EMSCRIPTEN_PLATFORM_ #include #endif @@ -599,7 +601,7 @@ bool CIrrDeviceSDL::createWindowWithContext() SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); break; default: - _IRR_DEBUG_BREAK_IF(1); + assert(false); } if (CreationParams.DriverDebug) { diff --git a/irr/src/CMakeLists.txt b/irr/src/CMakeLists.txt index 820af4fe9..8b6f71b3a 100644 --- a/irr/src/CMakeLists.txt +++ b/irr/src/CMakeLists.txt @@ -521,10 +521,10 @@ target_link_libraries(IrrlichtMt PRIVATE ) if(WIN32) - target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header + target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") - target_compile_definitions(IrrlichtMt INTERFACE _DEBUG) # same + target_compile_definitions(IrrlichtMt INTERFACE _DEBUG) endif() if(APPLE OR ANDROID OR EMSCRIPTEN) target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) diff --git a/irr/src/CMeshManipulator.cpp b/irr/src/CMeshManipulator.cpp index 63157403b..659e8dff8 100644 --- a/irr/src/CMeshManipulator.cpp +++ b/irr/src/CMeshManipulator.cpp @@ -9,6 +9,8 @@ #include "SAnimatedMesh.h" #include "os.h" +#include + namespace irr { namespace scene @@ -118,14 +120,14 @@ void CMeshManipulator::recalculateNormals(scene::IMesh *mesh, bool smooth, bool template void copyVertices(const scene::IVertexBuffer *src, scene::CVertexBuffer *dst) { - _IRR_DEBUG_BREAK_IF(T::getType() != src->getType()); + assert(T::getType() == src->getType()); auto *data = static_cast(src->getData()); dst->Data.assign(data, data + src->getCount()); } static void copyIndices(const scene::IIndexBuffer *src, scene::SIndexBuffer *dst) { - _IRR_DEBUG_BREAK_IF(src->getType() != video::EIT_16BIT); + assert(src->getType() == video::EIT_16BIT); auto *data = static_cast(src->getData()); dst->Data.assign(data, data + src->getCount()); } diff --git a/irr/src/CNullDriver.cpp b/irr/src/CNullDriver.cpp index 21346e6ed..f54f7a418 100644 --- a/irr/src/CNullDriver.cpp +++ b/irr/src/CNullDriver.cpp @@ -17,6 +17,8 @@ #include "IReferenceCounted.h" #include "IRenderTarget.h" +#include + namespace irr { namespace video @@ -1092,7 +1094,7 @@ void CNullDriver::drawBuffers(const scene::IVertexBuffer *vb, if (vb->getHWBuffer() || ib->getHWBuffer()) { // subclass is supposed to override this if it supports hw buffers - _IRR_DEBUG_BREAK_IF(1); + assert(false); } drawVertexPrimitiveList(vb->getData(), vb->getCount(), ib->getData(), @@ -1138,7 +1140,7 @@ CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IIndexBuffer void CNullDriver::registerHardwareBuffer(SHWBufferLink *HWBuffer) { - _IRR_DEBUG_BREAK_IF(!HWBuffer) + assert(HWBuffer); HWBuffer->ListPosition = HWBufferList.size(); HWBufferList.push_back(HWBuffer); } @@ -1168,7 +1170,7 @@ void CNullDriver::deleteHardwareBuffer(SHWBufferLink *HWBuffer) if (!HWBuffer) return; const size_t pos = HWBuffer->ListPosition; - _IRR_DEBUG_BREAK_IF(HWBufferList.at(pos) != HWBuffer) + assert(HWBufferList.at(pos) == HWBuffer); if (HWBufferList.size() < 2 || pos == HWBufferList.size() - 1) { HWBufferList.erase(HWBufferList.begin() + pos); } else { diff --git a/irr/src/COpenGLCoreCacheHandler.h b/irr/src/COpenGLCoreCacheHandler.h index bf588aa8a..8302f182a 100644 --- a/irr/src/COpenGLCoreCacheHandler.h +++ b/irr/src/COpenGLCoreCacheHandler.h @@ -9,6 +9,8 @@ #include "mt_opengl.h" +#include + namespace irr { namespace video @@ -101,7 +103,7 @@ class COpenGLCoreCacheHandler #endif auto name = static_cast(texture)->getOpenGLTextureName(); - _IRR_DEBUG_BREAK_IF(name == 0) + assert(name != 0); GL.BindTexture(curTextureType, name); } else { texture = 0; diff --git a/irr/src/COpenGLCoreTexture.h b/irr/src/COpenGLCoreTexture.h index bc9a7e919..b2b7403c2 100644 --- a/irr/src/COpenGLCoreTexture.h +++ b/irr/src/COpenGLCoreTexture.h @@ -5,6 +5,8 @@ #pragma once #include +#include + #include "SMaterialLayer.h" #include "ITexture.h" #include "EDriverFeatures.h" @@ -48,10 +50,10 @@ public: TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_RGBA), PixelType(GL_UNSIGNED_BYTE), MSAA(0), Converter(0), LockReadOnly(false), LockImage(0), LockLayer(0), KeepImage(false), MipLevelStored(0) { - _IRR_DEBUG_BREAK_IF(srcImages.empty()) + assert(!srcImages.empty()); DriverType = Driver->getDriverType(); - _IRR_DEBUG_BREAK_IF(Type == ETT_2D_MS) // not supported by this constructor + assert(Type != ETT_2D_MS); // not supported by this constructor TextureType = TextureTypeIrrToGL(Type); HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY); @@ -142,7 +144,7 @@ public: MipLevelStored(0) { DriverType = Driver->getDriverType(); - _IRR_DEBUG_BREAK_IF(Type == ETT_2D_ARRAY) // not supported by this constructor + assert(Type != ETT_2D_ARRAY); // not supported by this constructor TextureType = TextureTypeIrrToGL(Type); HasMipMaps = false; IsRenderTarget = true; @@ -242,7 +244,7 @@ public: MipLevelStored = mipmapLevel; if (KeepImage) { - _IRR_DEBUG_BREAK_IF(LockLayer > Images.size()) + assert(LockLayer < Images.size()); if (mipmapLevel == 0) { LockImage = Images[LockLayer]; @@ -252,7 +254,7 @@ public: if (!LockImage) { core::dimension2d lockImageSize(IImage::getMipMapsSize(Size, MipLevelStored)); - _IRR_DEBUG_BREAK_IF(lockImageSize.Width == 0 || lockImageSize.Height == 0) + assert(lockImageSize.Width > 0 && lockImageSize.Height > 0); LockImage = Driver->createImage(ColorFormat, lockImageSize); @@ -512,7 +514,7 @@ protected: { // Compressed textures cannot be pre-allocated and are initialized on upload if (IImage::isCompressedFormat(ColorFormat)) { - _IRR_DEBUG_BREAK_IF(IsRenderTarget) + assert(!IsRenderTarget); return; } @@ -587,7 +589,7 @@ protected: TEST_GL_ERROR(Driver); break; default: - _IRR_DEBUG_BREAK_IF(1) + assert(false); break; } } @@ -628,7 +630,7 @@ protected: GL.TexSubImage3D(tmpTextureType, level, 0, 0, layer, width, height, 1, PixelFormat, PixelType, tmpData); break; default: - _IRR_DEBUG_BREAK_IF(1) + assert(false); break; } TEST_GL_ERROR(Driver); @@ -643,7 +645,7 @@ protected: Driver->irrGlCompressedTexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, dataSize, data); break; default: - _IRR_DEBUG_BREAK_IF(1) + assert(false); break; } TEST_GL_ERROR(Driver); @@ -671,7 +673,7 @@ protected: { GLenum tmp = TextureType; if (tmp == GL_TEXTURE_CUBE_MAP) { - _IRR_DEBUG_BREAK_IF(layer > 5) + assert(layer < 6); tmp = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer; } return tmp; diff --git a/irr/src/COpenGLDriver.cpp b/irr/src/COpenGLDriver.cpp index 50e097362..9c37e2f79 100644 --- a/irr/src/COpenGLDriver.cpp +++ b/irr/src/COpenGLDriver.cpp @@ -710,7 +710,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void *vertices, u32 vertexCoun } } else { // avoid passing broken pointer to OpenGL - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } } @@ -983,7 +983,7 @@ void COpenGLDriver::draw2DVertexPrimitiveList(const void *vertices, u32 vertexCo } } else { // avoid passing broken pointer to OpenGL - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } } @@ -1124,7 +1124,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture *texture, const core::posi if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); else { - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } @@ -1204,7 +1204,7 @@ void COpenGLDriver::draw2DImage(const video::ITexture *texture, const core::rect if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); else { - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } @@ -1352,7 +1352,7 @@ void COpenGLDriver::draw2DImageBatch(const video::ITexture *texture, if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); else { - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } @@ -1519,7 +1519,7 @@ void COpenGLDriver::draw2DRectangle(const core::rect &position, if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); else { - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } @@ -1555,7 +1555,7 @@ void COpenGLDriver::draw2DLine(const core::position2d &start, if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); else { - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } @@ -2478,7 +2478,7 @@ void COpenGLDriver::draw3DLine(const core::vector3df &start, if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast(Quad2DVertices))[0].Color); else { - _IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); + assert(!ColorBuffer.empty()); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); } diff --git a/irr/src/CSceneManager.cpp b/irr/src/CSceneManager.cpp index 23e5335ce..41c59fe66 100644 --- a/irr/src/CSceneManager.cpp +++ b/irr/src/CSceneManager.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in irrlicht.h #include +#include #include "CSceneManager.h" #include "IVideoDriver.h" @@ -305,7 +306,7 @@ void CSceneManager::render() //! returns the axis aligned bounding box of this node const core::aabbox3d &CSceneManager::getBoundingBox() const { - _IRR_DEBUG_BREAK_IF(true) // Bounding Box of Scene Manager should never be used. + assert(false); // Bounding Box of Scene Manager should never be used. static const core::aabbox3d dummy{{0.0f, 0.0f, 0.0f}}; return dummy; diff --git a/irr/src/SkinnedMesh.cpp b/irr/src/SkinnedMesh.cpp index ebf84cec5..938a50e17 100644 --- a/irr/src/SkinnedMesh.cpp +++ b/irr/src/SkinnedMesh.cpp @@ -9,6 +9,7 @@ #include "SSkinMeshBuffer.h" #include "os.h" #include +#include namespace irr { @@ -620,19 +621,19 @@ SkinnedMesh::SJoint *SkinnedMeshBuilder::addJoint(SJoint *parent) void SkinnedMeshBuilder::addPositionKey(SJoint *joint, f32 frame, core::vector3df pos) { - _IRR_DEBUG_BREAK_IF(!joint); + assert(joint); joint->keys.position.pushBack(frame, pos); } void SkinnedMeshBuilder::addScaleKey(SJoint *joint, f32 frame, core::vector3df scale) { - _IRR_DEBUG_BREAK_IF(!joint); + assert(joint); joint->keys.scale.pushBack(frame, scale); } void SkinnedMeshBuilder::addRotationKey(SJoint *joint, f32 frame, core::quaternion rot) { - _IRR_DEBUG_BREAK_IF(!joint); + assert(joint); joint->keys.rotation.pushBack(frame, rot); }