Recast: move implementation of alloc and assert to shared

Move the implementation as well, commit fa8d89d287752782ebdd5d9563f04fa72ef0bee9 was declaration (and some miscellaneous utility classes) only.
This commit is contained in:
Kawe Mazidjatari 2024-07-04 20:36:04 +02:00
parent 64fcdfb5f0
commit 2b16295d0e
7 changed files with 31 additions and 103 deletions

View File

@ -76,6 +76,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
"libspdlog"
"libdetour"
"navdebugutils"
"navsharedcommon"
"EAThread"
"DirtySDK"

View File

@ -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"

View File

@ -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()

View File

@ -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);
}
}

View File

@ -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