File: 0009-Changed-asserts-to-be-explicitly-disabled-with-RC_DI.patch

package info (click to toggle)
recastnavigation 1.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,892 kB
  • sloc: cpp: 50,116; ansic: 2,674; xml: 182; makefile: 16
file content (150 lines) | stat: -rw-r--r-- 6,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
From af6d4758ffae1d192de50b9c6217ee58211baa6a Mon Sep 17 00:00:00 2001
From: Graham Pentheny <grahamboree@users.noreply.github.com>
Date: Wed, 9 Aug 2023 19:15:04 -0400
Subject: [PATCH 09/36] Changed asserts to be explicitly disabled with
 RC_DISABLE_ASSERTS rather than using NDEBUG (#653)

* Changed asserts to be explicitly disabled with RC_DISABLE_ASSERTS rather than using NDEBUG

This gives explicit control to users over when recast asserts are enabled or disabled.  This is useful when users wish to disable asserts in debug mode or enable them in release mode.  e.g. it's common to compile game code in debug alongside third party code in release.

* Added Integration.md with documentation on the integration process for Recast
---
 Detour/Include/DetourAssert.h  |  2 +-
 Detour/Source/DetourAssert.cpp |  2 +-
 Integration.md                 | 32 ++++++++++++++++++++++++++++++++
 README.md                      | 10 +---------
 Recast/Include/RecastAssert.h  |  2 +-
 Recast/Source/RecastAssert.cpp |  2 +-
 RecastDemo/premake5.lua        |  2 +-
 7 files changed, 38 insertions(+), 14 deletions(-)
 create mode 100644 Integration.md

diff --git a/Detour/Include/DetourAssert.h b/Detour/Include/DetourAssert.h
index 038d538..ea58dd9 100644
--- a/Detour/Include/DetourAssert.h
+++ b/Detour/Include/DetourAssert.h
@@ -22,7 +22,7 @@
 // Note: This header file's only purpose is to include define assert.
 // Feel free to change the file and include your own implementation instead.
 
-#ifdef NDEBUG
+#ifdef RC_DISABLE_ASSERTS
 
 // From https://web.archive.org/web/20210117002833/http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
 #	define dtAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)  
diff --git a/Detour/Source/DetourAssert.cpp b/Detour/Source/DetourAssert.cpp
index 5e019e0..a9727a3 100644
--- a/Detour/Source/DetourAssert.cpp
+++ b/Detour/Source/DetourAssert.cpp
@@ -18,7 +18,7 @@
 
 #include "DetourAssert.h"
 
-#ifndef NDEBUG
+#ifndef RC_DISABLE_ASSERTS
 
 static dtAssertFailFunc* sAssertFailFunc = 0;
 
diff --git a/Integration.md b/Integration.md
new file mode 100644
index 0000000..60223d4
--- /dev/null
+++ b/Integration.md
@@ -0,0 +1,32 @@
+# Integration
+
+There are a few ways to integrate Recast and Detour into your project.  Source integration is the most popular and most flexible, and is what the project was designed for from the beginning.
+
+## Source Integration
+
+It is recommended to add the source directories `DebugUtils`, `Detour`, `DetourCrowd`, `DetourTileCache`, and `Recast` directly into your project depending on which parts of the project you need. For example your level building tool could include `DebugUtils`, `Recast`, and `Detour`, and your game runtime could just include `Detour`.
+
+- *Recast*: Core navmesh building system.
+- *Detour*: Runtime navmesh interface and query system
+- *DetourCrowd*: Runtime movement, obstacle avoidance and crowd sim systems
+- *DetourTileCache*: Runtime navmesh dynamic obstacle and re-baking system
+
+## Install through vcpkg
+
+If you are using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager you can alternatively download and install Recast with:
+
+```
+vcpkg install recast
+```
+
+# DLL and C API exports
+
+Recast does not currently provide a stable C API for use in a DLL or as bindings for another language.  The design of Recast currently relies on some C++ features, so providing a stable API is not possible without a few large changes to Recast.  There are a number of projects that offer unofficial language bindings for Recast, but official support for a C API is currently on our [Roadmap](Roadmap.md).
+
+# Preprocessor defines
+
+`RC_DISABLE_ASSERTS`: Disables assertion macros.  Useful for release builds that need to maximize performance.
+
+`DT_POLYREF64`: Use 64 bit (rather than 32 bit) polygon ID references.  Generally not needed, but sometimes useful for very large worlds.
+
+`DT_VIRTUAL_QUERYFILTER`: Define this if you plan to sub-class `dtQueryFilter`.  Enables the virtual destructor in `dtQueryFilter`
\ No newline at end of file
diff --git a/README.md b/README.md
index 1de41e8..5dfe543 100644
--- a/README.md
+++ b/README.md
@@ -66,15 +66,7 @@ RecastDemo uses [premake5](http://premake.github.io/) to build platform specific
 
 ## Integrating with your game or engine
 
-It is recommended to add the source directories `DebugUtils`, `Detour`, `DetourCrowd`, `DetourTileCache`, and `Recast` into your own project depending on which parts of the project you need. For example your level building tool could include `DebugUtils`, `Recast`, and `Detour`, and your game runtime could just include `Detour`.
-
-### Install through vcpkg
-
-If you are using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager you can download and install Recast with:
-
-```
-vcpkg install recast
-```
+See [Integration.md](Integration.md)
 
 ## Contribute
 
diff --git a/Recast/Include/RecastAssert.h b/Recast/Include/RecastAssert.h
index 81705bb..923b0ff 100644
--- a/Recast/Include/RecastAssert.h
+++ b/Recast/Include/RecastAssert.h
@@ -19,7 +19,7 @@
 #ifndef RECASTASSERT_H
 #define RECASTASSERT_H
 
-#ifdef NDEBUG
+#ifdef RC_DISABLE_ASSERTS
 
 // From https://web.archive.org/web/20210117002833/http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
 #	define rcAssert(x) do { (void)sizeof(x); } while ((void)(__LINE__==-1), false)
diff --git a/Recast/Source/RecastAssert.cpp b/Recast/Source/RecastAssert.cpp
index 973b681..2d899ca 100644
--- a/Recast/Source/RecastAssert.cpp
+++ b/Recast/Source/RecastAssert.cpp
@@ -18,7 +18,7 @@
 
 #include "RecastAssert.h"
 
-#ifndef NDEBUG
+#ifndef RC_DISABLE_ASSERTS
 
 static rcAssertFailFunc* sRecastAssertFailFunc = 0;
 
diff --git a/RecastDemo/premake5.lua b/RecastDemo/premake5.lua
index 05d2e9e..7ede4d6 100644
--- a/RecastDemo/premake5.lua
+++ b/RecastDemo/premake5.lua
@@ -28,7 +28,7 @@ workspace "recastnavigation"
  
  	-- release configs
 	filter "configurations:Release"
-		defines { "NDEBUG" }
+		defines { "RC_DISABLE_ASSERTS" }
 		optimize "On"
 		targetdir ( todir .. "/lib/Release" )
 
-- 
2.43.0