From 2b16295d0e4215e3fef6ce0910dfc38d5490dba7 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:36:04 +0200 Subject: [PATCH] Recast: move implementation of alloc and assert to shared Move the implementation as well, commit fa8d89d287752782ebdd5d9563f04fa72ef0bee9 was declaration (and some miscellaneous utility classes) only. --- src/core/CMakeLists.txt | 1 + src/naveditor/CMakeLists.txt | 1 + src/thirdparty/recast/CMakeLists.txt | 46 ++++++++++------- .../recast/Recast/Source/RecastAlloc.cpp | 51 ------------------- .../recast/Recast/Source/RecastAssert.cpp | 35 ------------- .../Source/SharedAlloc.cpp} | 0 .../Source/SharedAssert.cpp} | 0 7 files changed, 31 insertions(+), 103 deletions(-) delete mode 100644 src/thirdparty/recast/Recast/Source/RecastAlloc.cpp delete mode 100644 src/thirdparty/recast/Recast/Source/RecastAssert.cpp rename src/thirdparty/recast/{Detour/Source/DetourAlloc.cpp => Shared/Source/SharedAlloc.cpp} (100%) rename src/thirdparty/recast/{Detour/Source/DetourAssert.cpp => Shared/Source/SharedAssert.cpp} (100%) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 088125d1..ea40638b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -76,6 +76,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE "libspdlog" "libdetour" "navdebugutils" + "navsharedcommon" "EAThread" "DirtySDK" diff --git a/src/naveditor/CMakeLists.txt b/src/naveditor/CMakeLists.txt index fa8fa52d..c433f727 100644 --- a/src/naveditor/CMakeLists.txt +++ b/src/naveditor/CMakeLists.txt @@ -99,6 +99,7 @@ target_precompile_headers( ${PROJECT_NAME} PRIVATE "${ENGINE_SOURCE_DIR}/thirdparty/recast/Pch.h" ) target_link_libraries( ${PROJECT_NAME} PRIVATE + "navsharedcommon" "navdebugutils" "libsdl2" "libdetour" diff --git a/src/thirdparty/recast/CMakeLists.txt b/src/thirdparty/recast/CMakeLists.txt index 3309cc5f..d50759d5 100644 --- a/src/thirdparty/recast/CMakeLists.txt +++ b/src/thirdparty/recast/CMakeLists.txt @@ -1,9 +1,33 @@ cmake_minimum_required( VERSION 3.16 ) +# ----------------------------------------------------------------------------- +# Recast & Detour shared common +# ----------------------------------------------------------------------------- +add_module( "lib" "navsharedcommon" "" ${FOLDER_CONTEXT} TRUE TRUE ) + +start_sources() + +add_sources( SOURCE_GROUP "Source" + "Shared/Source/SharedAlloc.cpp" + "Shared/Source/SharedAssert.cpp" +) + +add_sources( SOURCE_GROUP "Include" + "Shared/Include/SharedAlloc.h" + "Shared/Include/SharedAssert.h" +) + +end_sources() +whole_program_optimization() + +target_precompile_headers( ${PROJECT_NAME} PRIVATE + "Pch.h" +) + # ----------------------------------------------------------------------------- # Recast & Detour debug utilities # ----------------------------------------------------------------------------- -add_module( "lib" "navdebugutils" "" ${FOLDER_CONTEXT} TRUE TRUE ) +add_module( "lib" "navdebugutils" "navsharedcommon" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() @@ -24,20 +48,14 @@ add_sources( SOURCE_GROUP "Include" end_sources() whole_program_optimization() -target_precompile_headers( ${PROJECT_NAME} PRIVATE - "Pch.h" -) - # ----------------------------------------------------------------------------- # Detour runtime # ----------------------------------------------------------------------------- -add_module( "lib" "libdetour" "navdebugutils" ${FOLDER_CONTEXT} TRUE TRUE ) +add_module( "lib" "libdetour" "navsharedcommon" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() add_sources( SOURCE_GROUP "Source" - "Detour/Source/DetourAlloc.cpp" - "Detour/Source/DetourAssert.cpp" "Detour/Source/DetourCommon.cpp" "Detour/Source/DetourNavMesh.cpp" "Detour/Source/DetourNavMeshBuilder.cpp" @@ -46,8 +64,6 @@ add_sources( SOURCE_GROUP "Source" ) add_sources( SOURCE_GROUP "Include" - "Detour/Include/DetourAlloc.h" - "Detour/Include/DetourAssert.h" "Detour/Include/DetourCommon.h" "Detour/Include/DetourMath.h" "Detour/Include/DetourNavMesh.h" @@ -63,7 +79,7 @@ whole_program_optimization() # ----------------------------------------------------------------------------- # Detour crowd # ----------------------------------------------------------------------------- -add_module( "lib" "libdetourcrowd" "navdebugutils" ${FOLDER_CONTEXT} TRUE TRUE ) +add_module( "lib" "libdetourcrowd" "navsharedcommon" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() @@ -93,7 +109,7 @@ whole_program_optimization() # ----------------------------------------------------------------------------- # Detour tile cache # ----------------------------------------------------------------------------- -add_module( "lib" "libdetourtilecache" "navdebugutils" ${FOLDER_CONTEXT} TRUE TRUE ) +add_module( "lib" "libdetourtilecache" "navsharedcommon" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() @@ -113,15 +129,13 @@ whole_program_optimization() # ----------------------------------------------------------------------------- # Recast runtime # ----------------------------------------------------------------------------- -add_module( "lib" "librecast" "navdebugutils" ${FOLDER_CONTEXT} TRUE TRUE ) +add_module( "lib" "librecast" "navsharedcommon" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() add_sources( SOURCE_GROUP "Source" "Recast/Source/Recast.cpp" - "Recast/Source/RecastAlloc.cpp" "Recast/Source/RecastArea.cpp" - "Recast/Source/RecastAssert.cpp" "Recast/Source/RecastContour.cpp" "Recast/Source/RecastFilter.cpp" "Recast/Source/RecastLayers.cpp" @@ -133,8 +147,6 @@ add_sources( SOURCE_GROUP "Source" add_sources( SOURCE_GROUP "Include" "Recast/Include/Recast.h" - "Recast/Include/RecastAlloc.h" - "Recast/Include/RecastAssert.h" ) end_sources() diff --git a/src/thirdparty/recast/Recast/Source/RecastAlloc.cpp b/src/thirdparty/recast/Recast/Source/RecastAlloc.cpp deleted file mode 100644 index 592243ae..00000000 --- a/src/thirdparty/recast/Recast/Source/RecastAlloc.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// - -#include "Shared/Include/SharedAlloc.h" - -static void* rdAllocDefault(size_t size, rdAllocHint) -{ - return malloc(size); -} - -static void rdFreeDefault(void *ptr) -{ - free(ptr); -} - -static rdAllocFunc* sRecastAllocFunc = rdAllocDefault; -static rdFreeFunc* sRecastFreeFunc = rdFreeDefault; - -void rdAllocSetCustom(rdAllocFunc* allocFunc, rdFreeFunc* freeFunc) -{ - sRecastAllocFunc = allocFunc ? allocFunc : rdAllocDefault; - sRecastFreeFunc = freeFunc ? freeFunc : rdFreeDefault; -} - -void* rdAlloc(size_t size, rdAllocHint hint) -{ - return sRecastAllocFunc(size, hint); -} - -void rdFree(void* ptr) -{ - if (ptr != NULL) - { - sRecastFreeFunc(ptr); - } -} diff --git a/src/thirdparty/recast/Recast/Source/RecastAssert.cpp b/src/thirdparty/recast/Recast/Source/RecastAssert.cpp deleted file mode 100644 index 8044763c..00000000 --- a/src/thirdparty/recast/Recast/Source/RecastAssert.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// 3. This notice may not be removed or altered from any source distribution. -// - -#include "Shared/Include/SharedAssert.h" - -#ifndef NDEBUG - -static rdAssertFailFunc* sRecastAssertFailFunc = 0; - -void rdAssertFailSetCustom(rdAssertFailFunc *assertFailFunc) -{ - sRecastAssertFailFunc = assertFailFunc; -} - -rdAssertFailFunc* rdAssertFailGetCustom() -{ - return sRecastAssertFailFunc; -} - -#endif diff --git a/src/thirdparty/recast/Detour/Source/DetourAlloc.cpp b/src/thirdparty/recast/Shared/Source/SharedAlloc.cpp similarity index 100% rename from src/thirdparty/recast/Detour/Source/DetourAlloc.cpp rename to src/thirdparty/recast/Shared/Source/SharedAlloc.cpp diff --git a/src/thirdparty/recast/Detour/Source/DetourAssert.cpp b/src/thirdparty/recast/Shared/Source/SharedAssert.cpp similarity index 100% rename from src/thirdparty/recast/Detour/Source/DetourAssert.cpp rename to src/thirdparty/recast/Shared/Source/SharedAssert.cpp