1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Replace _IRR_DEBUG_BREAK_IF with assertions

This commit is contained in:
Lars Mueller 2025-04-04 01:26:02 +02:00 committed by Lars Müller
parent 2f464843cb
commit 5f1ff453c9
22 changed files with 96 additions and 91 deletions

View file

@ -11,6 +11,7 @@
#include "IIndexBuffer.h" #include "IIndexBuffer.h"
#include "EHardwareBufferFlags.h" #include "EHardwareBufferFlags.h"
#include "EPrimitiveTypes.h" #include "EPrimitiveTypes.h"
#include <cassert>
namespace irr namespace irr
{ {
@ -121,7 +122,7 @@ public:
/** \return Pointer to indices array. */ /** \return Pointer to indices array. */
inline const u16 *getIndices() const inline const u16 *getIndices() const
{ {
_IRR_DEBUG_BREAK_IF(getIndexBuffer()->getType() != video::EIT_16BIT); assert(getIndexBuffer()->getType() == video::EIT_16BIT);
return static_cast<const u16*>(getIndexBuffer()->getData()); return static_cast<const u16*>(getIndexBuffer()->getData());
} }
@ -129,7 +130,7 @@ public:
/** \return Pointer to indices array. */ /** \return Pointer to indices array. */
inline u16 *getIndices() inline u16 *getIndices()
{ {
_IRR_DEBUG_BREAK_IF(getIndexBuffer()->getType() != video::EIT_16BIT); assert(getIndexBuffer()->getType() == video::EIT_16BIT);
return static_cast<u16*>(getIndexBuffer()->getData()); return static_cast<u16*>(getIndexBuffer()->getData());
} }

View file

@ -5,6 +5,7 @@
#pragma once #pragma once
#include "irrTypes.h" #include "irrTypes.h"
#include <cassert>
namespace irr namespace irr
{ {
@ -118,7 +119,7 @@ public:
bool drop() const bool drop() const
{ {
// someone is doing bad reference counting. // someone is doing bad reference counting.
_IRR_DEBUG_BREAK_IF(ReferenceCounter <= 0) assert(ReferenceCounter > 0);
--ReferenceCounter; --ReferenceCounter;
if (!ReferenceCounter) { if (!ReferenceCounter) {

View file

@ -16,6 +16,7 @@
#include <list> #include <list>
#include <optional> #include <optional>
#include <string> #include <string>
#include <cassert>
namespace irr namespace irr
{ {
@ -268,7 +269,7 @@ public:
return false; return false;
// The iterator must be set since the parent is not null. // 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; auto it = *child->ThisIterator;
child->ThisIterator = std::nullopt; child->ThisIterator = std::nullopt;
child->Parent = nullptr; child->Parent = nullptr;

View file

@ -8,6 +8,7 @@
#include "CVertexBuffer.h" #include "CVertexBuffer.h"
#include "CIndexBuffer.h" #include "CIndexBuffer.h"
#include "S3DVertex.h" #include "S3DVertex.h"
#include <cassert>
namespace irr namespace irr
{ {
@ -200,7 +201,7 @@ public:
//! append the vertices and indices to the current buffer //! append the vertices and indices to the current buffer
void append(const void *const vertices, u32 numVertices, const u16 *const indices, u32 numIndices) override 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 //! Describe what kind of primitive geometry is used by the meshbuffer

View file

@ -6,6 +6,7 @@
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <vector> #include <vector>
#include <cassert>
#include "irrTypes.h" #include "irrTypes.h"
#include "irrMath.h" #include "irrMath.h"
@ -108,7 +109,7 @@ public:
\param index: Where position to insert the new element. */ \param index: Where position to insert the new element. */
void insert(const T &element, u32 index = 0) 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); auto pos = std::next(m_data.begin(), index);
m_data.insert(pos, element); m_data.insert(pos, element);
is_sorted = false; is_sorted = false;
@ -190,32 +191,28 @@ public:
//! Direct access operator //! Direct access operator
T &operator[](u32 index) T &operator[](u32 index)
{ {
_IRR_DEBUG_BREAK_IF(index >= m_data.size()) // access violation assert(index < m_data.size());
return m_data[index]; return m_data[index];
} }
//! Direct const access operator //! Direct const access operator
const T &operator[](u32 index) const 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]; return m_data[index];
} }
//! Gets last element. //! Gets last element.
T &getLast() T &getLast()
{ {
_IRR_DEBUG_BREAK_IF(m_data.empty()) // access violation assert(!m_data.empty());
return m_data.back(); return m_data.back();
} }
//! Gets last element //! Gets last element
const T &getLast() const const T &getLast() const
{ {
_IRR_DEBUG_BREAK_IF(m_data.empty()) // access violation assert(!m_data.empty());
return m_data.back(); return m_data.back();
} }
@ -365,7 +362,7 @@ public:
\param index: Index of element to be erased. */ \param index: Index of element to be erased. */
void erase(u32 index) 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); auto it = std::next(m_data.begin(), index);
m_data.erase(it); m_data.erase(it);
} }

View file

@ -11,6 +11,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <cwchar> #include <cwchar>
#include <cassert>
/* HACK: import these string methods from MT's util/string.h */ /* HACK: import these string methods from MT's util/string.h */
extern std::wstring utf8_to_wide(std::string_view input); extern std::wstring utf8_to_wide(std::string_view input);
@ -174,9 +175,9 @@ public:
} }
if constexpr (sizeof(T) != sizeof(B)) { if constexpr (sizeof(T) != sizeof(B)) {
_IRR_DEBUG_BREAK_IF( assert(
(uintptr_t)c >= (uintptr_t)(str.data()) && (uintptr_t)c < (uintptr_t)(str.data()) ||
(uintptr_t)c < (uintptr_t)(str.data() + str.size())); (uintptr_t)c >= (uintptr_t)(str.data() + str.size()));
} }
if ((void *)c == (void *)c_str()) if ((void *)c == (void *)c_str())

View file

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <cassert>
namespace irr namespace irr
{ {
@ -65,22 +66,6 @@ typedef char fschar_t;
} // end namespace irr } // end namespace irr
//! define a break macro for debugging.
#if defined(_DEBUG)
#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER)
#include <crtdbg.h>
#define _IRR_DEBUG_BREAK_IF(_CONDITION_) \
if (_CONDITION_) { \
_CrtDbgBreak(); \
}
#else
#include <assert.h>
#define _IRR_DEBUG_BREAK_IF(_CONDITION_) assert(!(_CONDITION_));
#endif
#else
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
#endif
//! deprecated macro for virtual function override //! deprecated macro for virtual function override
/** prefer to use the override keyword for new code */ /** prefer to use the override keyword for new code */
#define _IRR_OVERRIDE_ override #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 // Note: an assert(false) is included first to catch this in debug builds
#if defined(__cpp_lib_unreachable) #if defined(__cpp_lib_unreachable)
#include <utility> #include <utility>
#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) #elif defined(__has_builtin)
#if __has_builtin(__builtin_unreachable) #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 #endif
#elif defined(_MSC_VER) #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 #endif
#ifndef IRR_CODE_UNREACHABLE #ifndef IRR_CODE_UNREACHABLE
#define IRR_CODE_UNREACHABLE() (void)0 #define IRR_CODE_UNREACHABLE() (void)0

View file

@ -12,6 +12,7 @@
#include "aabbox3d.h" #include "aabbox3d.h"
#include "rect.h" #include "rect.h"
#include "IrrCompileConfig.h" // for IRRLICHT_API #include "IrrCompileConfig.h" // for IRRLICHT_API
#include <cassert>
namespace irr namespace irr
{ {
@ -1198,10 +1199,10 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero)
{ {
const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); 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<T>(h / aspectRatio); const T w = static_cast<T>(h / aspectRatio);
_IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero assert(zNear != zFar); // divide by zero
M[0] = w; M[0] = w;
M[1] = 0; M[1] = 0;
M[2] = 0; M[2] = 0;
@ -1240,10 +1241,10 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveFovLH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero) f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero)
{ {
const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); 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<T>(h / aspectRatio); const T w = static_cast<T>(h / aspectRatio);
_IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero assert(zNear != zFar); // divide by zero
M[0] = w; M[0] = w;
M[1] = 0; M[1] = 0;
M[2] = 0; M[2] = 0;
@ -1282,7 +1283,7 @@ inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveFovInfinityLH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon) f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon)
{ {
const f64 h = reciprocal(tan(fieldOfViewRadians * 0.5)); 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<T>(h / aspectRatio); const T w = static_cast<T>(h / aspectRatio);
M[0] = w; M[0] = w;
@ -1313,9 +1314,9 @@ template <class T>
inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixOrthoLH( inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixOrthoLH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero)
{ {
_IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero assert(widthOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero assert(heightOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero assert(zNear != zFar); // divide by zero
M[0] = (T)(2 / widthOfViewVolume); M[0] = (T)(2 / widthOfViewVolume);
M[1] = 0; M[1] = 0;
M[2] = 0; M[2] = 0;
@ -1352,9 +1353,9 @@ template <class T>
inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixOrthoRH( inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixOrthoRH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero)
{ {
_IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero assert(widthOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero assert(heightOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero assert(zNear != zFar); // divide by zero
M[0] = (T)(2 / widthOfViewVolume); M[0] = (T)(2 / widthOfViewVolume);
M[1] = 0; M[1] = 0;
M[2] = 0; M[2] = 0;
@ -1391,9 +1392,9 @@ template <class T>
inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveRH( inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveRH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero)
{ {
_IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero assert(widthOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero assert(heightOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero assert(zNear != zFar); // divide by zero
M[0] = (T)(2 * zNear / widthOfViewVolume); M[0] = (T)(2 * zNear / widthOfViewVolume);
M[1] = 0; M[1] = 0;
M[2] = 0; M[2] = 0;
@ -1431,9 +1432,9 @@ template <class T>
inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveLH( inline CMatrix4<T> &CMatrix4<T>::buildProjectionMatrixPerspectiveLH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero) f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero)
{ {
_IRR_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); // divide by zero assert(widthOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); // divide by zero assert(heightOfViewVolume != 0.f); // divide by zero
_IRR_DEBUG_BREAK_IF(zNear == zFar); // divide by zero assert(zNear != zFar); // divide by zero
M[0] = (T)(2 * zNear / widthOfViewVolume); M[0] = (T)(2 * zNear / widthOfViewVolume);
M[1] = 0; M[1] = 0;
M[2] = 0; M[2] = 0;

View file

@ -9,6 +9,7 @@
#include <functional> #include <functional>
#include <array> #include <array>
#include <cassert>
namespace irr namespace irr
{ {

View file

@ -8,6 +8,7 @@
#include <functional> #include <functional>
#include <array> #include <array>
#include <cassert>
namespace irr namespace irr
{ {

View file

@ -20,6 +20,7 @@
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <cstring> #include <cstring>
#include <cassert>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <optional> #include <optional>
@ -797,7 +798,7 @@ std::optional<std::vector<u16>> SelfType::MeshExtractor::getIndices(
if (index == std::numeric_limits<u16>::max()) if (index == std::numeric_limits<u16>::max())
throw std::runtime_error("invalid index"); throw std::runtime_error("invalid index");
} else { } else {
_IRR_DEBUG_BREAK_IF(!std::holds_alternative<Accessor<u32>>(accessor)); assert(std::holds_alternative<Accessor<u32>>(accessor));
u32 indexWide = std::get<Accessor<u32>>(accessor).get(elemIdx); u32 indexWide = std::get<Accessor<u32>>(accessor).get(elemIdx);
// Use >= here for consistency. // Use >= here for consistency.
if (indexWide >= std::numeric_limits<u16>::max()) if (indexWide >= std::numeric_limits<u16>::max())

View file

@ -9,6 +9,8 @@
#include "os.h" #include "os.h"
#include "SoftwareDriver2_helper.h" #include "SoftwareDriver2_helper.h"
#include <cassert>
namespace irr namespace irr
{ {
namespace video namespace video
@ -20,7 +22,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32> &size, void *d
IImage(format, size, deleteMemory) IImage(format, size, deleteMemory)
{ {
if (ownForeignMemory) { if (ownForeignMemory) {
_IRR_DEBUG_BREAK_IF(!data) assert(data);
Data = reinterpret_cast<u8*>(data); Data = reinterpret_cast<u8*>(data);
if (reinterpret_cast<uintptr_t>(data) % sizeof(u32) != 0) if (reinterpret_cast<uintptr_t>(data) % sizeof(u32) != 0)
os::Printer::log("CImage created with foreign memory that's not aligned", ELL_WARNING); os::Printer::log("CImage created with foreign memory that's not aligned", ELL_WARNING);

View file

@ -1680,10 +1680,10 @@ const c8 *CIrrDeviceLinux::getTextFromSelection(Atom selection, core::stringc &t
}, },
(XPointer)&args); (XPointer)&args);
_IRR_DEBUG_BREAK_IF(!(event_ret.type == SelectionNotify && assert(event_ret.type == SelectionNotify &&
event_ret.xselection.requestor == XWindow && event_ret.xselection.requestor == XWindow &&
event_ret.xselection.selection == selection && 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; Atom property_set = event_ret.xselection.property;
if (event_ret.xselection.property == None) { if (event_ret.xselection.property == None) {

View file

@ -16,11 +16,13 @@
#include "irrString.h" #include "irrString.h"
#include "Keycodes.h" #include "Keycodes.h"
#include "COSOperator.h" #include "COSOperator.h"
#include <cstdio>
#include <cstdlib>
#include "SIrrCreationParameters.h" #include "SIrrCreationParameters.h"
#include <SDL_video.h> #include <SDL_video.h>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#ifdef _IRR_EMSCRIPTEN_PLATFORM_ #ifdef _IRR_EMSCRIPTEN_PLATFORM_
#include <emscripten.h> #include <emscripten.h>
#endif #endif
@ -599,7 +601,7 @@ bool CIrrDeviceSDL::createWindowWithContext()
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
break; break;
default: default:
_IRR_DEBUG_BREAK_IF(1); assert(false);
} }
if (CreationParams.DriverDebug) { if (CreationParams.DriverDebug) {

View file

@ -521,10 +521,10 @@ target_link_libraries(IrrlichtMt PRIVATE
) )
if(WIN32) 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() endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(IrrlichtMt INTERFACE _DEBUG) # same target_compile_definitions(IrrlichtMt INTERFACE _DEBUG)
endif() endif()
if(APPLE OR ANDROID OR EMSCRIPTEN) if(APPLE OR ANDROID OR EMSCRIPTEN)
target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)

View file

@ -9,6 +9,8 @@
#include "SAnimatedMesh.h" #include "SAnimatedMesh.h"
#include "os.h" #include "os.h"
#include <cassert>
namespace irr namespace irr
{ {
namespace scene namespace scene
@ -118,14 +120,14 @@ void CMeshManipulator::recalculateNormals(scene::IMesh *mesh, bool smooth, bool
template <typename T> template <typename T>
void copyVertices(const scene::IVertexBuffer *src, scene::CVertexBuffer<T> *dst) void copyVertices(const scene::IVertexBuffer *src, scene::CVertexBuffer<T> *dst)
{ {
_IRR_DEBUG_BREAK_IF(T::getType() != src->getType()); assert(T::getType() == src->getType());
auto *data = static_cast<const T*>(src->getData()); auto *data = static_cast<const T*>(src->getData());
dst->Data.assign(data, data + src->getCount()); dst->Data.assign(data, data + src->getCount());
} }
static void copyIndices(const scene::IIndexBuffer *src, scene::SIndexBuffer *dst) 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<const u16*>(src->getData()); auto *data = static_cast<const u16*>(src->getData());
dst->Data.assign(data, data + src->getCount()); dst->Data.assign(data, data + src->getCount());
} }

View file

@ -17,6 +17,8 @@
#include "IReferenceCounted.h" #include "IReferenceCounted.h"
#include "IRenderTarget.h" #include "IRenderTarget.h"
#include <cassert>
namespace irr namespace irr
{ {
namespace video namespace video
@ -1092,7 +1094,7 @@ void CNullDriver::drawBuffers(const scene::IVertexBuffer *vb,
if (vb->getHWBuffer() || ib->getHWBuffer()) { if (vb->getHWBuffer() || ib->getHWBuffer()) {
// subclass is supposed to override this if it supports hw buffers // 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(), drawVertexPrimitiveList(vb->getData(), vb->getCount(), ib->getData(),
@ -1138,7 +1140,7 @@ CNullDriver::SHWBufferLink *CNullDriver::getBufferLink(const scene::IIndexBuffer
void CNullDriver::registerHardwareBuffer(SHWBufferLink *HWBuffer) void CNullDriver::registerHardwareBuffer(SHWBufferLink *HWBuffer)
{ {
_IRR_DEBUG_BREAK_IF(!HWBuffer) assert(HWBuffer);
HWBuffer->ListPosition = HWBufferList.size(); HWBuffer->ListPosition = HWBufferList.size();
HWBufferList.push_back(HWBuffer); HWBufferList.push_back(HWBuffer);
} }
@ -1168,7 +1170,7 @@ void CNullDriver::deleteHardwareBuffer(SHWBufferLink *HWBuffer)
if (!HWBuffer) if (!HWBuffer)
return; return;
const size_t pos = HWBuffer->ListPosition; 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) { if (HWBufferList.size() < 2 || pos == HWBufferList.size() - 1) {
HWBufferList.erase(HWBufferList.begin() + pos); HWBufferList.erase(HWBufferList.begin() + pos);
} else { } else {

View file

@ -9,6 +9,8 @@
#include "mt_opengl.h" #include "mt_opengl.h"
#include <cassert>
namespace irr namespace irr
{ {
namespace video namespace video
@ -101,7 +103,7 @@ class COpenGLCoreCacheHandler
#endif #endif
auto name = static_cast<const TOpenGLTexture *>(texture)->getOpenGLTextureName(); auto name = static_cast<const TOpenGLTexture *>(texture)->getOpenGLTextureName();
_IRR_DEBUG_BREAK_IF(name == 0) assert(name != 0);
GL.BindTexture(curTextureType, name); GL.BindTexture(curTextureType, name);
} else { } else {
texture = 0; texture = 0;

View file

@ -5,6 +5,8 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include <cassert>
#include "SMaterialLayer.h" #include "SMaterialLayer.h"
#include "ITexture.h" #include "ITexture.h"
#include "EDriverFeatures.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), 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) KeepImage(false), MipLevelStored(0)
{ {
_IRR_DEBUG_BREAK_IF(srcImages.empty()) assert(!srcImages.empty());
DriverType = Driver->getDriverType(); 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); TextureType = TextureTypeIrrToGL(Type);
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY); KeepImage = Driver->getTextureCreationFlag(ETCF_ALLOW_MEMORY_COPY);
@ -142,7 +144,7 @@ public:
MipLevelStored(0) MipLevelStored(0)
{ {
DriverType = Driver->getDriverType(); 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); TextureType = TextureTypeIrrToGL(Type);
HasMipMaps = false; HasMipMaps = false;
IsRenderTarget = true; IsRenderTarget = true;
@ -242,7 +244,7 @@ public:
MipLevelStored = mipmapLevel; MipLevelStored = mipmapLevel;
if (KeepImage) { if (KeepImage) {
_IRR_DEBUG_BREAK_IF(LockLayer > Images.size()) assert(LockLayer < Images.size());
if (mipmapLevel == 0) { if (mipmapLevel == 0) {
LockImage = Images[LockLayer]; LockImage = Images[LockLayer];
@ -252,7 +254,7 @@ public:
if (!LockImage) { if (!LockImage) {
core::dimension2d<u32> lockImageSize(IImage::getMipMapsSize(Size, MipLevelStored)); core::dimension2d<u32> 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); LockImage = Driver->createImage(ColorFormat, lockImageSize);
@ -512,7 +514,7 @@ protected:
{ {
// Compressed textures cannot be pre-allocated and are initialized on upload // Compressed textures cannot be pre-allocated and are initialized on upload
if (IImage::isCompressedFormat(ColorFormat)) { if (IImage::isCompressedFormat(ColorFormat)) {
_IRR_DEBUG_BREAK_IF(IsRenderTarget) assert(!IsRenderTarget);
return; return;
} }
@ -587,7 +589,7 @@ protected:
TEST_GL_ERROR(Driver); TEST_GL_ERROR(Driver);
break; break;
default: default:
_IRR_DEBUG_BREAK_IF(1) assert(false);
break; break;
} }
} }
@ -628,7 +630,7 @@ protected:
GL.TexSubImage3D(tmpTextureType, level, 0, 0, layer, width, height, 1, PixelFormat, PixelType, tmpData); GL.TexSubImage3D(tmpTextureType, level, 0, 0, layer, width, height, 1, PixelFormat, PixelType, tmpData);
break; break;
default: default:
_IRR_DEBUG_BREAK_IF(1) assert(false);
break; break;
} }
TEST_GL_ERROR(Driver); TEST_GL_ERROR(Driver);
@ -643,7 +645,7 @@ protected:
Driver->irrGlCompressedTexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, dataSize, data); Driver->irrGlCompressedTexImage2D(tmpTextureType, level, InternalFormat, width, height, 0, dataSize, data);
break; break;
default: default:
_IRR_DEBUG_BREAK_IF(1) assert(false);
break; break;
} }
TEST_GL_ERROR(Driver); TEST_GL_ERROR(Driver);
@ -671,7 +673,7 @@ protected:
{ {
GLenum tmp = TextureType; GLenum tmp = TextureType;
if (tmp == GL_TEXTURE_CUBE_MAP) { if (tmp == GL_TEXTURE_CUBE_MAP) {
_IRR_DEBUG_BREAK_IF(layer > 5) assert(layer < 6);
tmp = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer; tmp = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
} }
return tmp; return tmp;

View file

@ -710,7 +710,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void *vertices, u32 vertexCoun
} }
} else { } else {
// avoid passing broken pointer to OpenGL // avoid passing broken pointer to OpenGL
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
} }
} }
@ -983,7 +983,7 @@ void COpenGLDriver::draw2DVertexPrimitiveList(const void *vertices, u32 vertexCo
} }
} else { } else {
// avoid passing broken pointer to OpenGL // avoid passing broken pointer to OpenGL
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); 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]) if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color); glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color);
else { else {
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); 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]) if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color); glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color);
else { else {
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); 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]) if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color); glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color);
else { else {
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
} }
@ -1519,7 +1519,7 @@ void COpenGLDriver::draw2DRectangle(const core::rect<s32> &position,
if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color); glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color);
else { else {
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
} }
@ -1555,7 +1555,7 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32> &start,
if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra]) if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color); glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color);
else { else {
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); 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]) if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color); glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex *>(Quad2DVertices))[0].Color);
else { else {
_IRR_DEBUG_BREAK_IF(ColorBuffer.size() == 0); assert(!ColorBuffer.empty());
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
} }

View file

@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
#include <algorithm> #include <algorithm>
#include <cassert>
#include "CSceneManager.h" #include "CSceneManager.h"
#include "IVideoDriver.h" #include "IVideoDriver.h"
@ -305,7 +306,7 @@ void CSceneManager::render()
//! returns the axis aligned bounding box of this node //! returns the axis aligned bounding box of this node
const core::aabbox3d<f32> &CSceneManager::getBoundingBox() const const core::aabbox3d<f32> &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<f32> dummy{{0.0f, 0.0f, 0.0f}}; static const core::aabbox3d<f32> dummy{{0.0f, 0.0f, 0.0f}};
return dummy; return dummy;

View file

@ -9,6 +9,7 @@
#include "SSkinMeshBuffer.h" #include "SSkinMeshBuffer.h"
#include "os.h" #include "os.h"
#include <vector> #include <vector>
#include <cassert>
namespace irr namespace irr
{ {
@ -620,19 +621,19 @@ SkinnedMesh::SJoint *SkinnedMeshBuilder::addJoint(SJoint *parent)
void SkinnedMeshBuilder::addPositionKey(SJoint *joint, f32 frame, core::vector3df pos) void SkinnedMeshBuilder::addPositionKey(SJoint *joint, f32 frame, core::vector3df pos)
{ {
_IRR_DEBUG_BREAK_IF(!joint); assert(joint);
joint->keys.position.pushBack(frame, pos); joint->keys.position.pushBack(frame, pos);
} }
void SkinnedMeshBuilder::addScaleKey(SJoint *joint, f32 frame, core::vector3df scale) void SkinnedMeshBuilder::addScaleKey(SJoint *joint, f32 frame, core::vector3df scale)
{ {
_IRR_DEBUG_BREAK_IF(!joint); assert(joint);
joint->keys.scale.pushBack(frame, scale); joint->keys.scale.pushBack(frame, scale);
} }
void SkinnedMeshBuilder::addRotationKey(SJoint *joint, f32 frame, core::quaternion rot) void SkinnedMeshBuilder::addRotationKey(SJoint *joint, f32 frame, core::quaternion rot)
{ {
_IRR_DEBUG_BREAK_IF(!joint); assert(joint);
joint->keys.rotation.pushBack(frame, rot); joint->keys.rotation.pushBack(frame, rot);
} }