diff --git a/source/blender/editors/include/ED_navmesh_conversion.h b/source/blender/blenkernel/BKE_navmesh_conversion.h similarity index 78% rename from source/blender/editors/include/ED_navmesh_conversion.h rename to source/blender/blenkernel/BKE_navmesh_conversion.h index 71b60cc4e4a..acb3c2963a9 100644 --- a/source/blender/editors/include/ED_navmesh_conversion.h +++ b/source/blender/blenkernel/BKE_navmesh_conversion.h @@ -27,12 +27,8 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef NAVMESH_CONVERSION_H -#define NAVMESH_CONVERSION_H - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef BKE_NAVMESH_CONVERSION_H +#define BKE_NAVMESH_CONVERSION_H struct DerivedMesh; @@ -65,32 +61,4 @@ bool polyIsConvex(const unsigned short* p, const int vertsPerPoly, const float* int polyFindVertex(const unsigned short* p, const int vertsPerPoly, unsigned short vertexIdx); float distPointToSegmentSq(const float* point, const float* a, const float* b); - -inline int bit(int a, int b) -{ - return (a & (1 << b)) >> b; -} - -inline void intToCol(int i, float* col) -{ - int r = bit(i, 0) + bit(i, 3) * 2 + 1; - int g = bit(i, 1) + bit(i, 4) * 2 + 1; - int b = bit(i, 2) + bit(i, 5) * 2 + 1; - col[0] = 1 - r*63.0f/255.0f; - col[1] = 1 - g*63.0f/255.0f; - col[2] = 1 - b*63.0f/255.0f; -} - -inline float area2(const float* a, const float* b, const float* c) -{ - return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]); -} -inline bool left(const float* a, const float* b, const float* c) -{ - return area2(a, b, c) < 0; -} - -#ifdef __cplusplus -} -#endif #endif //NAVMESH_CONVERSION_H diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c1797427cc2..52709b75ca0 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -353,6 +353,16 @@ if(WITH_LZMA) add_definitions(-DWITH_LZMA) endif() +if(WITH_GAMEENGINE) + list(APPEND INC_SYS + ../../../extern/recastnavigation/Recast/Include + ) + list(APPEND SRC + intern/navmesh_conversion.cpp + BKE_navmesh_conversion.h + ) +endif() + if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") endif() diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 5ea42ee65ae..e7999f18b34 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -1,7 +1,7 @@ #!/usr/bin/python Import ('env') -sources = env.Glob('intern/*.c') +sources = env.Glob('intern/*.c') + env.Glob('intern/*.cpp') incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include' incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager' @@ -90,6 +90,12 @@ if env['WITH_BF_LZMA']: incs += ' #/extern/lzma' defs.append('WITH_LZMA') +if env['WITH_BF_GAMEENGINE']: + incs += ' #/extern/recastnavigation/Recast/Include' + defs.append('WITH_GAMEENGINE') +else: + sources.remove('intern/navmesh_conversion.cpp') + if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] diff --git a/source/blender/editors/util/navmesh_conversion.cpp b/source/blender/blenkernel/intern/navmesh_conversion.cpp similarity index 97% rename from source/blender/editors/util/navmesh_conversion.cpp rename to source/blender/blenkernel/intern/navmesh_conversion.cpp index 8b3fee59e1a..245a2b23091 100644 --- a/source/blender/editors/util/navmesh_conversion.cpp +++ b/source/blender/blenkernel/intern/navmesh_conversion.cpp @@ -26,18 +26,28 @@ * * ***** END GPL LICENSE BLOCK ***** */ + #include #include "Recast.h" - extern "C"{ -#include "ED_navmesh_conversion.h" +#include "BKE_navmesh_conversion.h" #include "DNA_meshdata_types.h" #include "BKE_cdderivedmesh.h" #include "BLI_math.h" } +inline float area2(const float* a, const float* b, const float* c) +{ + return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]); +} + +inline bool left(const float* a, const float* b, const float* c) +{ + return area2(a, b, c) < 0; +} + int polyNumVerts(const unsigned short* p, const int vertsPerPoly) { int nv = 0; diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index c64b16c2d08..72f13c14f5d 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -87,16 +87,4 @@ set(SRC ../include/UI_view2d.h ) -if(WITH_GAMEENGINE) - list(APPEND INC - ../../../../extern/recastnavigation/Recast/Include - ) - - list(APPEND SRC - navmesh_conversion.cpp - - ../include/ED_navmesh_conversion.h - ) -endif() - blender_add_lib(bf_editor_util "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/util/SConscript b/source/blender/editors/util/SConscript index 80c05dc5db4..cfbc735eb5c 100644 --- a/source/blender/editors/util/SConscript +++ b/source/blender/editors/util/SConscript @@ -1,15 +1,11 @@ #!/usr/bin/python Import ('env') -sources = env.Glob('*.c') + env.Glob('*.cpp') +sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna' -incs += ' #extern/recastnavigation/Recast/Include' incs += ' ../../blenloader' -if not env['WITH_BF_GAMEENGINE']: - sources.remove('navmesh_conversion.cpp') - env.BlenderLib ( 'bf_editors_util', sources, Split(incs), [], libtype=['core','player'], priority=[330,210] ) diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 083ad052a58..d8344a9e19b 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -122,7 +122,6 @@ if(WITH_GAMEENGINE) list(APPEND INC ../gpu ../../../extern/recastnavigation/Recast/Include - ../editors/include # XXX - BAD LEVEL CALL, REMOVE BEFORE RELEASE ) endif() diff --git a/source/blender/modifiers/SConscript b/source/blender/modifiers/SConscript index f90e637d151..da37539e950 100644 --- a/source/blender/modifiers/SConscript +++ b/source/blender/modifiers/SConscript @@ -7,8 +7,7 @@ incs = '. ./intern' incs += ' #/intern/guardedalloc #/intern/decimation/extern #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include' incs += ' ../render/extern/include ../blenloader' incs += ' ../include ../blenlib ../makesdna ../makesrna ../blenkernel ../blenkernel/intern' -incs += ' ../editors/include ../gpu' -incs += ' #extern/recastnavigation/Recast/Include' +incs += ' ../gpu' incs += ' ' + env['BF_ZLIB_INC'] @@ -21,6 +20,10 @@ defs += ['WITH_MOD_DECIMATE'] if env['BF_NO_ELBEEM']: defs.append('DISABLE_ELBEEM') +if env['WITH_BF_GAMEENGINE']: + incs += ' #/extern/recastnavigation/Recast/Include' + defs.append('WITH_GAMEENGINE') + env.BlenderLib ( libname = 'bf_modifiers', sources = sources, includes = Split(incs), defines=defs, libtype=['core','player'], priority = [80, 40] ) diff --git a/source/blender/modifiers/intern/MOD_navmesh.cpp b/source/blender/modifiers/intern/MOD_navmesh.cpp index d32281c12b6..927085033fc 100644 --- a/source/blender/modifiers/intern/MOD_navmesh.cpp +++ b/source/blender/modifiers/intern/MOD_navmesh.cpp @@ -34,11 +34,10 @@ extern "C"{ #ifdef WITH_GAMEENGINE -# include "ED_navmesh_conversion.h" -# include "BIF_gl.h" +# include "BKE_navmesh_conversion.h" +# include "GL/glew.h" # include "GPU_buffers.h" # include "GPU_draw.h" -# include "UI_resources.h" #endif #include "DNA_mesh_types.h" @@ -54,6 +53,22 @@ extern "C"{ #include "BKE_customdata.h" #include "MEM_guardedalloc.h" +inline int bit(int a, int b) +{ + return (a & (1 << b)) >> b; +} + +inline void intToCol(int i, float* col) +{ + int r = bit(i, 0) + bit(i, 3) * 2 + 1; + int g = bit(i, 1) + bit(i, 4) * 2 + 1; + int b = bit(i, 2) + bit(i, 5) * 2 + 1; + col[0] = 1 - r*63.0f/255.0f; + col[1] = 1 - g*63.0f/255.0f; + col[2] = 1 - b*63.0f/255.0f; +} + + static void initData(ModifierData *md) { /* NavMeshModifierData *nmmd = (NavMeshModifierData*) md; */ /* UNUSED */ diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 4b2d828fe81..9d8b1781869 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -59,7 +59,6 @@ set(INC_SYS ${GLEW_INCLUDE_PATH} ../../../extern/recastnavigation/Recast/Include ../../../extern/recastnavigation/Detour/Include - ../../blender/editors/include ) set(SRC diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 26990f6e82b..f72c98fb4bf 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -38,9 +38,7 @@ extern "C" { #include "BKE_customdata.h" #include "BKE_cdderivedmesh.h" #include "BKE_DerivedMesh.h" - - -#include "ED_navmesh_conversion.h" +#include "BKE_navmesh_conversion.h" } #include "KX_PythonInit.h" diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 7c9785c24e7..9b453ed76d5 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -21,7 +21,6 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common' incs += ' #source/gameengine/Physics/Dummy' incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu' incs += ' #extern/recastnavigation/Recast/Include #extern/recastnavigation/Detour/Include' -incs += ' #source/blender/editors/include' incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC']