[Bf-blender-cvs] [e4c25b0ab75] newboolean: Move to exact arithmetic for new boolean implementation.

Howard Trickey noreply at git.blender.org
Sun Jun 7 00:48:48 CEST 2020


Commit: e4c25b0ab7588c01166b208084a11996890841bf
Author: Howard Trickey
Date:   Sat Jun 6 18:46:06 2020 -0400
Branches: newboolean
https://developer.blender.org/rBe4c25b0ab7588c01166b208084a11996890841bf

Move to exact arithmetic for new boolean implementation.

This is a regression in functionality from the previous version,
as I have not yet got anything beyond intersection working (and
that only for triangulated meshes). But want to get this into
the repository now while I continue to work on the functionality,
and then, the performance.

===================================================================

M	CMakeLists.txt
M	build_files/build_environment/CMakeLists.txt
A	build_files/build_environment/cmake/gmp.cmake
M	build_files/build_environment/cmake/versions.cmake
A	build_files/build_environment/patches/cmakelists_gmpxx.txt
A	build_files/build_environment/patches/config_gmpxx.h
A	build_files/cmake/Modules/FindGMP.cmake
M	build_files/cmake/Modules/GTestTesting.cmake
M	build_files/cmake/config/blender_full.cmake
M	build_files/cmake/config/blender_lite.cmake
M	build_files/cmake/config/blender_release.cmake
M	build_files/cmake/macros.cmake
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	release/scripts/addons
A	source/blender/blenlib/BLI_boolean.h
M	source/blender/blenlib/BLI_delaunay_2d.h
A	source/blender/blenlib/BLI_double2.hh
A	source/blender/blenlib/BLI_double3.hh
M	source/blender/blenlib/BLI_float2.hh
M	source/blender/blenlib/BLI_float3.hh
M	source/blender/blenlib/BLI_math_base.h
M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/BLI_math_matrix.h
A	source/blender/blenlib/BLI_math_mpq.hh
M	source/blender/blenlib/BLI_math_vector.h
A	source/blender/blenlib/BLI_mesh_intersect.hh
A	source/blender/blenlib/BLI_mpq2.hh
A	source/blender/blenlib/BLI_mpq3.hh
M	source/blender/blenlib/CMakeLists.txt
A	source/blender/blenlib/intern/boolean.cc
D	source/blender/blenlib/intern/delaunay_2d.c
A	source/blender/blenlib/intern/delaunay_2d.cc
M	source/blender/blenlib/intern/math_base_inline.c
M	source/blender/blenlib/intern/math_geom.c
M	source/blender/blenlib/intern/math_geom_inline.c
M	source/blender/blenlib/intern/math_matrix.c
A	source/blender/blenlib/intern/math_vec.cc
M	source/blender/blenlib/intern/math_vector.c
M	source/blender/blenlib/intern/math_vector_inline.c
A	source/blender/blenlib/intern/mesh_intersect.cc
M	source/blender/bmesh/bmesh_tools.h
M	source/blender/bmesh/tools/bmesh_boolean.c
M	source/blender/bmesh/tools/bmesh_boolean.h
M	source/blender/bmesh/tools/bmesh_decimate_collapse.c
M	source/blender/editors/mesh/editmesh_intersect.c
M	source/blender/modifiers/intern/MOD_boolean.c
M	source/blender/python/mathutils/mathutils_geometry.c
M	source/creator/CMakeLists.txt
A	tests/gtests/blenlib/BLI_boolean_test.cc
M	tests/gtests/blenlib/BLI_delaunay_2d_test.cc
A	tests/gtests/blenlib/BLI_mesh_intersect_test.cc
M	tests/gtests/blenlib/CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4037dc1e3e..230daf4525e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,6 +183,7 @@ if(APPLE)
 else()
   option(WITH_XR_OPENXR   "Enable VR features through the OpenXR specification" ON)
 endif()
+option(WITH_GMP "Enable features depending on GMP (Exact Boolean)" ON)
 
 # Compositor
 option(WITH_COMPOSITOR         "Enable the tile based nodal compositor" ON)
@@ -1734,6 +1735,7 @@ if(FIRST_RUN)
   info_cfg_option(WITH_QUADRIFLOW)
   info_cfg_option(WITH_USD)
   info_cfg_option(WITH_TBB)
+  info_cfg_option(WITH_GMP)
 
   info_cfg_text("Compiler Options:")
   info_cfg_option(WITH_BUILDINFO)
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index dd90eb9adde..cf9dca70966 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -118,6 +118,7 @@ endif()
 
 if(NOT WIN32 OR ENABLE_MINGW64)
   include(cmake/openjpeg.cmake)
+  include(cmake/gmp.cmake)
   if(NOT WIN32 OR BUILD_MODE STREQUAL Release)
     if(WIN32)
       include(cmake/zlib_mingw.cmake)
diff --git a/build_files/build_environment/cmake/gmp.cmake b/build_files/build_environment/cmake/gmp.cmake
new file mode 100644
index 00000000000..228416ae822
--- /dev/null
+++ b/build_files/build_environment/cmake/gmp.cmake
@@ -0,0 +1,88 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(GMP_EXTRA_ARGS -enable-cxx)
+
+if(WIN32)
+  # Shared for windows because static libs will drag in a libgcc dependency.
+  set(GMP_OPTIONS --disable-static --enable-shared --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32)
+else()
+  set(GMP_OPTIONS --enable-static --disable-shared )
+endif()
+
+ExternalProject_Add(external_gmp
+  URL ${GMP_URI}
+  DOWNLOAD_DIR ${DOWNLOAD_DIR}
+  URL_HASH MD5=${GMP_HASH}
+  PREFIX ${BUILD_DIR}/gmp
+  CONFIGURE_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/gmp ${GMP_OPTIONS} ${GMP_EXTRA_ARGS}
+  BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && make -j${MAKE_THREADS}
+  INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && make install
+  INSTALL_DIR ${LIBDIR}/gmp
+)
+
+if(MSVC)
+  set_target_properties(external_gmp PROPERTIES FOLDER Mingw)
+endif()
+
+if(BUILD_MODE STREQUAL Release AND WIN32)
+  ExternalProject_Add_Step(external_gmp after_install
+      COMMAND  ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-3.dll.def ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def
+      COMMAND  lib /def:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def /machine:x64 /out:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib
+      COMMAND  ${CMAKE_COMMAND} -E copy ${LIBDIR}/gmp/bin/libgmp-10.dll ${HARVEST_TARGET}/gmp/lib/libgmp-10.dll
+      COMMAND  ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib ${HARVEST_TARGET}/gmp/lib/libgmp-10.lib
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/gmp/include ${HARVEST_TARGET}/gmp/include
+    DEPENDEES install
+  )
+endif()
+
+if(BUILD_MODE STREQUAL Debug AND WIN32)
+ExternalProject_Add_Step(external_gmp after_install
+      COMMAND  ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-3.dll.def ${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def
+      COMMAND  lib /def:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.def /machine:x64 /out:${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib
+    DEPENDEES install
+  )
+endif()
+
+if(WIN32)
+  # gmpxx is somewhat special, it builds on the C style gmp library but exposes C++ bindings
+  # given the C++ ABI between msvc and mingw is not compatible, we need to build the bindings
+  # with MSVC, while GMP builds with mingw.
+  ExternalProject_Add(external_gmpxx
+    URL ${GMP_URI}
+    DOWNLOAD_DIR ${DOWNLOAD_DIR}
+    URL_HASH MD5=${GMP_HASH}
+    PREFIX ${BUILD_DIR}/gmpxx
+    PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_gmpxx.txt ${BUILD_DIR}/gmpxx/src/external_gmpxx/CMakeLists.txt &&
+                          ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/config_gmpxx.h ${BUILD_DIR}/gmpxx/src/external_gmpxx/config.h
+    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmpxx ${DEFAULT_CMAKE_FLAGS} -DGMP_LIBRARY=${BUILD_DIR}/gmp/src/external_gmp/.libs/libgmp-10.lib -DGMP_INCLUDE_DIR=${BUILD_DIR}/gmp/src/external_gmp -DCMAKE_DEBUG_POSTFIX=_d
+    INSTALL_DIR ${LIBDIR}/gmpxx
+  )
+  set_target_properties(external_gmpxx PROPERTIES FOLDER Mingw)
+
+  add_dependencies(
+    external_gmpxx
+    external_gmp
+  )
+
+  ExternalProject_Add_Step(external_gmpxx after_install
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/gmpxx/ ${HARVEST_TARGET}/gmp
+    DEPENDEES install
+  )
+
+endif()
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index c1dcf98318c..ba177dceecd 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -316,3 +316,8 @@ set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
 set(XR_OPENXR_SDK_VERSION 1.0.8)
 set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
 set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07)
+
+set(GMP_VERSION 6.2.0)
+set(GMP_URI https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz)
+set(GMP_HASH a325e3f09e6d91e62101e59f9bda3ec1)
+
diff --git a/build_files/build_environment/patches/cmakelists_gmpxx.txt b/build_files/build_environment/patches/cmakelists_gmpxx.txt
new file mode 100644
index 00000000000..5aa6c404035
--- /dev/null
+++ b/build_files/build_environment/patches/cmakelists_gmpxx.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.1)
+project(libgmpxx)
+
+include_directories(. cxx ${GMP_INCLUDE_DIR})
+add_definitions(-D__GMP_WITHIN_GMPXX)
+add_library(libgmpxx SHARED
+  cxx/dummy.cc
+  cxx/isfuns.cc
+  cxx/ismpf.cc
+  cxx/ismpq.cc
+  cxx/ismpz.cc
+  cxx/ismpznw.cc
+  cxx/limits.cc
+  cxx/osdoprnti.cc
+  cxx/osfuns.cc
+  cxx/osmpf.cc
+  cxx/osmpq.cc
+  cxx/osmpz.cc
+)
+
+target_link_libraries(libgmpxx ${GMP_LIBRARY})
+install(TARGETS libgmpxx DESTINATION lib)
diff --git a/build_files/build_environment/patches/config_gmpxx.h b/build_files/build_environment/patches/config_gmpxx.h
new file mode 100644
index 00000000000..842d6d5d240
--- /dev/null
+++ b/build_files/build_environment/patches/config_gmpxx.h
@@ -0,0 +1,668 @@
+/* config.h.  Generated from config.in by configure.  */
+/* config.in.  Generated from configure.ac by autoheader.  */
+
+/*
+
+Copyright 1996-2020 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of either:
+
+  * the GNU Lesser General Public License as published by the Free
+    Software Foundation; either version 3 of the License, or (at your
+    option) any later version.
+
+or
+
+  * the GNU General Public License as published by the Free Software
+    Foundation; either version 2 of the License, or (at your option) any
+    later version.
+
+or both in parallel, as here.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library.  If not,
+see https://www.gnu.org/licenses/.
+*/
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* The gmp-mparam.h file (a string) the tune program should suggest updating.
+   */
+#define GMP_MPARAM_H_SUGGEST "./mpn/x86_64/coreisbr/gmp-mparam.h"
+
+/* Define to 1 if you have the `alarm' function. */
+#define HAVE_ALARM 1
+
+/* Define to 1 if alloca() works (via gmp-impl.h). */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+/* #undef HAVE_ALLOCA_H */
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((const)) */
+//#define HAVE_ATTRIBUTE_CONST 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((malloc)) */
+//#define HAVE_ATTRIBUTE_MALLOC 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))
+   */
+//#define HAVE_ATTRIBUTE_MODE 1
+
+/* Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn)) */
+//#define HAVE_ATTRIBUTE_NORETURN 1
+
+/* Define to 1 if you have the `attr_get' function. */
+/* #undef HAVE_ATTR_GET */
+
+/* Define to 1 if tests/libtests has calling conventions checking for the CPU
+   */
+/* #undef HAVE_CALLING_CONVENTIONS */
+
+/* Define to 1 if you have the `clock' function. */
+#define HAVE_CLOCK 1
+
+/* Define to 1 if you have the `clock_gettime' function */
+/* #undef HAVE_CLOCK_GETTIME */
+
+/* Define to 1 if you have the `cputime' function. */
+/* #undef HAVE_CPUTIME */
+
+/* Define to 1 if you have the declaration of `fgetc', and to 0 if you don't.
+   */
+#define HAVE_DECL_FGETC 1
+
+/* Define to 1 if you have the declaration of `fscanf', and to 0 if you don't.
+   */
+#define HAVE_DECL_FSCANF 1
+
+/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
+   */
+#define HAVE_DECL

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list