From 5c494ad1eecbdc879d4195788a343f806f247874 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 14 Apr 2023 23:02:00 +0200 Subject: [PATCH] RecastLayers: set RC_MAX_LAYERS and RC_MAX_NEIS as optional defines (#624) It makes possible for a project integrating Recast to set custom values via CXXFLAGS while remaining build system agnostic. Type checking is kept. --- Recast/Source/RecastLayers.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Recast/Source/RecastLayers.cpp b/Recast/Source/RecastLayers.cpp index d5eb06a..4d4fa46 100644 --- a/Recast/Source/RecastLayers.cpp +++ b/Recast/Source/RecastLayers.cpp @@ -28,8 +28,21 @@ // Must be 255 or smaller (not 256) because layer IDs are stored as // a byte where 255 is a special value. -static const int RC_MAX_LAYERS = 63; -static const int RC_MAX_NEIS = 16; +#ifndef RC_MAX_LAYERS_DEF +#define RC_MAX_LAYERS_DEF 63 +#endif + +#if RC_MAX_LAYERS_DEF > 255 +#error RC_MAX_LAYERS_DEF must be 255 or smaller +#endif + +#ifndef RC_MAX_NEIS_DEF +#define RC_MAX_NEIS_DEF 16 +#endif + +// Keep type checking. +static const int RC_MAX_LAYERS = RC_MAX_LAYERS_DEF; +static const int RC_MAX_NEIS = RC_MAX_NEIS_DEF; struct rcLayerRegion {