aboutsummaryrefslogtreecommitdiff
path: root/dep/recastnavigation/Recast/Include/RecastAssert.h
diff options
context:
space:
mode:
Diffstat (limited to 'dep/recastnavigation/Recast/Include/RecastAssert.h')
-rw-r--r--dep/recastnavigation/Recast/Include/RecastAssert.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/dep/recastnavigation/Recast/Include/RecastAssert.h b/dep/recastnavigation/Recast/Include/RecastAssert.h
index 2aca0d9a14f..e7cc10e4961 100644
--- a/dep/recastnavigation/Recast/Include/RecastAssert.h
+++ b/dep/recastnavigation/Recast/Include/RecastAssert.h
@@ -23,11 +23,34 @@
// Feel free to change the file and include your own implementation instead.
#ifdef NDEBUG
+
// From http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
-# define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
+# define rcAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
+
#else
+
+/// An assertion failure function.
+// @param[in] expression asserted expression.
+// @param[in] file Filename of the failed assertion.
+// @param[in] line Line number of the failed assertion.
+/// @see rcAssertFailSetCustom
+typedef void (rcAssertFailFunc)(const char* expression, const char* file, int line);
+
+/// Sets the base custom assertion failure function to be used by Recast.
+/// @param[in] assertFailFunc The function to be used in case of failure of #dtAssert
+void rcAssertFailSetCustom(rcAssertFailFunc *assertFailFunc);
+
+/// Gets the base custom assertion failure function to be used by Recast.
+rcAssertFailFunc* rcAssertFailGetCustom();
+
# include <assert.h>
-# define rcAssert assert
+# define rcAssert(expression) \
+ { \
+ rcAssertFailFunc* failFunc = rcAssertFailGetCustom(); \
+ if(failFunc == NULL) { assert(expression); } \
+ else if(!(expression)) { (*failFunc)(#expression, __FILE__, __LINE__); } \
+ }
+
#endif
#endif // RECASTASSERT_H