Debian Codegraph @

debian/patches/0009-Changed-asserts-to-be-explicitly-disabled-with-RC_DI.patch

raw
1 From af6d4758ffae1d192de50b9c6217ee58211baa6a Mon Sep 17 00:00:00 2001
2 From: Graham Pentheny <[email protected]>
3 Date: Wed, 9 Aug 2023 19:15:04 -0400
4 Subject: [PATCH 09/36] Changed asserts to be explicitly disabled with
5 RC_DISABLE_ASSERTS rather than using NDEBUG (#653)
6
7 * Changed asserts to be explicitly disabled with RC_DISABLE_ASSERTS rather than using NDEBUG
8
9 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.
10
11 * Added Integration.md with documentation on the integration process for Recast
12 ---
13 Detour/Include/DetourAssert.h | 2 +-
14 Detour/Source/DetourAssert.cpp | 2 +-
15 Integration.md | 32 ++++++++++++++++++++++++++++++++
16 README.md | 10 +---------
17 Recast/Include/RecastAssert.h | 2 +-
18 Recast/Source/RecastAssert.cpp | 2 +-
19 RecastDemo/premake5.lua | 2 +-
20 7 files changed, 38 insertions(+), 14 deletions(-)
21 create mode 100644 Integration.md
22
23 diff --git a/Detour/Include/DetourAssert.h b/Detour/Include/DetourAssert.h
24 index 038d538..ea58dd9 100644
25 --- a/Detour/Include/DetourAssert.h
26 +++ b/Detour/Include/DetourAssert.h
27 @@ -22,7 +22,7 @@
28 // Note: This header file's only purpose is to include define assert.
29 // Feel free to change the file and include your own implementation instead.
30
31 -#ifdef NDEBUG
32 +#ifdef RC_DISABLE_ASSERTS
33
34 // From https://web.archive.org/web/20210117002833/http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
35 # define dtAssert(x) do { (void)sizeof(x); } while((void)(__LINE__==-1),false)
36 diff --git a/Detour/Source/DetourAssert.cpp b/Detour/Source/DetourAssert.cpp
37 index 5e019e0..a9727a3 100644
38 --- a/Detour/Source/DetourAssert.cpp
39 +++ b/Detour/Source/DetourAssert.cpp
40 @@ -18,7 +18,7 @@
41
42 #include "DetourAssert.h"
43
44 -#ifndef NDEBUG
45 +#ifndef RC_DISABLE_ASSERTS
46
47 static dtAssertFailFunc* sAssertFailFunc = 0;
48
49 diff --git a/Integration.md b/Integration.md
50 new file mode 100644
51 index 0000000..60223d4
52 --- /dev/null
53 +++ b/Integration.md
54 @@ -0,0 +1,32 @@
55 +# Integration
56 +
57 +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.
58 +
59 +## Source Integration
60 +
61 +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`.
62 +
63 +- *Recast*: Core navmesh building system.
64 +- *Detour*: Runtime navmesh interface and query system
65 +- *DetourCrowd*: Runtime movement, obstacle avoidance and crowd sim systems
66 +- *DetourTileCache*: Runtime navmesh dynamic obstacle and re-baking system
67 +
68 +## Install through vcpkg
69 +
70 +If you are using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager you can alternatively download and install Recast with:
71 +
72 +```
73 +vcpkg install recast
74 +```
75 +
76 +# DLL and C API exports
77 +
78 +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).
79 +
80 +# Preprocessor defines
81 +
82 +`RC_DISABLE_ASSERTS`: Disables assertion macros. Useful for release builds that need to maximize performance.
83 +
84 +`DT_POLYREF64`: Use 64 bit (rather than 32 bit) polygon ID references. Generally not needed, but sometimes useful for very large worlds.
85 +
86 +`DT_VIRTUAL_QUERYFILTER`: Define this if you plan to sub-class `dtQueryFilter`. Enables the virtual destructor in `dtQueryFilter`
87 \ No newline at end of file
88 diff --git a/README.md b/README.md
89 index 1de41e8..5dfe543 100644
90 --- a/README.md
91 +++ b/README.md
92 @@ -66,15 +66,7 @@ RecastDemo uses [premake5](http://premake.github.io/) to build platform specific
93
94 ## Integrating with your game or engine
95
96 -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`.
97 -
98 -### Install through vcpkg
99 -
100 -If you are using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager you can download and install Recast with:
101 -
102 -```
103 -vcpkg install recast
104 -```
105 +See [Integration.md](Integration.md)
106
107 ## Contribute
108
109 diff --git a/Recast/Include/RecastAssert.h b/Recast/Include/RecastAssert.h
110 index 81705bb..923b0ff 100644
111 --- a/Recast/Include/RecastAssert.h
112 +++ b/Recast/Include/RecastAssert.h
113 @@ -19,7 +19,7 @@
114 #ifndef RECASTASSERT_H
115 #define RECASTASSERT_H
116
117 -#ifdef NDEBUG
118 +#ifdef RC_DISABLE_ASSERTS
119
120 // From https://web.archive.org/web/20210117002833/http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
121 # define rcAssert(x) do { (void)sizeof(x); } while ((void)(__LINE__==-1), false)
122 diff --git a/Recast/Source/RecastAssert.cpp b/Recast/Source/RecastAssert.cpp
123 index 973b681..2d899ca 100644
124 --- a/Recast/Source/RecastAssert.cpp
125 +++ b/Recast/Source/RecastAssert.cpp
126 @@ -18,7 +18,7 @@
127
128 #include "RecastAssert.h"
129
130 -#ifndef NDEBUG
131 +#ifndef RC_DISABLE_ASSERTS
132
133 static rcAssertFailFunc* sRecastAssertFailFunc = 0;
134
135 diff --git a/RecastDemo/premake5.lua b/RecastDemo/premake5.lua
136 index 05d2e9e..7ede4d6 100644
137 --- a/RecastDemo/premake5.lua
138 +++ b/RecastDemo/premake5.lua
139 @@ -28,7 +28,7 @@ workspace "recastnavigation"
140
141 -- release configs
142 filter "configurations:Release"
143 - defines { "NDEBUG" }
144 + defines { "RC_DISABLE_ASSERTS" }
145 optimize "On"
146 targetdir ( todir .. "/lib/Release" )
147
148 --
149 2.43.0
150