forked from bartvdbraak/blender
Booleans: Boost is no longer a dependency for Carve
SCons is currently broken on my laptop, so can't test if it works for sure, so please do tests of that.
This commit is contained in:
parent
4d35ecc3bb
commit
f82f1513e0
@ -544,7 +544,7 @@ if(NOT WITH_PYTHON)
|
|||||||
set(WITH_CYCLES OFF)
|
set(WITH_CYCLES OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# enable boost for cycles, booleans, audaspace or i18n
|
# enable boost for cycles, audaspace or i18n
|
||||||
# otherwise if the user disabled
|
# otherwise if the user disabled
|
||||||
if(NOT WITH_BOOST)
|
if(NOT WITH_BOOST)
|
||||||
# Explicitly disabled. so disable all deps.
|
# Explicitly disabled. so disable all deps.
|
||||||
@ -557,13 +557,12 @@ if(NOT WITH_BOOST)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
set_and_warn(WITH_CYCLES OFF)
|
set_and_warn(WITH_CYCLES OFF)
|
||||||
set_and_warn(WITH_MOD_BOOLEAN OFF)
|
|
||||||
set_and_warn(WITH_AUDASPACE OFF)
|
set_and_warn(WITH_AUDASPACE OFF)
|
||||||
set_and_warn(WITH_INTERNATIONAL OFF)
|
set_and_warn(WITH_INTERNATIONAL OFF)
|
||||||
|
|
||||||
set_and_warn(WITH_OPENAL OFF) # depends on AUDASPACE
|
set_and_warn(WITH_OPENAL OFF) # depends on AUDASPACE
|
||||||
set_and_warn(WITH_GAMEENGINE OFF) # depends on AUDASPACE
|
set_and_warn(WITH_GAMEENGINE OFF) # depends on AUDASPACE
|
||||||
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL)
|
elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL)
|
||||||
# Keep enabled
|
# Keep enabled
|
||||||
else()
|
else()
|
||||||
# Enabled but we don't need it
|
# Enabled but we don't need it
|
||||||
|
1
extern/carve/CMakeLists.txt
vendored
1
extern/carve/CMakeLists.txt
vendored
@ -161,6 +161,7 @@ if(WITH_BOOST)
|
|||||||
|
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DCARVE_SYSTEM_BOOST
|
-DCARVE_SYSTEM_BOOST
|
||||||
|
-DHAVE_BOOST_LIBRARY
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND INC_SYS
|
list(APPEND INC_SYS
|
||||||
|
1
extern/carve/SConscript
vendored
1
extern/carve/SConscript
vendored
@ -19,6 +19,7 @@ if env['WITH_BF_BOOST']:
|
|||||||
defs.append('HAVE_BOOST_UNORDERED_COLLECTIONS')
|
defs.append('HAVE_BOOST_UNORDERED_COLLECTIONS')
|
||||||
|
|
||||||
defs.append('CARVE_SYSTEM_BOOST')
|
defs.append('CARVE_SYSTEM_BOOST')
|
||||||
|
defs.append('HAVE_BOOST_LIBRARY')
|
||||||
incs.append(env['BF_BOOST_INC'])
|
incs.append(env['BF_BOOST_INC'])
|
||||||
|
|
||||||
env.BlenderLib ('extern_carve', Split(sources), incs, defs, libtype=['extern'], priority=[40] )
|
env.BlenderLib ('extern_carve', Split(sources), incs, defs, libtype=['extern'], priority=[40] )
|
||||||
|
4
extern/carve/bundle.sh
vendored
4
extern/carve/bundle.sh
vendored
@ -31,6 +31,8 @@ headers=`find ./lib -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t
|
|||||||
includes=`find ./include -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/' | sort -d`
|
includes=`find ./include -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/' | sort -d`
|
||||||
|
|
||||||
cp patches/files/config.h include/carve/config.h
|
cp patches/files/config.h include/carve/config.h
|
||||||
|
mkdir -p include/carve/random
|
||||||
|
cp patches/files/random.h include/carve/random/random.h
|
||||||
|
|
||||||
cat > CMakeLists.txt << EOF
|
cat > CMakeLists.txt << EOF
|
||||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
@ -91,6 +93,7 @@ if(WITH_BOOST)
|
|||||||
|
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DCARVE_SYSTEM_BOOST
|
-DCARVE_SYSTEM_BOOST
|
||||||
|
-DHAVE_BOOST_LIBRARY
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND INC_SYS
|
list(APPEND INC_SYS
|
||||||
@ -123,6 +126,7 @@ if env['WITH_BF_BOOST']:
|
|||||||
defs.append('HAVE_BOOST_UNORDERED_COLLECTIONS')
|
defs.append('HAVE_BOOST_UNORDERED_COLLECTIONS')
|
||||||
|
|
||||||
defs.append('CARVE_SYSTEM_BOOST')
|
defs.append('CARVE_SYSTEM_BOOST')
|
||||||
|
defs.append('HAVE_BOOST_LIBRARY')
|
||||||
incs.append(env['BF_BOOST_INC'])
|
incs.append(env['BF_BOOST_INC'])
|
||||||
|
|
||||||
env.BlenderLib ('extern_carve', Split(sources), incs, defs, libtype=['extern'], priority=[40] )
|
env.BlenderLib ('extern_carve', Split(sources), incs, defs, libtype=['extern'], priority=[40] )
|
||||||
|
61
extern/carve/include/carve/random/random.h
vendored
Normal file
61
extern/carve/include/carve/random/random.h
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
#if __cplusplus > 199711L
|
||||||
|
# include <random>
|
||||||
|
typedef std::mt19937 mt19937;
|
||||||
|
#else
|
||||||
|
# include <stdlib.h>
|
||||||
|
struct mt19937 {
|
||||||
|
int operator()() {
|
||||||
|
return rand();
|
||||||
|
}
|
||||||
|
|
||||||
|
int max() {
|
||||||
|
return RAND_MAX;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct uniform_on_sphere {
|
||||||
|
typedef std::vector<T> result_type;
|
||||||
|
|
||||||
|
uniform_on_sphere(int dimension) {
|
||||||
|
assert(dimension == 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<T>
|
||||||
|
operator()(float u1, float u2) {
|
||||||
|
T z = 1.0 - 2.0*u1;
|
||||||
|
T r = std::sqrt(std::max(0.0, 1.0 - z*z));
|
||||||
|
T phi = 2.0*M_PI*u2;
|
||||||
|
T x = r*std::cos(phi);
|
||||||
|
T y = r*std::sin(phi);
|
||||||
|
std::vector<T> result;
|
||||||
|
result.push_back(x);
|
||||||
|
result.push_back(y);
|
||||||
|
result.push_back(z);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename RNG, typename DISTR>
|
||||||
|
struct variate_generator {
|
||||||
|
|
||||||
|
variate_generator(RNG rng, DISTR distr)
|
||||||
|
: rng_(rng), distr_(distr) {}
|
||||||
|
|
||||||
|
typename DISTR::result_type
|
||||||
|
operator()() {
|
||||||
|
float rng_max_inv = 1.0 / rng_.max();
|
||||||
|
return distr_(rng_() * rng_max_inv, rng_() * rng_max_inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
RNG rng_;
|
||||||
|
DISTR distr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
4
extern/carve/lib/polyhedron.cpp
vendored
4
extern/carve/lib/polyhedron.cpp
vendored
@ -36,7 +36,11 @@
|
|||||||
|
|
||||||
#include <carve/mesh.hpp>
|
#include <carve/mesh.hpp>
|
||||||
|
|
||||||
|
#ifdef HAVE_BOOST_LIBRARY
|
||||||
# include BOOST_INCLUDE(random.hpp)
|
# include BOOST_INCLUDE(random.hpp)
|
||||||
|
#else
|
||||||
|
# include <carve/random/random.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool emb_test(carve::poly::Polyhedron *poly,
|
bool emb_test(carve::poly::Polyhedron *poly,
|
||||||
|
61
extern/carve/patches/files/random.h
vendored
Normal file
61
extern/carve/patches/files/random.h
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
#if __cplusplus > 199711L
|
||||||
|
# include <random>
|
||||||
|
typedef std::mt19937 mt19937;
|
||||||
|
#else
|
||||||
|
# include <stdlib.h>
|
||||||
|
struct mt19937 {
|
||||||
|
int operator()() {
|
||||||
|
return rand();
|
||||||
|
}
|
||||||
|
|
||||||
|
int max() {
|
||||||
|
return RAND_MAX;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct uniform_on_sphere {
|
||||||
|
typedef std::vector<T> result_type;
|
||||||
|
|
||||||
|
uniform_on_sphere(int dimension) {
|
||||||
|
assert(dimension == 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<T>
|
||||||
|
operator()(float u1, float u2) {
|
||||||
|
T z = 1.0 - 2.0*u1;
|
||||||
|
T r = std::sqrt(std::max(0.0, 1.0 - z*z));
|
||||||
|
T phi = 2.0*M_PI*u2;
|
||||||
|
T x = r*std::cos(phi);
|
||||||
|
T y = r*std::sin(phi);
|
||||||
|
std::vector<T> result;
|
||||||
|
result.push_back(x);
|
||||||
|
result.push_back(y);
|
||||||
|
result.push_back(z);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename RNG, typename DISTR>
|
||||||
|
struct variate_generator {
|
||||||
|
|
||||||
|
variate_generator(RNG rng, DISTR distr)
|
||||||
|
: rng_(rng), distr_(distr) {}
|
||||||
|
|
||||||
|
typename DISTR::result_type
|
||||||
|
operator()() {
|
||||||
|
float rng_max_inv = 1.0 / rng_.max();
|
||||||
|
return distr_(rng_() * rng_max_inv, rng_() * rng_max_inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
RNG rng_;
|
||||||
|
DISTR distr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
16
extern/carve/patches/random.patch
vendored
Normal file
16
extern/carve/patches/random.patch
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
diff -r 9a85d733a43d lib/polyhedron.cpp
|
||||||
|
--- a/lib/polyhedron.cpp Tue Jun 24 11:15:23 2014 +1000
|
||||||
|
+++ b/lib/polyhedron.cpp Thu Nov 13 17:36:06 2014 +0500
|
||||||
|
@@ -36,7 +36,11 @@
|
||||||
|
|
||||||
|
#include <carve/mesh.hpp>
|
||||||
|
|
||||||
|
-#include BOOST_INCLUDE(random.hpp)
|
||||||
|
+#ifdef HAVE_BOOST_LIBRARY
|
||||||
|
+# include BOOST_INCLUDE(random.hpp)
|
||||||
|
+#else
|
||||||
|
+# include <carve/random/random.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
bool emb_test(carve::poly::Polyhedron *poly,
|
1
extern/carve/patches/series
vendored
1
extern/carve/patches/series
vendored
@ -11,3 +11,4 @@ mesh_simplify_uninitialized_var.patch
|
|||||||
memory_leak_fix.patch
|
memory_leak_fix.patch
|
||||||
msvc_fix.patch
|
msvc_fix.patch
|
||||||
face_hole_merge_workaround.patch
|
face_hole_merge_workaround.patch
|
||||||
|
random.patch
|
||||||
|
Loading…
Reference in New Issue
Block a user