Compare commits
12 Commits
tmp-gltext
...
temp-ui-bu
Author | SHA1 | Date | |
---|---|---|---|
0d2d4a6d4a | |||
9b416c66fb | |||
89dbb12c29 | |||
4de632b48b | |||
2400160bc4 | |||
a903f7c243 | |||
2a515fe612 | |||
190ef51fd5 | |||
51afd98b1d | |||
6609fa2996 | |||
b4f92bf7bc | |||
dc9df6540c |
@@ -238,7 +238,6 @@ ForEachMacros:
|
||||
- LISTBASE_FOREACH_BACKWARD
|
||||
- LISTBASE_FOREACH_MUTABLE
|
||||
- LISTBASE_FOREACH_BACKWARD_MUTABLE
|
||||
- LISTBASE_FOREACH_INDEX
|
||||
- MAN_ITER_AXES_BEGIN
|
||||
- NODE_INSTANCE_HASH_ITER
|
||||
- NODE_SOCKET_TYPES_BEGIN
|
||||
@@ -253,8 +252,8 @@ ForEachMacros:
|
||||
- RNA_STRUCT_BEGIN_SKIP_RNA_TYPE
|
||||
- SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN
|
||||
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN
|
||||
- SEQ_ALL_BEGIN
|
||||
- SEQ_CURRENT_BEGIN
|
||||
- SEQP_BEGIN
|
||||
- SEQ_BEGIN
|
||||
- SURFACE_QUAD_ITER_BEGIN
|
||||
- foreach
|
||||
- ED_screen_areas_iter
|
||||
|
@@ -12,8 +12,11 @@ Checks: >
|
||||
|
||||
-readability-misleading-indentation,
|
||||
|
||||
-readability-else-after-return,
|
||||
-readability-inconsistent-declaration-parameter-name,
|
||||
-readability-redundant-preprocessor,
|
||||
-readability-function-size,
|
||||
-readability-function-size,
|
||||
-readability-redundant-member-init,
|
||||
-readability-const-return-type,
|
||||
-readability-static-accessed-through-instance,
|
||||
@@ -31,6 +34,11 @@ Checks: >
|
||||
-bugprone-sizeof-expression,
|
||||
-bugprone-integer-division,
|
||||
-bugprone-incorrect-roundings,
|
||||
-bugprone-suspicious-string-compare,
|
||||
-bugprone-not-null-terminated-result,
|
||||
-bugprone-suspicious-missing-comma,
|
||||
-bugprone-parent-virtual-call,
|
||||
-bugprone-infinite-loop,
|
||||
-bugprone-copy-constructor-init,
|
||||
|
||||
WarningsAsErrors: '*'
|
||||
|
@@ -102,11 +102,6 @@ if(POLICY CMP0068)
|
||||
cmake_policy(SET CMP0068 NEW)
|
||||
endif()
|
||||
|
||||
# find_package() uses <PackageName>_ROOT variables.
|
||||
if(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Load some macros.
|
||||
include(build_files/cmake/macros.cmake)
|
||||
@@ -188,7 +183,6 @@ 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)
|
||||
@@ -436,10 +430,6 @@ if(WIN32)
|
||||
option(WITH_TBB_MALLOC_PROXY "Enable the TBB malloc replacement" ON)
|
||||
endif()
|
||||
|
||||
# This should be turned off when Blender enter beta/rc/release
|
||||
option(WITH_EXPERIMENTAL_FEATURES "Enable experimental features (still need to enable them in the user preferences)" ON)
|
||||
mark_as_advanced(WITH_EXPERIMENTAL_FEATURES)
|
||||
|
||||
# Unit testsing
|
||||
option(WITH_GTESTS "Enable GTest unit testing" OFF)
|
||||
option(WITH_OPENGL_RENDER_TESTS "Enable OpenGL render related unit testing (Experimental)" OFF)
|
||||
@@ -1572,12 +1562,6 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
|
||||
# Make MSVC properly report the value of the __cplusplus preprocessor macro
|
||||
# Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless
|
||||
# of the C++ standard chosen above
|
||||
if(MSVC_VERSION GREATER 1913)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
|
||||
endif()
|
||||
elseif(
|
||||
CMAKE_COMPILER_IS_GNUCC OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "Clang" OR
|
||||
@@ -1740,7 +1724,6 @@ 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)
|
||||
|
@@ -57,6 +57,7 @@ include(cmake/zlib.cmake)
|
||||
include(cmake/openal.cmake)
|
||||
include(cmake/png.cmake)
|
||||
include(cmake/jpeg.cmake)
|
||||
include(cmake/boost.cmake)
|
||||
include(cmake/blosc.cmake)
|
||||
include(cmake/pthreads.cmake)
|
||||
include(cmake/openexr.cmake)
|
||||
@@ -88,8 +89,6 @@ include(cmake/python_site_packages.cmake)
|
||||
include(cmake/package_python.cmake)
|
||||
include(cmake/numpy.cmake)
|
||||
include(cmake/usd.cmake)
|
||||
# Boost needs to be included after python.cmake due to the PYTHON_BINARY variable being needed.
|
||||
include(cmake/boost.cmake)
|
||||
if(UNIX)
|
||||
# Rely on PugiXML compiled with OpenImageIO
|
||||
else()
|
||||
|
@@ -19,6 +19,17 @@
|
||||
set(BOOST_ADDRESS_MODEL 64)
|
||||
|
||||
if(WIN32)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
set(PYTHON_ARCH x64)
|
||||
set(PYTHON_ARCH2 win-AMD64)
|
||||
set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/amd64/)
|
||||
else()
|
||||
set(PYTHON_ARCH x86)
|
||||
set(PYTHON_ARCH2 win32)
|
||||
set(PYTHON_OUTPUTDIR ${BUILD_DIR}/python/src/external_python/pcbuild/win32/)
|
||||
set(BOOST_ADDRESS_MODEL 32)
|
||||
endif()
|
||||
|
||||
set(BOOST_TOOLSET toolset=msvc-14.1)
|
||||
set(BOOST_COMPILER_STRING -vc141)
|
||||
|
||||
@@ -49,21 +60,6 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_BOOST_PYTHON)
|
||||
set(JAM_FILE ${BUILD_DIR}/boost.user-config.jam)
|
||||
configure_file(${PATCH_DIR}/boost.user.jam.in ${JAM_FILE})
|
||||
set(BOOST_PYTHON_OPTIONS
|
||||
--with-python
|
||||
--user-config=${JAM_FILE}
|
||||
)
|
||||
if(WIN32 AND BUILD_MODE STREQUAL Debug)
|
||||
set(BOOST_PYTHON_OPTIONS
|
||||
${BOOST_PYTHON_OPTIONS}
|
||||
define=BOOST_DEBUG_PYTHON
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(BOOST_OPTIONS
|
||||
--with-filesystem
|
||||
--with-locale
|
||||
@@ -80,7 +76,6 @@ set(BOOST_OPTIONS
|
||||
-sNO_LZMA=1
|
||||
-sNO_ZSTD=1
|
||||
${BOOST_TOOLSET}
|
||||
${BOOST_PYTHON_OPTIONS}
|
||||
)
|
||||
|
||||
string(TOLOWER ${BUILD_MODE} BOOST_BUILD_TYPE)
|
||||
@@ -97,11 +92,3 @@ ExternalProject_Add(external_boost
|
||||
BUILD_IN_SOURCE 1
|
||||
INSTALL_COMMAND "${BOOST_HARVEST_CMD}"
|
||||
)
|
||||
|
||||
if(WITH_BOOST_PYTHON)
|
||||
add_dependencies(
|
||||
external_boost
|
||||
external_python
|
||||
external_numpy
|
||||
)
|
||||
endif()
|
||||
|
@@ -95,6 +95,8 @@ ExternalProject_Add(external_ffmpeg
|
||||
--disable-version3
|
||||
--disable-debug
|
||||
--enable-optimizations
|
||||
--disable-sse
|
||||
--disable-ssse3
|
||||
--enable-ffplay
|
||||
--disable-openssl
|
||||
--disable-securetransport
|
||||
|
@@ -25,13 +25,6 @@ else()
|
||||
set(GMP_OPTIONS --enable-static --disable-shared )
|
||||
endif()
|
||||
|
||||
if(APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64"))
|
||||
set(GMP_OPTIONS
|
||||
${GMP_OPTIONS}
|
||||
--disable-assembly
|
||||
)
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(external_gmp
|
||||
URL ${GMP_URI}
|
||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||
|
@@ -20,14 +20,6 @@ if(BUILD_MODE STREQUAL Debug)
|
||||
set(BLOSC_POST _d)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(OPENVDB_SHARED ON)
|
||||
set(OPENVDB_STATIC OFF)
|
||||
else()
|
||||
set(OPENVDB_SHARED OFF)
|
||||
set(OPENVDB_STATIC ON)
|
||||
endif()
|
||||
|
||||
set(OPENVDB_EXTRA_ARGS
|
||||
-DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
|
||||
-DBoost_USE_MULTITHREADED=ON
|
||||
@@ -50,10 +42,8 @@ set(OPENVDB_EXTRA_ARGS
|
||||
-DOPENEXR_LIBRARYDIR=${LIBDIR}/openexr/lib
|
||||
# All libs live in openexr, even the ilmbase ones
|
||||
-DILMBASE_LIBRARYDIR=${LIBDIR}/openexr/lib
|
||||
-DOPENVDB_CORE_SHARED=${OPENVDB_SHARED}
|
||||
-DOPENVDB_CORE_STATIC=${OPENVDB_STATIC}
|
||||
-DOPENVDB_CORE_SHARED=Off
|
||||
-DOPENVDB_BUILD_BINARIES=Off
|
||||
-DCMAKE_DEBUG_POSTFIX=_d
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
@@ -97,15 +87,13 @@ if(WIN32)
|
||||
if(BUILD_MODE STREQUAL Release)
|
||||
ExternalProject_Add_Step(openvdb after_install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openvdb/include ${HARVEST_TARGET}/openvdb/include
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb.dll ${HARVEST_TARGET}/openvdb/bin/openvdb.dll
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/libopenvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib
|
||||
DEPENDEES install
|
||||
)
|
||||
endif()
|
||||
if(BUILD_MODE STREQUAL Debug)
|
||||
ExternalProject_Add_Step(openvdb after_install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb_d.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb_d.dll ${HARVEST_TARGET}/openvdb/bin/openvdb_d.dll
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/libopenvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib
|
||||
DEPENDEES install
|
||||
)
|
||||
endif()
|
||||
|
@@ -20,7 +20,6 @@ if(WIN32)
|
||||
option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/fftw3 by installing mingw64" ON)
|
||||
endif()
|
||||
option(WITH_WEBP "Enable building of oiio with webp support" OFF)
|
||||
option(WITH_BOOST_PYTHON "Enable building of boost with python support" OFF)
|
||||
set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with")
|
||||
|
||||
if(NOT BUILD_MODE)
|
||||
@@ -195,6 +194,18 @@ set(DEFAULT_CMAKE_FLAGS
|
||||
${PLATFORM_CMAKE_FLAGS}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
# We need both flavors to build the thumbnail dlls
|
||||
if(MSVC12)
|
||||
set(GENERATOR_32 "Visual Studio 12 2013")
|
||||
set(GENERATOR_64 "Visual Studio 12 2013 Win64")
|
||||
elseif(MSVC14)
|
||||
set(GENERATOR_32 "Visual Studio 14 2015")
|
||||
set(GENERATOR_64 "Visual Studio 14 2015 Win64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(WIN32)
|
||||
if(BUILD_MODE STREQUAL Debug)
|
||||
set(ZLIB_LIBRARY zlibstaticd${LIBEXT})
|
||||
|
@@ -42,7 +42,7 @@ if(WIN32)
|
||||
URL_HASH MD5=${PYTHON_HASH}
|
||||
PREFIX ${BUILD_DIR}/python
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && call build.bat -e -p x64 -c ${BUILD_MODE}
|
||||
BUILD_COMMAND cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && call build.bat -e -p ${PYTHON_ARCH} -c ${BUILD_MODE}
|
||||
INSTALL_COMMAND ${PYTHON_BINARY_INTERNAL} ${PYTHON_SRC}/PC/layout/main.py -b ${PYTHON_SRC}/PCbuild/amd64 -s ${PYTHON_SRC} -t ${PYTHON_SRC}/tmp/ --include-underpth --include-stable --include-pip --include-dev --include-launchers --include-venv --include-symbols ${PYTHON_EXTRA_INSTLAL_FLAGS} --copy ${LIBDIR}/python
|
||||
)
|
||||
|
||||
|
@@ -312,7 +312,6 @@ set(NASM_HASH f4fd1329b1713e1ccd34b2fc121c4bcd278c9f91cc4cb205ae8fcd2e4728dd14)
|
||||
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(ISPC_VERSION v1.13.0)
|
||||
set(ISPC_URI https://github.com/ispc/ispc/archive/${ISPC_VERSION}.tar.gz)
|
||||
set(ISPC_HASH 4bf5e8d0020c4b9980faa702c1a6f25f)
|
||||
|
@@ -374,96 +374,71 @@ NO_BUILD=false
|
||||
NO_CONFIRM=false
|
||||
USE_CXX11=true
|
||||
|
||||
# Note about versions: Min is inclusive, Max is exclusive (i.e. XXX_VERSION_MIN <= ACTUAL_VERSION < XXX_VERSION_MAX)
|
||||
# XXX_VERSION is officially supported/used version in official builds.
|
||||
# XXX_VERSION_SHORT is used for various things, like preferred version (when distribution provides several of them),
|
||||
# and to name shortcuts to built libraries' installation directories...
|
||||
|
||||
CLANG_FORMAT_VERSION_MIN="6.0"
|
||||
CLANG_FORMAT_VERSION_MAX="10.0"
|
||||
|
||||
PYTHON_VERSION="3.7.7"
|
||||
PYTHON_VERSION_SHORT="3.7"
|
||||
PYTHON_VERSION_MIN="3.7"
|
||||
PYTHON_VERSION_MAX="3.9"
|
||||
PYTHON_VERSION_INSTALLED=$PYTHON_VERSION_MIN
|
||||
PYTHON_FORCE_BUILD=false
|
||||
PYTHON_FORCE_REBUILD=false
|
||||
PYTHON_SKIP=false
|
||||
|
||||
NUMPY_VERSION="1.17.5"
|
||||
NUMPY_VERSION_SHORT="1.17"
|
||||
NUMPY_VERSION="1.17.0"
|
||||
NUMPY_VERSION_MIN="1.8"
|
||||
NUMPY_VERSION_MAX="2.0"
|
||||
NUMPY_FORCE_BUILD=false
|
||||
NUMPY_FORCE_REBUILD=false
|
||||
NUMPY_SKIP=false
|
||||
|
||||
BOOST_VERSION="1.70.0"
|
||||
BOOST_VERSION_SHORT="1.70"
|
||||
BOOST_VERSION_MIN="1.49"
|
||||
BOOST_VERSION_MAX="2.0"
|
||||
BOOST_FORCE_BUILD=false
|
||||
BOOST_FORCE_REBUILD=false
|
||||
BOOST_SKIP=false
|
||||
|
||||
TBB_VERSION="2019"
|
||||
TBB_VERSION_SHORT="2019"
|
||||
TBB_VERSION_UPDATE="_U9" # Used for source packages...
|
||||
TBB_VERSION_MIN="2018"
|
||||
TBB_VERSION_MAX="2021"
|
||||
TBB_FORCE_BUILD=false
|
||||
TBB_FORCE_REBUILD=false
|
||||
TBB_SKIP=false
|
||||
|
||||
OCIO_VERSION="1.1.1"
|
||||
OCIO_VERSION_SHORT="1.1"
|
||||
OCIO_VERSION="1.1.0"
|
||||
OCIO_VERSION_MIN="1.0"
|
||||
OCIO_VERSION_MAX="1.2"
|
||||
OCIO_FORCE_BUILD=false
|
||||
OCIO_FORCE_REBUILD=false
|
||||
OCIO_SKIP=false
|
||||
|
||||
OPENEXR_VERSION="2.4.0"
|
||||
OPENEXR_VERSION_SHORT="2.4"
|
||||
OPENEXR_VERSION_MIN="2.3"
|
||||
OPENEXR_VERSION_MAX="3.0"
|
||||
OPENEXR_FORCE_BUILD=false
|
||||
OPENEXR_FORCE_REBUILD=false
|
||||
OPENEXR_SKIP=false
|
||||
_with_built_openexr=false
|
||||
|
||||
OIIO_VERSION="2.1.15.0"
|
||||
OIIO_VERSION_SHORT="2.1"
|
||||
OIIO_VERSION_MIN="1.8"
|
||||
OIIO_VERSION_MAX="3.0"
|
||||
OIIO_VERSION="1.8.13"
|
||||
OIIO_VERSION_MIN="1.8.13"
|
||||
OIIO_VERSION_MAX="99.99.0" # UNKNOWN currently # Not supported by current OSL...
|
||||
OIIO_FORCE_BUILD=false
|
||||
OIIO_FORCE_REBUILD=false
|
||||
OIIO_SKIP=false
|
||||
|
||||
LLVM_VERSION="9.0.1"
|
||||
LLVM_VERSION_SHORT="9.0"
|
||||
LLVM_VERSION_MIN="6.0"
|
||||
LLVM_VERSION_MAX="11.0"
|
||||
LLVM_VERSION_FOUND=""
|
||||
LLVM_FORCE_BUILD=false
|
||||
LLVM_FORCE_REBUILD=false
|
||||
LLVM_SKIP=false
|
||||
|
||||
# OSL needs to be compiled for now!
|
||||
OSL_VERSION="1.10.10"
|
||||
OSL_VERSION_SHORT="1.10"
|
||||
OSL_VERSION_MIN="1.10"
|
||||
OSL_VERSION_MAX="2.0"
|
||||
OSL_VERSION="1.10.9"
|
||||
OSL_VERSION_MIN=$OSL_VERSION
|
||||
OSL_FORCE_BUILD=false
|
||||
OSL_FORCE_REBUILD=false
|
||||
OSL_SKIP=false
|
||||
|
||||
# OpenSubdiv needs to be compiled for now
|
||||
OSD_VERSION="3.4.3"
|
||||
OSD_VERSION_SHORT="3.4"
|
||||
OSD_VERSION_MIN="3.4"
|
||||
OSD_VERSION_MAX="4.0"
|
||||
OSD_VERSION_MIN=$OSD_VERSION
|
||||
OSD_FORCE_BUILD=false
|
||||
OSD_FORCE_REBUILD=false
|
||||
OSD_SKIP=false
|
||||
@@ -472,69 +447,46 @@ OSD_SKIP=false
|
||||
OPENVDB_BLOSC_VERSION="1.5.0"
|
||||
|
||||
OPENVDB_VERSION="7.0.0"
|
||||
OPENVDB_VERSION_SHORT="7.0"
|
||||
OPENVDB_VERSION_MIN="7.0"
|
||||
OPENVDB_VERSION_MAX="8.0"
|
||||
OPENVDB_VERSION_MIN=$OPENVDB_VERSION
|
||||
OPENVDB_FORCE_BUILD=false
|
||||
OPENVDB_FORCE_REBUILD=false
|
||||
OPENVDB_SKIP=false
|
||||
|
||||
# Alembic needs to be compiled for now
|
||||
ALEMBIC_VERSION="1.7.12"
|
||||
ALEMBIC_VERSION_SHORT="1.7"
|
||||
ALEMBIC_VERSION_MIN="1.7"
|
||||
ALEMBIC_VERSION_MAX="2.0"
|
||||
ALEMBIC_VERSION_MIN=$ALEMBIC_VERSION
|
||||
ALEMBIC_FORCE_BUILD=false
|
||||
ALEMBIC_FORCE_REBUILD=false
|
||||
ALEMBIC_SKIP=false
|
||||
|
||||
USD_VERSION="20.05"
|
||||
USD_VERSION_SHORT="20.05"
|
||||
USD_VERSION_MIN="20.05"
|
||||
USD_VERSION_MAX="20.06"
|
||||
USD_FORCE_BUILD=false
|
||||
USD_FORCE_REBUILD=false
|
||||
USD_SKIP=false
|
||||
|
||||
OPENCOLLADA_VERSION="1.6.68"
|
||||
OPENCOLLADA_VERSION_SHORT="1.6"
|
||||
OPENCOLLADA_VERSION_MIN="1.6.68"
|
||||
OPENCOLLADA_VERSION_MAX="1.7"
|
||||
OPENCOLLADA_FORCE_BUILD=false
|
||||
OPENCOLLADA_FORCE_REBUILD=false
|
||||
OPENCOLLADA_SKIP=false
|
||||
|
||||
EMBREE_VERSION="3.10.0"
|
||||
EMBREE_VERSION_SHORT="3.10"
|
||||
EMBREE_VERSION_MIN="3.10"
|
||||
EMBREE_VERSION_MAX="4.0"
|
||||
EMBREE_FORCE_BUILD=false
|
||||
EMBREE_FORCE_REBUILD=false
|
||||
EMBREE_SKIP=false
|
||||
|
||||
OIDN_VERSION="1.2.1"
|
||||
OIDN_VERSION_SHORT="1.2"
|
||||
OIDN_VERSION_MIN="1.2.0"
|
||||
OIDN_VERSION_MAX="1.3"
|
||||
OIDN_VERSION="1.0.0"
|
||||
OIDN_FORCE_BUILD=false
|
||||
OIDN_FORCE_REBUILD=false
|
||||
OIDN_SKIP=false
|
||||
|
||||
ISPC_VERSION="1.14.0"
|
||||
|
||||
FFMPEG_VERSION="4.2.3"
|
||||
FFMPEG_VERSION_SHORT="4.2"
|
||||
FFMPEG_VERSION_MIN="3.0"
|
||||
FFMPEG_VERSION_MAX="5.0"
|
||||
FFMPEG_VERSION_MIN="2.8.4"
|
||||
FFMPEG_FORCE_BUILD=false
|
||||
FFMPEG_FORCE_REBUILD=false
|
||||
FFMPEG_SKIP=false
|
||||
_ffmpeg_list_sep=";"
|
||||
|
||||
XR_OPENXR_VERSION="1.0.8"
|
||||
XR_OPENXR_VERSION_SHORT="1.0"
|
||||
XR_OPENXR_VERSION_MIN="1.0.8"
|
||||
XR_OPENXR_VERSION_MAX="2.0"
|
||||
XR_OPENXR_FORCE_BUILD=false
|
||||
XR_OPENXR_FORCE_REBUILD=false
|
||||
XR_OPENXR_SKIP=false
|
||||
@@ -682,43 +634,36 @@ while true; do
|
||||
--ver-ocio)
|
||||
OCIO_VERSION="$2"
|
||||
OCIO_VERSION_MIN=$OCIO_VERSION
|
||||
OCIO_VERSION_SHORT=$OCIO_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--ver-oiio)
|
||||
OIIO_VERSION="$2"
|
||||
OIIO_VERSION_MIN=$OIIO_VERSION
|
||||
OIIO_VERSION_SHORT=$OIIO_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--ver-llvm)
|
||||
LLVM_VERSION="$2"
|
||||
LLVM_VERSION_MIN=$LLVM_VERSION
|
||||
LLVM_VERSION_SHORT=$LLVM_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--ver-osl)
|
||||
OSL_VERSION="$2"
|
||||
OSL_VERSION_MIN=$OSL_VERSION
|
||||
OSL_VERSION_SHORT=$OSL_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--ver-osd)
|
||||
OSD_VERSION="$2"
|
||||
OSD_VERSION_MIN=$OSD_VERSION
|
||||
OSD_VERSION_SHORT=$OSD_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--ver-openvdb)
|
||||
OPENVDB_VERSION="$2"
|
||||
OPENVDB_VERSION_MIN=$OPENVDB_VERSION
|
||||
OPENVDB_VERSION_SHORT=$OPENVDB_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--ver-xr-openxr)
|
||||
XR_OPENXR_VERSION="$2"
|
||||
XR_OPENXR_VERSION_MIN=$XR_OPENXR_VERSION
|
||||
XR_OPENXR_VERSION_SHORT=$XR_OPENXR_VERSION
|
||||
shift; shift; continue
|
||||
;;
|
||||
--build-all)
|
||||
@@ -1060,8 +1005,6 @@ OIDN_SOURCE=( "https://github.com/OpenImageDenoise/oidn/releases/download/v${OID
|
||||
#~ OIDN_REPO_UID="dabfd9c80101edae9d25a710160d12d6d963c591"
|
||||
#~ OIDN_REPO_BRANCH="master"
|
||||
|
||||
ISPC_BINARY=( "https://github.com/ispc/ispc/releases/download/v${ISPC_VERSION}/ispc-v${ISPC_VERSION}-linux.tar.gz" )
|
||||
|
||||
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
|
||||
|
||||
XR_OPENXR_USE_REPO=false
|
||||
@@ -1087,7 +1030,7 @@ Those libraries should be available as packages in all recent distributions (opt
|
||||
* libjpeg, libpng, libtiff, [openjpeg2], [libopenal].
|
||||
* libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed).
|
||||
* libsqlite3, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp.
|
||||
* libsdl2, libglew, [libgmp], [libglewmx], fontconfig.\""
|
||||
* libsdl2, libglew, [libgmp], [libglewmx].\""
|
||||
|
||||
DEPS_SPECIFIC_INFO="\"BUILDABLE DEPENDENCIES:
|
||||
|
||||
@@ -1327,7 +1270,7 @@ _init_python() {
|
||||
_src=$SRC/Python-$PYTHON_VERSION
|
||||
_git=false
|
||||
_inst=$INST/python-$PYTHON_VERSION
|
||||
_inst_shortcut=$INST/python-$PYTHON_VERSION_SHORT
|
||||
_inst_shortcut=$INST/python-$PYTHON_VERSION_MIN
|
||||
}
|
||||
|
||||
_update_deps_python() {
|
||||
@@ -1402,7 +1345,7 @@ compile_Python() {
|
||||
INFO "If you want to force rebuild of this lib, use the --force-python option."
|
||||
fi
|
||||
|
||||
run_ldconfig "python-$PYTHON_VERSION_SHORT"
|
||||
run_ldconfig "python-$PYTHON_VERSION_MIN"
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -1412,8 +1355,8 @@ _init_numpy() {
|
||||
_src=$SRC/numpy-$NUMPY_VERSION
|
||||
_git=false
|
||||
_inst=$INST/numpy-$NUMPY_VERSION
|
||||
_python=$INST/python-$PYTHON_VERSION_SHORT
|
||||
_site=lib/python$PYTHON_VERSION_SHORT/site-packages
|
||||
_python=$INST/python-$PYTHON_VERSION
|
||||
_site=lib/python$PYTHON_VERSION_MIN/site-packages
|
||||
_inst_shortcut=$_python/$_site/numpy
|
||||
}
|
||||
|
||||
@@ -1492,7 +1435,7 @@ compile_Numpy() {
|
||||
_init_boost() {
|
||||
_src=$SRC/boost-$BOOST_VERSION
|
||||
_git=false
|
||||
_inst=$INST/boost-$BOOST_VERSION_SHORT
|
||||
_inst=$INST/boost-$BOOST_VERSION
|
||||
_inst_shortcut=$INST/boost
|
||||
}
|
||||
|
||||
@@ -1585,7 +1528,7 @@ compile_Boost() {
|
||||
_init_tbb() {
|
||||
_src=$SRC/TBB-$TBB_VERSION
|
||||
_git=false
|
||||
_inst=$INST/tbb-$TBB_VERSION_SHORT
|
||||
_inst=$INST/tbb-$TBB_VERSION
|
||||
_inst_shortcut=$INST/tbb
|
||||
}
|
||||
|
||||
@@ -1713,7 +1656,7 @@ _init_ocio() {
|
||||
else
|
||||
_git=false
|
||||
fi
|
||||
_inst=$INST/ocio-$OCIO_VERSION_SHORT
|
||||
_inst=$INST/ocio-$OCIO_VERSION
|
||||
_inst_shortcut=$INST/ocio
|
||||
}
|
||||
|
||||
@@ -1838,7 +1781,7 @@ compile_OCIO() {
|
||||
_init_openexr() {
|
||||
_src=$SRC/OpenEXR-$OPENEXR_VERSION
|
||||
_git=false
|
||||
_inst=$INST/openexr-$OPENEXR_VERSION_SHORT
|
||||
_inst=$INST/openexr-$OPENEXR_VERSION
|
||||
_inst_shortcut=$INST/openexr
|
||||
}
|
||||
|
||||
@@ -1968,7 +1911,7 @@ compile_OPENEXR() {
|
||||
_init_oiio() {
|
||||
_src=$SRC/OpenImageIO-$OIIO_VERSION
|
||||
_git=true
|
||||
_inst=$INST/oiio-$OIIO_VERSION_SHORT
|
||||
_inst=$INST/oiio-$OIIO_VERSION
|
||||
_inst_shortcut=$INST/oiio
|
||||
}
|
||||
|
||||
@@ -2123,7 +2066,7 @@ _init_llvm() {
|
||||
_src=$SRC/LLVM-$LLVM_VERSION
|
||||
_src_clang=$SRC/CLANG-$LLVM_VERSION
|
||||
_git=false
|
||||
_inst=$INST/llvm-$LLVM_VERSION_SHORT
|
||||
_inst=$INST/llvm-$LLVM_VERSION
|
||||
_inst_shortcut=$INST/llvm
|
||||
}
|
||||
|
||||
@@ -2235,7 +2178,7 @@ compile_LLVM() {
|
||||
_init_osl() {
|
||||
_src=$SRC/OpenShadingLanguage-$OSL_VERSION
|
||||
_git=true
|
||||
_inst=$INST/osl-$OSL_VERSION_SHORT
|
||||
_inst=$INST/osl-$OSL_VERSION
|
||||
_inst_shortcut=$INST/osl
|
||||
}
|
||||
|
||||
@@ -2380,7 +2323,7 @@ compile_OSL() {
|
||||
_init_osd() {
|
||||
_src=$SRC/OpenSubdiv-$OSD_VERSION
|
||||
_git=true
|
||||
_inst=$INST/osd-$OSD_VERSION_SHORT
|
||||
_inst=$INST/osd-$OSD_VERSION
|
||||
_inst_shortcut=$INST/osd
|
||||
}
|
||||
|
||||
@@ -2594,7 +2537,7 @@ compile_BLOSC() {
|
||||
_init_openvdb() {
|
||||
_src=$SRC/openvdb-$OPENVDB_VERSION
|
||||
_git=false
|
||||
_inst=$INST/openvdb-$OPENVDB_VERSION_SHORT
|
||||
_inst=$INST/openvdb-$OPENVDB_VERSION
|
||||
_inst_shortcut=$INST/openvdb
|
||||
}
|
||||
|
||||
@@ -2712,7 +2655,7 @@ compile_OPENVDB() {
|
||||
_init_alembic() {
|
||||
_src=$SRC/alembic-$ALEMBIC_VERSION
|
||||
_git=false
|
||||
_inst=$INST/alembic-$ALEMBIC_VERSION_SHORT
|
||||
_inst=$INST/alembic-$ALEMBIC_VERSION
|
||||
_inst_shortcut=$INST/alembic
|
||||
}
|
||||
|
||||
@@ -2817,7 +2760,7 @@ compile_ALEMBIC() {
|
||||
_init_usd() {
|
||||
_src=$SRC/USD-$USD_VERSION
|
||||
_git=false
|
||||
_inst=$INST/usd-$USD_VERSION_SHORT
|
||||
_inst=$INST/usd-$USD_VERSION
|
||||
_inst_shortcut=$INST/usd
|
||||
}
|
||||
|
||||
@@ -2916,7 +2859,7 @@ compile_USD() {
|
||||
_init_opencollada() {
|
||||
_src=$SRC/OpenCOLLADA-$OPENCOLLADA_VERSION
|
||||
_git=true
|
||||
_inst=$INST/opencollada-$OPENCOLLADA_VERSION_SHORT
|
||||
_inst=$INST/opencollada-$OPENCOLLADA_VERSION
|
||||
_inst_shortcut=$INST/opencollada
|
||||
}
|
||||
|
||||
@@ -3022,7 +2965,7 @@ compile_OpenCOLLADA() {
|
||||
_init_embree() {
|
||||
_src=$SRC/embree-$EMBREE_VERSION
|
||||
_git=true
|
||||
_inst=$INST/embree-$EMBREE_VERSION_SHORT
|
||||
_inst=$INST/embree-$EMBREE_VERSION
|
||||
_inst_shortcut=$INST/embree
|
||||
}
|
||||
|
||||
@@ -3132,83 +3075,10 @@ compile_Embree() {
|
||||
# ----------------------------------------------------------------------------
|
||||
# Build OpenImageDenoise
|
||||
|
||||
_init_ispc() {
|
||||
_src=$SRC/ispc-v$ISPC_VERSION
|
||||
_inst=$INST/ispc-v$ISPC_VERSION
|
||||
_inst_shortcut=$INST/ispc
|
||||
}
|
||||
|
||||
_update_deps_ispc() {
|
||||
OIDN_FORCE_REBUILD=true
|
||||
if [ "$_is_building" = true ]; then
|
||||
OIDN_FORCE_BUILD=true
|
||||
fi
|
||||
}
|
||||
|
||||
clean_ispc() {
|
||||
_init_ispc
|
||||
if [ -d $_inst ]; then
|
||||
_update_deps_ispc
|
||||
fi
|
||||
_clean
|
||||
}
|
||||
|
||||
install_ISPC() {
|
||||
# To be changed each time we make edits that would modify the compiled results!
|
||||
ispc_magic=0
|
||||
_init_ispc
|
||||
|
||||
# Clean install if needed!
|
||||
magic_compile_check ispc-$ISPC_VERSION $ispc_magic
|
||||
if [ $? -eq 1 ]; then
|
||||
clean_ispc
|
||||
fi
|
||||
|
||||
if [ ! -d $_inst ]; then
|
||||
INFO "Installing Implicit SPMD Program Compiler v$ISPC_VERSION"
|
||||
_is_building=true
|
||||
|
||||
# Rebuild dependencies as well!
|
||||
_update_deps_ispc
|
||||
|
||||
prepare_opt
|
||||
|
||||
if [ ! -d $_src ]; then
|
||||
mkdir -p $SRC
|
||||
download ISPC_BINARY[@] "$_src.tar.gz"
|
||||
INFO "Unpacking ISPC-v$ISPC_VERSION"
|
||||
tar -C $SRC --transform "s,(.*/?)ispc-v$ISPC_VERSION-linux[^/]*(.*),\1ispc-v$ISPC_VERSION\2,x" \
|
||||
-xf $_src.tar.gz
|
||||
fi
|
||||
|
||||
mkdir -p $_inst
|
||||
cp -r $_src/bin $_inst/bin
|
||||
|
||||
if [ -d $_inst ]; then
|
||||
_create_inst_shortcut
|
||||
else
|
||||
ERROR "ISPC-v$ISPC_VERSION failed to install, exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
magic_compile_set ispc-$ISPC_VERSION $ispc_magic
|
||||
|
||||
cd $CWD
|
||||
INFO "Done compiling ISPC-v$ISPC_VERSION!"
|
||||
_is_building=false
|
||||
else
|
||||
INFO "Own ISPC-v$ISPC_VERSION is up to date, nothing to do!"
|
||||
fi
|
||||
|
||||
_ispc_path_bin=$_inst/bin
|
||||
run_ldconfig "ispc"
|
||||
}
|
||||
|
||||
|
||||
_init_oidn() {
|
||||
_src=$SRC/oidn-$OIDN_VERSION
|
||||
_git=true
|
||||
_inst=$INST/oidn-$OIDN_VERSION_SHORT
|
||||
_inst=$INST/oidn-$OIDN_VERSION
|
||||
_inst_shortcut=$INST/oidn
|
||||
}
|
||||
|
||||
@@ -3230,9 +3100,6 @@ compile_OIDN() {
|
||||
return
|
||||
fi
|
||||
|
||||
# Latest OIDN requires ISPC compiler tool...
|
||||
install_ISPC
|
||||
|
||||
# To be changed each time we make edits that would modify the compiled results!
|
||||
oidn_magic=9
|
||||
_init_oidn
|
||||
@@ -3285,7 +3152,6 @@ compile_OIDN() {
|
||||
cmake_d="$cmake_d -D WITH_EXAMPLE=OFF"
|
||||
cmake_d="$cmake_d -D WITH_TEST=OFF"
|
||||
cmake_d="$cmake_d -D OIDN_STATIC_LIB=ON"
|
||||
cmake_d="$cmake_d -D ISPC_DIR_HINT=$_ispc_path_bin"
|
||||
|
||||
if [ -d $INST/tbb ]; then
|
||||
make_d="$make_d TBB_ROOT=$INST/tbb"
|
||||
@@ -3321,7 +3187,7 @@ compile_OIDN() {
|
||||
|
||||
_init_ffmpeg() {
|
||||
_src=$SRC/ffmpeg-$FFMPEG_VERSION
|
||||
_inst=$INST/ffmpeg-$FFMPEG_VERSION_SHORT
|
||||
_inst=$INST/ffmpeg-$FFMPEG_VERSION
|
||||
_inst_shortcut=$INST/ffmpeg
|
||||
}
|
||||
|
||||
@@ -3450,7 +3316,7 @@ compile_FFmpeg() {
|
||||
_init_xr_openxr_sdk() {
|
||||
_src=$SRC/XR-OpenXR-SDK-$XR_OPENXR_VERSION
|
||||
_git=true
|
||||
_inst=$INST/xr-openxr-sdk-$XR_OPENXR_VERSION_SHORT
|
||||
_inst=$INST/xr-openxr-sdk-$XR_OPENXR_VERSION
|
||||
_inst_shortcut=$INST/xr-openxr-sdk
|
||||
}
|
||||
|
||||
@@ -3654,7 +3520,7 @@ install_DEB() {
|
||||
THEORA_DEV="libtheora-dev"
|
||||
|
||||
_packages="gawk cmake cmake-curses-gui build-essential libjpeg-dev libpng-dev libtiff-dev \
|
||||
git libfreetype6-dev libfontconfig-dev libx11-dev flex bison libxxf86vm-dev \
|
||||
git libfreetype6-dev libx11-dev flex bison libxxf86vm-dev \
|
||||
libxcursor-dev libxi-dev wget libsqlite3-dev libxrandr-dev libxinerama-dev \
|
||||
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
|
||||
libopenal-dev libglew-dev yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV \
|
||||
@@ -3689,18 +3555,13 @@ install_DEB() {
|
||||
|
||||
PRINT ""
|
||||
CLANG_FORMAT="clang-format"
|
||||
check_package_version_ge_DEB $CLANG_FORMAT $CLANG_FORMAT_VERSION
|
||||
check_package_version_ge_DEB $CLANG_FORMAT $CLANG_FORMAT_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
_packages="$_packages $CLANG_FORMAT"
|
||||
else
|
||||
check_package_version_ge_DEB $CLANG_FORMAT $CLANG_FORMAT_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
_packages="$_packages $CLANG_FORMAT"
|
||||
else
|
||||
PRINT ""
|
||||
WARNING "clang-format $CLANG_FORMAT_VERSION_MIN or higher not found, this is NOT needed to get Blender compiling..."
|
||||
PRINT ""
|
||||
fi
|
||||
PRINT ""
|
||||
WARNING "clang-format $CLANG_FORMAT_VERSION_MIN or higher not found, this is NOT needed to get Blender compiling..."
|
||||
PRINT ""
|
||||
fi
|
||||
|
||||
if [ "$WITH_JACK" = true ]; then
|
||||
@@ -3815,7 +3676,7 @@ install_DEB() {
|
||||
INFO "Forced Python/NumPy building, as requested..."
|
||||
_do_compile_python=true
|
||||
else
|
||||
check_package_version_ge_lt_DEB python3-dev $PYTHON_VERSION_MIN $PYTHON_VERSION_MAX
|
||||
check_package_version_ge_DEB python3-dev $PYTHON_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_DEB python3-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||
|
||||
@@ -3857,7 +3718,7 @@ install_DEB() {
|
||||
INFO "Forced Boost building, as requested..."
|
||||
compile_Boost
|
||||
else
|
||||
check_package_version_ge_lt_DEB libboost-dev $BOOST_VERSION_MIN $BOOST_VERSION_MAX
|
||||
check_package_version_ge_DEB libboost-dev $BOOST_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libboost-dev
|
||||
|
||||
@@ -3878,7 +3739,7 @@ install_DEB() {
|
||||
INFO "Forced TBB building, as requested..."
|
||||
compile_TBB
|
||||
else
|
||||
check_package_version_ge_lt_DEB libtbb-dev $TBB_VERSION_MIN $TBB_VERSION_MAX
|
||||
check_package_version_ge_DEB libtbb-dev $TBB_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libtbb-dev
|
||||
clean_TBB
|
||||
@@ -3895,13 +3756,14 @@ install_DEB() {
|
||||
INFO "Forced OpenColorIO building, as requested..."
|
||||
compile_OCIO
|
||||
else
|
||||
check_package_version_ge_lt_DEB libopencolorio-dev $OCIO_VERSION_MIN $OCIO_VERSION_MAX
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libopencolorio-dev
|
||||
clean_OCIO
|
||||
else
|
||||
# XXX Always force build of own OCIO, until linux distro guys update their package to default libyaml-cpp ver (0.5)!
|
||||
#check_package_version_ge_DEB libopencolorio-dev $OCIO_VERSION_MIN
|
||||
#if [ $? -eq 0 ]; then
|
||||
#install_packages_DEB libopencolorio-dev
|
||||
#clean_OCIO
|
||||
#else
|
||||
compile_OCIO
|
||||
fi
|
||||
#fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -3912,7 +3774,7 @@ install_DEB() {
|
||||
INFO "Forced ILMBase/OpenEXR building, as requested..."
|
||||
compile_OPENEXR
|
||||
else
|
||||
check_package_version_ge_lt_DEB libopenexr-dev $OPENEXR_VERSION_MIN $OPENEXR_VERSION_MAX
|
||||
check_package_version_ge_DEB libopenexr-dev $OPENEXR_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libopenexr-dev
|
||||
OPENEXR_VERSION=`get_package_version_DEB libopenexr-dev`
|
||||
@@ -3931,13 +3793,14 @@ install_DEB() {
|
||||
INFO "Forced OpenImageIO building, as requested..."
|
||||
compile_OIIO
|
||||
else
|
||||
check_package_version_ge_lt_DEB libopenimageio-dev $OIIO_VERSION_MIN $OIIO_VERSION_MAX
|
||||
if [ $? -eq 0 -a "$_with_built_openexr" = false ]; then
|
||||
install_packages_DEB libopenimageio-dev
|
||||
clean_OIIO
|
||||
else
|
||||
# XXX Debian Testing / Ubuntu 16.04 pulls in WAY too many deps (gtk2/opencv ?!) incl. OCIO build against libyaml-cpp0.3 so build for now...
|
||||
#check_package_version_ge_lt_DEB libopenimageio-dev $OIIO_VERSION_MIN $OIIO_VERSION_MAX
|
||||
#if [ $? -eq 0 -a "$_with_built_openexr" = false ]; then
|
||||
# install_packages_DEB libopenimageio-dev
|
||||
# clean_OIIO
|
||||
#else
|
||||
compile_OIIO
|
||||
fi
|
||||
#fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -3951,12 +3814,11 @@ install_DEB() {
|
||||
INFO "Forced LLVM building, as requested..."
|
||||
_do_compile_llvm=true
|
||||
else
|
||||
check_package_version_ge_lt_DEB llvm-dev $LLVM_VERSION_MIN $LLVM_VERSION_MAX
|
||||
check_package_DEB clang-$LLVM_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB llvm-dev clang
|
||||
install_packages_DEB llvm-$LLVM_VERSION_MIN-dev clang-$LLVM_VERSION_MIN
|
||||
have_llvm=true
|
||||
LLVM_VERSION=`get_package_version_DEB llvm-dev`
|
||||
LLVM_VERSION_FOUND=$LLVM_VERSION
|
||||
LLVM_VERSION_FOUND=$LLVM_VERSION_MIN
|
||||
clean_LLVM
|
||||
else
|
||||
_do_compile_llvm=true
|
||||
@@ -3982,13 +3844,8 @@ install_DEB() {
|
||||
INFO "Forced OpenShadingLanguage building, as requested..."
|
||||
_do_compile_osl=true
|
||||
else
|
||||
check_package_version_ge_lt_DEB libopenshadinglanguage-dev $OSL_VERSION_MIN $OSL_VERSION_MAX
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libopenshadinglanguage-dev
|
||||
clean_OSL
|
||||
else
|
||||
_do_compile_osl=true
|
||||
fi
|
||||
# No package currently!
|
||||
_do_compile_osl=true
|
||||
fi
|
||||
|
||||
if [ "$_do_compile_osl" = true ]; then
|
||||
@@ -4020,7 +3877,7 @@ install_DEB() {
|
||||
INFO "Forced OpenVDB building, as requested..."
|
||||
compile_OPENVDB
|
||||
else
|
||||
check_package_version_ge_lt_DEB libopenvdb-dev $OPENVDB_VERSION_MIN $OPENVDB_VERSION_MAX
|
||||
check_package_version_ge_DEB libopenvdb-dev $OPENVDB_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libopenvdb-dev libblosc-dev
|
||||
clean_OPENVDB
|
||||
@@ -4081,14 +3938,8 @@ install_DEB() {
|
||||
INFO "Forced Embree building, as requested..."
|
||||
_do_compile_embree=true
|
||||
else
|
||||
# There is a package, but it does not provide everything that Blender needs...
|
||||
#~ check_package_version_ge_lt_DEB libembree-dev $EMBREE_VERSION_MIN $EMBREE_VERSION_MAX
|
||||
#~ if [ $? -eq 0 ]; then
|
||||
#~ install_packages_DEB libembree-dev
|
||||
#~ clean_Embree
|
||||
#~ else
|
||||
_do_compile_embree=true
|
||||
#~ fi
|
||||
# No package currently!
|
||||
_do_compile_embree=true
|
||||
fi
|
||||
|
||||
if [ "$_do_compile_embree" = true ]; then
|
||||
@@ -4124,7 +3975,7 @@ install_DEB() {
|
||||
# XXX Debian Testing / Ubuntu 16.04 finally includes FFmpeg, so check as usual
|
||||
check_package_DEB ffmpeg
|
||||
if [ $? -eq 0 ]; then
|
||||
check_package_version_ge_lt_DEB ffmpeg $FFMPEG_VERSION_MIN $FFMPEG_VERSION_MAX
|
||||
check_package_version_ge_DEB ffmpeg $FFMPEG_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_DEB libavdevice-dev
|
||||
clean_FFmpeg
|
||||
@@ -4320,7 +4171,7 @@ install_RPM() {
|
||||
OGG_DEV="libogg-devel"
|
||||
THEORA_DEV="libtheora-devel"
|
||||
|
||||
_packages="gcc gcc-c++ git make cmake tar bzip2 xz findutils flex bison fontconfig-devel \
|
||||
_packages="gcc gcc-c++ git make cmake tar bzip2 xz findutils flex bison \
|
||||
libtiff-devel libjpeg-devel libpng-devel sqlite-devel fftw-devel SDL2-devel \
|
||||
libX11-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel \
|
||||
wget ncurses-devel readline-devel $OPENJPEG_DEV openal-soft-devel \
|
||||
@@ -4448,7 +4299,7 @@ install_RPM() {
|
||||
INFO "Forced Python/NumPy building, as requested..."
|
||||
_do_compile_python=true
|
||||
else
|
||||
check_package_version_ge_lt_RPM python3-devel $PYTHON_VERSION_MIN $PYTHON_VERSION_MAX
|
||||
check_package_version_ge_RPM python3-devel $PYTHON_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_RPM python3-devel` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||
|
||||
@@ -4458,7 +4309,7 @@ install_RPM() {
|
||||
if [ "$NUMPY_SKIP" = true ]; then
|
||||
WARNING "Skipping NumPy installation, as requested..."
|
||||
else
|
||||
check_package_version_ge_lt_RPM python3-numpy $NUMPY_VERSION_MIN $NUMPY_VERSION_MAX
|
||||
check_package_version_ge_RPM python3-numpy $NUMPY_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM python3-numpy
|
||||
else
|
||||
@@ -4491,7 +4342,7 @@ install_RPM() {
|
||||
INFO "Forced Boost building, as requested..."
|
||||
_do_compile_boost=true
|
||||
else
|
||||
check_package_version_ge_lt_RPM boost-devel $BOOST_VERSION_MIN $BOOST_VERSION_MAX
|
||||
check_package_version_ge_RPM boost-devel $BOOST_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM boost-devel
|
||||
clean_Boost
|
||||
@@ -4518,7 +4369,7 @@ install_RPM() {
|
||||
INFO "Forced TBB building, as requested..."
|
||||
compile_TBB
|
||||
else
|
||||
check_package_version_ge_lt_RPM tbb-devel $TBB_VERSION_MIN $TBB_VERSION_MAX
|
||||
check_package_version_ge_RPM tbb-devel $TBB_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM tbb-devel
|
||||
clean_TBB
|
||||
@@ -4536,7 +4387,7 @@ install_RPM() {
|
||||
compile_OCIO
|
||||
else
|
||||
if [ "$RPM" = "SUSE" ]; then
|
||||
check_package_version_ge_lt_RPM OpenColorIO-devel $OCIO_VERSION_MIN $OCIO_VERSION_MAX
|
||||
check_package_version_ge_RPM OpenColorIO-devel $OCIO_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM OpenColorIO-devel
|
||||
clean_OCIO
|
||||
@@ -4556,7 +4407,7 @@ install_RPM() {
|
||||
INFO "Forced ILMBase/OpenEXR building, as requested..."
|
||||
compile_OPENEXR
|
||||
else
|
||||
check_package_version_ge_lt_RPM openexr-devel $OPENEXR_VERSION_MIN $OPENEXR_VERSION_MAX
|
||||
check_package_version_ge_RPM openexr-devel $OPENEXR_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM openexr-devel
|
||||
OPENEXR_VERSION=`get_package_version_RPM openexr-devel`
|
||||
@@ -4574,6 +4425,7 @@ install_RPM() {
|
||||
INFO "Forced OpenImageIO building, as requested..."
|
||||
compile_OIIO
|
||||
else
|
||||
# XXX RPM distros pulls in too much and depends on old libs, so better to build for now...
|
||||
#check_package_version_ge_lt_RPM OpenImageIO-devel $OIIO_VERSION_MIN $OIIO_VERSION_MAX
|
||||
#if [ $? -eq 0 -a $_with_built_openexr == false ]; then
|
||||
# install_packages_RPM OpenImageIO-devel
|
||||
@@ -4599,11 +4451,10 @@ install_RPM() {
|
||||
else
|
||||
CLANG_DEV="clang-devel"
|
||||
fi
|
||||
check_package_version_ge_lt_RPM llvm-devel $LLVM_VERSION_MIN $LLVM_VERSION_MAX
|
||||
check_package_version_match_RPM $CLANG_DEV $LLVM_VERSION
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM llvm-devel $CLANG_DEV
|
||||
have_llvm=true
|
||||
LLVM_VERSION=`get_package_version_RPM llvm-devel`
|
||||
LLVM_VERSION_FOUND=$LLVM_VERSION
|
||||
clean_LLVM
|
||||
else
|
||||
@@ -4630,18 +4481,8 @@ install_RPM() {
|
||||
INFO "Forced OpenShadingLanguage building, as requested..."
|
||||
_do_compile_osl=true
|
||||
else
|
||||
if [ "$RPM" = "SUSE" ]; then
|
||||
OSL_DEV="OpenShadingLanguage-devel"
|
||||
else
|
||||
OSL_DEV="openshadinglanguage-devel"
|
||||
fi
|
||||
check_package_version_ge_lt_RPM $OSL_DEV $OSL_VERSION_MIN $OSL_VERSION_MAX
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM $OSL_DEV
|
||||
clean_OSL
|
||||
else
|
||||
_do_compile_osl=true
|
||||
fi
|
||||
# No package currently!
|
||||
_do_compile_osl=true
|
||||
fi
|
||||
|
||||
if [ "$_do_compile_osl" = true ]; then
|
||||
@@ -4729,14 +4570,8 @@ install_RPM() {
|
||||
INFO "Forced Embree building, as requested..."
|
||||
_do_compile_embree=true
|
||||
else
|
||||
# There is a package, but it does not provide everything that Blender needs...
|
||||
#~ check_package_version_ge_lt_RPM embree-devel $EMBREE_VERSION_MIN $EMBREE_VERSION_MAX
|
||||
#~ if [ $? -eq 0 ]; then
|
||||
#~ install_packages_RPM embree-devel
|
||||
#~ clean_Embree
|
||||
#~ else
|
||||
_do_compile_embree=true
|
||||
#~ fi
|
||||
# No package...
|
||||
_do_compile_embree=true
|
||||
fi
|
||||
|
||||
if [ "$_do_compile_embree" = true ]; then
|
||||
@@ -4769,7 +4604,7 @@ install_RPM() {
|
||||
INFO "Forced FFMpeg building, as requested..."
|
||||
compile_FFmpeg
|
||||
else
|
||||
check_package_version_ge_lt_RPM ffmpeg-devel $FFMPEG_VERSION_MIN $FFMPEG_VERSION_MAX
|
||||
check_package_version_ge_RPM ffmpeg-devel $FFMPEG_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_RPM ffmpeg ffmpeg-devel
|
||||
clean_FFmpeg
|
||||
@@ -4898,7 +4733,7 @@ install_ARCH() {
|
||||
BASE_DEVEL=`pacman -Sgq base-devel | sed -e 's/^gcc$/gcc-multilib/g' | paste -s -d' '`
|
||||
fi
|
||||
|
||||
_packages="$BASE_DEVEL git cmake fontconfig \
|
||||
_packages="$BASE_DEVEL git cmake \
|
||||
libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
|
||||
$OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl2 fftw \
|
||||
libxml2 yaml-cpp tinyxml python-requests jemalloc gmp"
|
||||
@@ -4989,7 +4824,7 @@ install_ARCH() {
|
||||
INFO "Forced Python/NumPy building, as requested..."
|
||||
_do_compile_python=true
|
||||
else
|
||||
check_package_version_ge_lt_ARCH python $PYTHON_VERSION_MIN $PYTHON_VERSION_MAX
|
||||
check_package_version_ge_ARCH python $PYTHON_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_ARCH python` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||
|
||||
@@ -4999,7 +4834,7 @@ install_ARCH() {
|
||||
if [ "$NUMPY_SKIP" = true ]; then
|
||||
WARNING "Skipping NumPy installation, as requested..."
|
||||
else
|
||||
check_package_version_ge_ARCH python-numpy $NUMPY_VERSION_MIN $NUMPY_VERSION_MAX
|
||||
check_package_version_ge_ARCH python-numpy $NUMPY_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH python-numpy
|
||||
else
|
||||
@@ -5031,7 +4866,7 @@ install_ARCH() {
|
||||
INFO "Forced Boost building, as requested..."
|
||||
compile_Boost
|
||||
else
|
||||
check_package_version_ge_lt_ARCH boost $BOOST_VERSION_MIN $BOOST_VERSION_MAX
|
||||
check_package_version_ge_ARCH boost $BOOST_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH boost
|
||||
clean_Boost
|
||||
@@ -5048,7 +4883,7 @@ install_ARCH() {
|
||||
INFO "Forced TBB building, as requested..."
|
||||
compile_TBB
|
||||
else
|
||||
check_package_version_ge_lt_ARCH intel-tbb $TBB_VERSION_MIN $TBB_VERSION_MAX
|
||||
check_package_version_ge_ARCH intel-tbb $TBB_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH intel-tbb
|
||||
clean_TBB
|
||||
@@ -5065,7 +4900,7 @@ install_ARCH() {
|
||||
INFO "Forced OpenColorIO building, as requested..."
|
||||
compile_OCIO
|
||||
else
|
||||
check_package_version_ge_lt_ARCH opencolorio $OCIO_VERSION_MIN $OCIO_VERSION_MAX
|
||||
check_package_version_ge_ARCH opencolorio $OCIO_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH opencolorio
|
||||
clean_OCIO
|
||||
@@ -5082,7 +4917,7 @@ install_ARCH() {
|
||||
INFO "Forced ILMBase/OpenEXR building, as requested..."
|
||||
compile_OPENEXR
|
||||
else
|
||||
check_package_version_ge_lt_ARCH openexr $OPENEXR_VERSION_MIN $OPENEXR_VERSION_MAX
|
||||
check_package_version_ge_ARCH openexr $OPENEXR_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH openexr
|
||||
OPENEXR_VERSION=`get_package_version_ARCH openexr`
|
||||
@@ -5121,7 +4956,7 @@ install_ARCH() {
|
||||
INFO "Forced LLVM building, as requested..."
|
||||
_do_compile_llvm=true
|
||||
else
|
||||
check_package_version_ge_lt_ARCH llvm $LLVM_VERSION_MIN $LLVM_VERSION_MAX
|
||||
check_package_version_match_ARCH llvm $LLVM_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH llvm clang
|
||||
have_llvm=true
|
||||
@@ -5152,13 +4987,14 @@ install_ARCH() {
|
||||
INFO "Forced OpenShadingLanguage building, as requested..."
|
||||
_do_compile_osl=true
|
||||
else
|
||||
check_package_version_ge_lt_ARCH openshadinglanguage $OSL_VERSION_MIN $OSL_VERSION_MAX
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH openshadinglanguage
|
||||
clean_OSL
|
||||
else
|
||||
# XXX Compile for now due to requirement of LLVM 3.4 ...
|
||||
#check_package_version_ge_ARCH openshadinglanguage $OSL_VERSION_MIN
|
||||
#if [ $? -eq 0 ]; then
|
||||
# install_packages_ARCH openshadinglanguage
|
||||
# clean_OSL
|
||||
#else
|
||||
_do_compile_osl=true
|
||||
fi
|
||||
#fi
|
||||
fi
|
||||
|
||||
if [ "$_do_compile_osl" = true ]; then
|
||||
@@ -5178,7 +5014,7 @@ install_ARCH() {
|
||||
INFO "Forced OpenSubdiv building, as requested..."
|
||||
compile_OSD
|
||||
else
|
||||
check_package_version_ge_lt_ARCH opensubdiv $OSD_VERSION_MIN $OSD_VERSION_MAX
|
||||
check_package_version_ge_ARCH opensubdiv $OSD_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH opensubdiv
|
||||
clean_OSD
|
||||
@@ -5195,7 +5031,7 @@ install_ARCH() {
|
||||
INFO "Forced OpenVDB building, as requested..."
|
||||
compile_OPENVDB
|
||||
else
|
||||
check_package_version_ge_lt_ARCH openvdb $OPENVDB_VERSION_MIN $OPENVDB_VERSION_MAX
|
||||
check_package_version_ge_ARCH openvdb $OPENVDB_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH openvdb
|
||||
clean_OPENVDB
|
||||
@@ -5260,14 +5096,13 @@ install_ARCH() {
|
||||
INFO "Forced Embree building, as requested..."
|
||||
_do_compile_embree=true
|
||||
else
|
||||
# There is a package, but it does not provide everything that Blender needs...
|
||||
#~ check_package_version_ge_lt_ARCH embree $EMBREE_VERSION_MIN $EMBREE_VERSION_MAX
|
||||
#~ if [ $? -eq 0 ]; then
|
||||
#~ install_packages_ARCH embree
|
||||
#~ clean_Embree
|
||||
#~ else
|
||||
check_package_ARCH embree
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH embree
|
||||
clean_Embree
|
||||
else
|
||||
_do_compile_embree=true
|
||||
#~ fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$_do_compile_embree" = true ]; then
|
||||
@@ -5300,7 +5135,7 @@ install_ARCH() {
|
||||
INFO "Forced FFMpeg building, as requested..."
|
||||
compile_FFmpeg
|
||||
else
|
||||
check_package_version_ge_lt_ARCH ffmpeg $FFMPEG_VERSION_MIN $FFMPEG_VERSION_MAX
|
||||
check_package_version_ge_ARCH ffmpeg $FFMPEG_VERSION_MIN
|
||||
if [ $? -eq 0 ]; then
|
||||
install_packages_ARCH ffmpeg
|
||||
clean_FFmpeg
|
||||
@@ -5577,8 +5412,7 @@ print_info() {
|
||||
|
||||
_buildargs="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB*"
|
||||
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*"
|
||||
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *BLOSC* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD*"
|
||||
_buildargs="$_buildargs -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR*"
|
||||
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD*"
|
||||
|
||||
_1="-D WITH_CODEC_SNDFILE=ON"
|
||||
PRINT " $_1"
|
||||
|
@@ -1,4 +0,0 @@
|
||||
using python : @PYTHON_SHORT_VERSION@ : @PYTHON_BINARY@
|
||||
: @LIBDIR@/python/include @LIBDIR@/python/include/python@PYTHON_SHORT_VERSION@m/
|
||||
: @LIBDIR@/python/libs
|
||||
;
|
11
build_files/build_environment/patches/hdf5.diff
Normal file
11
build_files/build_environment/patches/hdf5.diff
Normal file
@@ -0,0 +1,11 @@
|
||||
--- UserMacros.cmake
|
||||
+++ UserMacros.cmake
|
||||
@@ -16,6 +16,8 @@
|
||||
if (BUILD_USER_DEFINED_LIBS)
|
||||
MACRO_USER_DEFINED_LIBS ()
|
||||
endif (BUILD_USER_DEFINED_LIBS)
|
||||
+
|
||||
+include(Config/cmake/usermacros/windows_mt.cmake)
|
||||
#-----------------------------------------------------------------------------
|
||||
#------------------- E X A M P L E E N D -----------------------------------
|
||||
#-----------------------------------------------------------------------------
|
@@ -1,6 +1,6 @@
|
||||
diff -Naur orig/cmake/FindIlmBase.cmake openvdb/cmake/FindIlmBase.cmake
|
||||
--- orig/cmake/FindIlmBase.cmake 2019-12-06 12:11:33 -0700
|
||||
+++ openvdb/cmake/FindIlmBase.cmake 2020-08-12 12:48:44 -0600
|
||||
--- orig/cmake/FindIlmBase.cmake 2019-12-06 13:11:33 -0700
|
||||
+++ openvdb/cmake/FindIlmBase.cmake 2020-01-16 09:06:32 -0700
|
||||
@@ -225,6 +225,12 @@
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
"-${IlmBase_VERSION_MAJOR}_${IlmBase_VERSION_MINOR}.lib"
|
||||
@@ -15,8 +15,8 @@ diff -Naur orig/cmake/FindIlmBase.cmake openvdb/cmake/FindIlmBase.cmake
|
||||
if(ILMBASE_USE_STATIC_LIBS)
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
diff -Naur orig/cmake/FindOpenEXR.cmake openvdb/cmake/FindOpenEXR.cmake
|
||||
--- orig/cmake/FindOpenEXR.cmake 2019-12-06 12:11:33 -0700
|
||||
+++ openvdb/cmake/FindOpenEXR.cmake 2020-08-12 12:48:44 -0600
|
||||
--- orig/cmake/FindOpenEXR.cmake 2019-12-06 13:11:33 -0700
|
||||
+++ openvdb/cmake/FindOpenEXR.cmake 2020-01-16 09:06:39 -0700
|
||||
@@ -218,6 +218,12 @@
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
"-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}.lib"
|
||||
@@ -31,20 +31,9 @@ diff -Naur orig/cmake/FindOpenEXR.cmake openvdb/cmake/FindOpenEXR.cmake
|
||||
if(OPENEXR_USE_STATIC_LIBS)
|
||||
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
diff -Naur orig/openvdb/CMakeLists.txt openvdb/openvdb/CMakeLists.txt
|
||||
--- orig/openvdb/CMakeLists.txt 2019-12-06 12:11:33 -0700
|
||||
+++ openvdb/openvdb/CMakeLists.txt 2020-08-12 14:12:26 -0600
|
||||
@@ -105,7 +105,9 @@
|
||||
# http://boost.2283326.n4.nabble.com/CMake-config-scripts-broken-in-1-70-td4708957.html
|
||||
# https://github.com/boostorg/boost_install/commit/160c7cb2b2c720e74463865ef0454d4c4cd9ae7c
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
- set(Boost_USE_STATIC_LIBS OFF)
|
||||
+ if(NOT WIN32) # blender links boost statically on windows
|
||||
+ set(Boost_USE_STATIC_LIBS OFF)
|
||||
+ endif()
|
||||
endif()
|
||||
|
||||
find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS iostreams system)
|
||||
@@ -193,6 +195,7 @@
|
||||
--- orig/openvdb/CMakeLists.txt 2019-12-06 13:11:33 -0700
|
||||
+++ openvdb/openvdb/CMakeLists.txt 2020-01-16 08:56:25 -0700
|
||||
@@ -193,11 +193,12 @@
|
||||
if(OPENVDB_DISABLE_BOOST_IMPLICIT_LINKING)
|
||||
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||
endif()
|
||||
@@ -52,69 +41,33 @@ diff -Naur orig/openvdb/CMakeLists.txt openvdb/openvdb/CMakeLists.txt
|
||||
endif()
|
||||
|
||||
# @todo Should be target definitions
|
||||
@@ -383,7 +386,12 @@
|
||||
# imported targets.
|
||||
|
||||
if(OPENVDB_CORE_SHARED)
|
||||
- add_library(openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES})
|
||||
+ if(WIN32)
|
||||
+ configure_file(version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
||||
+ add_library(openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
+ else()
|
||||
+ add_library(openvdb_shared SHARED ${OPENVDB_LIBRARY_SOURCE_FILES})
|
||||
+ endif()
|
||||
if(WIN32)
|
||||
- add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_DLL)
|
||||
+ add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_STATICLIB)
|
||||
endif()
|
||||
|
||||
if(OPENVDB_CORE_STATIC)
|
||||
diff -Naur orig/openvdb/version.rc.in openvdb/openvdb/version.rc.in
|
||||
--- orig/openvdb/version.rc.in 1969-12-31 17:00:00 -0700
|
||||
+++ openvdb/openvdb/version.rc.in 2020-08-12 14:15:01 -0600
|
||||
@@ -0,0 +1,48 @@
|
||||
+#include <winver.h>
|
||||
+
|
||||
+#define VER_FILEVERSION @OpenVDB_MAJOR_VERSION@,@OpenVDB_MINOR_VERSION@,@OpenVDB_PATCH_VERSION@,0
|
||||
+#define VER_FILEVERSION_STR "@OpenVDB_MAJOR_VERSION@.@OpenVDB_MINOR_VERSION@.@OpenVDB_PATCH_VERSION@.0\0"
|
||||
+
|
||||
+#define VER_PRODUCTVERSION @OpenVDB_MAJOR_VERSION@,@OpenVDB_MINOR_VERSION@,@OpenVDB_PATCH_VERSION@,0
|
||||
+#define VER_PRODUCTVERSION_STR "@OpenVDB_MAJOR_VERSION@.@OpenVDB_MINOR_VERSION@\0"
|
||||
+
|
||||
+#ifndef DEBUG
|
||||
+#define VER_DEBUG 0
|
||||
+#else
|
||||
+#define VER_DEBUG VS_FF_DEBUG
|
||||
+#endif
|
||||
+
|
||||
+VS_VERSION_INFO VERSIONINFO
|
||||
+FILEVERSION VER_FILEVERSION
|
||||
+PRODUCTVERSION VER_PRODUCTVERSION
|
||||
+FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
+FILEFLAGS (VER_DEBUG)
|
||||
+FILEOS VOS__WINDOWS32
|
||||
+FILETYPE VFT_DLL
|
||||
+FILESUBTYPE VFT2_UNKNOWN
|
||||
+BEGIN
|
||||
+ BLOCK "StringFileInfo"
|
||||
+ BEGIN
|
||||
+ BLOCK "040904E4"
|
||||
+ BEGIN
|
||||
+ VALUE "FileDescription", "OpenVDB"
|
||||
+ VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
+ VALUE "InternalName", "OpenVDB"
|
||||
+ VALUE "ProductName", "OpenVDB"
|
||||
+ VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
+ END
|
||||
+ END
|
||||
+
|
||||
+ BLOCK "VarFileInfo"
|
||||
+ BEGIN
|
||||
+ /* The following line should only be modified for localized versions. */
|
||||
+ /* It consists of any number of WORD,WORD pairs, with each pair */
|
||||
+ /* describing a language,codepage combination supported by the file. */
|
||||
+ /* */
|
||||
+ /* For example, a file might have values "0x409,1252" indicating that it */
|
||||
+ /* supports English language (0x409) in the Windows ANSI codepage (1252). */
|
||||
+
|
||||
+ VALUE "Translation", 0x409, 1252
|
||||
+
|
||||
+ END
|
||||
+END
|
||||
##### Core library configuration
|
||||
diff -Naur orig/openvdb/cmd/CMakeLists.txt openvdb/openvdb/cmd/CMakeLists.txt
|
||||
--- orig/openvdb/cmd/CMakeLists.txt 2019-12-06 13:11:33 -0700
|
||||
+++ openvdb/openvdb/cmd/CMakeLists.txt 2020-01-16 08:56:25 -0700
|
||||
@@ -53,7 +53,7 @@
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
- add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_DLL)
|
||||
+ add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_STATICLIB)
|
||||
endif()
|
||||
|
||||
# rpath handling
|
||||
diff -Naur orig/openvdb/unittest/CMakeLists.txt openvdb/openvdb/unittest/CMakeLists.txt
|
||||
--- orig/openvdb/unittest/CMakeLists.txt 2019-12-06 13:11:33 -0700
|
||||
+++ openvdb/openvdb/unittest/CMakeLists.txt 2020-01-16 08:56:25 -0700
|
||||
@@ -49,7 +49,7 @@
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
- add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_DLL)
|
||||
+ add_definitions(-D_WIN32 -DNOMINMAX -DOPENVDB_STATICLIB)
|
||||
endif()
|
||||
|
||||
##### VDB unit tests
|
||||
|
@@ -10,6 +10,77 @@ diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defau
|
||||
add_definitions(${TBB_DEFINITIONS})
|
||||
|
||||
# --math
|
||||
diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plug/initConfig.cpp
|
||||
--- usd.orig/pxr/base/plug/initConfig.cpp.orig 2020-06-12 17:20:07.478199779 +0200
|
||||
+++ external_usd/pxr/base/plug/initConfig.cpp 2020-06-12 17:25:28.648588552 +0200
|
||||
@@ -69,10 +69,40 @@
|
||||
|
||||
ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void)
|
||||
{
|
||||
+ /* The contents of this constructor have been moved to usd_initialise_plugin_path(...) */
|
||||
+}
|
||||
+
|
||||
+}; // end of anonymous namespace
|
||||
+
|
||||
+/**
|
||||
+ * The contents of this function used to be in the static constructor Plug_InitConfig.
|
||||
+ * This static constructor made it impossible for Blender to pass a path to the USD
|
||||
+ * library at runtime, as the constructor would run before Blender's main() function.
|
||||
+ *
|
||||
+ * This function is wrapped in a C function of the same name (defined below),
|
||||
+ * so that it can be called from Blender's main() function.
|
||||
+ *
|
||||
+ * The datafiles_usd_path path is used to point to the USD plugin path when Blender
|
||||
+ * has been installed. The fallback_usd_path path should point to the build-time
|
||||
+ * location of the USD plugin files so that Blender can be run on a development machine
|
||||
+ * without requiring an installation step.
|
||||
+ */
|
||||
+void
|
||||
+usd_initialise_plugin_path(const char *datafiles_usd_path)
|
||||
+{
|
||||
std::vector<std::string> result;
|
||||
|
||||
std::vector<std::string> debugMessages;
|
||||
|
||||
+ // Add Blender-specific paths. They MUST end in a slash, or symlinks will not be treated as directory.
|
||||
+ if (datafiles_usd_path != NULL && datafiles_usd_path[0] != '\0') {
|
||||
+ std::string datafiles_usd_path_str(datafiles_usd_path);
|
||||
+ if (datafiles_usd_path_str.back() != '/') {
|
||||
+ datafiles_usd_path_str += "/";
|
||||
+ }
|
||||
+ result.push_back(datafiles_usd_path_str);
|
||||
+ }
|
||||
+
|
||||
// Determine the absolute path to the Plug shared library. Any relative
|
||||
// paths specified in the plugin search path will be anchored to this
|
||||
// directory, to allow for relocatability. Note that this can fail when pxr
|
||||
@@ -114,9 +144,24 @@
|
||||
_AppendPathList(&result, installLocation, binaryPath);
|
||||
#endif // PXR_INSTALL_LOCATION
|
||||
|
||||
- Plug_SetPaths(result, debugMessages);
|
||||
-}
|
||||
+ if (!TfGetenv("PXR_PATH_DEBUG").empty()) {
|
||||
+ printf("USD Plugin paths: (%zu in total):\n", result.size());
|
||||
+ for(const std::string &path : result) {
|
||||
+ printf(" %s\n", path.c_str());
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+ Plug_SetPaths(result, debugMessages);
|
||||
}
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
+
|
||||
+/* Workaround to make it possible to pass a path at runtime to USD. */
|
||||
+extern "C" {
|
||||
+void
|
||||
+usd_initialise_plugin_path(
|
||||
+ const char *datafiles_usd_path)
|
||||
+{
|
||||
+ PXR_NS::usd_initialise_plugin_path(datafiles_usd_path);
|
||||
+}
|
||||
+}
|
||||
diff -Naur external_usd_base/cmake/macros/Public.cmake external_usd/cmake/macros/Public.cmake
|
||||
--- external_usd_base/cmake/macros/Public.cmake 2019-10-24 14:39:53 -0600
|
||||
+++ external_usd/cmake/macros/Public.cmake 2020-01-11 13:33:29 -0700
|
||||
|
@@ -12,8 +12,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2016 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If ALEMBIC_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -47,7 +51,7 @@ FIND_LIBRARY(ALEMBIC_LIBRARY
|
||||
# handle the QUIETLY and REQUIRED arguments and set ALEMBIC_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Alembic DEFAULT_MSG ALEMBIC_LIBRARY ALEMBIC_INCLUDE_DIR)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALEMBIC DEFAULT_MSG ALEMBIC_LIBRARY ALEMBIC_INCLUDE_DIR)
|
||||
|
||||
IF(ALEMBIC_FOUND)
|
||||
SET(ALEMBIC_LIBRARIES ${ALEMBIC_LIBRARY})
|
||||
|
@@ -11,13 +11,6 @@
|
||||
# AUDASPACE_PY_INCLUDE_DIRS - the audaspace's python binding include directories
|
||||
# AUDASPACE_PY_LIBRARIES - link these to use audaspace's python binding
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2014 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
#=============================================================================
|
||||
|
||||
IF(NOT AUDASPACE_ROOT_DIR AND NOT $ENV{AUDASPACE_ROOT_DIR} STREQUAL "")
|
||||
SET(AUDASPACE_ROOT_DIR $ENV{AUDASPACE_ROOT_DIR})
|
||||
ENDIF()
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2018 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If BLOSC_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -49,7 +53,7 @@ FIND_LIBRARY(BLOSC_LIBRARY
|
||||
# handle the QUIETLY and REQUIRED arguments and set BLOSC_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Blosc DEFAULT_MSG
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(BLOSC DEFAULT_MSG
|
||||
BLOSC_LIBRARY BLOSC_INCLUDE_DIR)
|
||||
|
||||
IF(BLOSC_FOUND)
|
||||
|
@@ -17,8 +17,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2020 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If CLANG_TIDY_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -10,8 +10,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If EIGEN3_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -7,12 +7,19 @@
|
||||
# EMBREE_ROOT_DIR, The base directory to search for Embree.
|
||||
# This can also be an environment variable.
|
||||
# EMBREEFOUND, If false, do not try to use Embree.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# EMBREE_LIBRARY, where to find the Embree library.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2018 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If EMBREE_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -59,18 +66,19 @@ FOREACH(COMPONENT ${_embree_FIND_COMPONENTS})
|
||||
PATH_SUFFIXES
|
||||
lib64 lib
|
||||
)
|
||||
IF (NOT EMBREE_${UPPERCOMPONENT}_LIBRARY)
|
||||
IF (EMBREE_EMBREE3_LIBRARY)
|
||||
# If we can't find all the static libraries, try to fall back to the shared library if found.
|
||||
# This allows building with a shared embree library
|
||||
SET(_embree_LIBRARIES ${EMBREE_EMBREE3_LIBRARY})
|
||||
BREAK()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
LIST(APPEND _embree_LIBRARIES "${EMBREE_${UPPERCOMPONENT}_LIBRARY}")
|
||||
ENDFOREACH()
|
||||
|
||||
|
||||
FIND_LIBRARY(EMBREE_LIBRARY
|
||||
NAMES
|
||||
libembree3
|
||||
HINTS
|
||||
${_embree_SEARCH_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib64 lib
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If FFTW3_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -13,8 +13,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If GLEW_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -47,7 +51,7 @@ FIND_LIBRARY(GLEW_LIBRARY
|
||||
# handle the QUIETLY and REQUIRED arguments and set GLEW_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLEW DEFAULT_MSG
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glew DEFAULT_MSG
|
||||
GLEW_LIBRARY GLEW_INCLUDE_DIR)
|
||||
|
||||
IF(GLEW_FOUND)
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If GMP_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -80,7 +84,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG
|
||||
GMP_LIBRARY GMPXX_LIBRARY GMP_INCLUDE_DIR GMPXX_INCLUDE_DIR)
|
||||
|
||||
IF(GMP_FOUND)
|
||||
SET(GMP_LIBRARIES ${GMPXX_LIBRARY} ${GMP_LIBRARY})
|
||||
SET(GMP_LIBRARIES ${GMP_LIBRARY} ${GMPXX_LIBRARY})
|
||||
SET(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR} ${GMPXX_INCLUDE_DIR})
|
||||
ENDIF(GMP_FOUND)
|
||||
|
||||
|
@@ -12,8 +12,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2012 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If ICU_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If JACK_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If JEMALLOC_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -13,8 +13,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
if(LLVM_ROOT_DIR)
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If LZO_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -7,12 +7,19 @@
|
||||
# OPENCOLLADA_ROOT_DIR, The base directory to search for OpenCOLLADA.
|
||||
# This can also be an environment variable.
|
||||
# OPENCOLLADA_FOUND, If false, do not try to use OpenCOLLADA.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# OPENCOLLADA_LIBRARY, where to find the OpenCOLLADA library.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# note about include paths, there are 2 ways includes are set
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2012 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENCOLORIO_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -21,8 +21,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENEXR_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -10,13 +10,6 @@
|
||||
# OPENGLES_LIBRARIES - all libraries needed for OpenGLES
|
||||
# OPENGLES_INCLUDES - all includes needed for OpenGLES
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2014 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENGLES_ROOT_DIR was defined in the environment, use it.
|
||||
IF(NOT OPENGLES_ROOT_DIR AND NOT $ENV{OPENGLES_ROOT_DIR} STREQUAL "")
|
||||
SET(OPENGLES_ROOT_DIR $ENV{OPENGLES_ROOT_DIR})
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2019 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENIMAGEDENOISE_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -16,8 +16,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENIMAGEIO_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENJPEG_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OSL_ROOT_DIR was defined in the environment, use it.
|
@@ -7,12 +7,19 @@
|
||||
# OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
|
||||
# This can also be an environment variable.
|
||||
# OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2013 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENSUBDIV_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPENVDB_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -49,7 +53,7 @@ FIND_LIBRARY(OPENVDB_LIBRARY
|
||||
# handle the QUIETLY and REQUIRED arguments and set OPENVDB_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenVDB DEFAULT_MSG
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENVDB DEFAULT_MSG
|
||||
OPENVDB_LIBRARY OPENVDB_INCLUDE_DIR)
|
||||
|
||||
IF(OPENVDB_FOUND)
|
||||
|
@@ -10,8 +10,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2019 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If OPTIX_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If PCRE_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If PUGIXML_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -25,8 +25,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If PYTHON_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -13,8 +13,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If SDL2_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If LIBSNDFILE_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If SPACENAV_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2016 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If TBB_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -12,8 +12,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2019 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If USD_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -14,8 +14,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2011 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If XML2_ROOT_DIR was defined in the environment, use it.
|
||||
|
@@ -20,8 +20,12 @@
|
||||
# XR_OPENXR_SDK_LOADER_LIBRARY, where to find the OpenXR-SDK loader library.
|
||||
|
||||
#=============================================================================
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
|
||||
# If XR_OPENXR_SDK_ROOT_DIR was defined in the environment, use it.
|
||||
@@ -55,7 +59,7 @@ FIND_LIBRARY(XR_OPENXR_SDK_LOADER_LIBRARY
|
||||
# handle the QUIETLY and REQUIRED arguments and set XR_OPENXR_SDK_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XR_OpenXR_SDK DEFAULT_MSG
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XR_OPENXR_SDK DEFAULT_MSG
|
||||
XR_OPENXR_SDK_LOADER_LIBRARY XR_OPENXR_SDK_INCLUDE_DIR)
|
||||
|
||||
IF(XR_OPENXR_SDK_FOUND)
|
@@ -1,5 +1,5 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
GoogleTest
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
# Blender: disable ASAN leak detection when trying to discover tests.
|
||||
set(ENV{ASAN_OPTIONS} "detect_leaks=0")
|
||||
|
@@ -1,8 +1,12 @@
|
||||
#=============================================================================
|
||||
# Copyright 2014 Blender Foundation.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD 3-Clause License,
|
||||
# see accompanying file BSD-3-Clause-license.txt for details.
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#
|
||||
# Inspired on the Testing.cmake from Libmv
|
||||
#
|
||||
@@ -70,9 +74,6 @@ macro(BLENDER_SRC_GTEST_EX)
|
||||
if(WITH_TBB)
|
||||
target_link_libraries(${TARGET_NAME} ${TBB_LIBRARIES})
|
||||
endif()
|
||||
if(WITH_GMP)
|
||||
target_link_libraries(${TARGET_NAME} ${GMP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(GENERATOR_IS_MULTI_CONFIG)
|
||||
|
@@ -15,12 +15,11 @@ set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
|
||||
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
|
||||
set(WITH_DRACO ON CACHE BOOL "" FORCE)
|
||||
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
|
||||
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
|
||||
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
|
||||
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP ON CACHE BOOL "" FORCE)
|
||||
set(WITH_IK_SOLVER ON CACHE BOOL "" FORCE)
|
||||
set(WITH_IK_ITASC ON CACHE BOOL "" FORCE)
|
||||
set(WITH_IMAGE_CINEON ON CACHE BOOL "" FORCE)
|
||||
|
@@ -25,7 +25,6 @@ set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_IK_SOLVER OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_IK_ITASC OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_IMAGE_CINEON OFF CACHE BOOL "" FORCE)
|
||||
|
@@ -16,12 +16,11 @@ set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
|
||||
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
|
||||
set(WITH_DRACO ON CACHE BOOL "" FORCE)
|
||||
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
|
||||
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
|
||||
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
|
||||
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
|
||||
set(WITH_GMP ON CACHE BOOL "" FORCE)
|
||||
set(WITH_IK_SOLVER ON CACHE BOOL "" FORCE)
|
||||
set(WITH_IK_ITASC ON CACHE BOOL "" FORCE)
|
||||
set(WITH_IMAGE_CINEON ON CACHE BOOL "" FORCE)
|
||||
|
@@ -496,10 +496,6 @@ function(SETUP_LIBDIRS)
|
||||
link_directories(${ALEMBIC_LIBPATH})
|
||||
endif()
|
||||
|
||||
if(WITH_GMP)
|
||||
link_directories(${GMP_LIBPATH})
|
||||
endif()
|
||||
|
||||
if(WITH_GHOST_WAYLAND)
|
||||
link_directories(
|
||||
${wayland-client_LIBRARY_DIRS}
|
||||
|
@@ -373,9 +373,8 @@ if(WITH_CYCLES_OSL)
|
||||
list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
|
||||
find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
|
||||
find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
|
||||
find_path(OSL_SHADER_DIR NAMES stdosl.h PATHS ${CYCLES_OSL}/shaders)
|
||||
|
||||
if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER AND OSL_SHADER_DIR)
|
||||
if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
|
||||
set(OSL_FOUND TRUE)
|
||||
else()
|
||||
message(STATUS "OSL not found")
|
||||
@@ -407,15 +406,6 @@ if(WITH_TBB)
|
||||
find_package(TBB)
|
||||
endif()
|
||||
|
||||
if(WITH_GMP)
|
||||
find_package(GMP)
|
||||
|
||||
if(NOT GMP_FOUND)
|
||||
set(WITH_GMP OFF)
|
||||
message(STATUS "GMP not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CMake FindOpenMP doesn't know about AppleClang before 3.12, so provide custom flags.
|
||||
if(WITH_OPENMP)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0")
|
||||
@@ -440,8 +430,8 @@ if(WITH_OPENMP)
|
||||
endif()
|
||||
|
||||
if(WITH_XR_OPENXR)
|
||||
find_package(XR_OpenXR_SDK)
|
||||
if(NOT XR_OPENXR_SDK_FOUND)
|
||||
find_package(OpenXR-SDK)
|
||||
if(NOT OPENXR_SDK_FOUND)
|
||||
message(WARNING "OpenXR-SDK was not found, disabling WITH_XR_OPENXR")
|
||||
set(WITH_XR_OPENXR OFF)
|
||||
endif()
|
||||
|
@@ -234,10 +234,10 @@ endif()
|
||||
|
||||
if(WITH_CYCLES_OSL)
|
||||
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
|
||||
if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT)
|
||||
if(NOT OSL_ROOT)
|
||||
set(OSL_ROOT ${CYCLES_OSL})
|
||||
endif()
|
||||
find_package_wrapper(OSL)
|
||||
find_package_wrapper(OpenShadingLanguage)
|
||||
if(OSL_FOUND)
|
||||
if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")
|
||||
# Note: --whole-archive is needed to force loading of all symbols in liboslexec,
|
||||
@@ -427,17 +427,8 @@ if(WITH_TBB)
|
||||
find_package_wrapper(TBB)
|
||||
endif()
|
||||
|
||||
if(WITH_GMP)
|
||||
find_package(GMP)
|
||||
|
||||
if(NOT GMP_FOUND)
|
||||
set(WITH_GMP OFF)
|
||||
message(STATUS "GMP not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_XR_OPENXR)
|
||||
find_package(XR_OpenXR_SDK)
|
||||
find_package(XR-OpenXR-SDK)
|
||||
if(NOT XR_OPENXR_SDK_FOUND)
|
||||
message(WARNING "OpenXR-SDK not found, disabling WITH_XR_OPENXR")
|
||||
set(WITH_XR_OPENXR OFF)
|
||||
@@ -599,14 +590,6 @@ endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
|
||||
|
||||
# `maybe-uninitialized` is unreliable in release builds, but fine in debug builds.
|
||||
set(GCC_EXTRA_FLAGS_RELEASE "-Wno-maybe-uninitialized")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
unset(GCC_EXTRA_FLAGS_RELEASE)
|
||||
|
||||
if(WITH_LINKER_GOLD)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
|
||||
|
@@ -136,13 +136,6 @@ add_definitions(
|
||||
# MSVC11 needs _ALLOW_KEYWORD_MACROS to build
|
||||
add_definitions(-D_ALLOW_KEYWORD_MACROS)
|
||||
|
||||
# RTTI is on by default even without this switch
|
||||
# however having it in the CXX Flags makes it difficult
|
||||
# to remove for individual files that want to disable it
|
||||
# using the /GR- flag without generating a build warning
|
||||
# that both /GR and /GR- are specified.
|
||||
remove_cc_flag("/GR")
|
||||
|
||||
# We want to support Windows 7 level ABI
|
||||
add_definitions(-D_WIN32_WINNT=0x601)
|
||||
include(build_files/cmake/platform/platform_win32_bundle_crt.cmake)
|
||||
@@ -423,6 +416,9 @@ if(WITH_BOOST)
|
||||
if(WITH_INTERNATIONAL)
|
||||
list(APPEND boost_extra_libs locale)
|
||||
endif()
|
||||
if(WITH_OPENVDB)
|
||||
list(APPEND boost_extra_libs iostreams)
|
||||
endif()
|
||||
set(Boost_USE_STATIC_RUNTIME ON) # prefix lib
|
||||
set(Boost_USE_MULTITHREADED ON) # suffix -mt
|
||||
set(Boost_USE_STATIC_LIBS ON) # suffix -s
|
||||
@@ -528,11 +524,12 @@ if(WITH_OPENCOLORIO)
|
||||
endif()
|
||||
|
||||
if(WITH_OPENVDB)
|
||||
set(BLOSC_LIBRARIES optimized ${LIBDIR}/blosc/lib/libblosc.lib debug ${LIBDIR}/blosc/lib/libblosc_d.lib)
|
||||
set(OPENVDB ${LIBDIR}/openVDB)
|
||||
set(OPENVDB_LIBPATH ${OPENVDB}/lib)
|
||||
set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
|
||||
set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib )
|
||||
set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES)
|
||||
set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${BLOSC_LIBRARIES})
|
||||
set(OPENVDB_DEFINITIONS -DNOMINMAX -DOPENVDB_STATICLIB -D_USE_MATH_DEFINES)
|
||||
endif()
|
||||
|
||||
if(WITH_OPENIMAGEDENOISE)
|
||||
|
@@ -5,14 +5,6 @@ if(WITH_WINDOWS_BUNDLE_CRT)
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
|
||||
set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
|
||||
|
||||
# This sometimes can change when updates are installed and the compiler version
|
||||
# changes, so test if it exists and if not, give InstallRequiredSystemLibraries
|
||||
# another chance to figure out the path.
|
||||
if(MSVC_REDIST_DIR AND NOT EXISTS "${MSVC_REDIST_DIR}")
|
||||
unset(MSVC_REDIST_DIR CACHE)
|
||||
endif()
|
||||
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
||||
# Install the CRT to the blender.crt Sub folder.
|
||||
|
@@ -1,26 +0,0 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
File diff suppressed because it is too large
Load Diff
2
extern/audaspace/bindings/python/PySound.cpp
vendored
2
extern/audaspace/bindings/python/PySound.cpp
vendored
@@ -2016,7 +2016,7 @@ AUD_API Sound* checkSound(PyObject* sound)
|
||||
|
||||
bool initializeSound()
|
||||
{
|
||||
import_array1(false);
|
||||
import_array();
|
||||
|
||||
return PyType_Ready(&SoundType) >= 0;
|
||||
}
|
||||
|
22
extern/bullet2/CMakeLists.txt
vendored
22
extern/bullet2/CMakeLists.txt
vendored
@@ -18,16 +18,6 @@
|
||||
# All rights reserved.
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
# avoid noisy warnings
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
remove_cc_flag(
|
||||
"-Wall"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Use double precision to make simulations of small objects stable.
|
||||
add_definitions(-DBT_USE_DOUBLE_PRECISION)
|
||||
|
||||
set(INC
|
||||
.
|
||||
src
|
||||
@@ -44,6 +34,7 @@ set(SRC
|
||||
src/BulletCollision/BroadphaseCollision/btDbvt.cpp
|
||||
src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp
|
||||
src/BulletCollision/BroadphaseCollision/btDispatcher.cpp
|
||||
src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp
|
||||
src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp
|
||||
src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp
|
||||
src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp
|
||||
@@ -91,14 +82,12 @@ set(SRC
|
||||
src/BulletCollision/CollisionShapes/btCylinderShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btEmptyShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btMiniSDF.cpp
|
||||
src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp
|
||||
src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btSdfCollisionShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btShapeHull.cpp
|
||||
src/BulletCollision/CollisionShapes/btSphereShape.cpp
|
||||
src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp
|
||||
@@ -152,6 +141,7 @@ set(SRC
|
||||
src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp
|
||||
src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp
|
||||
src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp
|
||||
src/BulletDynamics/Dynamics/Bullet-C-API.cpp
|
||||
src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp
|
||||
src/BulletDynamics/Dynamics/btRigidBody.cpp
|
||||
src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp
|
||||
@@ -184,7 +174,6 @@ set(SRC
|
||||
src/LinearMath/btPolarDecomposition.cpp
|
||||
src/LinearMath/btQuickprof.cpp
|
||||
src/LinearMath/btSerializer.cpp
|
||||
src/LinearMath/btSerializer64.cpp
|
||||
src/LinearMath/btVector3.cpp
|
||||
|
||||
src/BulletCollision/BroadphaseCollision/btAxisSweep3.h
|
||||
@@ -194,6 +183,7 @@ set(SRC
|
||||
src/BulletCollision/BroadphaseCollision/btDbvt.h
|
||||
src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.h
|
||||
src/BulletCollision/BroadphaseCollision/btDispatcher.h
|
||||
src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
|
||||
src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.h
|
||||
src/BulletCollision/BroadphaseCollision/btOverlappingPairCallback.h
|
||||
src/BulletCollision/BroadphaseCollision/btQuantizedBvh.h
|
||||
@@ -247,14 +237,12 @@ set(SRC
|
||||
src/BulletCollision/CollisionShapes/btEmptyShape.h
|
||||
src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
|
||||
src/BulletCollision/CollisionShapes/btMaterial.h
|
||||
src/BulletCollision/CollisionShapes/btMiniSDF.h
|
||||
src/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
|
||||
src/BulletCollision/CollisionShapes/btMultiSphereShape.h
|
||||
src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
|
||||
src/BulletCollision/CollisionShapes/btOptimizedBvh.h
|
||||
src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
|
||||
src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
|
||||
src/BulletCollision/CollisionShapes/btSdfCollisionShape.h
|
||||
src/BulletCollision/CollisionShapes/btShapeHull.h
|
||||
src/BulletCollision/CollisionShapes/btSphereShape.h
|
||||
src/BulletCollision/CollisionShapes/btStaticPlaneShape.h
|
||||
@@ -416,6 +404,7 @@ set(SRC
|
||||
|
||||
src/btBulletCollisionCommon.h
|
||||
src/btBulletDynamicsCommon.h
|
||||
src/Bullet-C-Api.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
@@ -430,8 +419,7 @@ if(MSVC)
|
||||
# bullet is responsible for quite a few silly warnings
|
||||
# suppress all of them. Not great, but they really needed
|
||||
# to sort that out themselves.
|
||||
remove_cc_flag("/W3")
|
||||
add_c_flag("/W0")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
|
||||
endif()
|
||||
|
||||
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
368
extern/bullet2/patches/blender.patch
vendored
Normal file
368
extern/bullet2/patches/blender.patch
vendored
Normal file
@@ -0,0 +1,368 @@
|
||||
diff --git a/extern/bullet2/src/LinearMath/btVector3.h b/extern/bullet2/src/LinearMath/btVector3.h
|
||||
index 839b19c..3058195 100644
|
||||
--- a/extern/bullet2/src/LinearMath/btVector3.h
|
||||
+++ b/extern/bullet2/src/LinearMath/btVector3.h
|
||||
@@ -39,7 +39,7 @@ subject to the following restrictions:
|
||||
#endif
|
||||
|
||||
|
||||
-#define BT_SHUFFLE(x,y,z,w) ((w)<<6 | (z)<<4 | (y)<<2 | (x))
|
||||
+#define BT_SHUFFLE(x,y,z,w) (((w) << 6 | (z) << 4 | (y) << 2 | (x)) & 0xff)
|
||||
//#define bt_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) )
|
||||
#define bt_pshufd_ps( _a, _mask ) _mm_shuffle_ps((_a), (_a), (_mask) )
|
||||
#define bt_splat3_ps( _a, _i ) bt_pshufd_ps((_a), BT_SHUFFLE(_i,_i,_i, 3) )
|
||||
diff --git a/extern/bullet2/src/LinearMath/btScalar.h b/extern/bullet2/src/LinearMath/btScalar.h
|
||||
--- a/extern/bullet2/src/LinearMath/btScalar.h
|
||||
+++ b/extern/bullet2/src/LinearMath/btScalar.h
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
#ifndef BT_SCALAR_H
|
||||
#define BT_SCALAR_H
|
||||
+#if defined(_MSC_VER) && defined(__clang__) /* clang supplies it's own overloads already */
|
||||
+#define BT_NO_SIMD_OPERATOR_OVERLOADS
|
||||
+#endif
|
||||
|
||||
#ifdef BT_MANAGED_CODE
|
||||
//Aligned data types not supported in managed code
|
||||
@@ -83,7 +86,7 @@
|
||||
#ifdef BT_USE_SSE
|
||||
|
||||
#if (_MSC_FULL_VER >= 170050727)//Visual Studio 2012 can compile SSE4/FMA3 (but SSE4/FMA3 is not enabled by default)
|
||||
- #define BT_ALLOW_SSE4
|
||||
+ //#define BT_ALLOW_SSE4 //disable this cause blender targets sse2
|
||||
#endif //(_MSC_FULL_VER >= 160040219)
|
||||
|
||||
//BT_USE_SSE_IN_API is disabled under Windows by default, because
|
||||
@@ -102,7 +105,7 @@
|
||||
#endif //__MINGW32__
|
||||
|
||||
#ifdef BT_DEBUG
|
||||
- #ifdef _MSC_VER
|
||||
+ #if defined(_MSC_VER) && !defined(__clang__)
|
||||
#include <stdio.h>
|
||||
#define btAssert(x) { if(!(x)){printf("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak(); }}
|
||||
#else//_MSC_VER
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
||||
index be9eca6..ec40c96 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.h
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
/**
|
||||
- * @mainpage Bullet Documentation
|
||||
+ * @page Bullet Documentation
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
* Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp
|
||||
index 36dd043..57eb817 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp
|
||||
@@ -579,14 +579,10 @@ btCollisionShape* btCollisionWorldImporter::convertCollisionShape( btCollisionS
|
||||
btCompoundShapeData* compoundData = (btCompoundShapeData*)shapeData;
|
||||
btCompoundShape* compoundShape = createCompoundShape();
|
||||
|
||||
- btCompoundShapeChildData* childShapeDataArray = &compoundData->m_childShapePtr[0];
|
||||
-
|
||||
|
||||
btAlignedObjectArray<btCollisionShape*> childShapes;
|
||||
for (int i=0;i<compoundData->m_numChildShapes;i++)
|
||||
{
|
||||
- btCompoundShapeChildData* ptr = &compoundData->m_childShapePtr[i];
|
||||
-
|
||||
btCollisionShapeData* cd = compoundData->m_childShapePtr[i].m_childShape;
|
||||
|
||||
btCollisionShape* childShape = convertCollisionShape(cd);
|
||||
diff --git a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
|
||||
index 57fc119..31faf1d 100644
|
||||
--- a/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
|
||||
+++ b/extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp
|
||||
@@ -29,14 +29,11 @@ subject to the following restrictions:
|
||||
static btVector3
|
||||
getNormalizedVector(const btVector3& v)
|
||||
{
|
||||
- btScalar l = v.length();
|
||||
- btVector3 n = v;
|
||||
- if (l < SIMD_EPSILON) {
|
||||
- n.setValue(0,0,0);
|
||||
- } else {
|
||||
- n /= l;
|
||||
- }
|
||||
+ btVector3 n(0, 0, 0);
|
||||
|
||||
+ if (v.length() > SIMD_EPSILON) {
|
||||
+ n = v.normalized();
|
||||
+ }
|
||||
return n;
|
||||
}
|
||||
|
||||
diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
|
||||
index 27ccefe..8e4456e 100644
|
||||
--- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
|
||||
+++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btSolverBody.h
|
||||
@@ -37,8 +37,13 @@ struct btSimdScalar
|
||||
{
|
||||
|
||||
}
|
||||
-
|
||||
+/* workaround for clang 3.4 ( == apple clang 5.1 ) issue, friction would fail with forced inlining */
|
||||
+#if (defined(__clang__) && defined(__apple_build_version__) && (__clang_major__ == 5) && (__clang_minor__ == 1)) \
|
||||
+|| (defined(__clang__) && !defined(__apple_build_version__) && (__clang_major__ == 3) && (__clang_minor__ == 4))
|
||||
+ inline __attribute__ ((noinline)) btSimdScalar(float fl)
|
||||
+#else
|
||||
SIMD_FORCE_INLINE btSimdScalar(float fl)
|
||||
+#endif
|
||||
:m_vec128 (_mm_set1_ps(fl))
|
||||
{
|
||||
}
|
||||
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp
|
||||
index 5d62da7..fcd312e 100644
|
||||
--- a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp
|
||||
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBody.cpp
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "btMultiBodyJointFeedback.h"
|
||||
#include "LinearMath/btTransformUtil.h"
|
||||
#include "LinearMath/btSerializer.h"
|
||||
-#include "Bullet3Common/b3Logging.h"
|
||||
// #define INCLUDE_GYRO_TERM
|
||||
|
||||
///todo: determine if we need these options. If so, make a proper API, otherwise delete those globals
|
||||
@@ -1732,7 +1731,6 @@ void btMultiBody::goToSleep()
|
||||
|
||||
void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep)
|
||||
{
|
||||
- int num_links = getNumLinks();
|
||||
extern bool gDisableDeactivation;
|
||||
if (!m_canSleep || gDisableDeactivation)
|
||||
{
|
||||
diff --git a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp
|
||||
index 8a034b3..4f66b20 100644
|
||||
--- a/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp
|
||||
+++ b/extern/bullet2/src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp
|
||||
@@ -809,7 +809,6 @@ static void applyJointFeedback(btMultiBodyJacobianData& data, const btMultiBodyS
|
||||
}
|
||||
#endif
|
||||
|
||||
-#include "Bullet3Common/b3Logging.h"
|
||||
void btMultiBodyConstraintSolver::writeBackSolverBodyToMultiBody(btMultiBodySolverConstraint& c, btScalar deltaTime)
|
||||
{
|
||||
#if 1
|
||||
diff --git a/extern/bullet2/src/BulletSoftBody/btSparseSDF.h b/extern/bullet2/src/BulletSoftBody/btSparseSDF.h
|
||||
index bcf0c79..8992ddb 100644
|
||||
--- a/extern/bullet2/src/BulletSoftBody/btSparseSDF.h
|
||||
+++ b/extern/bullet2/src/BulletSoftBody/btSparseSDF.h
|
||||
@@ -185,7 +185,6 @@ struct btSparseSdf
|
||||
{
|
||||
++nprobes;
|
||||
++ncells;
|
||||
- int sz = sizeof(Cell);
|
||||
if (ncells>m_clampCells)
|
||||
{
|
||||
static int numResets=0;
|
||||
diff --git a/extern/bullet2/src/LinearMath/btConvexHullComputer.cpp b/extern/bullet2/src/LinearMath/btConvexHullComputer.cpp
|
||||
index d58ac95..3fd77df 100644
|
||||
--- a/extern/bullet2/src/LinearMath/btConvexHullComputer.cpp
|
||||
+++ b/extern/bullet2/src/LinearMath/btConvexHullComputer.cpp
|
||||
@@ -2665,6 +2665,7 @@ btScalar btConvexHullComputer::compute(const void* coords, bool doubleCoords, in
|
||||
}
|
||||
|
||||
vertices.resize(0);
|
||||
+ original_vertex_index.resize(0);
|
||||
edges.resize(0);
|
||||
faces.resize(0);
|
||||
|
||||
@@ -2675,6 +2676,7 @@ btScalar btConvexHullComputer::compute(const void* coords, bool doubleCoords, in
|
||||
{
|
||||
btConvexHullInternal::Vertex* v = oldVertices[copied];
|
||||
vertices.push_back(hull.getCoordinates(v));
|
||||
+ original_vertex_index.push_back(v->point.index);
|
||||
btConvexHullInternal::Edge* firstEdge = v->edges;
|
||||
if (firstEdge)
|
||||
{
|
||||
diff --git a/extern/bullet2/src/LinearMath/btConvexHullComputer.h b/extern/bullet2/src/LinearMath/btConvexHullComputer.h
|
||||
index 7240ac4..6871ce8 100644
|
||||
--- a/extern/bullet2/src/LinearMath/btConvexHullComputer.h
|
||||
+++ b/extern/bullet2/src/LinearMath/btConvexHullComputer.h
|
||||
@@ -67,6 +67,7 @@ class btConvexHullComputer
|
||||
|
||||
// Vertices of the output hull
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
+ btAlignedObjectArray<int> original_vertex_index;
|
||||
|
||||
// Edges of the output hull
|
||||
btAlignedObjectArray<Edge> edges;
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
|
||||
index 0623e35..02ea503 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexHullShape.cpp
|
||||
@@ -13,9 +13,9 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
-#if defined (_WIN32) || defined (__i386__)
|
||||
-#define BT_USE_SSE_IN_API
|
||||
-#endif
|
||||
+//#if defined (_WIN32) || defined (__i386__)
|
||||
+//#define BT_USE_SSE_IN_API
|
||||
+//#endif
|
||||
|
||||
#include "btConvexHullShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
|
||||
index b56d729..88018b4 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConvexShape.cpp
|
||||
@@ -13,9 +13,9 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
-#if defined (_WIN32) || defined (__i386__)
|
||||
-#define BT_USE_SSE_IN_API
|
||||
-#endif
|
||||
+//#if defined (_WIN32) || defined (__i386__)
|
||||
+//#define BT_USE_SSE_IN_API
|
||||
+//#endif
|
||||
|
||||
#include "btConvexShape.h"
|
||||
#include "btTriangleShape.h"
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
|
||||
index a7362ea..6abfdff 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
|
||||
@@ -13,9 +13,9 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
-#if defined (_WIN32) || defined (__i386__)
|
||||
-#define BT_USE_SSE_IN_API
|
||||
-#endif
|
||||
+//#if defined (_WIN32) || defined (__i386__)
|
||||
+//#define BT_USE_SSE_IN_API
|
||||
+//#endif
|
||||
|
||||
#include "btMultiSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
index 4854f37..9095c59 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
@@ -12,9 +12,9 @@ subject to the following restrictions:
|
||||
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.
|
||||
*/
|
||||
-#if defined (_WIN32) || defined (__i386__)
|
||||
-#define BT_USE_SSE_IN_API
|
||||
-#endif
|
||||
+//#if defined (_WIN32) || defined (__i386__)
|
||||
+//#define BT_USE_SSE_IN_API
|
||||
+//#endif
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
||||
#include "btConvexPolyhedron.h"
|
||||
diff --git a/extern/bullet2/src/LinearMath/btVector3.cpp b/extern/bullet2/src/LinearMath/btVector3.cpp
|
||||
index e05bdcc..dbcf2b6 100644
|
||||
--- a/extern/bullet2/src/LinearMath/btVector3.cpp
|
||||
+++ b/extern/bullet2/src/LinearMath/btVector3.cpp
|
||||
@@ -15,9 +15,9 @@
|
||||
This source version has been altered.
|
||||
*/
|
||||
|
||||
-#if defined (_WIN32) || defined (__i386__)
|
||||
-#define BT_USE_SSE_IN_API
|
||||
-#endif
|
||||
+//#if defined (_WIN32) || defined (__i386__)
|
||||
+//#define BT_USE_SSE_IN_API
|
||||
+//#endif
|
||||
|
||||
|
||||
#include "btVector3.h"
|
||||
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.cpp
|
||||
index e0e8bc7..a788268 100644
|
||||
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.cpp
|
||||
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.cpp
|
||||
@@ -425,50 +425,38 @@ void btRigidBody::setCenterOfMassTransform(const btTransform& xform)
|
||||
}
|
||||
|
||||
|
||||
+bool btRigidBody::checkCollideWithOverride(const btCollisionObject* co) const
|
||||
+{
|
||||
+ const btRigidBody* otherRb = btRigidBody::upcast(co);
|
||||
+ if (!otherRb)
|
||||
+ return true;
|
||||
+
|
||||
+ for (int i = 0; i < m_constraintRefs.size(); ++i)
|
||||
+ {
|
||||
+ const btTypedConstraint* c = m_constraintRefs[i];
|
||||
+ if (c->isEnabled())
|
||||
+ if (&c->getRigidBodyA() == otherRb || &c->getRigidBodyB() == otherRb)
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
|
||||
|
||||
|
||||
void btRigidBody::addConstraintRef(btTypedConstraint* c)
|
||||
{
|
||||
- ///disable collision with the 'other' body
|
||||
-
|
||||
int index = m_constraintRefs.findLinearSearch(c);
|
||||
- //don't add constraints that are already referenced
|
||||
- //btAssert(index == m_constraintRefs.size());
|
||||
if (index == m_constraintRefs.size())
|
||||
- {
|
||||
- m_constraintRefs.push_back(c);
|
||||
- btCollisionObject* colObjA = &c->getRigidBodyA();
|
||||
- btCollisionObject* colObjB = &c->getRigidBodyB();
|
||||
- if (colObjA == this)
|
||||
- {
|
||||
- colObjA->setIgnoreCollisionCheck(colObjB, true);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- colObjB->setIgnoreCollisionCheck(colObjA, true);
|
||||
- }
|
||||
- }
|
||||
+ m_constraintRefs.push_back(c);
|
||||
+
|
||||
+ m_checkCollideWith = true;
|
||||
}
|
||||
|
||||
void btRigidBody::removeConstraintRef(btTypedConstraint* c)
|
||||
{
|
||||
- int index = m_constraintRefs.findLinearSearch(c);
|
||||
- //don't remove constraints that are not referenced
|
||||
- if(index < m_constraintRefs.size())
|
||||
- {
|
||||
- m_constraintRefs.remove(c);
|
||||
- btCollisionObject* colObjA = &c->getRigidBodyA();
|
||||
- btCollisionObject* colObjB = &c->getRigidBodyB();
|
||||
- if (colObjA == this)
|
||||
- {
|
||||
- colObjA->setIgnoreCollisionCheck(colObjB, false);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- colObjB->setIgnoreCollisionCheck(colObjA, false);
|
||||
- }
|
||||
- }
|
||||
+ m_constraintRefs.remove(c);
|
||||
+ m_checkCollideWith = m_constraintRefs.size() > 0;
|
||||
}
|
||||
|
||||
int btRigidBody::calculateSerializeBufferSize() const
|
||||
diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
|
||||
index 1d177db..c2f8c5d 100644
|
||||
--- a/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
|
||||
+++ b/extern/bullet2/src/BulletDynamics/Dynamics/btRigidBody.h
|
||||
@@ -509,6 +509,8 @@ public:
|
||||
return (getBroadphaseProxy() != 0);
|
||||
}
|
||||
|
||||
+ virtual bool checkCollideWithOverride(const btCollisionObject* co) const;
|
||||
+
|
||||
void addConstraintRef(btTypedConstraint* c);
|
||||
void removeConstraintRef(btTypedConstraint* c);
|
||||
|
41
extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch
vendored
Normal file
41
extern/bullet2/patches/btPolyhedralConvexShape_Inertia_fix.patch
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
index 9095c592d87..b831e20c2f9 100644
|
||||
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
@@ -406,17 +406,17 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
|
||||
#ifndef __SPU__
|
||||
//not yet, return box inertia
|
||||
|
||||
- btScalar margin = getMargin();
|
||||
+ //btScalar margin = getMargin();
|
||||
|
||||
btTransform ident;
|
||||
ident.setIdentity();
|
||||
btVector3 aabbMin,aabbMax;
|
||||
- getAabb(ident,aabbMin,aabbMax);
|
||||
+ getAabb(ident,aabbMin,aabbMax); // This already contains the margin
|
||||
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
|
||||
|
||||
- btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
|
||||
- btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
|
||||
- btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
|
||||
+ btScalar lx=btScalar(2.)*(halfExtents.x());
|
||||
+ btScalar ly=btScalar(2.)*(halfExtents.y());
|
||||
+ btScalar lz=btScalar(2.)*(halfExtents.z());
|
||||
const btScalar x2 = lx*lx;
|
||||
const btScalar y2 = ly*ly;
|
||||
const btScalar z2 = lz*lz;
|
||||
@@ -476,10 +476,10 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
|
||||
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
|
||||
- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
|
||||
+ m_localAabbMax[i] = _supporting[i][i];
|
||||
+ m_localAabbMin[i] = _supporting[i + 3][i];
|
||||
}
|
||||
-
|
||||
+
|
||||
#else
|
||||
|
||||
for (int i=0;i<3;i++)
|
113
extern/bullet2/patches/inertia.patch
vendored
113
extern/bullet2/patches/inertia.patch
vendored
@@ -1,113 +0,0 @@
|
||||
From 1b4c1687748bafd3c521f454bfdfc89b3857b65e Mon Sep 17 00:00:00 2001
|
||||
From: David Vogel <Dadido3@aol.com>
|
||||
Date: Mon, 30 Mar 2020 19:45:23 +0200
|
||||
Subject: [PATCH 1/2] Fix inertia and margin calculation for
|
||||
btPolyhedralConvexShape
|
||||
|
||||
---
|
||||
.../CollisionShapes/btPolyhedralConvexShape.cpp | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
index 521ecfc760..e4bd7bb4d5 100644
|
||||
--- a/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
+++ b/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
|
||||
@@ -463,17 +463,17 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass, btVector3& in
|
||||
#ifndef __SPU__
|
||||
//not yet, return box inertia
|
||||
|
||||
- btScalar margin = getMargin();
|
||||
+ //btScalar margin = getMargin();
|
||||
|
||||
btTransform ident;
|
||||
ident.setIdentity();
|
||||
btVector3 aabbMin, aabbMax;
|
||||
- getAabb(ident, aabbMin, aabbMax);
|
||||
+ getAabb(ident, aabbMin, aabbMax); // This already contains the margin
|
||||
btVector3 halfExtents = (aabbMax - aabbMin) * btScalar(0.5);
|
||||
|
||||
- btScalar lx = btScalar(2.) * (halfExtents.x() + margin);
|
||||
- btScalar ly = btScalar(2.) * (halfExtents.y() + margin);
|
||||
- btScalar lz = btScalar(2.) * (halfExtents.z() + margin);
|
||||
+ btScalar lx = btScalar(2.) * (halfExtents.x());
|
||||
+ btScalar ly = btScalar(2.) * (halfExtents.y());
|
||||
+ btScalar lz = btScalar(2.) * (halfExtents.z());
|
||||
const btScalar x2 = lx * lx;
|
||||
const btScalar y2 = ly * ly;
|
||||
const btScalar z2 = lz * lz;
|
||||
@@ -529,8 +529,8 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
|
||||
- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
|
||||
+ m_localAabbMax[i] = _supporting[i][i];
|
||||
+ m_localAabbMin[i] = _supporting[i + 3][i];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
From 4b9a201d4c1b8cacbcdd68f9cdb55745caa6adc4 Mon Sep 17 00:00:00 2001
|
||||
From: David Vogel <Dadido3@aol.com>
|
||||
Date: Mon, 30 Mar 2020 20:43:55 +0200
|
||||
Subject: [PATCH 2/2] Fix margins
|
||||
|
||||
- Margin in ineratia calculation of btConeShape is already contained in the AABB
|
||||
- Remove margin from the cached AABB in btConvexInternalShape, as it is added on getAabb()
|
||||
---
|
||||
src/BulletCollision/CollisionShapes/btConeShape.h | 10 ++++------
|
||||
.../CollisionShapes/btConvexInternalShape.cpp | 8 ++++----
|
||||
2 files changed, 8 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/BulletCollision/CollisionShapes/btConeShape.h b/src/BulletCollision/CollisionShapes/btConeShape.h
|
||||
index 49f26bc4e5..ee6786c807 100644
|
||||
--- a/src/BulletCollision/CollisionShapes/btConeShape.h
|
||||
+++ b/src/BulletCollision/CollisionShapes/btConeShape.h
|
||||
@@ -56,15 +56,13 @@ btConeShape : public btConvexInternalShape
|
||||
btTransform identity;
|
||||
identity.setIdentity();
|
||||
btVector3 aabbMin, aabbMax;
|
||||
- getAabb(identity, aabbMin, aabbMax);
|
||||
|
||||
+ getAabb(identity, aabbMin, aabbMax); // This already contains the margin
|
||||
btVector3 halfExtents = (aabbMax - aabbMin) * btScalar(0.5);
|
||||
|
||||
- btScalar margin = getMargin();
|
||||
-
|
||||
- btScalar lx = btScalar(2.) * (halfExtents.x() + margin);
|
||||
- btScalar ly = btScalar(2.) * (halfExtents.y() + margin);
|
||||
- btScalar lz = btScalar(2.) * (halfExtents.z() + margin);
|
||||
+ btScalar lx = btScalar(2.) * (halfExtents.x());
|
||||
+ btScalar ly = btScalar(2.) * (halfExtents.y());
|
||||
+ btScalar lz = btScalar(2.) * (halfExtents.z());
|
||||
const btScalar x2 = lx * lx;
|
||||
const btScalar y2 = ly * ly;
|
||||
const btScalar z2 = lz * lz;
|
||||
diff --git a/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp b/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
|
||||
index 4d598b1aa2..b847f8f40f 100644
|
||||
--- a/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
|
||||
+++ b/src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
|
||||
@@ -117,8 +117,8 @@ void btConvexInternalAabbCachingShape::recalcLocalAabb()
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
- m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
|
||||
- m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
|
||||
+ m_localAabbMax[i] = _supporting[i][i];
|
||||
+ m_localAabbMin[i] = _supporting[i + 3][i];
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -128,10 +128,10 @@ void btConvexInternalAabbCachingShape::recalcLocalAabb()
|
||||
btVector3 vec(btScalar(0.), btScalar(0.), btScalar(0.));
|
||||
vec[i] = btScalar(1.);
|
||||
btVector3 tmp = localGetSupportingVertex(vec);
|
||||
- m_localAabbMax[i] = tmp[i] + m_collisionMargin;
|
||||
+ m_localAabbMax[i] = tmp[i];
|
||||
vec[i] = btScalar(-1.);
|
||||
tmp = localGetSupportingVertex(vec);
|
||||
- m_localAabbMin[i] = tmp[i] - m_collisionMargin;
|
||||
+ m_localAabbMin[i] = tmp[i];
|
||||
}
|
||||
#endif
|
||||
}
|
187
extern/bullet2/src/Bullet-C-Api.h
vendored
Normal file
187
extern/bullet2/src/Bullet-C-Api.h
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Draft high-level generic physics C-API. For low-level access, use the physics SDK native API's.
|
||||
Work in progress, functionality will be added on demand.
|
||||
|
||||
If possible, use the richer Bullet C++ API, by including "btBulletDynamicsCommon.h"
|
||||
*/
|
||||
|
||||
#ifndef BULLET_C_API_H
|
||||
#define BULLET_C_API_H
|
||||
|
||||
#define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
|
||||
|
||||
#ifdef BT_USE_DOUBLE_PRECISION
|
||||
typedef double plReal;
|
||||
#else
|
||||
typedef float plReal;
|
||||
#endif
|
||||
|
||||
typedef plReal plVector3[3];
|
||||
typedef plReal plQuaternion[4];
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Particular physics SDK (C-API) */
|
||||
PL_DECLARE_HANDLE(plPhysicsSdkHandle);
|
||||
|
||||
/** Dynamics world, belonging to some physics SDK (C-API)*/
|
||||
PL_DECLARE_HANDLE(plDynamicsWorldHandle);
|
||||
|
||||
/** Rigid Body that can be part of a Dynamics World (C-API)*/
|
||||
PL_DECLARE_HANDLE(plRigidBodyHandle);
|
||||
|
||||
/** Collision Shape/Geometry, property of a Rigid Body (C-API)*/
|
||||
PL_DECLARE_HANDLE(plCollisionShapeHandle);
|
||||
|
||||
/** Constraint for Rigid Bodies (C-API)*/
|
||||
PL_DECLARE_HANDLE(plConstraintHandle);
|
||||
|
||||
/** Triangle Mesh interface (C-API)*/
|
||||
PL_DECLARE_HANDLE(plMeshInterfaceHandle);
|
||||
|
||||
/** Broadphase Scene/Proxy Handles (C-API)*/
|
||||
PL_DECLARE_HANDLE(plCollisionBroadphaseHandle);
|
||||
PL_DECLARE_HANDLE(plBroadphaseProxyHandle);
|
||||
PL_DECLARE_HANDLE(plCollisionWorldHandle);
|
||||
|
||||
/**
|
||||
Create and Delete a Physics SDK
|
||||
*/
|
||||
|
||||
extern plPhysicsSdkHandle plNewBulletSdk(void); //this could be also another sdk, like ODE, PhysX etc.
|
||||
extern void plDeletePhysicsSdk(plPhysicsSdkHandle physicsSdk);
|
||||
|
||||
/** Collision World, not strictly necessary, you can also just create a Dynamics World with Rigid Bodies which internally manages the Collision World with Collision Objects */
|
||||
|
||||
typedef void(*btBroadphaseCallback)(void* clientData, void* object1,void* object2);
|
||||
|
||||
extern plCollisionBroadphaseHandle plCreateSapBroadphase(btBroadphaseCallback beginCallback,btBroadphaseCallback endCallback);
|
||||
|
||||
extern void plDestroyBroadphase(plCollisionBroadphaseHandle bp);
|
||||
|
||||
extern plBroadphaseProxyHandle plCreateProxy(plCollisionBroadphaseHandle bp, void* clientData, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ);
|
||||
|
||||
extern void plDestroyProxy(plCollisionBroadphaseHandle bp, plBroadphaseProxyHandle proxyHandle);
|
||||
|
||||
extern void plSetBoundingBox(plBroadphaseProxyHandle proxyHandle, plReal minX,plReal minY,plReal minZ, plReal maxX,plReal maxY, plReal maxZ);
|
||||
|
||||
/* todo: add pair cache support with queries like add/remove/find pair */
|
||||
|
||||
extern plCollisionWorldHandle plCreateCollisionWorld(plPhysicsSdkHandle physicsSdk);
|
||||
|
||||
/* todo: add/remove objects */
|
||||
|
||||
|
||||
/* Dynamics World */
|
||||
|
||||
extern plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdk);
|
||||
|
||||
extern void plDeleteDynamicsWorld(plDynamicsWorldHandle world);
|
||||
|
||||
extern void plStepSimulation(plDynamicsWorldHandle, plReal timeStep);
|
||||
|
||||
extern void plAddRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object);
|
||||
|
||||
extern void plRemoveRigidBody(plDynamicsWorldHandle world, plRigidBodyHandle object);
|
||||
|
||||
|
||||
/* Rigid Body */
|
||||
|
||||
extern plRigidBodyHandle plCreateRigidBody( void* user_data, float mass, plCollisionShapeHandle cshape );
|
||||
|
||||
extern void plDeleteRigidBody(plRigidBodyHandle body);
|
||||
|
||||
|
||||
/* Collision Shape definition */
|
||||
|
||||
extern plCollisionShapeHandle plNewSphereShape(plReal radius);
|
||||
extern plCollisionShapeHandle plNewBoxShape(plReal x, plReal y, plReal z);
|
||||
extern plCollisionShapeHandle plNewCapsuleShape(plReal radius, plReal height);
|
||||
extern plCollisionShapeHandle plNewConeShape(plReal radius, plReal height);
|
||||
extern plCollisionShapeHandle plNewCylinderShape(plReal radius, plReal height);
|
||||
extern plCollisionShapeHandle plNewCompoundShape(void);
|
||||
extern void plAddChildShape(plCollisionShapeHandle compoundShape,plCollisionShapeHandle childShape, plVector3 childPos,plQuaternion childOrn);
|
||||
|
||||
extern void plDeleteShape(plCollisionShapeHandle shape);
|
||||
|
||||
/* Convex Meshes */
|
||||
extern plCollisionShapeHandle plNewConvexHullShape(void);
|
||||
extern void plAddVertex(plCollisionShapeHandle convexHull, plReal x,plReal y,plReal z);
|
||||
/* Concave static triangle meshes */
|
||||
extern plMeshInterfaceHandle plNewMeshInterface(void);
|
||||
extern void plAddTriangle(plMeshInterfaceHandle meshHandle, plVector3 v0,plVector3 v1,plVector3 v2);
|
||||
extern plCollisionShapeHandle plNewStaticTriangleMeshShape(plMeshInterfaceHandle);
|
||||
|
||||
extern void plSetScaling(plCollisionShapeHandle shape, plVector3 scaling);
|
||||
|
||||
/* SOLID has Response Callback/Table/Management */
|
||||
/* PhysX has Triggers, User Callbacks and filtering */
|
||||
/* ODE has the typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); */
|
||||
|
||||
/* typedef void plUpdatedPositionCallback(void* userData, plRigidBodyHandle rbHandle, plVector3 pos); */
|
||||
/* typedef void plUpdatedOrientationCallback(void* userData, plRigidBodyHandle rbHandle, plQuaternion orientation); */
|
||||
|
||||
/* get world transform */
|
||||
extern void plGetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix);
|
||||
extern void plGetPosition(plRigidBodyHandle object,plVector3 position);
|
||||
extern void plGetOrientation(plRigidBodyHandle object,plQuaternion orientation);
|
||||
|
||||
/* set world transform (position/orientation) */
|
||||
extern void plSetPosition(plRigidBodyHandle object, const plVector3 position);
|
||||
extern void plSetOrientation(plRigidBodyHandle object, const plQuaternion orientation);
|
||||
extern void plSetEuler(plReal yaw,plReal pitch,plReal roll, plQuaternion orient);
|
||||
extern void plSetOpenGLMatrix(plRigidBodyHandle object, plReal* matrix);
|
||||
|
||||
typedef struct plRayCastResult {
|
||||
plRigidBodyHandle m_body;
|
||||
plCollisionShapeHandle m_shape;
|
||||
plVector3 m_positionWorld;
|
||||
plVector3 m_normalWorld;
|
||||
} plRayCastResult;
|
||||
|
||||
extern int plRayCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plRayCastResult res);
|
||||
|
||||
/* Sweep API */
|
||||
|
||||
/* extern plRigidBodyHandle plObjectCast(plDynamicsWorldHandle world, const plVector3 rayStart, const plVector3 rayEnd, plVector3 hitpoint, plVector3 normal); */
|
||||
|
||||
/* Continuous Collision Detection API */
|
||||
|
||||
// needed for source/blender/blenkernel/intern/collision.c
|
||||
double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float q2[3], float q3[3], float *pa, float *pb, float normal[3]);
|
||||
|
||||
|
||||
/* Convex Hull */
|
||||
PL_DECLARE_HANDLE(plConvexHull);
|
||||
plConvexHull plConvexHullCompute(float (*coords)[3], int count);
|
||||
void plConvexHullDelete(plConvexHull hull);
|
||||
int plConvexHullNumVertices(plConvexHull hull);
|
||||
int plConvexHullNumFaces(plConvexHull hull);
|
||||
void plConvexHullGetVertex(plConvexHull hull, int n, float coords[3], int *original_index);
|
||||
int plConvexHullGetFaceSize(plConvexHull hull, int n);
|
||||
void plConvexHullGetFaceVertices(plConvexHull hull, int n, int *vertices);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif //BULLET_C_API_H
|
||||
|
@@ -2,6 +2,7 @@
|
||||
//Bullet Continuous Collision Detection and Physics Library
|
||||
//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
|
||||
//
|
||||
// btAxisSweep3
|
||||
//
|
||||
@@ -18,15 +19,18 @@
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
#include "btAxisSweep3.h"
|
||||
|
||||
btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin, const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
|
||||
: btAxisSweep3Internal<unsigned short int>(worldAabbMin, worldAabbMax, 0xfffe, 0xffff, maxHandles, pairCache, disableRaycastAccelerator)
|
||||
|
||||
btAxisSweep3::btAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned short int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
|
||||
:btAxisSweep3Internal<unsigned short int>(worldAabbMin,worldAabbMax,0xfffe,0xffff,maxHandles,pairCache,disableRaycastAccelerator)
|
||||
{
|
||||
// 1 handle is reserved as sentinel
|
||||
btAssert(maxHandles > 1 && maxHandles < 32767);
|
||||
|
||||
}
|
||||
|
||||
bt32BitAxisSweep3::bt32BitAxisSweep3(const btVector3& worldAabbMin, const btVector3& worldAabbMax, unsigned int maxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
|
||||
: btAxisSweep3Internal<unsigned int>(worldAabbMin, worldAabbMax, 0xfffffffe, 0x7fffffff, maxHandles, pairCache, disableRaycastAccelerator)
|
||||
|
||||
bt32BitAxisSweep3::bt32BitAxisSweep3(const btVector3& worldAabbMin,const btVector3& worldAabbMax, unsigned int maxHandles , btOverlappingPairCache* pairCache , bool disableRaycastAccelerator)
|
||||
:btAxisSweep3Internal<unsigned int>(worldAabbMin,worldAabbMax,0xfffffffe,0x7fffffff,maxHandles,pairCache,disableRaycastAccelerator)
|
||||
{
|
||||
// 1 handle is reserved as sentinel
|
||||
btAssert(maxHandles > 1 && maxHandles < 2147483647);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,954 +0,0 @@
|
||||
//Bullet Continuous Collision Detection and Physics Library
|
||||
//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
//
|
||||
// btAxisSweep3.h
|
||||
//
|
||||
// Copyright (c) 2006 Simon Hobbs
|
||||
//
|
||||
// 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.
|
||||
|
||||
#ifndef BT_AXIS_SWEEP_3_INTERNAL_H
|
||||
#define BT_AXIS_SWEEP_3_INTERNAL_H
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "btOverlappingPairCache.h"
|
||||
#include "btBroadphaseInterface.h"
|
||||
#include "btBroadphaseProxy.h"
|
||||
#include "btOverlappingPairCallback.h"
|
||||
#include "btDbvtBroadphase.h"
|
||||
|
||||
//#define DEBUG_BROADPHASE 1
|
||||
#define USE_OVERLAP_TEST_ON_REMOVES 1
|
||||
|
||||
/// The internal templace class btAxisSweep3Internal implements the sweep and prune broadphase.
|
||||
/// It uses quantized integers to represent the begin and end points for each of the 3 axis.
|
||||
/// Dont use this class directly, use btAxisSweep3 or bt32BitAxisSweep3 instead.
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
class btAxisSweep3Internal : public btBroadphaseInterface
|
||||
{
|
||||
protected:
|
||||
BP_FP_INT_TYPE m_bpHandleMask;
|
||||
BP_FP_INT_TYPE m_handleSentinel;
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
class Edge
|
||||
{
|
||||
public:
|
||||
BP_FP_INT_TYPE m_pos; // low bit is min/max
|
||||
BP_FP_INT_TYPE m_handle;
|
||||
|
||||
BP_FP_INT_TYPE IsMax() const { return static_cast<BP_FP_INT_TYPE>(m_pos & 1); }
|
||||
};
|
||||
|
||||
public:
|
||||
class Handle : public btBroadphaseProxy
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
// indexes into the edge arrays
|
||||
BP_FP_INT_TYPE m_minEdges[3], m_maxEdges[3]; // 6 * 2 = 12
|
||||
// BP_FP_INT_TYPE m_uniqueId;
|
||||
btBroadphaseProxy* m_dbvtProxy; //for faster raycast
|
||||
//void* m_pOwner; this is now in btBroadphaseProxy.m_clientObject
|
||||
|
||||
SIMD_FORCE_INLINE void SetNextFree(BP_FP_INT_TYPE next) { m_minEdges[0] = next; }
|
||||
SIMD_FORCE_INLINE BP_FP_INT_TYPE GetNextFree() const { return m_minEdges[0]; }
|
||||
}; // 24 bytes + 24 for Edge structures = 44 bytes total per entry
|
||||
|
||||
protected:
|
||||
btVector3 m_worldAabbMin; // overall system bounds
|
||||
btVector3 m_worldAabbMax; // overall system bounds
|
||||
|
||||
btVector3 m_quantize; // scaling factor for quantization
|
||||
|
||||
BP_FP_INT_TYPE m_numHandles; // number of active handles
|
||||
BP_FP_INT_TYPE m_maxHandles; // max number of handles
|
||||
Handle* m_pHandles; // handles pool
|
||||
|
||||
BP_FP_INT_TYPE m_firstFreeHandle; // free handles list
|
||||
|
||||
Edge* m_pEdges[3]; // edge arrays for the 3 axes (each array has m_maxHandles * 2 + 2 sentinel entries)
|
||||
void* m_pEdgesRawPtr[3];
|
||||
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
|
||||
///btOverlappingPairCallback is an additional optional user callback for adding/removing overlapping pairs, similar interface to btOverlappingPairCache.
|
||||
btOverlappingPairCallback* m_userPairCallback;
|
||||
|
||||
bool m_ownsPairCache;
|
||||
|
||||
int m_invalidPair;
|
||||
|
||||
///additional dynamic aabb structure, used to accelerate ray cast queries.
|
||||
///can be disabled using a optional argument in the constructor
|
||||
btDbvtBroadphase* m_raycastAccelerator;
|
||||
btOverlappingPairCache* m_nullPairCache;
|
||||
|
||||
// allocation/deallocation
|
||||
BP_FP_INT_TYPE allocHandle();
|
||||
void freeHandle(BP_FP_INT_TYPE handle);
|
||||
|
||||
bool testOverlap2D(const Handle* pHandleA, const Handle* pHandleB, int axis0, int axis1);
|
||||
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
void debugPrintAxis(int axis, bool checkCardinality = true);
|
||||
#endif //DEBUG_BROADPHASE
|
||||
|
||||
//Overlap* AddOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB);
|
||||
//void RemoveOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB);
|
||||
|
||||
void sortMinDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps);
|
||||
void sortMinUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps);
|
||||
void sortMaxDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps);
|
||||
void sortMaxUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps);
|
||||
|
||||
public:
|
||||
btAxisSweep3Internal(const btVector3& worldAabbMin, const btVector3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel, BP_FP_INT_TYPE maxHandles = 16384, btOverlappingPairCache* pairCache = 0, bool disableRaycastAccelerator = false);
|
||||
|
||||
virtual ~btAxisSweep3Internal();
|
||||
|
||||
BP_FP_INT_TYPE getNumHandles() const
|
||||
{
|
||||
return m_numHandles;
|
||||
}
|
||||
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
BP_FP_INT_TYPE addHandle(const btVector3& aabbMin, const btVector3& aabbMax, void* pOwner, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher);
|
||||
void removeHandle(BP_FP_INT_TYPE handle, btDispatcher* dispatcher);
|
||||
void updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const { return m_pHandles + index; }
|
||||
|
||||
virtual void resetPool(btDispatcher* dispatcher);
|
||||
|
||||
void processAllOverlappingPairs(btOverlapCallback* callback);
|
||||
|
||||
//Broadphase Interface
|
||||
virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
virtual void getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const;
|
||||
|
||||
virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin = btVector3(0, 0, 0), const btVector3& aabbMax = btVector3(0, 0, 0));
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
|
||||
|
||||
void quantize(BP_FP_INT_TYPE* out, const btVector3& point, int isMax) const;
|
||||
///unQuantize should be conservative: aabbMin/aabbMax should be larger then 'getAabb' result
|
||||
void unQuantize(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const;
|
||||
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1);
|
||||
|
||||
btOverlappingPairCache* getOverlappingPairCache()
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
|
||||
void setOverlappingPairUserCallback(btOverlappingPairCallback* pairCallback)
|
||||
{
|
||||
m_userPairCallback = pairCallback;
|
||||
}
|
||||
const btOverlappingPairCallback* getOverlappingPairUserCallback() const
|
||||
{
|
||||
return m_userPairCallback;
|
||||
}
|
||||
|
||||
///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
|
||||
///will add some transform later
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin, btVector3& aabbMax) const
|
||||
{
|
||||
aabbMin = m_worldAabbMin;
|
||||
aabbMax = m_worldAabbMax;
|
||||
}
|
||||
|
||||
virtual void printStats()
|
||||
{
|
||||
/* printf("btAxisSweep3.h\n");
|
||||
printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
|
||||
printf("aabbMin=%f,%f,%f,aabbMax=%f,%f,%f\n",m_worldAabbMin.getX(),m_worldAabbMin.getY(),m_worldAabbMin.getZ(),
|
||||
m_worldAabbMax.getX(),m_worldAabbMax.getY(),m_worldAabbMax.getZ());
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
#include <stdio.h>
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3<BP_FP_INT_TYPE>::debugPrintAxis(int axis, bool checkCardinality)
|
||||
{
|
||||
int numEdges = m_pHandles[0].m_maxEdges[axis];
|
||||
printf("SAP Axis %d, numEdges=%d\n", axis, numEdges);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numEdges + 1; i++)
|
||||
{
|
||||
Edge* pEdge = m_pEdges[axis] + i;
|
||||
Handle* pHandlePrev = getHandle(pEdge->m_handle);
|
||||
int handleIndex = pEdge->IsMax() ? pHandlePrev->m_maxEdges[axis] : pHandlePrev->m_minEdges[axis];
|
||||
char beginOrEnd;
|
||||
beginOrEnd = pEdge->IsMax() ? 'E' : 'B';
|
||||
printf(" [%c,h=%d,p=%x,i=%d]\n", beginOrEnd, pEdge->m_handle, pEdge->m_pos, handleIndex);
|
||||
}
|
||||
|
||||
if (checkCardinality)
|
||||
btAssert(numEdges == m_numHandles * 2 + 1);
|
||||
}
|
||||
#endif //DEBUG_BROADPHASE
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
btBroadphaseProxy* btAxisSweep3Internal<BP_FP_INT_TYPE>::createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher)
|
||||
{
|
||||
(void)shapeType;
|
||||
BP_FP_INT_TYPE handleId = addHandle(aabbMin, aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher);
|
||||
|
||||
Handle* handle = getHandle(handleId);
|
||||
|
||||
if (m_raycastAccelerator)
|
||||
{
|
||||
btBroadphaseProxy* rayProxy = m_raycastAccelerator->createProxy(aabbMin, aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher);
|
||||
handle->m_dbvtProxy = rayProxy;
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher)
|
||||
{
|
||||
Handle* handle = static_cast<Handle*>(proxy);
|
||||
if (m_raycastAccelerator)
|
||||
m_raycastAccelerator->destroyProxy(handle->m_dbvtProxy, dispatcher);
|
||||
removeHandle(static_cast<BP_FP_INT_TYPE>(handle->m_uniqueId), dispatcher);
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher)
|
||||
{
|
||||
Handle* handle = static_cast<Handle*>(proxy);
|
||||
handle->m_aabbMin = aabbMin;
|
||||
handle->m_aabbMax = aabbMax;
|
||||
updateHandle(static_cast<BP_FP_INT_TYPE>(handle->m_uniqueId), aabbMin, aabbMax, dispatcher);
|
||||
if (m_raycastAccelerator)
|
||||
m_raycastAccelerator->setAabb(handle->m_dbvtProxy, aabbMin, aabbMax, dispatcher);
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::rayTest(const btVector3& rayFrom, const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin, const btVector3& aabbMax)
|
||||
{
|
||||
if (m_raycastAccelerator)
|
||||
{
|
||||
m_raycastAccelerator->rayTest(rayFrom, rayTo, rayCallback, aabbMin, aabbMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
//choose axis?
|
||||
BP_FP_INT_TYPE axis = 0;
|
||||
//for each proxy
|
||||
for (BP_FP_INT_TYPE i = 1; i < m_numHandles * 2 + 1; i++)
|
||||
{
|
||||
if (m_pEdges[axis][i].IsMax())
|
||||
{
|
||||
rayCallback.process(getHandle(m_pEdges[axis][i].m_handle));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback)
|
||||
{
|
||||
if (m_raycastAccelerator)
|
||||
{
|
||||
m_raycastAccelerator->aabbTest(aabbMin, aabbMax, callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
//choose axis?
|
||||
BP_FP_INT_TYPE axis = 0;
|
||||
//for each proxy
|
||||
for (BP_FP_INT_TYPE i = 1; i < m_numHandles * 2 + 1; i++)
|
||||
{
|
||||
if (m_pEdges[axis][i].IsMax())
|
||||
{
|
||||
Handle* handle = getHandle(m_pEdges[axis][i].m_handle);
|
||||
if (TestAabbAgainstAabb2(aabbMin, aabbMax, handle->m_aabbMin, handle->m_aabbMax))
|
||||
{
|
||||
callback.process(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const
|
||||
{
|
||||
Handle* pHandle = static_cast<Handle*>(proxy);
|
||||
aabbMin = pHandle->m_aabbMin;
|
||||
aabbMax = pHandle->m_aabbMax;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::unQuantize(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const
|
||||
{
|
||||
Handle* pHandle = static_cast<Handle*>(proxy);
|
||||
|
||||
unsigned short vecInMin[3];
|
||||
unsigned short vecInMax[3];
|
||||
|
||||
vecInMin[0] = m_pEdges[0][pHandle->m_minEdges[0]].m_pos;
|
||||
vecInMax[0] = m_pEdges[0][pHandle->m_maxEdges[0]].m_pos + 1;
|
||||
vecInMin[1] = m_pEdges[1][pHandle->m_minEdges[1]].m_pos;
|
||||
vecInMax[1] = m_pEdges[1][pHandle->m_maxEdges[1]].m_pos + 1;
|
||||
vecInMin[2] = m_pEdges[2][pHandle->m_minEdges[2]].m_pos;
|
||||
vecInMax[2] = m_pEdges[2][pHandle->m_maxEdges[2]].m_pos + 1;
|
||||
|
||||
aabbMin.setValue((btScalar)(vecInMin[0]) / (m_quantize.getX()), (btScalar)(vecInMin[1]) / (m_quantize.getY()), (btScalar)(vecInMin[2]) / (m_quantize.getZ()));
|
||||
aabbMin += m_worldAabbMin;
|
||||
|
||||
aabbMax.setValue((btScalar)(vecInMax[0]) / (m_quantize.getX()), (btScalar)(vecInMax[1]) / (m_quantize.getY()), (btScalar)(vecInMax[2]) / (m_quantize.getZ()));
|
||||
aabbMax += m_worldAabbMin;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
btAxisSweep3Internal<BP_FP_INT_TYPE>::btAxisSweep3Internal(const btVector3& worldAabbMin, const btVector3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel, BP_FP_INT_TYPE userMaxHandles, btOverlappingPairCache* pairCache, bool disableRaycastAccelerator)
|
||||
: m_bpHandleMask(handleMask),
|
||||
m_handleSentinel(handleSentinel),
|
||||
m_pairCache(pairCache),
|
||||
m_userPairCallback(0),
|
||||
m_ownsPairCache(false),
|
||||
m_invalidPair(0),
|
||||
m_raycastAccelerator(0)
|
||||
{
|
||||
BP_FP_INT_TYPE maxHandles = static_cast<BP_FP_INT_TYPE>(userMaxHandles + 1); //need to add one sentinel handle
|
||||
|
||||
if (!m_pairCache)
|
||||
{
|
||||
void* ptr = btAlignedAlloc(sizeof(btHashedOverlappingPairCache), 16);
|
||||
m_pairCache = new (ptr) btHashedOverlappingPairCache();
|
||||
m_ownsPairCache = true;
|
||||
}
|
||||
|
||||
if (!disableRaycastAccelerator)
|
||||
{
|
||||
m_nullPairCache = new (btAlignedAlloc(sizeof(btNullPairCache), 16)) btNullPairCache();
|
||||
m_raycastAccelerator = new (btAlignedAlloc(sizeof(btDbvtBroadphase), 16)) btDbvtBroadphase(m_nullPairCache); //m_pairCache);
|
||||
m_raycastAccelerator->m_deferedcollide = true; //don't add/remove pairs
|
||||
}
|
||||
|
||||
//btAssert(bounds.HasVolume());
|
||||
|
||||
// init bounds
|
||||
m_worldAabbMin = worldAabbMin;
|
||||
m_worldAabbMax = worldAabbMax;
|
||||
|
||||
btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
|
||||
|
||||
BP_FP_INT_TYPE maxInt = m_handleSentinel;
|
||||
|
||||
m_quantize = btVector3(btScalar(maxInt), btScalar(maxInt), btScalar(maxInt)) / aabbSize;
|
||||
|
||||
// allocate handles buffer, using btAlignedAlloc, and put all handles on free list
|
||||
m_pHandles = new Handle[maxHandles];
|
||||
|
||||
m_maxHandles = maxHandles;
|
||||
m_numHandles = 0;
|
||||
|
||||
// handle 0 is reserved as the null index, and is also used as the sentinel
|
||||
m_firstFreeHandle = 1;
|
||||
{
|
||||
for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < maxHandles; i++)
|
||||
m_pHandles[i].SetNextFree(static_cast<BP_FP_INT_TYPE>(i + 1));
|
||||
m_pHandles[maxHandles - 1].SetNextFree(0);
|
||||
}
|
||||
|
||||
{
|
||||
// allocate edge buffers
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
m_pEdgesRawPtr[i] = btAlignedAlloc(sizeof(Edge) * maxHandles * 2, 16);
|
||||
m_pEdges[i] = new (m_pEdgesRawPtr[i]) Edge[maxHandles * 2];
|
||||
}
|
||||
}
|
||||
//removed overlap management
|
||||
|
||||
// make boundary sentinels
|
||||
|
||||
m_pHandles[0].m_clientObject = 0;
|
||||
|
||||
for (int axis = 0; axis < 3; axis++)
|
||||
{
|
||||
m_pHandles[0].m_minEdges[axis] = 0;
|
||||
m_pHandles[0].m_maxEdges[axis] = 1;
|
||||
|
||||
m_pEdges[axis][0].m_pos = 0;
|
||||
m_pEdges[axis][0].m_handle = 0;
|
||||
m_pEdges[axis][1].m_pos = m_handleSentinel;
|
||||
m_pEdges[axis][1].m_handle = 0;
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
debugPrintAxis(axis);
|
||||
#endif //DEBUG_BROADPHASE
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
btAxisSweep3Internal<BP_FP_INT_TYPE>::~btAxisSweep3Internal()
|
||||
{
|
||||
if (m_raycastAccelerator)
|
||||
{
|
||||
m_nullPairCache->~btOverlappingPairCache();
|
||||
btAlignedFree(m_nullPairCache);
|
||||
m_raycastAccelerator->~btDbvtBroadphase();
|
||||
btAlignedFree(m_raycastAccelerator);
|
||||
}
|
||||
|
||||
for (int i = 2; i >= 0; i--)
|
||||
{
|
||||
btAlignedFree(m_pEdgesRawPtr[i]);
|
||||
}
|
||||
delete[] m_pHandles;
|
||||
|
||||
if (m_ownsPairCache)
|
||||
{
|
||||
m_pairCache->~btOverlappingPairCache();
|
||||
btAlignedFree(m_pairCache);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::quantize(BP_FP_INT_TYPE* out, const btVector3& point, int isMax) const
|
||||
{
|
||||
#ifdef OLD_CLAMPING_METHOD
|
||||
///problem with this clamping method is that the floating point during quantization might still go outside the range [(0|isMax) .. (m_handleSentinel&m_bpHandleMask]|isMax]
|
||||
///see http://code.google.com/p/bullet/issues/detail?id=87
|
||||
btVector3 clampedPoint(point);
|
||||
clampedPoint.setMax(m_worldAabbMin);
|
||||
clampedPoint.setMin(m_worldAabbMax);
|
||||
btVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize;
|
||||
out[0] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getX() & m_bpHandleMask) | isMax);
|
||||
out[1] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getY() & m_bpHandleMask) | isMax);
|
||||
out[2] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getZ() & m_bpHandleMask) | isMax);
|
||||
#else
|
||||
btVector3 v = (point - m_worldAabbMin) * m_quantize;
|
||||
out[0] = (v[0] <= 0) ? (BP_FP_INT_TYPE)isMax : (v[0] >= m_handleSentinel) ? (BP_FP_INT_TYPE)((m_handleSentinel & m_bpHandleMask) | isMax) : (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[0] & m_bpHandleMask) | isMax);
|
||||
out[1] = (v[1] <= 0) ? (BP_FP_INT_TYPE)isMax : (v[1] >= m_handleSentinel) ? (BP_FP_INT_TYPE)((m_handleSentinel & m_bpHandleMask) | isMax) : (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[1] & m_bpHandleMask) | isMax);
|
||||
out[2] = (v[2] <= 0) ? (BP_FP_INT_TYPE)isMax : (v[2] >= m_handleSentinel) ? (BP_FP_INT_TYPE)((m_handleSentinel & m_bpHandleMask) | isMax) : (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v[2] & m_bpHandleMask) | isMax);
|
||||
#endif //OLD_CLAMPING_METHOD
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle()
|
||||
{
|
||||
btAssert(m_firstFreeHandle);
|
||||
|
||||
BP_FP_INT_TYPE handle = m_firstFreeHandle;
|
||||
m_firstFreeHandle = getHandle(handle)->GetNextFree();
|
||||
m_numHandles++;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle)
|
||||
{
|
||||
btAssert(handle > 0 && handle < m_maxHandles);
|
||||
|
||||
getHandle(handle)->SetNextFree(m_firstFreeHandle);
|
||||
m_firstFreeHandle = handle;
|
||||
|
||||
m_numHandles--;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btVector3& aabbMin, const btVector3& aabbMax, void* pOwner, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher)
|
||||
{
|
||||
// quantize the bounds
|
||||
BP_FP_INT_TYPE min[3], max[3];
|
||||
quantize(min, aabbMin, 0);
|
||||
quantize(max, aabbMax, 1);
|
||||
|
||||
// allocate a handle
|
||||
BP_FP_INT_TYPE handle = allocHandle();
|
||||
|
||||
Handle* pHandle = getHandle(handle);
|
||||
|
||||
pHandle->m_uniqueId = static_cast<int>(handle);
|
||||
//pHandle->m_pOverlaps = 0;
|
||||
pHandle->m_clientObject = pOwner;
|
||||
pHandle->m_collisionFilterGroup = collisionFilterGroup;
|
||||
pHandle->m_collisionFilterMask = collisionFilterMask;
|
||||
|
||||
// compute current limit of edge arrays
|
||||
BP_FP_INT_TYPE limit = static_cast<BP_FP_INT_TYPE>(m_numHandles * 2);
|
||||
|
||||
// insert new edges just inside the max boundary edge
|
||||
for (BP_FP_INT_TYPE axis = 0; axis < 3; axis++)
|
||||
{
|
||||
m_pHandles[0].m_maxEdges[axis] += 2;
|
||||
|
||||
m_pEdges[axis][limit + 1] = m_pEdges[axis][limit - 1];
|
||||
|
||||
m_pEdges[axis][limit - 1].m_pos = min[axis];
|
||||
m_pEdges[axis][limit - 1].m_handle = handle;
|
||||
|
||||
m_pEdges[axis][limit].m_pos = max[axis];
|
||||
m_pEdges[axis][limit].m_handle = handle;
|
||||
|
||||
pHandle->m_minEdges[axis] = static_cast<BP_FP_INT_TYPE>(limit - 1);
|
||||
pHandle->m_maxEdges[axis] = limit;
|
||||
}
|
||||
|
||||
// now sort the new edges to their correct position
|
||||
sortMinDown(0, pHandle->m_minEdges[0], dispatcher, false);
|
||||
sortMaxDown(0, pHandle->m_maxEdges[0], dispatcher, false);
|
||||
sortMinDown(1, pHandle->m_minEdges[1], dispatcher, false);
|
||||
sortMaxDown(1, pHandle->m_maxEdges[1], dispatcher, false);
|
||||
sortMinDown(2, pHandle->m_minEdges[2], dispatcher, true);
|
||||
sortMaxDown(2, pHandle->m_maxEdges[2], dispatcher, true);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::removeHandle(BP_FP_INT_TYPE handle, btDispatcher* dispatcher)
|
||||
{
|
||||
Handle* pHandle = getHandle(handle);
|
||||
|
||||
//explicitly remove the pairs containing the proxy
|
||||
//we could do it also in the sortMinUp (passing true)
|
||||
///@todo: compare performance
|
||||
if (!m_pairCache->hasDeferredRemoval())
|
||||
{
|
||||
m_pairCache->removeOverlappingPairsContainingProxy(pHandle, dispatcher);
|
||||
}
|
||||
|
||||
// compute current limit of edge arrays
|
||||
int limit = static_cast<int>(m_numHandles * 2);
|
||||
|
||||
int axis;
|
||||
|
||||
for (axis = 0; axis < 3; axis++)
|
||||
{
|
||||
m_pHandles[0].m_maxEdges[axis] -= 2;
|
||||
}
|
||||
|
||||
// remove the edges by sorting them up to the end of the list
|
||||
for (axis = 0; axis < 3; axis++)
|
||||
{
|
||||
Edge* pEdges = m_pEdges[axis];
|
||||
BP_FP_INT_TYPE max = pHandle->m_maxEdges[axis];
|
||||
pEdges[max].m_pos = m_handleSentinel;
|
||||
|
||||
sortMaxUp(axis, max, dispatcher, false);
|
||||
|
||||
BP_FP_INT_TYPE i = pHandle->m_minEdges[axis];
|
||||
pEdges[i].m_pos = m_handleSentinel;
|
||||
|
||||
sortMinUp(axis, i, dispatcher, false);
|
||||
|
||||
pEdges[limit - 1].m_handle = 0;
|
||||
pEdges[limit - 1].m_pos = m_handleSentinel;
|
||||
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
debugPrintAxis(axis, false);
|
||||
#endif //DEBUG_BROADPHASE
|
||||
}
|
||||
|
||||
// free the handle
|
||||
freeHandle(handle);
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
if (m_numHandles == 0)
|
||||
{
|
||||
m_firstFreeHandle = 1;
|
||||
{
|
||||
for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < m_maxHandles; i++)
|
||||
m_pHandles[i].SetNextFree(static_cast<BP_FP_INT_TYPE>(i + 1));
|
||||
m_pHandles[m_maxHandles - 1].SetNextFree(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
if (m_pairCache->hasDeferredRemoval())
|
||||
{
|
||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
|
||||
int i;
|
||||
|
||||
btBroadphasePair previousPair;
|
||||
previousPair.m_pProxy0 = 0;
|
||||
previousPair.m_pProxy1 = 0;
|
||||
previousPair.m_algorithm = 0;
|
||||
|
||||
for (i = 0; i < overlappingPairArray.size(); i++)
|
||||
{
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
bool isDuplicate = (pair == previousPair);
|
||||
|
||||
previousPair = pair;
|
||||
|
||||
bool needsRemoval = false;
|
||||
|
||||
if (!isDuplicate)
|
||||
{
|
||||
///important to use an AABB test that is consistent with the broadphase
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0, pair.m_pProxy1);
|
||||
|
||||
if (hasOverlap)
|
||||
{
|
||||
needsRemoval = false; //callback->processOverlap(pair);
|
||||
}
|
||||
else
|
||||
{
|
||||
needsRemoval = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//remove duplicate
|
||||
needsRemoval = true;
|
||||
//should have no algorithm
|
||||
btAssert(!pair.m_algorithm);
|
||||
}
|
||||
|
||||
if (needsRemoval)
|
||||
{
|
||||
m_pairCache->cleanOverlappingPair(pair, dispatcher);
|
||||
|
||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
// m_overlappingPairArray.pop_back();
|
||||
pair.m_pProxy0 = 0;
|
||||
pair.m_pProxy1 = 0;
|
||||
m_invalidPair++;
|
||||
}
|
||||
}
|
||||
|
||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||
#define CLEAN_INVALID_PAIRS 1
|
||||
#ifdef CLEAN_INVALID_PAIRS
|
||||
|
||||
//perform a sort, to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif //CLEAN_INVALID_PAIRS
|
||||
|
||||
//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
bool btAxisSweep3Internal<BP_FP_INT_TYPE>::testAabbOverlap(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||
{
|
||||
const Handle* pHandleA = static_cast<Handle*>(proxy0);
|
||||
const Handle* pHandleB = static_cast<Handle*>(proxy1);
|
||||
|
||||
//optimization 1: check the array index (memory address), instead of the m_pos
|
||||
|
||||
for (int axis = 0; axis < 3; axis++)
|
||||
{
|
||||
if (pHandleA->m_maxEdges[axis] < pHandleB->m_minEdges[axis] ||
|
||||
pHandleB->m_maxEdges[axis] < pHandleA->m_minEdges[axis])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
bool btAxisSweep3Internal<BP_FP_INT_TYPE>::testOverlap2D(const Handle* pHandleA, const Handle* pHandleB, int axis0, int axis1)
|
||||
{
|
||||
//optimization 1: check the array index (memory address), instead of the m_pos
|
||||
|
||||
if (pHandleA->m_maxEdges[axis0] < pHandleB->m_minEdges[axis0] ||
|
||||
pHandleB->m_maxEdges[axis0] < pHandleA->m_minEdges[axis0] ||
|
||||
pHandleA->m_maxEdges[axis1] < pHandleB->m_minEdges[axis1] ||
|
||||
pHandleB->m_maxEdges[axis1] < pHandleA->m_minEdges[axis1])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher)
|
||||
{
|
||||
// btAssert(bounds.IsFinite());
|
||||
//btAssert(bounds.HasVolume());
|
||||
|
||||
Handle* pHandle = getHandle(handle);
|
||||
|
||||
// quantize the new bounds
|
||||
BP_FP_INT_TYPE min[3], max[3];
|
||||
quantize(min, aabbMin, 0);
|
||||
quantize(max, aabbMax, 1);
|
||||
|
||||
// update changed edges
|
||||
for (int axis = 0; axis < 3; axis++)
|
||||
{
|
||||
BP_FP_INT_TYPE emin = pHandle->m_minEdges[axis];
|
||||
BP_FP_INT_TYPE emax = pHandle->m_maxEdges[axis];
|
||||
|
||||
int dmin = (int)min[axis] - (int)m_pEdges[axis][emin].m_pos;
|
||||
int dmax = (int)max[axis] - (int)m_pEdges[axis][emax].m_pos;
|
||||
|
||||
m_pEdges[axis][emin].m_pos = min[axis];
|
||||
m_pEdges[axis][emax].m_pos = max[axis];
|
||||
|
||||
// expand (only adds overlaps)
|
||||
if (dmin < 0)
|
||||
sortMinDown(axis, emin, dispatcher, true);
|
||||
|
||||
if (dmax > 0)
|
||||
sortMaxUp(axis, emax, dispatcher, true);
|
||||
|
||||
// shrink (only removes overlaps)
|
||||
if (dmin > 0)
|
||||
sortMinUp(axis, emin, dispatcher, true);
|
||||
|
||||
if (dmax < 0)
|
||||
sortMaxDown(axis, emax, dispatcher, true);
|
||||
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
debugPrintAxis(axis);
|
||||
#endif //DEBUG_BROADPHASE
|
||||
}
|
||||
}
|
||||
|
||||
// sorting a min edge downwards can only ever *add* overlaps
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMinDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* /* dispatcher */, bool updateOverlaps)
|
||||
{
|
||||
Edge* pEdge = m_pEdges[axis] + edge;
|
||||
Edge* pPrev = pEdge - 1;
|
||||
Handle* pHandleEdge = getHandle(pEdge->m_handle);
|
||||
|
||||
while (pEdge->m_pos < pPrev->m_pos)
|
||||
{
|
||||
Handle* pHandlePrev = getHandle(pPrev->m_handle);
|
||||
|
||||
if (pPrev->IsMax())
|
||||
{
|
||||
// if previous edge is a maximum check the bounds and add an overlap if necessary
|
||||
const int axis1 = (1 << axis) & 3;
|
||||
const int axis2 = (1 << axis1) & 3;
|
||||
if (updateOverlaps && testOverlap2D(pHandleEdge, pHandlePrev, axis1, axis2))
|
||||
{
|
||||
m_pairCache->addOverlappingPair(pHandleEdge, pHandlePrev);
|
||||
if (m_userPairCallback)
|
||||
m_userPairCallback->addOverlappingPair(pHandleEdge, pHandlePrev);
|
||||
|
||||
//AddOverlap(pEdge->m_handle, pPrev->m_handle);
|
||||
}
|
||||
|
||||
// update edge reference in other handle
|
||||
pHandlePrev->m_maxEdges[axis]++;
|
||||
}
|
||||
else
|
||||
pHandlePrev->m_minEdges[axis]++;
|
||||
|
||||
pHandleEdge->m_minEdges[axis]--;
|
||||
|
||||
// swap the edges
|
||||
Edge swap = *pEdge;
|
||||
*pEdge = *pPrev;
|
||||
*pPrev = swap;
|
||||
|
||||
// decrement
|
||||
pEdge--;
|
||||
pPrev--;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
debugPrintAxis(axis);
|
||||
#endif //DEBUG_BROADPHASE
|
||||
}
|
||||
|
||||
// sorting a min edge upwards can only ever *remove* overlaps
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMinUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps)
|
||||
{
|
||||
Edge* pEdge = m_pEdges[axis] + edge;
|
||||
Edge* pNext = pEdge + 1;
|
||||
Handle* pHandleEdge = getHandle(pEdge->m_handle);
|
||||
|
||||
while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos))
|
||||
{
|
||||
Handle* pHandleNext = getHandle(pNext->m_handle);
|
||||
|
||||
if (pNext->IsMax())
|
||||
{
|
||||
Handle* handle0 = getHandle(pEdge->m_handle);
|
||||
Handle* handle1 = getHandle(pNext->m_handle);
|
||||
const int axis1 = (1 << axis) & 3;
|
||||
const int axis2 = (1 << axis1) & 3;
|
||||
|
||||
// if next edge is maximum remove any overlap between the two handles
|
||||
if (updateOverlaps
|
||||
#ifdef USE_OVERLAP_TEST_ON_REMOVES
|
||||
&& testOverlap2D(handle0, handle1, axis1, axis2)
|
||||
#endif //USE_OVERLAP_TEST_ON_REMOVES
|
||||
)
|
||||
{
|
||||
m_pairCache->removeOverlappingPair(handle0, handle1, dispatcher);
|
||||
if (m_userPairCallback)
|
||||
m_userPairCallback->removeOverlappingPair(handle0, handle1, dispatcher);
|
||||
}
|
||||
|
||||
// update edge reference in other handle
|
||||
pHandleNext->m_maxEdges[axis]--;
|
||||
}
|
||||
else
|
||||
pHandleNext->m_minEdges[axis]--;
|
||||
|
||||
pHandleEdge->m_minEdges[axis]++;
|
||||
|
||||
// swap the edges
|
||||
Edge swap = *pEdge;
|
||||
*pEdge = *pNext;
|
||||
*pNext = swap;
|
||||
|
||||
// increment
|
||||
pEdge++;
|
||||
pNext++;
|
||||
}
|
||||
}
|
||||
|
||||
// sorting a max edge downwards can only ever *remove* overlaps
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMaxDown(int axis, BP_FP_INT_TYPE edge, btDispatcher* dispatcher, bool updateOverlaps)
|
||||
{
|
||||
Edge* pEdge = m_pEdges[axis] + edge;
|
||||
Edge* pPrev = pEdge - 1;
|
||||
Handle* pHandleEdge = getHandle(pEdge->m_handle);
|
||||
|
||||
while (pEdge->m_pos < pPrev->m_pos)
|
||||
{
|
||||
Handle* pHandlePrev = getHandle(pPrev->m_handle);
|
||||
|
||||
if (!pPrev->IsMax())
|
||||
{
|
||||
// if previous edge was a minimum remove any overlap between the two handles
|
||||
Handle* handle0 = getHandle(pEdge->m_handle);
|
||||
Handle* handle1 = getHandle(pPrev->m_handle);
|
||||
const int axis1 = (1 << axis) & 3;
|
||||
const int axis2 = (1 << axis1) & 3;
|
||||
|
||||
if (updateOverlaps
|
||||
#ifdef USE_OVERLAP_TEST_ON_REMOVES
|
||||
&& testOverlap2D(handle0, handle1, axis1, axis2)
|
||||
#endif //USE_OVERLAP_TEST_ON_REMOVES
|
||||
)
|
||||
{
|
||||
//this is done during the overlappingpairarray iteration/narrowphase collision
|
||||
|
||||
m_pairCache->removeOverlappingPair(handle0, handle1, dispatcher);
|
||||
if (m_userPairCallback)
|
||||
m_userPairCallback->removeOverlappingPair(handle0, handle1, dispatcher);
|
||||
}
|
||||
|
||||
// update edge reference in other handle
|
||||
pHandlePrev->m_minEdges[axis]++;
|
||||
;
|
||||
}
|
||||
else
|
||||
pHandlePrev->m_maxEdges[axis]++;
|
||||
|
||||
pHandleEdge->m_maxEdges[axis]--;
|
||||
|
||||
// swap the edges
|
||||
Edge swap = *pEdge;
|
||||
*pEdge = *pPrev;
|
||||
*pPrev = swap;
|
||||
|
||||
// decrement
|
||||
pEdge--;
|
||||
pPrev--;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BROADPHASE
|
||||
debugPrintAxis(axis);
|
||||
#endif //DEBUG_BROADPHASE
|
||||
}
|
||||
|
||||
// sorting a max edge upwards can only ever *add* overlaps
|
||||
template <typename BP_FP_INT_TYPE>
|
||||
void btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMaxUp(int axis, BP_FP_INT_TYPE edge, btDispatcher* /* dispatcher */, bool updateOverlaps)
|
||||
{
|
||||
Edge* pEdge = m_pEdges[axis] + edge;
|
||||
Edge* pNext = pEdge + 1;
|
||||
Handle* pHandleEdge = getHandle(pEdge->m_handle);
|
||||
|
||||
while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos))
|
||||
{
|
||||
Handle* pHandleNext = getHandle(pNext->m_handle);
|
||||
|
||||
const int axis1 = (1 << axis) & 3;
|
||||
const int axis2 = (1 << axis1) & 3;
|
||||
|
||||
if (!pNext->IsMax())
|
||||
{
|
||||
// if next edge is a minimum check the bounds and add an overlap if necessary
|
||||
if (updateOverlaps && testOverlap2D(pHandleEdge, pHandleNext, axis1, axis2))
|
||||
{
|
||||
Handle* handle0 = getHandle(pEdge->m_handle);
|
||||
Handle* handle1 = getHandle(pNext->m_handle);
|
||||
m_pairCache->addOverlappingPair(handle0, handle1);
|
||||
if (m_userPairCallback)
|
||||
m_userPairCallback->addOverlappingPair(handle0, handle1);
|
||||
}
|
||||
|
||||
// update edge reference in other handle
|
||||
pHandleNext->m_minEdges[axis]--;
|
||||
}
|
||||
else
|
||||
pHandleNext->m_maxEdges[axis]--;
|
||||
|
||||
pHandleEdge->m_maxEdges[axis]++;
|
||||
|
||||
// swap the edges
|
||||
Edge swap = *pEdge;
|
||||
*pEdge = *pNext;
|
||||
*pNext = swap;
|
||||
|
||||
// increment
|
||||
pEdge++;
|
||||
pNext++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -13,8 +13,10 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef BT_BROADPHASE_INTERFACE_H
|
||||
#define BT_BROADPHASE_INTERFACE_H
|
||||
#ifndef BT_BROADPHASE_INTERFACE_H
|
||||
#define BT_BROADPHASE_INTERFACE_H
|
||||
|
||||
|
||||
|
||||
struct btDispatcherInfo;
|
||||
class btDispatcher;
|
||||
@@ -22,23 +24,23 @@ class btDispatcher;
|
||||
|
||||
class btOverlappingPairCache;
|
||||
|
||||
struct btBroadphaseAabbCallback
|
||||
|
||||
|
||||
struct btBroadphaseAabbCallback
|
||||
{
|
||||
virtual ~btBroadphaseAabbCallback() {}
|
||||
virtual bool process(const btBroadphaseProxy* proxy) = 0;
|
||||
virtual bool process(const btBroadphaseProxy* proxy) = 0;
|
||||
};
|
||||
|
||||
struct btBroadphaseRayCallback : public btBroadphaseAabbCallback
|
||||
|
||||
struct btBroadphaseRayCallback : public btBroadphaseAabbCallback
|
||||
{
|
||||
///added some cached data to accelerate ray-AABB tests
|
||||
btVector3 m_rayDirectionInverse;
|
||||
unsigned int m_signs[3];
|
||||
btScalar m_lambda_max;
|
||||
btVector3 m_rayDirectionInverse;
|
||||
unsigned int m_signs[3];
|
||||
btScalar m_lambda_max;
|
||||
|
||||
virtual ~btBroadphaseRayCallback() {}
|
||||
|
||||
protected:
|
||||
btBroadphaseRayCallback() {}
|
||||
};
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
@@ -51,29 +53,30 @@ class btBroadphaseInterface
|
||||
public:
|
||||
virtual ~btBroadphaseInterface() {}
|
||||
|
||||
virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher) = 0;
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher) = 0;
|
||||
virtual void setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher) = 0;
|
||||
virtual void getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const = 0;
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy) =0;
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)=0;
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)=0;
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const =0;
|
||||
|
||||
virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin = btVector3(0, 0, 0), const btVector3& aabbMax = btVector3(0, 0, 0)) = 0;
|
||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)) = 0;
|
||||
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback) = 0;
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback) = 0;
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher) = 0;
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher)=0;
|
||||
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache() = 0;
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const = 0;
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache()=0;
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const =0;
|
||||
|
||||
///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
|
||||
///will add some transform later
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin, btVector3& aabbMax) const = 0;
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0;
|
||||
|
||||
///reset broadphase internal structures, to ensure determinism/reproducability
|
||||
virtual void resetPool(btDispatcher* dispatcher) { (void)dispatcher; };
|
||||
virtual void resetPool(btDispatcher* dispatcher) { (void) dispatcher; };
|
||||
|
||||
virtual void printStats() = 0;
|
||||
|
||||
virtual void printStats() = 0;
|
||||
};
|
||||
|
||||
#endif //BT_BROADPHASE_INTERFACE_H
|
||||
#endif //BT_BROADPHASE_INTERFACE_H
|
||||
|
@@ -15,4 +15,3 @@ subject to the following restrictions:
|
||||
|
||||
#include "btBroadphaseProxy.h"
|
||||
|
||||
BT_NOT_EMPTY_FILE // fix warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
|
||||
|
@@ -16,10 +16,11 @@ subject to the following restrictions:
|
||||
#ifndef BT_BROADPHASE_PROXY_H
|
||||
#define BT_BROADPHASE_PROXY_H
|
||||
|
||||
#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
|
||||
#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/btAlignedAllocator.h"
|
||||
|
||||
|
||||
/// btDispatcher uses these types
|
||||
/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave
|
||||
/// to facilitate type checking
|
||||
@@ -34,8 +35,8 @@ enum BroadphaseNativeTypes
|
||||
CONVEX_HULL_SHAPE_PROXYTYPE,
|
||||
CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
|
||||
CUSTOM_POLYHEDRAL_SHAPE_TYPE,
|
||||
//implicit convex shapes
|
||||
IMPLICIT_CONVEX_SHAPES_START_HERE,
|
||||
//implicit convex shapes
|
||||
IMPLICIT_CONVEX_SHAPES_START_HERE,
|
||||
SPHERE_SHAPE_PROXYTYPE,
|
||||
MULTI_SPHERE_SHAPE_PROXYTYPE,
|
||||
CAPSULE_SHAPE_PROXYTYPE,
|
||||
@@ -48,8 +49,8 @@ enum BroadphaseNativeTypes
|
||||
BOX_2D_SHAPE_PROXYTYPE,
|
||||
CONVEX_2D_SHAPE_PROXYTYPE,
|
||||
CUSTOM_CONVEX_SHAPE_TYPE,
|
||||
//concave shapes
|
||||
CONCAVE_SHAPES_START_HERE,
|
||||
//concave shapes
|
||||
CONCAVE_SHAPES_START_HERE,
|
||||
//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
|
||||
TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||
SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
|
||||
@@ -57,16 +58,15 @@ enum BroadphaseNativeTypes
|
||||
FAST_CONCAVE_MESH_PROXYTYPE,
|
||||
//terrain
|
||||
TERRAIN_SHAPE_PROXYTYPE,
|
||||
///Used for GIMPACT Trimesh integration
|
||||
///Used for GIMPACT Trimesh integration
|
||||
GIMPACT_SHAPE_PROXYTYPE,
|
||||
///Multimaterial mesh
|
||||
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
|
||||
|
||||
///Multimaterial mesh
|
||||
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
|
||||
|
||||
EMPTY_SHAPE_PROXYTYPE,
|
||||
STATIC_PLANE_PROXYTYPE,
|
||||
CUSTOM_CONCAVE_SHAPE_TYPE,
|
||||
SDF_SHAPE_PROXYTYPE = CUSTOM_CONCAVE_SHAPE_TYPE,
|
||||
CONCAVE_SHAPES_END_HERE,
|
||||
CONCAVE_SHAPES_END_HERE,
|
||||
|
||||
COMPOUND_SHAPE_PROXYTYPE,
|
||||
|
||||
@@ -76,37 +76,38 @@ enum BroadphaseNativeTypes
|
||||
INVALID_SHAPE_PROXYTYPE,
|
||||
|
||||
MAX_BROADPHASE_COLLISION_TYPES
|
||||
|
||||
|
||||
};
|
||||
|
||||
///The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
|
||||
///It stores collision shape type information, collision filter information and a client object, typically a btCollisionObject or btRigidBody.
|
||||
ATTRIBUTE_ALIGNED16(struct)
|
||||
btBroadphaseProxy
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
///The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
|
||||
///It stores collision shape type information, collision filter information and a client object, typically a btCollisionObject or btRigidBody.
|
||||
ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy
|
||||
{
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
///optional filtering to cull potential collisions
|
||||
enum CollisionFilterGroups
|
||||
{
|
||||
DefaultFilter = 1,
|
||||
StaticFilter = 2,
|
||||
KinematicFilter = 4,
|
||||
DebrisFilter = 8,
|
||||
SensorTrigger = 16,
|
||||
CharacterFilter = 32,
|
||||
AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
|
||||
DefaultFilter = 1,
|
||||
StaticFilter = 2,
|
||||
KinematicFilter = 4,
|
||||
DebrisFilter = 8,
|
||||
SensorTrigger = 16,
|
||||
CharacterFilter = 32,
|
||||
AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
|
||||
};
|
||||
|
||||
//Usually the client btCollisionObject or Rigidbody class
|
||||
void* m_clientObject;
|
||||
int m_collisionFilterGroup;
|
||||
int m_collisionFilterMask;
|
||||
void* m_clientObject;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
void* m_multiSapParentProxy;
|
||||
int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
|
||||
|
||||
int m_uniqueId; //m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
|
||||
|
||||
btVector3 m_aabbMin;
|
||||
btVector3 m_aabbMax;
|
||||
btVector3 m_aabbMin;
|
||||
btVector3 m_aabbMax;
|
||||
|
||||
SIMD_FORCE_INLINE int getUid() const
|
||||
{
|
||||
@@ -114,45 +115,48 @@ btBroadphaseProxy
|
||||
}
|
||||
|
||||
//used for memory pools
|
||||
btBroadphaseProxy() : m_clientObject(0)
|
||||
btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
|
||||
{
|
||||
}
|
||||
|
||||
btBroadphaseProxy(const btVector3& aabbMin, const btVector3& aabbMax, void* userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
: m_clientObject(userPtr),
|
||||
m_collisionFilterGroup(collisionFilterGroup),
|
||||
m_collisionFilterMask(collisionFilterMask),
|
||||
m_aabbMin(aabbMin),
|
||||
m_aabbMax(aabbMax)
|
||||
btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
|
||||
:m_clientObject(userPtr),
|
||||
m_collisionFilterGroup(collisionFilterGroup),
|
||||
m_collisionFilterMask(collisionFilterMask),
|
||||
m_aabbMin(aabbMin),
|
||||
m_aabbMax(aabbMax)
|
||||
{
|
||||
m_multiSapParentProxy = multiSapParentProxy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType)
|
||||
{
|
||||
return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE);
|
||||
return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE);
|
||||
}
|
||||
|
||||
static SIMD_FORCE_INLINE bool isConvex(int proxyType)
|
||||
static SIMD_FORCE_INLINE bool isConvex(int proxyType)
|
||||
{
|
||||
return (proxyType < CONCAVE_SHAPES_START_HERE);
|
||||
}
|
||||
|
||||
static SIMD_FORCE_INLINE bool isNonMoving(int proxyType)
|
||||
static SIMD_FORCE_INLINE bool isNonMoving(int proxyType)
|
||||
{
|
||||
return (isConcave(proxyType) && !(proxyType == GIMPACT_SHAPE_PROXYTYPE));
|
||||
return (isConcave(proxyType) && !(proxyType==GIMPACT_SHAPE_PROXYTYPE));
|
||||
}
|
||||
|
||||
static SIMD_FORCE_INLINE bool isConcave(int proxyType)
|
||||
static SIMD_FORCE_INLINE bool isConcave(int proxyType)
|
||||
{
|
||||
return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
|
||||
(proxyType < CONCAVE_SHAPES_END_HERE));
|
||||
(proxyType < CONCAVE_SHAPES_END_HERE));
|
||||
}
|
||||
static SIMD_FORCE_INLINE bool isCompound(int proxyType)
|
||||
static SIMD_FORCE_INLINE bool isCompound(int proxyType)
|
||||
{
|
||||
return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
|
||||
}
|
||||
|
||||
static SIMD_FORCE_INLINE bool isSoftBody(int proxyType)
|
||||
static SIMD_FORCE_INLINE bool isSoftBody(int proxyType)
|
||||
{
|
||||
return (proxyType == SOFTBODY_SHAPE_PROXYTYPE);
|
||||
}
|
||||
@@ -164,55 +168,67 @@ btBroadphaseProxy
|
||||
|
||||
static SIMD_FORCE_INLINE bool isConvex2d(int proxyType)
|
||||
{
|
||||
return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE);
|
||||
return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
class btCollisionAlgorithm;
|
||||
|
||||
struct btBroadphaseProxy;
|
||||
|
||||
|
||||
|
||||
///The btBroadphasePair class contains a pair of aabb-overlapping objects.
|
||||
///A btDispatcher can search a btCollisionAlgorithm that performs exact/narrowphase collision detection on the actual collision shapes.
|
||||
ATTRIBUTE_ALIGNED16(struct)
|
||||
btBroadphasePair
|
||||
ATTRIBUTE_ALIGNED16(struct) btBroadphasePair
|
||||
{
|
||||
btBroadphasePair()
|
||||
: m_pProxy0(0),
|
||||
m_pProxy1(0),
|
||||
m_algorithm(0),
|
||||
m_internalInfo1(0)
|
||||
btBroadphasePair ()
|
||||
:
|
||||
m_pProxy0(0),
|
||||
m_pProxy1(0),
|
||||
m_algorithm(0),
|
||||
m_internalInfo1(0)
|
||||
{
|
||||
}
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btBroadphasePair(btBroadphaseProxy & proxy0, btBroadphaseProxy & proxy1)
|
||||
btBroadphasePair(const btBroadphasePair& other)
|
||||
: m_pProxy0(other.m_pProxy0),
|
||||
m_pProxy1(other.m_pProxy1),
|
||||
m_algorithm(other.m_algorithm),
|
||||
m_internalInfo1(other.m_internalInfo1)
|
||||
{
|
||||
}
|
||||
btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
|
||||
{
|
||||
|
||||
//keep them sorted, so the std::set operations work
|
||||
if (proxy0.m_uniqueId < proxy1.m_uniqueId)
|
||||
{
|
||||
m_pProxy0 = &proxy0;
|
||||
m_pProxy1 = &proxy1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pProxy0 = &proxy1;
|
||||
m_pProxy1 = &proxy0;
|
||||
}
|
||||
{
|
||||
m_pProxy0 = &proxy0;
|
||||
m_pProxy1 = &proxy1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pProxy0 = &proxy1;
|
||||
m_pProxy1 = &proxy0;
|
||||
}
|
||||
|
||||
m_algorithm = 0;
|
||||
m_internalInfo1 = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btBroadphaseProxy* m_pProxy0;
|
||||
btBroadphaseProxy* m_pProxy1;
|
||||
|
||||
|
||||
mutable btCollisionAlgorithm* m_algorithm;
|
||||
union {
|
||||
void* m_internalInfo1;
|
||||
int m_internalTmpValue;
|
||||
}; //don't use this data, it will be removed in future version.
|
||||
union { void* m_internalInfo1; int m_internalTmpValue;};//don't use this data, it will be removed in future version.
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -224,25 +240,31 @@ SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePa
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class btBroadphasePairSortPredicate
|
||||
{
|
||||
public:
|
||||
bool operator()(const btBroadphasePair& a, const btBroadphasePair& b) const
|
||||
{
|
||||
const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
|
||||
const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
|
||||
const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
|
||||
const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
|
||||
public:
|
||||
|
||||
return uidA0 > uidB0 ||
|
||||
(a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
|
||||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
|
||||
}
|
||||
bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) const
|
||||
{
|
||||
const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
|
||||
const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
|
||||
const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
|
||||
const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
|
||||
|
||||
return uidA0 > uidB0 ||
|
||||
(a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
|
||||
(a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
|
||||
}
|
||||
};
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
|
||||
|
||||
SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
|
||||
{
|
||||
return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
|
||||
return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
|
||||
}
|
||||
|
||||
#endif //BT_BROADPHASE_PROXY_H
|
||||
|
||||
#endif //BT_BROADPHASE_PROXY_H
|
||||
|
||||
|
@@ -20,3 +20,4 @@ btCollisionAlgorithm::btCollisionAlgorithm(const btCollisionAlgorithmConstructio
|
||||
{
|
||||
m_dispatcher = ci.m_dispatcher1;
|
||||
}
|
||||
|
||||
|
@@ -25,51 +25,57 @@ class btManifoldResult;
|
||||
class btCollisionObject;
|
||||
struct btCollisionObjectWrapper;
|
||||
struct btDispatcherInfo;
|
||||
class btPersistentManifold;
|
||||
class btPersistentManifold;
|
||||
|
||||
typedef btAlignedObjectArray<btPersistentManifold*> btManifoldArray;
|
||||
typedef btAlignedObjectArray<btPersistentManifold*> btManifoldArray;
|
||||
|
||||
struct btCollisionAlgorithmConstructionInfo
|
||||
{
|
||||
btCollisionAlgorithmConstructionInfo()
|
||||
: m_dispatcher1(0),
|
||||
m_manifold(0)
|
||||
:m_dispatcher1(0),
|
||||
m_manifold(0)
|
||||
{
|
||||
}
|
||||
btCollisionAlgorithmConstructionInfo(btDispatcher* dispatcher, int temp)
|
||||
: m_dispatcher1(dispatcher)
|
||||
btCollisionAlgorithmConstructionInfo(btDispatcher* dispatcher,int temp)
|
||||
:m_dispatcher1(dispatcher)
|
||||
{
|
||||
(void)temp;
|
||||
}
|
||||
|
||||
btDispatcher* m_dispatcher1;
|
||||
btPersistentManifold* m_manifold;
|
||||
btDispatcher* m_dispatcher1;
|
||||
btPersistentManifold* m_manifold;
|
||||
|
||||
// int getDispatcherId();
|
||||
|
||||
// int getDispatcherId();
|
||||
};
|
||||
|
||||
|
||||
///btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatcher.
|
||||
///It is persistent over frames
|
||||
class btCollisionAlgorithm
|
||||
{
|
||||
protected:
|
||||
btDispatcher* m_dispatcher;
|
||||
|
||||
protected:
|
||||
// int getDispatcherId();
|
||||
|
||||
btDispatcher* m_dispatcher;
|
||||
|
||||
protected:
|
||||
// int getDispatcherId();
|
||||
|
||||
public:
|
||||
btCollisionAlgorithm(){};
|
||||
|
||||
btCollisionAlgorithm() {};
|
||||
|
||||
btCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
|
||||
|
||||
virtual ~btCollisionAlgorithm(){};
|
||||
virtual ~btCollisionAlgorithm() {};
|
||||
|
||||
virtual void processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut) = 0;
|
||||
virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
|
||||
|
||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0, btCollisionObject* body1, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut) = 0;
|
||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
|
||||
|
||||
virtual void getAllContactManifolds(btManifoldArray& manifoldArray) = 0;
|
||||
virtual void getAllContactManifolds(btManifoldArray& manifoldArray) = 0;
|
||||
};
|
||||
|
||||
#endif //BT_COLLISION_ALGORITHM_H
|
||||
|
||||
#endif //BT_COLLISION_ALGORITHM_H
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -24,16 +24,15 @@ subject to the following restrictions:
|
||||
// Compile time config
|
||||
//
|
||||
|
||||
#define DBVT_BP_PROFILE 0
|
||||
#define DBVT_BP_PROFILE 0
|
||||
//#define DBVT_BP_SORTPAIRS 1
|
||||
#define DBVT_BP_PREVENTFALSEUPDATE 0
|
||||
#define DBVT_BP_ACCURATESLEEPING 0
|
||||
#define DBVT_BP_ENABLE_BENCHMARK 0
|
||||
//#define DBVT_BP_MARGIN (btScalar)0.05
|
||||
extern btScalar gDbvtMargin;
|
||||
#define DBVT_BP_PREVENTFALSEUPDATE 0
|
||||
#define DBVT_BP_ACCURATESLEEPING 0
|
||||
#define DBVT_BP_ENABLE_BENCHMARK 0
|
||||
#define DBVT_BP_MARGIN (btScalar)0.05
|
||||
|
||||
#if DBVT_BP_PROFILE
|
||||
#define DBVT_BP_PROFILING_RATE 256
|
||||
#define DBVT_BP_PROFILING_RATE 256
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#endif
|
||||
|
||||
@@ -42,90 +41,89 @@ extern btScalar gDbvtMargin;
|
||||
//
|
||||
struct btDbvtProxy : btBroadphaseProxy
|
||||
{
|
||||
/* Fields */
|
||||
/* Fields */
|
||||
//btDbvtAabbMm aabb;
|
||||
btDbvtNode* leaf;
|
||||
btDbvtProxy* links[2];
|
||||
int stage;
|
||||
/* ctor */
|
||||
btDbvtProxy(const btVector3& aabbMin, const btVector3& aabbMax, void* userPtr, int collisionFilterGroup, int collisionFilterMask) : btBroadphaseProxy(aabbMin, aabbMax, userPtr, collisionFilterGroup, collisionFilterMask)
|
||||
btDbvtNode* leaf;
|
||||
btDbvtProxy* links[2];
|
||||
int stage;
|
||||
/* ctor */
|
||||
btDbvtProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask) :
|
||||
btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask)
|
||||
{
|
||||
links[0] = links[1] = 0;
|
||||
links[0]=links[1]=0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef btAlignedObjectArray<btDbvtProxy*> btDbvtProxyArray;
|
||||
typedef btAlignedObjectArray<btDbvtProxy*> btDbvtProxyArray;
|
||||
|
||||
///The btDbvtBroadphase implements a broadphase using two dynamic AABB bounding volume hierarchies/trees (see btDbvt).
|
||||
///One tree is used for static/non-moving objects, and another tree is used for dynamic objects. Objects can move from one tree to the other.
|
||||
///This is a very fast broadphase, especially for very dynamic worlds where many objects are moving. Its insert/add and remove of objects is generally faster than the sweep and prune broadphases btAxisSweep3 and bt32BitAxisSweep3.
|
||||
struct btDbvtBroadphase : btBroadphaseInterface
|
||||
struct btDbvtBroadphase : btBroadphaseInterface
|
||||
{
|
||||
/* Config */
|
||||
enum
|
||||
{
|
||||
DYNAMIC_SET = 0, /* Dynamic set index */
|
||||
FIXED_SET = 1, /* Fixed set index */
|
||||
STAGECOUNT = 2 /* Number of stages */
|
||||
/* Config */
|
||||
enum {
|
||||
DYNAMIC_SET = 0, /* Dynamic set index */
|
||||
FIXED_SET = 1, /* Fixed set index */
|
||||
STAGECOUNT = 2 /* Number of stages */
|
||||
};
|
||||
/* Fields */
|
||||
btDbvt m_sets[2]; // Dbvt sets
|
||||
btDbvtProxy* m_stageRoots[STAGECOUNT + 1]; // Stages list
|
||||
btOverlappingPairCache* m_paircache; // Pair cache
|
||||
btScalar m_prediction; // Velocity prediction
|
||||
int m_stageCurrent; // Current stage
|
||||
int m_fupdates; // % of fixed updates per frame
|
||||
int m_dupdates; // % of dynamic updates per frame
|
||||
int m_cupdates; // % of cleanup updates per frame
|
||||
int m_newpairs; // Number of pairs created
|
||||
int m_fixedleft; // Fixed optimization left
|
||||
unsigned m_updates_call; // Number of updates call
|
||||
unsigned m_updates_done; // Number of updates done
|
||||
btScalar m_updates_ratio; // m_updates_done/m_updates_call
|
||||
int m_pid; // Parse id
|
||||
int m_cid; // Cleanup index
|
||||
int m_gid; // Gen id
|
||||
bool m_releasepaircache; // Release pair cache on delete
|
||||
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
||||
bool m_needcleanup; // Need to run cleanup?
|
||||
btAlignedObjectArray<btAlignedObjectArray<const btDbvtNode*> > m_rayTestStacks;
|
||||
/* Fields */
|
||||
btDbvt m_sets[2]; // Dbvt sets
|
||||
btDbvtProxy* m_stageRoots[STAGECOUNT+1]; // Stages list
|
||||
btOverlappingPairCache* m_paircache; // Pair cache
|
||||
btScalar m_prediction; // Velocity prediction
|
||||
int m_stageCurrent; // Current stage
|
||||
int m_fupdates; // % of fixed updates per frame
|
||||
int m_dupdates; // % of dynamic updates per frame
|
||||
int m_cupdates; // % of cleanup updates per frame
|
||||
int m_newpairs; // Number of pairs created
|
||||
int m_fixedleft; // Fixed optimization left
|
||||
unsigned m_updates_call; // Number of updates call
|
||||
unsigned m_updates_done; // Number of updates done
|
||||
btScalar m_updates_ratio; // m_updates_done/m_updates_call
|
||||
int m_pid; // Parse id
|
||||
int m_cid; // Cleanup index
|
||||
int m_gid; // Gen id
|
||||
bool m_releasepaircache; // Release pair cache on delete
|
||||
bool m_deferedcollide; // Defere dynamic/static collision to collide call
|
||||
bool m_needcleanup; // Need to run cleanup?
|
||||
#if DBVT_BP_PROFILE
|
||||
btClock m_clock;
|
||||
struct
|
||||
{
|
||||
unsigned long m_total;
|
||||
unsigned long m_ddcollide;
|
||||
unsigned long m_fdcollide;
|
||||
unsigned long m_cleanup;
|
||||
unsigned long m_jobcount;
|
||||
} m_profiling;
|
||||
btClock m_clock;
|
||||
struct {
|
||||
unsigned long m_total;
|
||||
unsigned long m_ddcollide;
|
||||
unsigned long m_fdcollide;
|
||||
unsigned long m_cleanup;
|
||||
unsigned long m_jobcount;
|
||||
} m_profiling;
|
||||
#endif
|
||||
/* Methods */
|
||||
btDbvtBroadphase(btOverlappingPairCache* paircache = 0);
|
||||
/* Methods */
|
||||
btDbvtBroadphase(btOverlappingPairCache* paircache=0);
|
||||
~btDbvtBroadphase();
|
||||
void collide(btDispatcher* dispatcher);
|
||||
void optimize();
|
||||
|
||||
void collide(btDispatcher* dispatcher);
|
||||
void optimize();
|
||||
|
||||
/* btBroadphaseInterface Implementation */
|
||||
btBroadphaseProxy* createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin = btVector3(0, 0, 0), const btVector3& aabbMax = btVector3(0, 0, 0));
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
|
||||
btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher);
|
||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0));
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
|
||||
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache();
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const;
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const;
|
||||
virtual void printStats();
|
||||
|
||||
virtual void getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const;
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache();
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const;
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin, btVector3& aabbMax) const;
|
||||
virtual void printStats();
|
||||
|
||||
///reset broadphase internal structures, to ensure determinism/reproducability
|
||||
virtual void resetPool(btDispatcher* dispatcher);
|
||||
|
||||
void performDeferredRemoval(btDispatcher* dispatcher);
|
||||
|
||||
void setVelocityPrediction(btScalar prediction)
|
||||
void performDeferredRemoval(btDispatcher* dispatcher);
|
||||
|
||||
void setVelocityPrediction(btScalar prediction)
|
||||
{
|
||||
m_prediction = prediction;
|
||||
}
|
||||
@@ -134,13 +132,15 @@ struct btDbvtBroadphase : btBroadphaseInterface
|
||||
return m_prediction;
|
||||
}
|
||||
|
||||
///this setAabbForceUpdate is similar to setAabb but always forces the aabb update.
|
||||
///this setAabbForceUpdate is similar to setAabb but always forces the aabb update.
|
||||
///it is not part of the btBroadphaseInterface but specific to btDbvtBroadphase.
|
||||
///it bypasses certain optimizations that prevent aabb updates (when the aabb shrinks), see
|
||||
///http://code.google.com/p/bullet/issues/detail?id=223
|
||||
void setAabbForceUpdate(btBroadphaseProxy* absproxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* /*dispatcher*/);
|
||||
void setAabbForceUpdate( btBroadphaseProxy* absproxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* /*dispatcher*/);
|
||||
|
||||
static void benchmark(btBroadphaseInterface*);
|
||||
|
||||
|
||||
static void benchmark(btBroadphaseInterface*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -17,4 +17,6 @@ subject to the following restrictions:
|
||||
|
||||
btDispatcher::~btDispatcher()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
||||
class btCollisionAlgorithm;
|
||||
struct btBroadphaseProxy;
|
||||
class btRigidBody;
|
||||
class btCollisionObject;
|
||||
class btCollisionObject;
|
||||
class btOverlappingPairCache;
|
||||
struct btCollisionObjectWrapper;
|
||||
|
||||
@@ -35,76 +35,73 @@ struct btDispatcherInfo
|
||||
DISPATCH_CONTINUOUS
|
||||
};
|
||||
btDispatcherInfo()
|
||||
: m_timeStep(btScalar(0.)),
|
||||
m_stepCount(0),
|
||||
m_dispatchFunc(DISPATCH_DISCRETE),
|
||||
m_timeOfImpact(btScalar(1.)),
|
||||
m_useContinuous(true),
|
||||
m_debugDraw(0),
|
||||
m_enableSatConvex(false),
|
||||
m_enableSPU(true),
|
||||
m_useEpa(true),
|
||||
m_allowedCcdPenetration(btScalar(0.04)),
|
||||
m_useConvexConservativeDistanceUtil(false),
|
||||
m_convexConservativeDistanceThreshold(0.0f),
|
||||
m_deterministicOverlappingPairs(false)
|
||||
:m_timeStep(btScalar(0.)),
|
||||
m_stepCount(0),
|
||||
m_dispatchFunc(DISPATCH_DISCRETE),
|
||||
m_timeOfImpact(btScalar(1.)),
|
||||
m_useContinuous(true),
|
||||
m_debugDraw(0),
|
||||
m_enableSatConvex(false),
|
||||
m_enableSPU(true),
|
||||
m_useEpa(true),
|
||||
m_allowedCcdPenetration(btScalar(0.04)),
|
||||
m_useConvexConservativeDistanceUtil(false),
|
||||
m_convexConservativeDistanceThreshold(0.0f)
|
||||
{
|
||||
}
|
||||
btScalar m_timeStep;
|
||||
int m_stepCount;
|
||||
int m_dispatchFunc;
|
||||
mutable btScalar m_timeOfImpact;
|
||||
bool m_useContinuous;
|
||||
class btIDebugDraw* m_debugDraw;
|
||||
bool m_enableSatConvex;
|
||||
bool m_enableSPU;
|
||||
bool m_useEpa;
|
||||
btScalar m_allowedCcdPenetration;
|
||||
bool m_useConvexConservativeDistanceUtil;
|
||||
btScalar m_convexConservativeDistanceThreshold;
|
||||
bool m_deterministicOverlappingPairs;
|
||||
};
|
||||
|
||||
enum ebtDispatcherQueryType
|
||||
{
|
||||
BT_CONTACT_POINT_ALGORITHMS = 1,
|
||||
BT_CLOSEST_POINT_ALGORITHMS = 2
|
||||
}
|
||||
btScalar m_timeStep;
|
||||
int m_stepCount;
|
||||
int m_dispatchFunc;
|
||||
mutable btScalar m_timeOfImpact;
|
||||
bool m_useContinuous;
|
||||
class btIDebugDraw* m_debugDraw;
|
||||
bool m_enableSatConvex;
|
||||
bool m_enableSPU;
|
||||
bool m_useEpa;
|
||||
btScalar m_allowedCcdPenetration;
|
||||
bool m_useConvexConservativeDistanceUtil;
|
||||
btScalar m_convexConservativeDistanceThreshold;
|
||||
};
|
||||
|
||||
///The btDispatcher interface class can be used in combination with broadphase to dispatch calculations for overlapping pairs.
|
||||
///For example for pairwise collision detection, calculating contact points stored in btPersistentManifold or user callbacks (game logic).
|
||||
class btDispatcher
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
virtual ~btDispatcher();
|
||||
virtual ~btDispatcher() ;
|
||||
|
||||
virtual btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, btPersistentManifold* sharedManifold, ebtDispatcherQueryType queryType) = 0;
|
||||
virtual btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btPersistentManifold* sharedManifold=0) = 0;
|
||||
|
||||
virtual btPersistentManifold* getNewManifold(const btCollisionObject* b0, const btCollisionObject* b1) = 0;
|
||||
virtual btPersistentManifold* getNewManifold(const btCollisionObject* b0,const btCollisionObject* b1)=0;
|
||||
|
||||
virtual void releaseManifold(btPersistentManifold* manifold) = 0;
|
||||
virtual void releaseManifold(btPersistentManifold* manifold)=0;
|
||||
|
||||
virtual void clearManifold(btPersistentManifold* manifold) = 0;
|
||||
virtual void clearManifold(btPersistentManifold* manifold)=0;
|
||||
|
||||
virtual bool needsCollision(const btCollisionObject* body0, const btCollisionObject* body1) = 0;
|
||||
virtual bool needsCollision(const btCollisionObject* body0,const btCollisionObject* body1) = 0;
|
||||
|
||||
virtual bool needsResponse(const btCollisionObject* body0, const btCollisionObject* body1) = 0;
|
||||
virtual bool needsResponse(const btCollisionObject* body0,const btCollisionObject* body1)=0;
|
||||
|
||||
virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache, const btDispatcherInfo& dispatchInfo, btDispatcher* dispatcher) = 0;
|
||||
virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) =0;
|
||||
|
||||
virtual int getNumManifolds() const = 0;
|
||||
|
||||
virtual btPersistentManifold* getManifoldByIndexInternal(int index) = 0;
|
||||
|
||||
virtual btPersistentManifold** getInternalManifoldPointer() = 0;
|
||||
virtual btPersistentManifold** getInternalManifoldPointer() = 0;
|
||||
|
||||
virtual btPoolAllocator* getInternalManifoldPool() = 0;
|
||||
virtual btPoolAllocator* getInternalManifoldPool() = 0;
|
||||
|
||||
virtual const btPoolAllocator* getInternalManifoldPool() const = 0;
|
||||
virtual const btPoolAllocator* getInternalManifoldPool() const = 0;
|
||||
|
||||
virtual void* allocateCollisionAlgorithm(int size) = 0;
|
||||
virtual void* allocateCollisionAlgorithm(int size) = 0;
|
||||
|
||||
virtual void freeCollisionAlgorithm(void* ptr) = 0;
|
||||
|
||||
virtual void freeCollisionAlgorithm(void* ptr) = 0;
|
||||
};
|
||||
|
||||
#endif //BT_DISPATCHER_H
|
||||
|
||||
#endif //BT_DISPATCHER_H
|
||||
|
489
extern/bullet2/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp
vendored
Normal file
489
extern/bullet2/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp
vendored
Normal file
@@ -0,0 +1,489 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
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 "btMultiSapBroadphase.h"
|
||||
|
||||
#include "btSimpleBroadphase.h"
|
||||
#include "LinearMath/btAabbUtil2.h"
|
||||
#include "btQuantizedBvh.h"
|
||||
|
||||
/// btSapBroadphaseArray m_sapBroadphases;
|
||||
|
||||
/// btOverlappingPairCache* m_overlappingPairs;
|
||||
extern int gOverlappingPairs;
|
||||
|
||||
/*
|
||||
class btMultiSapSortedOverlappingPairCache : public btSortedOverlappingPairCache
|
||||
{
|
||||
public:
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
return btSortedOverlappingPairCache::addOverlappingPair((btBroadphaseProxy*)proxy0->m_multiSapParentProxy,(btBroadphaseProxy*)proxy1->m_multiSapParentProxy);
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
btMultiSapBroadphase::btMultiSapBroadphase(int /*maxProxies*/,btOverlappingPairCache* pairCache)
|
||||
:m_overlappingPairs(pairCache),
|
||||
m_optimizedAabbTree(0),
|
||||
m_ownsPairCache(false),
|
||||
m_invalidPair(0)
|
||||
{
|
||||
if (!m_overlappingPairs)
|
||||
{
|
||||
m_ownsPairCache = true;
|
||||
void* mem = btAlignedAlloc(sizeof(btSortedOverlappingPairCache),16);
|
||||
m_overlappingPairs = new (mem)btSortedOverlappingPairCache();
|
||||
}
|
||||
|
||||
struct btMultiSapOverlapFilterCallback : public btOverlapFilterCallback
|
||||
{
|
||||
virtual ~btMultiSapOverlapFilterCallback()
|
||||
{}
|
||||
// return true when pairs need collision
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) const
|
||||
{
|
||||
btBroadphaseProxy* multiProxy0 = (btBroadphaseProxy*)childProxy0->m_multiSapParentProxy;
|
||||
btBroadphaseProxy* multiProxy1 = (btBroadphaseProxy*)childProxy1->m_multiSapParentProxy;
|
||||
|
||||
bool collides = (multiProxy0->m_collisionFilterGroup & multiProxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (multiProxy1->m_collisionFilterGroup & multiProxy0->m_collisionFilterMask);
|
||||
|
||||
return collides;
|
||||
}
|
||||
};
|
||||
|
||||
void* mem = btAlignedAlloc(sizeof(btMultiSapOverlapFilterCallback),16);
|
||||
m_filterCallback = new (mem)btMultiSapOverlapFilterCallback();
|
||||
|
||||
m_overlappingPairs->setOverlapFilterCallback(m_filterCallback);
|
||||
// mem = btAlignedAlloc(sizeof(btSimpleBroadphase),16);
|
||||
// m_simpleBroadphase = new (mem) btSimpleBroadphase(maxProxies,m_overlappingPairs);
|
||||
}
|
||||
|
||||
btMultiSapBroadphase::~btMultiSapBroadphase()
|
||||
{
|
||||
if (m_ownsPairCache)
|
||||
{
|
||||
m_overlappingPairs->~btOverlappingPairCache();
|
||||
btAlignedFree(m_overlappingPairs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void btMultiSapBroadphase::buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax)
|
||||
{
|
||||
m_optimizedAabbTree = new btQuantizedBvh();
|
||||
m_optimizedAabbTree->setQuantizationValues(bvhAabbMin,bvhAabbMax);
|
||||
QuantizedNodeArray& nodes = m_optimizedAabbTree->getLeafNodeArray();
|
||||
for (int i=0;i<m_sapBroadphases.size();i++)
|
||||
{
|
||||
btQuantizedBvhNode node;
|
||||
btVector3 aabbMin,aabbMax;
|
||||
m_sapBroadphases[i]->getBroadphaseAabb(aabbMin,aabbMax);
|
||||
m_optimizedAabbTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0);
|
||||
m_optimizedAabbTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1);
|
||||
int partId = 0;
|
||||
node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | i;
|
||||
nodes.push_back(node);
|
||||
}
|
||||
m_optimizedAabbTree->buildInternal();
|
||||
}
|
||||
|
||||
btBroadphaseProxy* btMultiSapBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* /*ignoreMe*/)
|
||||
{
|
||||
//void* ignoreMe -> we could think of recursive multi-sap, if someone is interested
|
||||
|
||||
void* mem = btAlignedAlloc(sizeof(btMultiSapProxy),16);
|
||||
btMultiSapProxy* proxy = new (mem)btMultiSapProxy(aabbMin, aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask);
|
||||
m_multiSapProxies.push_back(proxy);
|
||||
|
||||
///this should deal with inserting/removal into child broadphases
|
||||
setAabb(proxy,aabbMin,aabbMax,dispatcher);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
void btMultiSapBroadphase::destroyProxy(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
///not yet
|
||||
btAssert(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void btMultiSapBroadphase::addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase)
|
||||
{
|
||||
void* mem = btAlignedAlloc(sizeof(btBridgeProxy),16);
|
||||
btBridgeProxy* bridgeProxyRef = new(mem) btBridgeProxy;
|
||||
bridgeProxyRef->m_childProxy = childProxy;
|
||||
bridgeProxyRef->m_childBroadphase = childBroadphase;
|
||||
parentMultiSapProxy->m_bridgeProxies.push_back(bridgeProxyRef);
|
||||
}
|
||||
|
||||
|
||||
bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax);
|
||||
bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax)
|
||||
{
|
||||
return
|
||||
amin.getX() >= bmin.getX() && amax.getX() <= bmax.getX() &&
|
||||
amin.getY() >= bmin.getY() && amax.getY() <= bmax.getY() &&
|
||||
amin.getZ() >= bmin.getZ() && amax.getZ() <= bmax.getZ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void btMultiSapBroadphase::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const
|
||||
{
|
||||
btMultiSapProxy* multiProxy = static_cast<btMultiSapProxy*>(proxy);
|
||||
aabbMin = multiProxy->m_aabbMin;
|
||||
aabbMax = multiProxy->m_aabbMax;
|
||||
}
|
||||
|
||||
void btMultiSapBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin,const btVector3& aabbMax)
|
||||
{
|
||||
for (int i=0;i<m_multiSapProxies.size();i++)
|
||||
{
|
||||
rayCallback.process(m_multiSapProxies[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher)
|
||||
{
|
||||
btMultiSapProxy* multiProxy = static_cast<btMultiSapProxy*>(proxy);
|
||||
multiProxy->m_aabbMin = aabbMin;
|
||||
multiProxy->m_aabbMax = aabbMax;
|
||||
|
||||
|
||||
// bool fullyContained = false;
|
||||
// bool alreadyInSimple = false;
|
||||
|
||||
|
||||
|
||||
|
||||
struct MyNodeOverlapCallback : public btNodeOverlapCallback
|
||||
{
|
||||
btMultiSapBroadphase* m_multiSap;
|
||||
btMultiSapProxy* m_multiProxy;
|
||||
btDispatcher* m_dispatcher;
|
||||
|
||||
MyNodeOverlapCallback(btMultiSapBroadphase* multiSap,btMultiSapProxy* multiProxy,btDispatcher* dispatcher)
|
||||
:m_multiSap(multiSap),
|
||||
m_multiProxy(multiProxy),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void processNode(int /*nodeSubPart*/, int broadphaseIndex)
|
||||
{
|
||||
btBroadphaseInterface* childBroadphase = m_multiSap->getBroadphaseArray()[broadphaseIndex];
|
||||
|
||||
int containingBroadphaseIndex = -1;
|
||||
//already found?
|
||||
for (int i=0;i<m_multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
|
||||
if (m_multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase)
|
||||
{
|
||||
containingBroadphaseIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (containingBroadphaseIndex<0)
|
||||
{
|
||||
//add it
|
||||
btBroadphaseProxy* childProxy = childBroadphase->createProxy(m_multiProxy->m_aabbMin,m_multiProxy->m_aabbMax,m_multiProxy->m_shapeType,m_multiProxy->m_clientObject,m_multiProxy->m_collisionFilterGroup,m_multiProxy->m_collisionFilterMask, m_dispatcher,m_multiProxy);
|
||||
m_multiSap->addToChildBroadphase(m_multiProxy,childProxy,childBroadphase);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MyNodeOverlapCallback myNodeCallback(this,multiProxy,dispatcher);
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_optimizedAabbTree)
|
||||
m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax);
|
||||
|
||||
int i;
|
||||
|
||||
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
btVector3 worldAabbMin,worldAabbMax;
|
||||
multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
|
||||
bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
|
||||
if (!overlapsBroadphase)
|
||||
{
|
||||
//remove it now
|
||||
btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[i];
|
||||
|
||||
btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy;
|
||||
bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher);
|
||||
|
||||
multiProxy->m_bridgeProxies.swap( i,multiProxy->m_bridgeProxies.size()-1);
|
||||
multiProxy->m_bridgeProxies.pop_back();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
if (1)
|
||||
{
|
||||
|
||||
//find broadphase that contain this multiProxy
|
||||
int numChildBroadphases = getBroadphaseArray().size();
|
||||
for (int i=0;i<numChildBroadphases;i++)
|
||||
{
|
||||
btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i];
|
||||
btVector3 worldAabbMin,worldAabbMax;
|
||||
childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
|
||||
bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
|
||||
|
||||
// fullyContained = fullyContained || boxIsContainedWithinBox(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax);
|
||||
int containingBroadphaseIndex = -1;
|
||||
|
||||
//if already contains this
|
||||
|
||||
for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
if (multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase)
|
||||
{
|
||||
containingBroadphaseIndex = i;
|
||||
}
|
||||
alreadyInSimple = alreadyInSimple || (multiProxy->m_bridgeProxies[i]->m_childBroadphase == m_simpleBroadphase);
|
||||
}
|
||||
|
||||
if (overlapsBroadphase)
|
||||
{
|
||||
if (containingBroadphaseIndex<0)
|
||||
{
|
||||
btBroadphaseProxy* childProxy = childBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
|
||||
childProxy->m_multiSapParentProxy = multiProxy;
|
||||
addToChildBroadphase(multiProxy,childProxy,childBroadphase);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (containingBroadphaseIndex>=0)
|
||||
{
|
||||
//remove
|
||||
btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[containingBroadphaseIndex];
|
||||
|
||||
btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy;
|
||||
bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher);
|
||||
|
||||
multiProxy->m_bridgeProxies.swap( containingBroadphaseIndex,multiProxy->m_bridgeProxies.size()-1);
|
||||
multiProxy->m_bridgeProxies.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///If we are in no other child broadphase, stick the proxy in the global 'simple' broadphase (brute force)
|
||||
///hopefully we don't end up with many entries here (can assert/provide feedback on stats)
|
||||
if (0)//!multiProxy->m_bridgeProxies.size())
|
||||
{
|
||||
///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision
|
||||
///this is needed to be able to calculate the aabb overlap
|
||||
btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
|
||||
childProxy->m_multiSapParentProxy = multiProxy;
|
||||
addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase);
|
||||
}
|
||||
}
|
||||
|
||||
if (!multiProxy->m_bridgeProxies.size())
|
||||
{
|
||||
///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision
|
||||
///this is needed to be able to calculate the aabb overlap
|
||||
btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher);
|
||||
childProxy->m_multiSapParentProxy = multiProxy;
|
||||
addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//update
|
||||
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
|
||||
{
|
||||
btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i];
|
||||
bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher);
|
||||
}
|
||||
|
||||
}
|
||||
bool stopUpdating=false;
|
||||
|
||||
|
||||
|
||||
class btMultiSapBroadphasePairSortPredicate
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 ) const
|
||||
{
|
||||
btMultiSapBroadphase::btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapBroadphase::btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
btMultiSapBroadphase::btMultiSapProxy* bProxy0 = b1.m_pProxy0 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapBroadphase::btMultiSapProxy* bProxy1 = b1.m_pProxy1 ? (btMultiSapBroadphase::btMultiSapProxy*)b1.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
|
||||
return aProxy0 > bProxy0 ||
|
||||
(aProxy0 == bProxy0 && aProxy1 > bProxy1) ||
|
||||
(aProxy0 == bProxy0 && aProxy1 == bProxy1 && a1.m_algorithm > b1.m_algorithm);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
|
||||
// m_simpleBroadphase->calculateOverlappingPairs(dispatcher);
|
||||
|
||||
if (!stopUpdating && getOverlappingPairCache()->hasDeferredRemoval())
|
||||
{
|
||||
|
||||
btBroadphasePairArray& overlappingPairArray = getOverlappingPairCache()->getOverlappingPairArray();
|
||||
|
||||
// quicksort(overlappingPairArray,0,overlappingPairArray.size());
|
||||
|
||||
overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate());
|
||||
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
// overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
btBroadphasePair previousPair;
|
||||
previousPair.m_pProxy0 = 0;
|
||||
previousPair.m_pProxy1 = 0;
|
||||
previousPair.m_algorithm = 0;
|
||||
|
||||
|
||||
for (i=0;i<overlappingPairArray.size();i++)
|
||||
{
|
||||
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
btMultiSapProxy* aProxy0 = pair.m_pProxy0 ? (btMultiSapProxy*)pair.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapProxy* aProxy1 = pair.m_pProxy1 ? (btMultiSapProxy*)pair.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
btMultiSapProxy* bProxy0 = previousPair.m_pProxy0 ? (btMultiSapProxy*)previousPair.m_pProxy0->m_multiSapParentProxy : 0;
|
||||
btMultiSapProxy* bProxy1 = previousPair.m_pProxy1 ? (btMultiSapProxy*)previousPair.m_pProxy1->m_multiSapParentProxy : 0;
|
||||
|
||||
bool isDuplicate = (aProxy0 == bProxy0) && (aProxy1 == bProxy1);
|
||||
|
||||
previousPair = pair;
|
||||
|
||||
bool needsRemoval = false;
|
||||
|
||||
if (!isDuplicate)
|
||||
{
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||
|
||||
if (hasOverlap)
|
||||
{
|
||||
needsRemoval = false;//callback->processOverlap(pair);
|
||||
} else
|
||||
{
|
||||
needsRemoval = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
//remove duplicate
|
||||
needsRemoval = true;
|
||||
//should have no algorithm
|
||||
btAssert(!pair.m_algorithm);
|
||||
}
|
||||
|
||||
if (needsRemoval)
|
||||
{
|
||||
getOverlappingPairCache()->cleanOverlappingPair(pair,dispatcher);
|
||||
|
||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
// m_overlappingPairArray.pop_back();
|
||||
pair.m_pProxy0 = 0;
|
||||
pair.m_pProxy1 = 0;
|
||||
m_invalidPair++;
|
||||
gOverlappingPairs--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||
#define CLEAN_INVALID_PAIRS 1
|
||||
#ifdef CLEAN_INVALID_PAIRS
|
||||
|
||||
//perform a sort, to sort 'invalid' pairs to the end
|
||||
//overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate());
|
||||
overlappingPairArray.quickSort(btMultiSapBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif//CLEAN_INVALID_PAIRS
|
||||
|
||||
//printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool btMultiSapBroadphase::testAabbOverlap(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1)
|
||||
{
|
||||
btMultiSapProxy* multiSapProxy0 = (btMultiSapProxy*)childProxy0->m_multiSapParentProxy;
|
||||
btMultiSapProxy* multiSapProxy1 = (btMultiSapProxy*)childProxy1->m_multiSapParentProxy;
|
||||
|
||||
return TestAabbAgainstAabb2(multiSapProxy0->m_aabbMin,multiSapProxy0->m_aabbMax,
|
||||
multiSapProxy1->m_aabbMin,multiSapProxy1->m_aabbMax);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void btMultiSapBroadphase::printStats()
|
||||
{
|
||||
/* printf("---------------------------------\n");
|
||||
|
||||
printf("btMultiSapBroadphase.h\n");
|
||||
printf("numHandles = %d\n",m_multiSapProxies.size());
|
||||
//find broadphase that contain this multiProxy
|
||||
int numChildBroadphases = getBroadphaseArray().size();
|
||||
for (int i=0;i<numChildBroadphases;i++)
|
||||
{
|
||||
|
||||
btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i];
|
||||
childBroadphase->printStats();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void btMultiSapBroadphase::resetPool(btDispatcher* dispatcher)
|
||||
{
|
||||
// not yet
|
||||
}
|
151
extern/bullet2/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
vendored
Normal file
151
extern/bullet2/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
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.
|
||||
*/
|
||||
#ifndef BT_MULTI_SAP_BROADPHASE
|
||||
#define BT_MULTI_SAP_BROADPHASE
|
||||
|
||||
#include "btBroadphaseInterface.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "btOverlappingPairCache.h"
|
||||
|
||||
|
||||
class btBroadphaseInterface;
|
||||
class btSimpleBroadphase;
|
||||
|
||||
|
||||
typedef btAlignedObjectArray<btBroadphaseInterface*> btSapBroadphaseArray;
|
||||
|
||||
///The btMultiSapBroadphase is a research project, not recommended to use in production. Use btAxisSweep3 or btDbvtBroadphase instead.
|
||||
///The btMultiSapBroadphase is a broadphase that contains multiple SAP broadphases.
|
||||
///The user can add SAP broadphases that cover the world. A btBroadphaseProxy can be in multiple child broadphases at the same time.
|
||||
///A btQuantizedBvh acceleration structures finds overlapping SAPs for each btBroadphaseProxy.
|
||||
///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328
|
||||
///and http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
|
||||
class btMultiSapBroadphase :public btBroadphaseInterface
|
||||
{
|
||||
btSapBroadphaseArray m_sapBroadphases;
|
||||
|
||||
btSimpleBroadphase* m_simpleBroadphase;
|
||||
|
||||
btOverlappingPairCache* m_overlappingPairs;
|
||||
|
||||
class btQuantizedBvh* m_optimizedAabbTree;
|
||||
|
||||
|
||||
bool m_ownsPairCache;
|
||||
|
||||
btOverlapFilterCallback* m_filterCallback;
|
||||
|
||||
int m_invalidPair;
|
||||
|
||||
struct btBridgeProxy
|
||||
{
|
||||
btBroadphaseProxy* m_childProxy;
|
||||
btBroadphaseInterface* m_childBroadphase;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
struct btMultiSapProxy : public btBroadphaseProxy
|
||||
{
|
||||
|
||||
///array with all the entries that this proxy belongs to
|
||||
btAlignedObjectArray<btBridgeProxy*> m_bridgeProxies;
|
||||
btVector3 m_aabbMin;
|
||||
btVector3 m_aabbMax;
|
||||
|
||||
int m_shapeType;
|
||||
|
||||
/* void* m_userPtr;
|
||||
short int m_collisionFilterGroup;
|
||||
short int m_collisionFilterMask;
|
||||
*/
|
||||
btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
|
||||
:btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask),
|
||||
m_aabbMin(aabbMin),
|
||||
m_aabbMax(aabbMax),
|
||||
m_shapeType(shapeType)
|
||||
{
|
||||
m_multiSapParentProxy =this;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
|
||||
|
||||
public:
|
||||
|
||||
btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0);
|
||||
|
||||
|
||||
btSapBroadphaseArray& getBroadphaseArray()
|
||||
{
|
||||
return m_sapBroadphases;
|
||||
}
|
||||
|
||||
const btSapBroadphaseArray& getBroadphaseArray() const
|
||||
{
|
||||
return m_sapBroadphases;
|
||||
}
|
||||
|
||||
virtual ~btMultiSapBroadphase();
|
||||
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
||||
|
||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback,const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0));
|
||||
|
||||
void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache()
|
||||
{
|
||||
return m_overlappingPairs;
|
||||
}
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
{
|
||||
return m_overlappingPairs;
|
||||
}
|
||||
|
||||
///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
|
||||
///will add some transform later
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
|
||||
{
|
||||
aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
|
||||
aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
|
||||
}
|
||||
|
||||
void buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
|
||||
|
||||
virtual void printStats();
|
||||
|
||||
void quicksort (btBroadphasePairArray& a, int lo, int hi);
|
||||
|
||||
///reset broadphase internal structures, to ensure determinism/reproducability
|
||||
virtual void resetPool(btDispatcher* dispatcher);
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_MULTI_SAP_BROADPHASE
|
@@ -13,6 +13,8 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "btOverlappingPairCache.h"
|
||||
|
||||
#include "btDispatcher.h"
|
||||
@@ -21,95 +23,127 @@ subject to the following restrictions:
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
btHashedOverlappingPairCache::btHashedOverlappingPairCache() : m_overlapFilterCallback(0),
|
||||
m_ghostPairCallback(0)
|
||||
int gOverlappingPairs = 0;
|
||||
|
||||
int gRemovePairs =0;
|
||||
int gAddedPairs =0;
|
||||
int gFindPairs =0;
|
||||
|
||||
|
||||
|
||||
|
||||
btHashedOverlappingPairCache::btHashedOverlappingPairCache():
|
||||
m_overlapFilterCallback(0),
|
||||
m_ghostPairCallback(0)
|
||||
{
|
||||
int initialAllocatedSize = 2;
|
||||
int initialAllocatedSize= 2;
|
||||
m_overlappingPairArray.reserve(initialAllocatedSize);
|
||||
growTables();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
btHashedOverlappingPairCache::~btHashedOverlappingPairCache()
|
||||
{
|
||||
}
|
||||
|
||||
void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair, btDispatcher* dispatcher)
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
|
||||
{
|
||||
if (pair.m_algorithm && dispatcher)
|
||||
{
|
||||
{
|
||||
pair.m_algorithm->~btCollisionAlgorithm();
|
||||
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
||||
pair.m_algorithm = 0;
|
||||
pair.m_algorithm=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btHashedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy, btDispatcher* dispatcher)
|
||||
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
|
||||
{
|
||||
class CleanPairCallback : public btOverlapCallback
|
||||
|
||||
class CleanPairCallback : public btOverlapCallback
|
||||
{
|
||||
btBroadphaseProxy* m_cleanProxy;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
btDispatcher* m_dispatcher;
|
||||
|
||||
public:
|
||||
CleanPairCallback(btBroadphaseProxy* cleanProxy, btOverlappingPairCache* pairCache, btDispatcher* dispatcher)
|
||||
: m_cleanProxy(cleanProxy),
|
||||
m_pairCache(pairCache),
|
||||
m_dispatcher(dispatcher)
|
||||
CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher)
|
||||
:m_cleanProxy(cleanProxy),
|
||||
m_pairCache(pairCache),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
if ((pair.m_pProxy0 == m_cleanProxy) ||
|
||||
(pair.m_pProxy1 == m_cleanProxy))
|
||||
{
|
||||
m_pairCache->cleanOverlappingPair(pair, m_dispatcher);
|
||||
m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CleanPairCallback cleanPairs(proxy, this, dispatcher);
|
||||
CleanPairCallback cleanPairs(proxy,this,dispatcher);
|
||||
|
||||
processAllOverlappingPairs(&cleanPairs,dispatcher);
|
||||
|
||||
processAllOverlappingPairs(&cleanPairs, dispatcher);
|
||||
}
|
||||
|
||||
void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher)
|
||||
|
||||
|
||||
|
||||
void btHashedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
|
||||
{
|
||||
class RemovePairCallback : public btOverlapCallback
|
||||
|
||||
class RemovePairCallback : public btOverlapCallback
|
||||
{
|
||||
btBroadphaseProxy* m_obsoleteProxy;
|
||||
|
||||
public:
|
||||
RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
|
||||
: m_obsoleteProxy(obsoleteProxy)
|
||||
:m_obsoleteProxy(obsoleteProxy)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
return ((pair.m_pProxy0 == m_obsoleteProxy) ||
|
||||
(pair.m_pProxy1 == m_obsoleteProxy));
|
||||
(pair.m_pProxy1 == m_obsoleteProxy));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
RemovePairCallback removeCallback(proxy);
|
||||
|
||||
processAllOverlappingPairs(&removeCallback, dispatcher);
|
||||
processAllOverlappingPairs(&removeCallback,dispatcher);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
btBroadphasePair* btHashedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||
{
|
||||
if (proxy0->m_uniqueId > proxy1->m_uniqueId)
|
||||
btSwap(proxy0, proxy1);
|
||||
gFindPairs++;
|
||||
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
||||
btSwap(proxy0,proxy1);
|
||||
int proxyId1 = proxy0->getUid();
|
||||
int proxyId2 = proxy1->getUid();
|
||||
|
||||
/*if (proxyId1 > proxyId2)
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
|
||||
|
||||
if (hash >= m_hashTable.size())
|
||||
{
|
||||
@@ -134,8 +168,9 @@ btBroadphasePair* btHashedOverlappingPairCache::findPair(btBroadphaseProxy* prox
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
void btHashedOverlappingPairCache::growTables()
|
||||
void btHashedOverlappingPairCache::growTables()
|
||||
{
|
||||
|
||||
int newCapacity = m_overlappingPairArray.capacity();
|
||||
|
||||
if (m_hashTable.size() < newCapacity)
|
||||
@@ -146,9 +181,10 @@ void btHashedOverlappingPairCache::growTables()
|
||||
m_hashTable.resize(newCapacity);
|
||||
m_next.resize(newCapacity);
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < newCapacity; ++i)
|
||||
for (i= 0; i < newCapacity; ++i)
|
||||
{
|
||||
m_hashTable[i] = BT_NULL_PAIR;
|
||||
}
|
||||
@@ -157,31 +193,35 @@ void btHashedOverlappingPairCache::growTables()
|
||||
m_next[i] = BT_NULL_PAIR;
|
||||
}
|
||||
|
||||
for (i = 0; i < curHashtableSize; i++)
|
||||
for(i=0;i<curHashtableSize;i++)
|
||||
{
|
||||
|
||||
const btBroadphasePair& pair = m_overlappingPairArray[i];
|
||||
int proxyId1 = pair.m_pProxy0->getUid();
|
||||
int proxyId2 = pair.m_pProxy1->getUid();
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
int hashValue = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1)); // New hash value with new mask
|
||||
int hashValue = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask
|
||||
m_next[i] = m_hashTable[hashValue];
|
||||
m_hashTable[hashValue] = i;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||
{
|
||||
if (proxy0->m_uniqueId > proxy1->m_uniqueId)
|
||||
btSwap(proxy0, proxy1);
|
||||
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
||||
btSwap(proxy0,proxy1);
|
||||
int proxyId1 = proxy0->getUid();
|
||||
int proxyId2 = proxy1->getUid();
|
||||
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1)); // New hash value with new mask
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1)); // New hash value with new mask
|
||||
|
||||
|
||||
btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
|
||||
if (pair != NULL)
|
||||
@@ -203,7 +243,7 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProx
|
||||
|
||||
//this is where we add an actual pair, so also call the 'ghost'
|
||||
if (m_ghostPairCallback)
|
||||
m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
|
||||
m_ghostPairCallback->addOverlappingPair(proxy0,proxy1);
|
||||
|
||||
int newCapacity = m_overlappingPairArray.capacity();
|
||||
|
||||
@@ -211,14 +251,15 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProx
|
||||
{
|
||||
growTables();
|
||||
//hash with new capacity
|
||||
hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
|
||||
hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
|
||||
}
|
||||
|
||||
pair = new (mem) btBroadphasePair(*proxy0, *proxy1);
|
||||
// pair->m_pProxy0 = proxy0;
|
||||
// pair->m_pProxy1 = proxy1;
|
||||
|
||||
pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
|
||||
// pair->m_pProxy0 = proxy0;
|
||||
// pair->m_pProxy1 = proxy1;
|
||||
pair->m_algorithm = 0;
|
||||
pair->m_internalTmpValue = 0;
|
||||
|
||||
|
||||
m_next[count] = m_hashTable[hash];
|
||||
m_hashTable[hash] = count;
|
||||
@@ -226,17 +267,20 @@ btBroadphasePair* btHashedOverlappingPairCache::internalAddPair(btBroadphaseProx
|
||||
return pair;
|
||||
}
|
||||
|
||||
void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, btDispatcher* dispatcher)
|
||||
|
||||
|
||||
void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1,btDispatcher* dispatcher)
|
||||
{
|
||||
if (proxy0->m_uniqueId > proxy1->m_uniqueId)
|
||||
btSwap(proxy0, proxy1);
|
||||
gRemovePairs++;
|
||||
if(proxy0->m_uniqueId>proxy1->m_uniqueId)
|
||||
btSwap(proxy0,proxy1);
|
||||
int proxyId1 = proxy0->getUid();
|
||||
int proxyId2 = proxy1->getUid();
|
||||
|
||||
/*if (proxyId1 > proxyId2)
|
||||
/*if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);*/
|
||||
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1), static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity() - 1));
|
||||
int hash = static_cast<int>(getHash(static_cast<unsigned int>(proxyId1),static_cast<unsigned int>(proxyId2)) & (m_overlappingPairArray.capacity()-1));
|
||||
|
||||
btBroadphasePair* pair = internalFindPair(proxy0, proxy1, hash);
|
||||
if (pair == NULL)
|
||||
@@ -244,7 +288,7 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
|
||||
return 0;
|
||||
}
|
||||
|
||||
cleanOverlappingPair(*pair, dispatcher);
|
||||
cleanOverlappingPair(*pair,dispatcher);
|
||||
|
||||
void* userData = pair->m_internalInfo1;
|
||||
|
||||
@@ -282,7 +326,7 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
|
||||
int lastPairIndex = m_overlappingPairArray.size() - 1;
|
||||
|
||||
if (m_ghostPairCallback)
|
||||
m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1, dispatcher);
|
||||
m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1,dispatcher);
|
||||
|
||||
// If the removed pair is the last pair, we are done.
|
||||
if (lastPairIndex == pairIndex)
|
||||
@@ -293,8 +337,8 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
|
||||
|
||||
// Remove the last pair from the hash table.
|
||||
const btBroadphasePair* last = &m_overlappingPairArray[lastPairIndex];
|
||||
/* missing swap here too, Nat. */
|
||||
int lastHash = static_cast<int>(getHash(static_cast<unsigned int>(last->m_pProxy0->getUid()), static_cast<unsigned int>(last->m_pProxy1->getUid())) & (m_overlappingPairArray.capacity() - 1));
|
||||
/* missing swap here too, Nat. */
|
||||
int lastHash = static_cast<int>(getHash(static_cast<unsigned int>(last->m_pProxy0->getUid()), static_cast<unsigned int>(last->m_pProxy1->getUid())) & (m_overlappingPairArray.capacity()-1));
|
||||
|
||||
index = m_hashTable[lastHash];
|
||||
btAssert(index != BT_NULL_PAIR);
|
||||
@@ -328,106 +372,44 @@ void* btHashedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
|
||||
return userData;
|
||||
}
|
||||
//#include <stdio.h>
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback, btDispatcher* dispatcher)
|
||||
|
||||
void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher)
|
||||
{
|
||||
BT_PROFILE("btHashedOverlappingPairCache::processAllOverlappingPairs");
|
||||
|
||||
int i;
|
||||
|
||||
// printf("m_overlappingPairArray.size()=%d\n",m_overlappingPairArray.size());
|
||||
for (i = 0; i < m_overlappingPairArray.size();)
|
||||
// printf("m_overlappingPairArray.size()=%d\n",m_overlappingPairArray.size());
|
||||
for (i=0;i<m_overlappingPairArray.size();)
|
||||
{
|
||||
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[i];
|
||||
if (callback->processOverlap(*pair))
|
||||
{
|
||||
removeOverlappingPair(pair->m_pProxy0, pair->m_pProxy1, dispatcher);
|
||||
}
|
||||
else
|
||||
removeOverlappingPair(pair->m_pProxy0,pair->m_pProxy1,dispatcher);
|
||||
|
||||
gOverlappingPairs--;
|
||||
} else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MyPairIndex
|
||||
{
|
||||
int m_orgIndex;
|
||||
int m_uidA0;
|
||||
int m_uidA1;
|
||||
};
|
||||
|
||||
class MyPairIndeSortPredicate
|
||||
{
|
||||
public:
|
||||
bool operator()(const MyPairIndex& a, const MyPairIndex& b) const
|
||||
{
|
||||
const int uidA0 = a.m_uidA0;
|
||||
const int uidB0 = b.m_uidA0;
|
||||
const int uidA1 = a.m_uidA1;
|
||||
const int uidB1 = b.m_uidA1;
|
||||
return uidA0 > uidB0 || (uidA0 == uidB0 && uidA1 > uidB1);
|
||||
}
|
||||
};
|
||||
|
||||
void btHashedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback, btDispatcher* dispatcher, const struct btDispatcherInfo& dispatchInfo)
|
||||
{
|
||||
if (dispatchInfo.m_deterministicOverlappingPairs)
|
||||
{
|
||||
btBroadphasePairArray& pa = getOverlappingPairArray();
|
||||
btAlignedObjectArray<MyPairIndex> indices;
|
||||
{
|
||||
BT_PROFILE("sortOverlappingPairs");
|
||||
indices.resize(pa.size());
|
||||
for (int i = 0; i < indices.size(); i++)
|
||||
{
|
||||
const btBroadphasePair& p = pa[i];
|
||||
const int uidA0 = p.m_pProxy0 ? p.m_pProxy0->m_uniqueId : -1;
|
||||
const int uidA1 = p.m_pProxy1 ? p.m_pProxy1->m_uniqueId : -1;
|
||||
|
||||
indices[i].m_uidA0 = uidA0;
|
||||
indices[i].m_uidA1 = uidA1;
|
||||
indices[i].m_orgIndex = i;
|
||||
}
|
||||
indices.quickSort(MyPairIndeSortPredicate());
|
||||
}
|
||||
{
|
||||
BT_PROFILE("btHashedOverlappingPairCache::processAllOverlappingPairs");
|
||||
int i;
|
||||
for (i = 0; i < indices.size();)
|
||||
{
|
||||
btBroadphasePair* pair = &pa[indices[i].m_orgIndex];
|
||||
if (callback->processOverlap(*pair))
|
||||
{
|
||||
removeOverlappingPair(pair->m_pProxy0, pair->m_pProxy1, dispatcher);
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
processAllOverlappingPairs(callback, dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
///need to keep hashmap in sync with pair address, so rebuild all
|
||||
btBroadphasePairArray tmpPairs;
|
||||
int i;
|
||||
for (i = 0; i < m_overlappingPairArray.size(); i++)
|
||||
for (i=0;i<m_overlappingPairArray.size();i++)
|
||||
{
|
||||
tmpPairs.push_back(m_overlappingPairArray[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < tmpPairs.size(); i++)
|
||||
for (i=0;i<tmpPairs.size();i++)
|
||||
{
|
||||
removeOverlappingPair(tmpPairs[i].m_pProxy0, tmpPairs[i].m_pProxy1, dispatcher);
|
||||
removeOverlappingPair(tmpPairs[i].m_pProxy0,tmpPairs[i].m_pProxy1,dispatcher);
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < m_next.size(); i++)
|
||||
{
|
||||
m_next[i] = BT_NULL_PAIR;
|
||||
@@ -435,28 +417,32 @@ void btHashedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher
|
||||
|
||||
tmpPairs.quickSort(btBroadphasePairSortPredicate());
|
||||
|
||||
for (i = 0; i < tmpPairs.size(); i++)
|
||||
for (i=0;i<tmpPairs.size();i++)
|
||||
{
|
||||
addOverlappingPair(tmpPairs[i].m_pProxy0, tmpPairs[i].m_pProxy1);
|
||||
addOverlappingPair(tmpPairs[i].m_pProxy0,tmpPairs[i].m_pProxy1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void* btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, btDispatcher* dispatcher)
|
||||
|
||||
void* btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1, btDispatcher* dispatcher )
|
||||
{
|
||||
if (!hasDeferredRemoval())
|
||||
{
|
||||
btBroadphasePair findPair(*proxy0, *proxy1);
|
||||
btBroadphasePair findPair(*proxy0,*proxy1);
|
||||
|
||||
int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
|
||||
if (findIndex < m_overlappingPairArray.size())
|
||||
{
|
||||
gOverlappingPairs--;
|
||||
btBroadphasePair& pair = m_overlappingPairArray[findIndex];
|
||||
void* userData = pair.m_internalInfo1;
|
||||
cleanOverlappingPair(pair, dispatcher);
|
||||
cleanOverlappingPair(pair,dispatcher);
|
||||
if (m_ghostPairCallback)
|
||||
m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1, dispatcher);
|
||||
|
||||
m_overlappingPairArray.swap(findIndex, m_overlappingPairArray.capacity() - 1);
|
||||
m_ghostPairCallback->removeOverlappingPair(proxy0, proxy1,dispatcher);
|
||||
|
||||
m_overlappingPairArray.swap(findIndex,m_overlappingPairArray.capacity()-1);
|
||||
m_overlappingPairArray.pop_back();
|
||||
return userData;
|
||||
}
|
||||
@@ -465,73 +451,99 @@ void* btSortedOverlappingPairCache::removeOverlappingPair(btBroadphaseProxy* pro
|
||||
return 0;
|
||||
}
|
||||
|
||||
btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
btBroadphasePair* btSortedOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
//don't add overlap with own
|
||||
btAssert(proxy0 != proxy1);
|
||||
|
||||
if (!needsBroadphaseCollision(proxy0, proxy1))
|
||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||
return 0;
|
||||
|
||||
|
||||
void* mem = &m_overlappingPairArray.expandNonInitializing();
|
||||
btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0, *proxy1);
|
||||
|
||||
btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
|
||||
|
||||
gOverlappingPairs++;
|
||||
gAddedPairs++;
|
||||
|
||||
if (m_ghostPairCallback)
|
||||
m_ghostPairCallback->addOverlappingPair(proxy0, proxy1);
|
||||
return pair;
|
||||
|
||||
}
|
||||
|
||||
///this findPair becomes really slow. Either sort the list to speedup the query, or
|
||||
///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed.
|
||||
///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address)
|
||||
///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
|
||||
btBroadphasePair* btSortedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||
btBroadphasePair* btSortedOverlappingPairCache::findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
if (!needsBroadphaseCollision(proxy0, proxy1))
|
||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||
return 0;
|
||||
|
||||
btBroadphasePair tmpPair(*proxy0, *proxy1);
|
||||
btBroadphasePair tmpPair(*proxy0,*proxy1);
|
||||
int findIndex = m_overlappingPairArray.findLinearSearch(tmpPair);
|
||||
|
||||
if (findIndex < m_overlappingPairArray.size())
|
||||
{
|
||||
//btAssert(it != m_overlappingPairSet.end());
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
|
||||
return pair;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback, btDispatcher* dispatcher)
|
||||
void btSortedOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback,btDispatcher* dispatcher)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < m_overlappingPairArray.size();)
|
||||
for (i=0;i<m_overlappingPairArray.size();)
|
||||
{
|
||||
|
||||
btBroadphasePair* pair = &m_overlappingPairArray[i];
|
||||
if (callback->processOverlap(*pair))
|
||||
{
|
||||
cleanOverlappingPair(*pair, dispatcher);
|
||||
cleanOverlappingPair(*pair,dispatcher);
|
||||
pair->m_pProxy0 = 0;
|
||||
pair->m_pProxy1 = 0;
|
||||
m_overlappingPairArray.swap(i, m_overlappingPairArray.size() - 1);
|
||||
m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
m_overlappingPairArray.pop_back();
|
||||
}
|
||||
else
|
||||
gOverlappingPairs--;
|
||||
} else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btSortedOverlappingPairCache::btSortedOverlappingPairCache() : m_blockedForChanges(false),
|
||||
m_hasDeferredRemoval(true),
|
||||
m_overlapFilterCallback(0),
|
||||
m_ghostPairCallback(0)
|
||||
|
||||
|
||||
|
||||
btSortedOverlappingPairCache::btSortedOverlappingPairCache():
|
||||
m_blockedForChanges(false),
|
||||
m_hasDeferredRemoval(true),
|
||||
m_overlapFilterCallback(0),
|
||||
m_ghostPairCallback(0)
|
||||
{
|
||||
int initialAllocatedSize = 2;
|
||||
int initialAllocatedSize= 2;
|
||||
m_overlappingPairArray.reserve(initialAllocatedSize);
|
||||
}
|
||||
|
||||
@@ -539,73 +551,82 @@ btSortedOverlappingPairCache::~btSortedOverlappingPairCache()
|
||||
{
|
||||
}
|
||||
|
||||
void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair, btDispatcher* dispatcher)
|
||||
void btSortedOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher)
|
||||
{
|
||||
if (pair.m_algorithm)
|
||||
{
|
||||
{
|
||||
pair.m_algorithm->~btCollisionAlgorithm();
|
||||
dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
|
||||
pair.m_algorithm = 0;
|
||||
pair.m_algorithm=0;
|
||||
gRemovePairs--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btSortedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy, btDispatcher* dispatcher)
|
||||
|
||||
void btSortedOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
|
||||
{
|
||||
class CleanPairCallback : public btOverlapCallback
|
||||
|
||||
class CleanPairCallback : public btOverlapCallback
|
||||
{
|
||||
btBroadphaseProxy* m_cleanProxy;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
btDispatcher* m_dispatcher;
|
||||
|
||||
public:
|
||||
CleanPairCallback(btBroadphaseProxy* cleanProxy, btOverlappingPairCache* pairCache, btDispatcher* dispatcher)
|
||||
: m_cleanProxy(cleanProxy),
|
||||
m_pairCache(pairCache),
|
||||
m_dispatcher(dispatcher)
|
||||
CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher)
|
||||
:m_cleanProxy(cleanProxy),
|
||||
m_pairCache(pairCache),
|
||||
m_dispatcher(dispatcher)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
if ((pair.m_pProxy0 == m_cleanProxy) ||
|
||||
(pair.m_pProxy1 == m_cleanProxy))
|
||||
{
|
||||
m_pairCache->cleanOverlappingPair(pair, m_dispatcher);
|
||||
m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CleanPairCallback cleanPairs(proxy, this, dispatcher);
|
||||
CleanPairCallback cleanPairs(proxy,this,dispatcher);
|
||||
|
||||
processAllOverlappingPairs(&cleanPairs,dispatcher);
|
||||
|
||||
processAllOverlappingPairs(&cleanPairs, dispatcher);
|
||||
}
|
||||
|
||||
void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher)
|
||||
|
||||
void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher)
|
||||
{
|
||||
class RemovePairCallback : public btOverlapCallback
|
||||
|
||||
class RemovePairCallback : public btOverlapCallback
|
||||
{
|
||||
btBroadphaseProxy* m_obsoleteProxy;
|
||||
|
||||
public:
|
||||
RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
|
||||
: m_obsoleteProxy(obsoleteProxy)
|
||||
:m_obsoleteProxy(obsoleteProxy)
|
||||
{
|
||||
}
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
return ((pair.m_pProxy0 == m_obsoleteProxy) ||
|
||||
(pair.m_pProxy1 == m_obsoleteProxy));
|
||||
(pair.m_pProxy1 == m_obsoleteProxy));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
RemovePairCallback removeCallback(proxy);
|
||||
|
||||
processAllOverlappingPairs(&removeCallback, dispatcher);
|
||||
processAllOverlappingPairs(&removeCallback,dispatcher);
|
||||
}
|
||||
|
||||
void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
void btSortedOverlappingPairCache::sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
//should already be sorted
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ subject to the following restrictions:
|
||||
#ifndef BT_OVERLAPPING_PAIR_CACHE_H
|
||||
#define BT_OVERLAPPING_PAIR_CACHE_H
|
||||
|
||||
|
||||
#include "btBroadphaseInterface.h"
|
||||
#include "btBroadphaseProxy.h"
|
||||
#include "btOverlappingPairCallback.h"
|
||||
@@ -23,164 +24,174 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
class btDispatcher;
|
||||
|
||||
typedef btAlignedObjectArray<btBroadphasePair> btBroadphasePairArray;
|
||||
typedef btAlignedObjectArray<btBroadphasePair> btBroadphasePairArray;
|
||||
|
||||
struct btOverlapCallback
|
||||
struct btOverlapCallback
|
||||
{
|
||||
virtual ~btOverlapCallback()
|
||||
{
|
||||
}
|
||||
{}
|
||||
//return true for deletion of the pair
|
||||
virtual bool processOverlap(btBroadphasePair& pair) = 0;
|
||||
virtual bool processOverlap(btBroadphasePair& pair) = 0;
|
||||
|
||||
};
|
||||
|
||||
struct btOverlapFilterCallback
|
||||
{
|
||||
virtual ~btOverlapFilterCallback()
|
||||
{
|
||||
}
|
||||
{}
|
||||
// return true when pairs need collision
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const = 0;
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0;
|
||||
};
|
||||
|
||||
const int BT_NULL_PAIR = 0xffffffff;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern int gRemovePairs;
|
||||
extern int gAddedPairs;
|
||||
extern int gFindPairs;
|
||||
|
||||
const int BT_NULL_PAIR=0xffffffff;
|
||||
|
||||
///The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
|
||||
///The btHashedOverlappingPairCache and btSortedOverlappingPairCache classes are two implementations.
|
||||
class btOverlappingPairCache : public btOverlappingPairCallback
|
||||
{
|
||||
public:
|
||||
virtual ~btOverlappingPairCache() {} // this is needed so we can get to the derived class destructor
|
||||
virtual ~btOverlappingPairCache() {} // this is needed so we can get to the derived class destructor
|
||||
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr() = 0;
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr() = 0;
|
||||
|
||||
virtual const btBroadphasePair* getOverlappingPairArrayPtr() const = 0;
|
||||
|
||||
virtual const btBroadphasePair* getOverlappingPairArrayPtr() const = 0;
|
||||
virtual btBroadphasePairArray& getOverlappingPairArray() = 0;
|
||||
|
||||
virtual btBroadphasePairArray& getOverlappingPairArray() = 0;
|
||||
|
||||
virtual void cleanOverlappingPair(btBroadphasePair& pair, btDispatcher* dispatcher) = 0;
|
||||
virtual void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual int getNumOverlappingPairs() const = 0;
|
||||
virtual bool needsBroadphaseCollision(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1) const = 0;
|
||||
virtual btOverlapFilterCallback* getOverlapFilterCallback() = 0;
|
||||
virtual void cleanProxyFromPairs(btBroadphaseProxy* proxy, btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void setOverlapFilterCallback(btOverlapFilterCallback* callback) = 0;
|
||||
virtual void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*, btDispatcher* dispatcher) = 0;
|
||||
virtual void setOverlapFilterCallback(btOverlapFilterCallback* callback) = 0;
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback* callback, btDispatcher* dispatcher, const struct btDispatcherInfo& /*dispatchInfo*/)
|
||||
{
|
||||
processAllOverlappingPairs(callback, dispatcher);
|
||||
}
|
||||
virtual btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) = 0;
|
||||
|
||||
virtual bool hasDeferredRemoval() = 0;
|
||||
virtual bool hasDeferredRemoval() = 0;
|
||||
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)=0;
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback) = 0;
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher) = 0;
|
||||
};
|
||||
|
||||
/// Hash-space based Pair Cache, thanks to Erin Catto, Box2D, http://www.box2d.org, and Pierre Terdiman, Codercorner, http://codercorner.com
|
||||
|
||||
ATTRIBUTE_ALIGNED16(class)
|
||||
btHashedOverlappingPairCache : public btOverlappingPairCache
|
||||
class btHashedOverlappingPairCache : public btOverlappingPairCache
|
||||
{
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||
|
||||
protected:
|
||||
btAlignedObjectArray<int> m_hashTable;
|
||||
btAlignedObjectArray<int> m_next;
|
||||
btOverlappingPairCallback* m_ghostPairCallback;
|
||||
|
||||
btAlignedObjectArray<int> m_hashTable;
|
||||
btAlignedObjectArray<int> m_next;
|
||||
btOverlappingPairCallback* m_ghostPairCallback;
|
||||
|
||||
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btHashedOverlappingPairCache();
|
||||
virtual ~btHashedOverlappingPairCache();
|
||||
|
||||
void removeOverlappingPairsContainingProxy(btBroadphaseProxy * proxy, btDispatcher * dispatcher);
|
||||
|
||||
void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
|
||||
virtual void* removeOverlappingPair(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1, btDispatcher * dispatcher);
|
||||
|
||||
SIMD_FORCE_INLINE bool needsBroadphaseCollision(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1) const
|
||||
virtual void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher);
|
||||
|
||||
SIMD_FORCE_INLINE bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
|
||||
{
|
||||
if (m_overlapFilterCallback)
|
||||
return m_overlapFilterCallback->needBroadphaseCollision(proxy0, proxy1);
|
||||
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
|
||||
|
||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||
|
||||
|
||||
return collides;
|
||||
}
|
||||
|
||||
// Add a pair and return the new pair. If the pair already exists,
|
||||
// no new pair is created and the old one is returned.
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1)
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
if (!needsBroadphaseCollision(proxy0, proxy1))
|
||||
gAddedPairs++;
|
||||
|
||||
if (!needsBroadphaseCollision(proxy0,proxy1))
|
||||
return 0;
|
||||
|
||||
return internalAddPair(proxy0, proxy1);
|
||||
return internalAddPair(proxy0,proxy1);
|
||||
}
|
||||
|
||||
void cleanProxyFromPairs(btBroadphaseProxy * proxy, btDispatcher * dispatcher);
|
||||
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*, btDispatcher * dispatcher);
|
||||
void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback * callback, btDispatcher * dispatcher, const struct btDispatcherInfo& dispatchInfo);
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
|
||||
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
void cleanOverlappingPair(btBroadphasePair & pair, btDispatcher * dispatcher);
|
||||
void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
||||
|
||||
btBroadphasePair* findPair(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1);
|
||||
|
||||
|
||||
btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1);
|
||||
|
||||
int GetCount() const { return m_overlappingPairArray.size(); }
|
||||
// btBroadphasePair* GetPairs() { return m_pairs; }
|
||||
// btBroadphasePair* GetPairs() { return m_pairs; }
|
||||
|
||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||
{
|
||||
return m_overlapFilterCallback;
|
||||
}
|
||||
|
||||
void setOverlapFilterCallback(btOverlapFilterCallback * callback)
|
||||
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
||||
{
|
||||
m_overlapFilterCallback = callback;
|
||||
}
|
||||
|
||||
int getNumOverlappingPairs() const
|
||||
int getNumOverlappingPairs() const
|
||||
{
|
||||
return m_overlappingPairArray.size();
|
||||
}
|
||||
|
||||
private:
|
||||
btBroadphasePair* internalAddPair(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1);
|
||||
|
||||
btBroadphasePair* internalAddPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
void growTables();
|
||||
void growTables();
|
||||
|
||||
SIMD_FORCE_INLINE bool equalsPair(const btBroadphasePair& pair, int proxyId1, int proxyId2)
|
||||
{
|
||||
{
|
||||
return pair.m_pProxy0->getUid() == proxyId1 && pair.m_pProxy1->getUid() == proxyId2;
|
||||
}
|
||||
|
||||
@@ -200,37 +211,43 @@ private:
|
||||
}
|
||||
*/
|
||||
|
||||
SIMD_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2)
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE unsigned int getHash(unsigned int proxyId1, unsigned int proxyId2)
|
||||
{
|
||||
unsigned int key = proxyId1 | (proxyId2 << 16);
|
||||
int key = static_cast<int>(((unsigned int)proxyId1) | (((unsigned int)proxyId2) <<16));
|
||||
// Thomas Wang's hash
|
||||
|
||||
key += ~(key << 15);
|
||||
key ^= (key >> 10);
|
||||
key += (key << 3);
|
||||
key ^= (key >> 6);
|
||||
key ^= (key >> 10);
|
||||
key += (key << 3);
|
||||
key ^= (key >> 6);
|
||||
key += ~(key << 11);
|
||||
key ^= (key >> 16);
|
||||
return key;
|
||||
key ^= (key >> 16);
|
||||
return static_cast<unsigned int>(key);
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE btBroadphasePair* internalFindPair(btBroadphaseProxy * proxy0, btBroadphaseProxy * proxy1, int hash)
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE btBroadphasePair* internalFindPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, int hash)
|
||||
{
|
||||
int proxyId1 = proxy0->getUid();
|
||||
int proxyId2 = proxy1->getUid();
|
||||
#if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat.
|
||||
#if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat.
|
||||
if (proxyId1 > proxyId2)
|
||||
btSwap(proxyId1, proxyId2);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int index = m_hashTable[hash];
|
||||
|
||||
while (index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
|
||||
|
||||
while( index != BT_NULL_PAIR && equalsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false)
|
||||
{
|
||||
index = m_next[index];
|
||||
}
|
||||
|
||||
if (index == BT_NULL_PAIR)
|
||||
if ( index == BT_NULL_PAIR )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -240,136 +257,155 @@ private:
|
||||
return &m_overlappingPairArray[index];
|
||||
}
|
||||
|
||||
virtual bool hasDeferredRemoval()
|
||||
virtual bool hasDeferredRemoval()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback * ghostPairCallback)
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)
|
||||
{
|
||||
m_ghostPairCallback = ghostPairCallback;
|
||||
}
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher * dispatcher);
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
///btSortedOverlappingPairCache maintains the objects with overlapping AABB
|
||||
///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
|
||||
class btSortedOverlappingPairCache : public btOverlappingPairCache
|
||||
class btSortedOverlappingPairCache : public btOverlappingPairCache
|
||||
{
|
||||
protected:
|
||||
//avoid brute-force finding all the time
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
protected:
|
||||
//avoid brute-force finding all the time
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
|
||||
//during the dispatch, check that user doesn't destroy/create proxy
|
||||
bool m_blockedForChanges;
|
||||
//during the dispatch, check that user doesn't destroy/create proxy
|
||||
bool m_blockedForChanges;
|
||||
|
||||
///by default, do the removal during the pair traversal
|
||||
bool m_hasDeferredRemoval;
|
||||
///by default, do the removal during the pair traversal
|
||||
bool m_hasDeferredRemoval;
|
||||
|
||||
//if set, use the callback instead of the built in filter in needBroadphaseCollision
|
||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||
|
||||
//if set, use the callback instead of the built in filter in needBroadphaseCollision
|
||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||
btOverlappingPairCallback* m_ghostPairCallback;
|
||||
|
||||
btOverlappingPairCallback* m_ghostPairCallback;
|
||||
public:
|
||||
|
||||
btSortedOverlappingPairCache();
|
||||
virtual ~btSortedOverlappingPairCache();
|
||||
|
||||
public:
|
||||
btSortedOverlappingPairCache();
|
||||
virtual ~btSortedOverlappingPairCache();
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*, btDispatcher* dispatcher);
|
||||
void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher);
|
||||
|
||||
void* removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, btDispatcher* dispatcher);
|
||||
void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
||||
|
||||
btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
void cleanOverlappingPair(btBroadphasePair& pair, btDispatcher* dispatcher);
|
||||
btBroadphasePair* findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
|
||||
void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
|
||||
btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1);
|
||||
void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
|
||||
btBroadphasePair* findPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1);
|
||||
|
||||
void cleanProxyFromPairs(btBroadphaseProxy* proxy, btDispatcher* dispatcher);
|
||||
inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
|
||||
{
|
||||
if (m_overlapFilterCallback)
|
||||
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
|
||||
|
||||
void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher);
|
||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||
|
||||
return collides;
|
||||
}
|
||||
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const
|
||||
{
|
||||
if (m_overlapFilterCallback)
|
||||
return m_overlapFilterCallback->needBroadphaseCollision(proxy0, proxy1);
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||
|
||||
|
||||
return collides;
|
||||
}
|
||||
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
|
||||
btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
int getNumOverlappingPairs() const
|
||||
{
|
||||
return m_overlappingPairArray.size();
|
||||
}
|
||||
|
||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||
{
|
||||
return m_overlapFilterCallback;
|
||||
}
|
||||
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
||||
{
|
||||
m_overlapFilterCallback = callback;
|
||||
}
|
||||
|
||||
int getNumOverlappingPairs() const
|
||||
{
|
||||
return m_overlappingPairArray.size();
|
||||
}
|
||||
virtual bool hasDeferredRemoval()
|
||||
{
|
||||
return m_hasDeferredRemoval;
|
||||
}
|
||||
|
||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||
{
|
||||
return m_overlapFilterCallback;
|
||||
}
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)
|
||||
{
|
||||
m_ghostPairCallback = ghostPairCallback;
|
||||
}
|
||||
|
||||
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
||||
{
|
||||
m_overlapFilterCallback = callback;
|
||||
}
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
|
||||
virtual bool hasDeferredRemoval()
|
||||
{
|
||||
return m_hasDeferredRemoval;
|
||||
}
|
||||
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* ghostPairCallback)
|
||||
{
|
||||
m_ghostPairCallback = ghostPairCallback;
|
||||
}
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher);
|
||||
};
|
||||
|
||||
|
||||
|
||||
///btNullPairCache skips add/removal of overlapping pairs. Userful for benchmarking and unit testing.
|
||||
class btNullPairCache : public btOverlappingPairCache
|
||||
{
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
|
||||
public:
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
|
||||
virtual btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||
{
|
||||
return &m_overlappingPairArray[0];
|
||||
}
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
virtual void cleanOverlappingPair(btBroadphasePair& /*pair*/, btDispatcher* /*dispatcher*/)
|
||||
|
||||
virtual void cleanOverlappingPair(btBroadphasePair& /*pair*/,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual int getNumOverlappingPairs() const
|
||||
@@ -377,23 +413,16 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void cleanProxyFromPairs(btBroadphaseProxy* /*proxy*/, btDispatcher* /*dispatcher*/)
|
||||
virtual void cleanProxyFromPairs(btBroadphaseProxy* /*proxy*/,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void setOverlapFilterCallback(btOverlapFilterCallback* /*callback*/)
|
||||
{
|
||||
}
|
||||
|
||||
bool needsBroadphaseCollision(btBroadphaseProxy*, btBroadphaseProxy*) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual void setOverlapFilterCallback(btOverlapFilterCallback* /*callback*/)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*, btDispatcher* /*dispatcher*/)
|
||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -402,33 +431,39 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual bool hasDeferredRemoval()
|
||||
virtual bool hasDeferredRemoval()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* /* ghostPairCallback */)
|
||||
virtual void setInternalGhostPairCallback(btOverlappingPairCallback* /* ghostPairCallback */)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* /*proxy0*/, btBroadphaseProxy* /*proxy1*/)
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* /*proxy0*/,btBroadphaseProxy* /*proxy1*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void* removeOverlappingPair(btBroadphaseProxy* /*proxy0*/, btBroadphaseProxy* /*proxy1*/, btDispatcher* /*dispatcher*/)
|
||||
virtual void* removeOverlappingPair(btBroadphaseProxy* /*proxy0*/,btBroadphaseProxy* /*proxy1*/,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* /*proxy0*/, btDispatcher* /*dispatcher*/)
|
||||
virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* /*proxy0*/,btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
(void) dispatcher;
|
||||
}
|
||||
|
||||
|
||||
virtual void sortOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
(void)dispatcher;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //BT_OVERLAPPING_PAIR_CACHE_H
|
||||
|
||||
#endif //BT_OVERLAPPING_PAIR_CACHE_H
|
||||
|
||||
|
||||
|
@@ -18,24 +18,23 @@ subject to the following restrictions:
|
||||
#define OVERLAPPING_PAIR_CALLBACK_H
|
||||
|
||||
class btDispatcher;
|
||||
struct btBroadphasePair;
|
||||
struct btBroadphasePair;
|
||||
|
||||
///The btOverlappingPairCallback class is an additional optional broadphase user callback for adding/removing overlapping pairs, similar interface to btOverlappingPairCache.
|
||||
class btOverlappingPairCallback
|
||||
{
|
||||
protected:
|
||||
btOverlappingPairCallback() {}
|
||||
|
||||
public:
|
||||
virtual ~btOverlappingPairCallback()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) = 0;
|
||||
|
||||
virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) = 0;
|
||||
virtual void* removeOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void* removeOverlappingPair(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1, btDispatcher* dispatcher) = 0;
|
||||
virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy0,btDispatcher* dispatcher) = 0;
|
||||
|
||||
virtual void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy0, btDispatcher* dispatcher) = 0;
|
||||
};
|
||||
|
||||
#endif //OVERLAPPING_PAIR_CALLBACK_H
|
||||
#endif //OVERLAPPING_PAIR_CALLBACK_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -22,11 +22,11 @@ class btSerializer;
|
||||
#ifdef DEBUG_CHECK_DEQUANTIZATION
|
||||
#ifdef __SPU__
|
||||
#define printf spu_printf
|
||||
#endif //__SPU__
|
||||
#endif //__SPU__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#endif //DEBUG_CHECK_DEQUANTIZATION
|
||||
#endif //DEBUG_CHECK_DEQUANTIZATION
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/btAlignedAllocator.h"
|
||||
@@ -41,10 +41,13 @@ class btSerializer;
|
||||
#define btQuantizedBvhDataName "btQuantizedBvhFloatData"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__m128.asp
|
||||
|
||||
|
||||
//Note: currently we have 16 bytes per quantized node
|
||||
#define MAX_SUBTREE_SIZE_IN_BYTES 2048
|
||||
#define MAX_SUBTREE_SIZE_IN_BYTES 2048
|
||||
|
||||
// 10 gives the potential for 1024 parts, with at most 2^21 (2097152) (minus one
|
||||
// actually) triangles each (since the sign bit is reserved
|
||||
@@ -52,16 +55,15 @@ class btSerializer;
|
||||
|
||||
///btQuantizedBvhNode is a compressed aabb node, 16 bytes.
|
||||
///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
|
||||
ATTRIBUTE_ALIGNED16(struct)
|
||||
btQuantizedBvhNode
|
||||
ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//12 bytes
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
unsigned short int m_quantizedAabbMax[3];
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
unsigned short int m_quantizedAabbMax[3];
|
||||
//4 bytes
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
int m_escapeIndexOrTriangleIndex;
|
||||
|
||||
bool isLeafNode() const
|
||||
{
|
||||
@@ -73,67 +75,68 @@ btQuantizedBvhNode
|
||||
btAssert(!isLeafNode());
|
||||
return -m_escapeIndexOrTriangleIndex;
|
||||
}
|
||||
int getTriangleIndex() const
|
||||
int getTriangleIndex() const
|
||||
{
|
||||
btAssert(isLeafNode());
|
||||
unsigned int x = 0;
|
||||
unsigned int y = (~(x & 0)) << (31 - MAX_NUM_PARTS_IN_BITS);
|
||||
unsigned int x=0;
|
||||
unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);
|
||||
// Get only the lower bits where the triangle index is stored
|
||||
return (m_escapeIndexOrTriangleIndex & ~(y));
|
||||
return (m_escapeIndexOrTriangleIndex&~(y));
|
||||
}
|
||||
int getPartId() const
|
||||
int getPartId() const
|
||||
{
|
||||
btAssert(isLeafNode());
|
||||
// Get only the highest bits where the part index is stored
|
||||
return (m_escapeIndexOrTriangleIndex >> (31 - MAX_NUM_PARTS_IN_BITS));
|
||||
return (m_escapeIndexOrTriangleIndex>>(31-MAX_NUM_PARTS_IN_BITS));
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
/// btOptimizedBvhNode contains both internal and leaf node information.
|
||||
/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
|
||||
ATTRIBUTE_ALIGNED16(struct)
|
||||
btOptimizedBvhNode
|
||||
ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
|
||||
{
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//32 bytes
|
||||
btVector3 m_aabbMinOrg;
|
||||
btVector3 m_aabbMaxOrg;
|
||||
btVector3 m_aabbMinOrg;
|
||||
btVector3 m_aabbMaxOrg;
|
||||
|
||||
//4
|
||||
int m_escapeIndex;
|
||||
int m_escapeIndex;
|
||||
|
||||
//8
|
||||
//for child nodes
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
|
||||
//pad the size to 64 bytes
|
||||
char m_padding[20];
|
||||
//pad the size to 64 bytes
|
||||
char m_padding[20];
|
||||
};
|
||||
|
||||
|
||||
///btBvhSubtreeInfo provides info to gather a subtree of limited size
|
||||
ATTRIBUTE_ALIGNED16(class)
|
||||
btBvhSubtreeInfo
|
||||
ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo
|
||||
{
|
||||
public:
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
//12 bytes
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
unsigned short int m_quantizedAabbMax[3];
|
||||
unsigned short int m_quantizedAabbMin[3];
|
||||
unsigned short int m_quantizedAabbMax[3];
|
||||
//4 bytes, points to the root of the subtree
|
||||
int m_rootNodeIndex;
|
||||
int m_rootNodeIndex;
|
||||
//4 bytes
|
||||
int m_subtreeSize;
|
||||
int m_padding[3];
|
||||
int m_subtreeSize;
|
||||
int m_padding[3];
|
||||
|
||||
btBvhSubtreeInfo()
|
||||
{
|
||||
//memset(&m_padding[0], 0, sizeof(m_padding));
|
||||
}
|
||||
|
||||
void setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
|
||||
|
||||
void setAabbFromQuantizeNode(const btQuantizedBvhNode& quantizedNode)
|
||||
{
|
||||
m_quantizedAabbMin[0] = quantizedNode.m_quantizedAabbMin[0];
|
||||
m_quantizedAabbMin[1] = quantizedNode.m_quantizedAabbMin[1];
|
||||
@@ -142,12 +145,14 @@ public:
|
||||
m_quantizedAabbMax[1] = quantizedNode.m_quantizedAabbMax[1];
|
||||
m_quantizedAabbMax[2] = quantizedNode.m_quantizedAabbMax[2];
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
class btNodeOverlapCallback
|
||||
{
|
||||
public:
|
||||
virtual ~btNodeOverlapCallback(){};
|
||||
virtual ~btNodeOverlapCallback() {};
|
||||
|
||||
virtual void processNode(int subPart, int triangleIndex) = 0;
|
||||
};
|
||||
@@ -155,16 +160,18 @@ public:
|
||||
#include "LinearMath/btAlignedAllocator.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
|
||||
|
||||
///for code readability:
|
||||
typedef btAlignedObjectArray<btOptimizedBvhNode> NodeArray;
|
||||
typedef btAlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
|
||||
typedef btAlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
|
||||
typedef btAlignedObjectArray<btOptimizedBvhNode> NodeArray;
|
||||
typedef btAlignedObjectArray<btQuantizedBvhNode> QuantizedNodeArray;
|
||||
typedef btAlignedObjectArray<btBvhSubtreeInfo> BvhSubtreeInfoArray;
|
||||
|
||||
|
||||
///The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU.
|
||||
///It is used by the btBvhTriangleMeshShape as midphase.
|
||||
///It is used by the btBvhTriangleMeshShape as midphase, and by the btMultiSapBroadphase.
|
||||
///It is recommended to use quantization for better performance and lower memory requirements.
|
||||
ATTRIBUTE_ALIGNED16(class)
|
||||
btQuantizedBvh
|
||||
ATTRIBUTE_ALIGNED16(class) btQuantizedBvh
|
||||
{
|
||||
public:
|
||||
enum btTraversalMode
|
||||
@@ -175,47 +182,54 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
btVector3 m_bvhAabbMin;
|
||||
btVector3 m_bvhAabbMax;
|
||||
btVector3 m_bvhQuantization;
|
||||
|
||||
int m_bulletVersion; //for serialization versioning. It could also be used to detect endianess.
|
||||
|
||||
int m_curNodeIndex;
|
||||
btVector3 m_bvhAabbMin;
|
||||
btVector3 m_bvhAabbMax;
|
||||
btVector3 m_bvhQuantization;
|
||||
|
||||
int m_bulletVersion; //for serialization versioning. It could also be used to detect endianess.
|
||||
|
||||
int m_curNodeIndex;
|
||||
//quantization data
|
||||
bool m_useQuantization;
|
||||
bool m_useQuantization;
|
||||
|
||||
NodeArray m_leafNodes;
|
||||
NodeArray m_contiguousNodes;
|
||||
QuantizedNodeArray m_quantizedLeafNodes;
|
||||
QuantizedNodeArray m_quantizedContiguousNodes;
|
||||
|
||||
btTraversalMode m_traversalMode;
|
||||
BvhSubtreeInfoArray m_SubtreeHeaders;
|
||||
|
||||
NodeArray m_leafNodes;
|
||||
NodeArray m_contiguousNodes;
|
||||
QuantizedNodeArray m_quantizedLeafNodes;
|
||||
QuantizedNodeArray m_quantizedContiguousNodes;
|
||||
|
||||
btTraversalMode m_traversalMode;
|
||||
BvhSubtreeInfoArray m_SubtreeHeaders;
|
||||
|
||||
//This is only used for serialization so we don't have to add serialization directly to btAlignedObjectArray
|
||||
mutable int m_subtreeHeaderCount;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///two versions, one for quantized and normal nodes. This allows code-reuse while maintaining readability (no template/macro!)
|
||||
///this might be refactored into a virtual, it is usually not calculated at run-time
|
||||
void setInternalNodeAabbMin(int nodeIndex, const btVector3& aabbMin)
|
||||
void setInternalNodeAabbMin(int nodeIndex, const btVector3& aabbMin)
|
||||
{
|
||||
if (m_useQuantization)
|
||||
{
|
||||
quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0], aabbMin, 0);
|
||||
}
|
||||
else
|
||||
quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] ,aabbMin,0);
|
||||
} else
|
||||
{
|
||||
m_contiguousNodes[nodeIndex].m_aabbMinOrg = aabbMin;
|
||||
|
||||
}
|
||||
}
|
||||
void setInternalNodeAabbMax(int nodeIndex, const btVector3& aabbMax)
|
||||
void setInternalNodeAabbMax(int nodeIndex,const btVector3& aabbMax)
|
||||
{
|
||||
if (m_useQuantization)
|
||||
{
|
||||
quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0], aabbMax, 1);
|
||||
}
|
||||
else
|
||||
quantize(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0],aabbMax,1);
|
||||
} else
|
||||
{
|
||||
m_contiguousNodes[nodeIndex].m_aabbMaxOrg = aabbMax;
|
||||
}
|
||||
@@ -229,102 +243,115 @@ protected:
|
||||
}
|
||||
//non-quantized
|
||||
return m_leafNodes[nodeIndex].m_aabbMinOrg;
|
||||
|
||||
}
|
||||
btVector3 getAabbMax(int nodeIndex) const
|
||||
{
|
||||
if (m_useQuantization)
|
||||
{
|
||||
return unQuantize(&m_quantizedLeafNodes[nodeIndex].m_quantizedAabbMax[0]);
|
||||
}
|
||||
}
|
||||
//non-quantized
|
||||
return m_leafNodes[nodeIndex].m_aabbMaxOrg;
|
||||
|
||||
}
|
||||
|
||||
void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
|
||||
|
||||
void setInternalNodeEscapeIndex(int nodeIndex, int escapeIndex)
|
||||
{
|
||||
if (m_useQuantization)
|
||||
{
|
||||
m_quantizedContiguousNodes[nodeIndex].m_escapeIndexOrTriangleIndex = -escapeIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_contiguousNodes[nodeIndex].m_escapeIndex = escapeIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void mergeInternalNodeAabb(int nodeIndex, const btVector3& newAabbMin, const btVector3& newAabbMax)
|
||||
void mergeInternalNodeAabb(int nodeIndex,const btVector3& newAabbMin,const btVector3& newAabbMax)
|
||||
{
|
||||
if (m_useQuantization)
|
||||
{
|
||||
unsigned short int quantizedAabbMin[3];
|
||||
unsigned short int quantizedAabbMax[3];
|
||||
quantize(quantizedAabbMin, newAabbMin, 0);
|
||||
quantize(quantizedAabbMax, newAabbMax, 1);
|
||||
for (int i = 0; i < 3; i++)
|
||||
quantize(quantizedAabbMin,newAabbMin,0);
|
||||
quantize(quantizedAabbMax,newAabbMax,1);
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] > quantizedAabbMin[i])
|
||||
m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] = quantizedAabbMin[i];
|
||||
|
||||
if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] < quantizedAabbMax[i])
|
||||
m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[i] = quantizedAabbMax[i];
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
//non-quantized
|
||||
m_contiguousNodes[nodeIndex].m_aabbMinOrg.setMin(newAabbMin);
|
||||
m_contiguousNodes[nodeIndex].m_aabbMaxOrg.setMax(newAabbMax);
|
||||
m_contiguousNodes[nodeIndex].m_aabbMaxOrg.setMax(newAabbMax);
|
||||
}
|
||||
}
|
||||
|
||||
void swapLeafNodes(int firstIndex, int secondIndex);
|
||||
void swapLeafNodes(int firstIndex,int secondIndex);
|
||||
|
||||
void assignInternalNodeFromLeafNode(int internalNode, int leafNodeIndex);
|
||||
void assignInternalNodeFromLeafNode(int internalNode,int leafNodeIndex);
|
||||
|
||||
protected:
|
||||
void buildTree(int startIndex, int endIndex);
|
||||
|
||||
int calcSplittingAxis(int startIndex, int endIndex);
|
||||
|
||||
|
||||
int sortAndCalcSplittingIndex(int startIndex, int endIndex, int splitAxis);
|
||||
void buildTree (int startIndex,int endIndex);
|
||||
|
||||
void walkStacklessTree(btNodeOverlapCallback * nodeCallback, const btVector3& aabbMin, const btVector3& aabbMax) const;
|
||||
int calcSplittingAxis(int startIndex,int endIndex);
|
||||
|
||||
void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex, int endNodeIndex) const;
|
||||
void walkStacklessQuantizedTree(btNodeOverlapCallback * nodeCallback, unsigned short int* quantizedQueryAabbMin, unsigned short int* quantizedQueryAabbMax, int startNodeIndex, int endNodeIndex) const;
|
||||
void walkStacklessTreeAgainstRay(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex, int endNodeIndex) const;
|
||||
int sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis);
|
||||
|
||||
void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||
|
||||
void walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessQuantizedTree(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax,int startNodeIndex,int endNodeIndex) const;
|
||||
void walkStacklessTreeAgainstRay(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax, int startNodeIndex,int endNodeIndex) const;
|
||||
|
||||
///tree traversal designed for small-memory processors like PS3 SPU
|
||||
void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback * nodeCallback, unsigned short int* quantizedQueryAabbMin, unsigned short int* quantizedQueryAabbMax) const;
|
||||
void walkStacklessQuantizedTreeCacheFriendly(btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
|
||||
|
||||
///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
|
||||
void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode, btNodeOverlapCallback* nodeCallback, unsigned short int* quantizedQueryAabbMin, unsigned short int* quantizedQueryAabbMax) const;
|
||||
void walkRecursiveQuantizedTreeAgainstQueryAabb(const btQuantizedBvhNode* currentNode,btNodeOverlapCallback* nodeCallback,unsigned short int* quantizedQueryAabbMin,unsigned short int* quantizedQueryAabbMax) const;
|
||||
|
||||
///use the 16-byte stackless 'skipindex' node tree to do a recursive traversal
|
||||
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA, const btQuantizedBvhNode* treeNodeB, btNodeOverlapCallback* nodeCallback) const;
|
||||
void walkRecursiveQuantizedTreeAgainstQuantizedTree(const btQuantizedBvhNode* treeNodeA,const btQuantizedBvhNode* treeNodeB,btNodeOverlapCallback* nodeCallback) const;
|
||||
|
||||
|
||||
void updateSubtreeHeaders(int leftChildNodexIndex, int rightChildNodexIndex);
|
||||
|
||||
|
||||
void updateSubtreeHeaders(int leftChildNodexIndex,int rightChildNodexIndex);
|
||||
|
||||
public:
|
||||
|
||||
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
btQuantizedBvh();
|
||||
|
||||
virtual ~btQuantizedBvh();
|
||||
|
||||
|
||||
///***************************************** expert/internal use only *************************
|
||||
void setQuantizationValues(const btVector3& bvhAabbMin, const btVector3& bvhAabbMax, btScalar quantizationMargin = btScalar(1.0));
|
||||
QuantizedNodeArray& getLeafNodeArray() { return m_quantizedLeafNodes; }
|
||||
void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0));
|
||||
QuantizedNodeArray& getLeafNodeArray() { return m_quantizedLeafNodes; }
|
||||
///buildInternal is expert use only: assumes that setQuantizationValues and LeafNodeArray are initialized
|
||||
void buildInternal();
|
||||
void buildInternal();
|
||||
///***************************************** expert/internal use only *************************
|
||||
|
||||
void reportAabbOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3& aabbMin, const btVector3& aabbMax) const;
|
||||
void reportRayOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
|
||||
void reportBoxCastOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin, const btVector3& aabbMax) const;
|
||||
void reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||
void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
|
||||
void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||
|
||||
SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point, int isMax) const
|
||||
SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point,int isMax) const
|
||||
{
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
|
||||
btAssert(point.getX() <= m_bvhAabbMax.getX());
|
||||
@@ -341,114 +368,122 @@ public:
|
||||
///@todo: double-check this
|
||||
if (isMax)
|
||||
{
|
||||
out[0] = (unsigned short)(((unsigned short)(v.getX() + btScalar(1.)) | 1));
|
||||
out[1] = (unsigned short)(((unsigned short)(v.getY() + btScalar(1.)) | 1));
|
||||
out[2] = (unsigned short)(((unsigned short)(v.getZ() + btScalar(1.)) | 1));
|
||||
}
|
||||
else
|
||||
out[0] = (unsigned short) (((unsigned short)(v.getX()+btScalar(1.)) | 1));
|
||||
out[1] = (unsigned short) (((unsigned short)(v.getY()+btScalar(1.)) | 1));
|
||||
out[2] = (unsigned short) (((unsigned short)(v.getZ()+btScalar(1.)) | 1));
|
||||
} else
|
||||
{
|
||||
out[0] = (unsigned short)(((unsigned short)(v.getX()) & 0xfffe));
|
||||
out[1] = (unsigned short)(((unsigned short)(v.getY()) & 0xfffe));
|
||||
out[2] = (unsigned short)(((unsigned short)(v.getZ()) & 0xfffe));
|
||||
out[0] = (unsigned short) (((unsigned short)(v.getX()) & 0xfffe));
|
||||
out[1] = (unsigned short) (((unsigned short)(v.getY()) & 0xfffe));
|
||||
out[2] = (unsigned short) (((unsigned short)(v.getZ()) & 0xfffe));
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_CHECK_DEQUANTIZATION
|
||||
btVector3 newPoint = unQuantize(out);
|
||||
if (isMax)
|
||||
{
|
||||
if (newPoint.getX() < point.getX())
|
||||
{
|
||||
printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n", newPoint.getX() - point.getX(), newPoint.getX(), point.getX());
|
||||
printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n",newPoint.getX()-point.getX(), newPoint.getX(),point.getX());
|
||||
}
|
||||
if (newPoint.getY() < point.getY())
|
||||
{
|
||||
printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n", newPoint.getY() - point.getY(), newPoint.getY(), point.getY());
|
||||
printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n",newPoint.getY()-point.getY(), newPoint.getY(),point.getY());
|
||||
}
|
||||
if (newPoint.getZ() < point.getZ())
|
||||
{
|
||||
printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n", newPoint.getZ() - point.getZ(), newPoint.getZ(), point.getZ());
|
||||
|
||||
printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n",newPoint.getZ()-point.getZ(), newPoint.getZ(),point.getZ());
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (newPoint.getX() > point.getX())
|
||||
{
|
||||
printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n", newPoint.getX() - point.getX(), newPoint.getX(), point.getX());
|
||||
printf("unconservative X, diffX = %f, oldX=%f,newX=%f\n",newPoint.getX()-point.getX(), newPoint.getX(),point.getX());
|
||||
}
|
||||
if (newPoint.getY() > point.getY())
|
||||
{
|
||||
printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n", newPoint.getY() - point.getY(), newPoint.getY(), point.getY());
|
||||
printf("unconservative Y, diffY = %f, oldY=%f,newY=%f\n",newPoint.getY()-point.getY(), newPoint.getY(),point.getY());
|
||||
}
|
||||
if (newPoint.getZ() > point.getZ())
|
||||
{
|
||||
printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n", newPoint.getZ() - point.getZ(), newPoint.getZ(), point.getZ());
|
||||
printf("unconservative Z, diffZ = %f, oldZ=%f,newZ=%f\n",newPoint.getZ()-point.getZ(), newPoint.getZ(),point.getZ());
|
||||
}
|
||||
}
|
||||
#endif //DEBUG_CHECK_DEQUANTIZATION
|
||||
#endif //DEBUG_CHECK_DEQUANTIZATION
|
||||
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point2, int isMax) const
|
||||
|
||||
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point2,int isMax) const
|
||||
{
|
||||
|
||||
btAssert(m_useQuantization);
|
||||
|
||||
btVector3 clampedPoint(point2);
|
||||
clampedPoint.setMax(m_bvhAabbMin);
|
||||
clampedPoint.setMin(m_bvhAabbMax);
|
||||
|
||||
quantize(out, clampedPoint, isMax);
|
||||
}
|
||||
quantize(out,clampedPoint,isMax);
|
||||
|
||||
SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const
|
||||
{
|
||||
btVector3 vecOut;
|
||||
vecOut.setValue(
|
||||
btVector3 vecOut;
|
||||
vecOut.setValue(
|
||||
(btScalar)(vecIn[0]) / (m_bvhQuantization.getX()),
|
||||
(btScalar)(vecIn[1]) / (m_bvhQuantization.getY()),
|
||||
(btScalar)(vecIn[2]) / (m_bvhQuantization.getZ()));
|
||||
vecOut += m_bvhAabbMin;
|
||||
return vecOut;
|
||||
vecOut += m_bvhAabbMin;
|
||||
return vecOut;
|
||||
}
|
||||
|
||||
///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.
|
||||
void setTraversalMode(btTraversalMode traversalMode)
|
||||
void setTraversalMode(btTraversalMode traversalMode)
|
||||
{
|
||||
m_traversalMode = traversalMode;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray()
|
||||
{
|
||||
return m_quantizedContiguousNodes;
|
||||
|
||||
SIMD_FORCE_INLINE QuantizedNodeArray& getQuantizedNodeArray()
|
||||
{
|
||||
return m_quantizedContiguousNodes;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray()
|
||||
|
||||
SIMD_FORCE_INLINE BvhSubtreeInfoArray& getSubtreeInfoArray()
|
||||
{
|
||||
return m_SubtreeHeaders;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////Calculate space needed to store BVH for serialization
|
||||
unsigned calculateSerializeBufferSize() const;
|
||||
|
||||
/// Data buffer MUST be 16 byte aligned
|
||||
virtual bool serialize(void* o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const;
|
||||
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const;
|
||||
|
||||
///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place'
|
||||
static btQuantizedBvh* deSerializeInPlace(void* i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian);
|
||||
static btQuantizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian);
|
||||
|
||||
static unsigned int getAlignmentSerializationPadding();
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual int calculateSerializeBufferSizeNew() const;
|
||||
|
||||
virtual int calculateSerializeBufferSizeNew() const;
|
||||
|
||||
///fills the dataBuffer and returns the struct name (and 0 on failure)
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
|
||||
|
||||
virtual void deSerializeFloat(struct btQuantizedBvhFloatData & quantizedBvhFloatData);
|
||||
virtual void deSerializeFloat(struct btQuantizedBvhFloatData& quantizedBvhFloatData);
|
||||
|
||||
virtual void deSerializeDouble(struct btQuantizedBvhDoubleData & quantizedBvhDoubleData);
|
||||
virtual void deSerializeDouble(struct btQuantizedBvhDoubleData& quantizedBvhDoubleData);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
SIMD_FORCE_INLINE bool isQuantized()
|
||||
{
|
||||
@@ -459,37 +494,38 @@ private:
|
||||
// Special "copy" constructor that allows for in-place deserialization
|
||||
// Prevents btVector3's default constructor from being called, but doesn't inialize much else
|
||||
// ownsMemory should most likely be false if deserializing, and if you are not, don't call this (it also changes the function signature, which we need)
|
||||
btQuantizedBvh(btQuantizedBvh & other, bool ownsMemory);
|
||||
};
|
||||
btQuantizedBvh(btQuantizedBvh &other, bool ownsMemory);
|
||||
|
||||
// clang-format off
|
||||
// parser needs * with the name
|
||||
struct btBvhSubtreeInfoData
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
struct btBvhSubtreeInfoData
|
||||
{
|
||||
int m_rootNodeIndex;
|
||||
int m_subtreeSize;
|
||||
int m_rootNodeIndex;
|
||||
int m_subtreeSize;
|
||||
unsigned short m_quantizedAabbMin[3];
|
||||
unsigned short m_quantizedAabbMax[3];
|
||||
};
|
||||
|
||||
struct btOptimizedBvhNodeFloatData
|
||||
{
|
||||
btVector3FloatData m_aabbMinOrg;
|
||||
btVector3FloatData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
btVector3FloatData m_aabbMinOrg;
|
||||
btVector3FloatData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
char m_pad[4];
|
||||
};
|
||||
|
||||
struct btOptimizedBvhNodeDoubleData
|
||||
{
|
||||
btVector3DoubleData m_aabbMinOrg;
|
||||
btVector3DoubleData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
char m_pad[4];
|
||||
btVector3DoubleData m_aabbMinOrg;
|
||||
btVector3DoubleData m_aabbMaxOrg;
|
||||
int m_escapeIndex;
|
||||
int m_subPart;
|
||||
int m_triangleIndex;
|
||||
char m_pad[4];
|
||||
};
|
||||
|
||||
|
||||
@@ -533,11 +569,13 @@ struct btQuantizedBvhDoubleData
|
||||
int m_numSubtreeHeaders;
|
||||
btBvhSubtreeInfoData *m_subTreeInfoPtr;
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
SIMD_FORCE_INLINE int btQuantizedBvh::calculateSerializeBufferSizeNew() const
|
||||
|
||||
SIMD_FORCE_INLINE int btQuantizedBvh::calculateSerializeBufferSizeNew() const
|
||||
{
|
||||
return sizeof(btQuantizedBvhData);
|
||||
}
|
||||
|
||||
#endif //BT_QUANTIZED_BVH_H
|
||||
|
||||
|
||||
#endif //BT_QUANTIZED_BVH_H
|
||||
|
@@ -24,45 +24,52 @@ subject to the following restrictions:
|
||||
|
||||
#include <new>
|
||||
|
||||
void btSimpleBroadphase::validate()
|
||||
extern int gOverlappingPairs;
|
||||
|
||||
void btSimpleBroadphase::validate()
|
||||
{
|
||||
for (int i = 0; i < m_numHandles; i++)
|
||||
for (int i=0;i<m_numHandles;i++)
|
||||
{
|
||||
for (int j = i + 1; j < m_numHandles; j++)
|
||||
for (int j=i+1;j<m_numHandles;j++)
|
||||
{
|
||||
btAssert(&m_pHandles[i] != &m_pHandles[j]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btSimpleBroadphase::btSimpleBroadphase(int maxProxies, btOverlappingPairCache* overlappingPairCache)
|
||||
: m_pairCache(overlappingPairCache),
|
||||
m_ownsPairCache(false),
|
||||
m_invalidPair(0)
|
||||
:m_pairCache(overlappingPairCache),
|
||||
m_ownsPairCache(false),
|
||||
m_invalidPair(0)
|
||||
{
|
||||
|
||||
if (!overlappingPairCache)
|
||||
{
|
||||
void* mem = btAlignedAlloc(sizeof(btHashedOverlappingPairCache), 16);
|
||||
m_pairCache = new (mem) btHashedOverlappingPairCache();
|
||||
void* mem = btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16);
|
||||
m_pairCache = new (mem)btHashedOverlappingPairCache();
|
||||
m_ownsPairCache = true;
|
||||
}
|
||||
|
||||
// allocate handles buffer and put all handles on free list
|
||||
m_pHandlesRawPtr = btAlignedAlloc(sizeof(btSimpleBroadphaseProxy) * maxProxies, 16);
|
||||
m_pHandles = new (m_pHandlesRawPtr) btSimpleBroadphaseProxy[maxProxies];
|
||||
m_pHandlesRawPtr = btAlignedAlloc(sizeof(btSimpleBroadphaseProxy)*maxProxies,16);
|
||||
m_pHandles = new(m_pHandlesRawPtr) btSimpleBroadphaseProxy[maxProxies];
|
||||
m_maxHandles = maxProxies;
|
||||
m_numHandles = 0;
|
||||
m_firstFreeHandle = 0;
|
||||
m_LastHandleIndex = -1;
|
||||
|
||||
|
||||
{
|
||||
for (int i = m_firstFreeHandle; i < maxProxies; i++)
|
||||
{
|
||||
m_pHandles[i].SetNextFree(i + 1);
|
||||
m_pHandles[i].m_uniqueId = i + 2; //any UID will do, we just avoid too trivial values (0,1) for debugging purposes
|
||||
m_pHandles[i].m_uniqueId = i+2;//any UID will do, we just avoid too trivial values (0,1) for debugging purposes
|
||||
}
|
||||
m_pHandles[maxProxies - 1].SetNextFree(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btSimpleBroadphase::~btSimpleBroadphase()
|
||||
@@ -76,25 +83,26 @@ btSimpleBroadphase::~btSimpleBroadphase()
|
||||
}
|
||||
}
|
||||
|
||||
btBroadphaseProxy* btSimpleBroadphase::createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* /*dispatcher*/)
|
||||
|
||||
btBroadphaseProxy* btSimpleBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* /*dispatcher*/,void* multiSapProxy)
|
||||
{
|
||||
if (m_numHandles >= m_maxHandles)
|
||||
{
|
||||
btAssert(0);
|
||||
return 0; //should never happen, but don't let the game crash ;-)
|
||||
return 0; //should never happen, but don't let the game crash ;-)
|
||||
}
|
||||
btAssert(aabbMin[0] <= aabbMax[0] && aabbMin[1] <= aabbMax[1] && aabbMin[2] <= aabbMax[2]);
|
||||
btAssert(aabbMin[0]<= aabbMax[0] && aabbMin[1]<= aabbMax[1] && aabbMin[2]<= aabbMax[2]);
|
||||
|
||||
int newHandleIndex = allocHandle();
|
||||
btSimpleBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex]) btSimpleBroadphaseProxy(aabbMin, aabbMax, shapeType, userPtr, collisionFilterGroup, collisionFilterMask);
|
||||
btSimpleBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex])btSimpleBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy);
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
class RemovingOverlapCallback : public btOverlapCallback
|
||||
class RemovingOverlapCallback : public btOverlapCallback
|
||||
{
|
||||
protected:
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
(void)pair;
|
||||
btAssert(0);
|
||||
@@ -104,13 +112,12 @@ protected:
|
||||
|
||||
class RemovePairContainingProxy
|
||||
{
|
||||
btBroadphaseProxy* m_targetProxy;
|
||||
|
||||
public:
|
||||
btBroadphaseProxy* m_targetProxy;
|
||||
public:
|
||||
virtual ~RemovePairContainingProxy()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
@@ -121,36 +128,38 @@ protected:
|
||||
};
|
||||
};
|
||||
|
||||
void btSimpleBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg, btDispatcher* dispatcher)
|
||||
void btSimpleBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg,btDispatcher* dispatcher)
|
||||
{
|
||||
m_pairCache->removeOverlappingPairsContainingProxy(proxyOrg, dispatcher);
|
||||
|
||||
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxyOrg);
|
||||
freeHandle(proxy0);
|
||||
|
||||
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxyOrg);
|
||||
freeHandle(proxy0);
|
||||
m_pairCache->removeOverlappingPairsContainingProxy(proxyOrg,dispatcher);
|
||||
|
||||
//validate();
|
||||
//validate();
|
||||
|
||||
}
|
||||
|
||||
void btSimpleBroadphase::getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const
|
||||
void btSimpleBroadphase::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const
|
||||
{
|
||||
const btSimpleBroadphaseProxy* sbp = getSimpleProxyFromProxy(proxy);
|
||||
aabbMin = sbp->m_aabbMin;
|
||||
aabbMax = sbp->m_aabbMax;
|
||||
}
|
||||
|
||||
void btSimpleBroadphase::setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* /*dispatcher*/)
|
||||
void btSimpleBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* /*dispatcher*/)
|
||||
{
|
||||
btSimpleBroadphaseProxy* sbp = getSimpleProxyFromProxy(proxy);
|
||||
sbp->m_aabbMin = aabbMin;
|
||||
sbp->m_aabbMax = aabbMax;
|
||||
}
|
||||
|
||||
void btSimpleBroadphase::rayTest(const btVector3& rayFrom, const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin, const btVector3& aabbMax)
|
||||
void btSimpleBroadphase::rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin,const btVector3& aabbMax)
|
||||
{
|
||||
for (int i = 0; i <= m_LastHandleIndex; i++)
|
||||
for (int i=0; i <= m_LastHandleIndex; i++)
|
||||
{
|
||||
btSimpleBroadphaseProxy* proxy = &m_pHandles[i];
|
||||
if (!proxy->m_clientObject)
|
||||
if(!proxy->m_clientObject)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -158,59 +167,69 @@ void btSimpleBroadphase::rayTest(const btVector3& rayFrom, const btVector3& rayT
|
||||
}
|
||||
}
|
||||
|
||||
void btSimpleBroadphase::aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback)
|
||||
|
||||
void btSimpleBroadphase::aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback)
|
||||
{
|
||||
for (int i = 0; i <= m_LastHandleIndex; i++)
|
||||
for (int i=0; i <= m_LastHandleIndex; i++)
|
||||
{
|
||||
btSimpleBroadphaseProxy* proxy = &m_pHandles[i];
|
||||
if (!proxy->m_clientObject)
|
||||
if(!proxy->m_clientObject)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (TestAabbAgainstAabb2(aabbMin, aabbMax, proxy->m_aabbMin, proxy->m_aabbMax))
|
||||
if (TestAabbAgainstAabb2(aabbMin,aabbMax,proxy->m_aabbMin,proxy->m_aabbMax))
|
||||
{
|
||||
callback.process(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool btSimpleBroadphase::aabbOverlap(btSimpleBroadphaseProxy* proxy0, btSimpleBroadphaseProxy* proxy1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool btSimpleBroadphase::aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1)
|
||||
{
|
||||
return proxy0->m_aabbMin[0] <= proxy1->m_aabbMax[0] && proxy1->m_aabbMin[0] <= proxy0->m_aabbMax[0] &&
|
||||
return proxy0->m_aabbMin[0] <= proxy1->m_aabbMax[0] && proxy1->m_aabbMin[0] <= proxy0->m_aabbMax[0] &&
|
||||
proxy0->m_aabbMin[1] <= proxy1->m_aabbMax[1] && proxy1->m_aabbMin[1] <= proxy0->m_aabbMax[1] &&
|
||||
proxy0->m_aabbMin[2] <= proxy1->m_aabbMax[2] && proxy1->m_aabbMin[2] <= proxy0->m_aabbMax[2];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//then remove non-overlapping ones
|
||||
class CheckOverlapCallback : public btOverlapCallback
|
||||
{
|
||||
public:
|
||||
virtual bool processOverlap(btBroadphasePair& pair)
|
||||
{
|
||||
return (!btSimpleBroadphase::aabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0), static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1)));
|
||||
return (!btSimpleBroadphase::aabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1)));
|
||||
}
|
||||
};
|
||||
|
||||
void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
{
|
||||
//first check for new overlapping pairs
|
||||
int i, j;
|
||||
int i,j;
|
||||
if (m_numHandles >= 0)
|
||||
{
|
||||
int new_largest_index = -1;
|
||||
for (i = 0; i <= m_LastHandleIndex; i++)
|
||||
for (i=0; i <= m_LastHandleIndex; i++)
|
||||
{
|
||||
btSimpleBroadphaseProxy* proxy0 = &m_pHandles[i];
|
||||
if (!proxy0->m_clientObject)
|
||||
if(!proxy0->m_clientObject)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
new_largest_index = i;
|
||||
for (j = i + 1; j <= m_LastHandleIndex; j++)
|
||||
for (j=i+1; j <= m_LastHandleIndex; j++)
|
||||
{
|
||||
btSimpleBroadphaseProxy* proxy1 = &m_pHandles[j];
|
||||
btAssert(proxy0 != proxy1);
|
||||
if (!proxy1->m_clientObject)
|
||||
if(!proxy1->m_clientObject)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -218,20 +237,19 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
|
||||
btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
|
||||
|
||||
if (aabbOverlap(p0, p1))
|
||||
if (aabbOverlap(p0,p1))
|
||||
{
|
||||
if (!m_pairCache->findPair(proxy0, proxy1))
|
||||
if ( !m_pairCache->findPair(proxy0,proxy1))
|
||||
{
|
||||
m_pairCache->addOverlappingPair(proxy0, proxy1);
|
||||
m_pairCache->addOverlappingPair(proxy0,proxy1);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (!m_pairCache->hasDeferredRemoval())
|
||||
{
|
||||
if (m_pairCache->findPair(proxy0, proxy1))
|
||||
if ( m_pairCache->findPair(proxy0,proxy1))
|
||||
{
|
||||
m_pairCache->removeOverlappingPair(proxy0, proxy1, dispatcher);
|
||||
m_pairCache->removeOverlappingPair(proxy0,proxy1,dispatcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +260,8 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
|
||||
if (m_ownsPairCache && m_pairCache->hasDeferredRemoval())
|
||||
{
|
||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||
|
||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.quickSort(btBroadphasePairSortPredicate());
|
||||
@@ -250,13 +269,16 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
|
||||
|
||||
btBroadphasePair previousPair;
|
||||
previousPair.m_pProxy0 = 0;
|
||||
previousPair.m_pProxy1 = 0;
|
||||
previousPair.m_algorithm = 0;
|
||||
|
||||
for (i = 0; i < overlappingPairArray.size(); i++)
|
||||
|
||||
for (i=0;i<overlappingPairArray.size();i++)
|
||||
{
|
||||
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
bool isDuplicate = (pair == previousPair);
|
||||
@@ -267,18 +289,16 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
|
||||
if (!isDuplicate)
|
||||
{
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0, pair.m_pProxy1);
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||
|
||||
if (hasOverlap)
|
||||
{
|
||||
needsRemoval = false; //callback->processOverlap(pair);
|
||||
}
|
||||
else
|
||||
needsRemoval = false;//callback->processOverlap(pair);
|
||||
} else
|
||||
{
|
||||
needsRemoval = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
//remove duplicate
|
||||
needsRemoval = true;
|
||||
@@ -288,14 +308,16 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
|
||||
if (needsRemoval)
|
||||
{
|
||||
m_pairCache->cleanOverlappingPair(pair, dispatcher);
|
||||
m_pairCache->cleanOverlappingPair(pair,dispatcher);
|
||||
|
||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
// m_overlappingPairArray.pop_back();
|
||||
pair.m_pProxy0 = 0;
|
||||
pair.m_pProxy1 = 0;
|
||||
m_invalidPair++;
|
||||
}
|
||||
gOverlappingPairs--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||
@@ -307,19 +329,21 @@ void btSimpleBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher)
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif //CLEAN_INVALID_PAIRS
|
||||
#endif//CLEAN_INVALID_PAIRS
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool btSimpleBroadphase::testAabbOverlap(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1)
|
||||
|
||||
bool btSimpleBroadphase::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
|
||||
btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
|
||||
return aabbOverlap(p0, p1);
|
||||
return aabbOverlap(p0,p1);
|
||||
}
|
||||
|
||||
void btSimpleBroadphase::resetPool(btDispatcher* dispatcher)
|
||||
void btSimpleBroadphase::resetPool(btDispatcher* dispatcher)
|
||||
{
|
||||
//not yet
|
||||
}
|
||||
|
@@ -16,47 +16,57 @@ subject to the following restrictions:
|
||||
#ifndef BT_SIMPLE_BROADPHASE_H
|
||||
#define BT_SIMPLE_BROADPHASE_H
|
||||
|
||||
|
||||
#include "btOverlappingPairCache.h"
|
||||
|
||||
|
||||
struct btSimpleBroadphaseProxy : public btBroadphaseProxy
|
||||
{
|
||||
int m_nextFree;
|
||||
int m_nextFree;
|
||||
|
||||
// int m_handleId;
|
||||
|
||||
// int m_handleId;
|
||||
|
||||
btSimpleBroadphaseProxy() {};
|
||||
|
||||
btSimpleBroadphaseProxy(){};
|
||||
|
||||
btSimpleBroadphaseProxy(const btVector3& minpt, const btVector3& maxpt, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask)
|
||||
: btBroadphaseProxy(minpt, maxpt, userPtr, collisionFilterGroup, collisionFilterMask)
|
||||
btSimpleBroadphaseProxy(const btVector3& minpt,const btVector3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy)
|
||||
:btBroadphaseProxy(minpt,maxpt,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy)
|
||||
{
|
||||
(void)shapeType;
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void SetNextFree(int next) {m_nextFree = next;}
|
||||
SIMD_FORCE_INLINE int GetNextFree() const {return m_nextFree;}
|
||||
|
||||
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void SetNextFree(int next) { m_nextFree = next; }
|
||||
SIMD_FORCE_INLINE int GetNextFree() const { return m_nextFree; }
|
||||
};
|
||||
|
||||
///The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead.
|
||||
///It is a brute force aabb culling broadphase based on O(n^2) aabb checks
|
||||
class btSimpleBroadphase : public btBroadphaseInterface
|
||||
{
|
||||
protected:
|
||||
int m_numHandles; // number of active handles
|
||||
int m_maxHandles; // max number of handles
|
||||
int m_LastHandleIndex;
|
||||
|
||||
btSimpleBroadphaseProxy* m_pHandles; // handles pool
|
||||
protected:
|
||||
|
||||
int m_numHandles; // number of active handles
|
||||
int m_maxHandles; // max number of handles
|
||||
int m_LastHandleIndex;
|
||||
|
||||
btSimpleBroadphaseProxy* m_pHandles; // handles pool
|
||||
|
||||
void* m_pHandlesRawPtr;
|
||||
int m_firstFreeHandle; // free handles list
|
||||
|
||||
int m_firstFreeHandle; // free handles list
|
||||
|
||||
int allocHandle()
|
||||
{
|
||||
btAssert(m_numHandles < m_maxHandles);
|
||||
int freeHandle = m_firstFreeHandle;
|
||||
m_firstFreeHandle = m_pHandles[freeHandle].GetNextFree();
|
||||
m_numHandles++;
|
||||
if (freeHandle > m_LastHandleIndex)
|
||||
if(freeHandle > m_LastHandleIndex)
|
||||
{
|
||||
m_LastHandleIndex = freeHandle;
|
||||
}
|
||||
@@ -65,9 +75,9 @@ protected:
|
||||
|
||||
void freeHandle(btSimpleBroadphaseProxy* proxy)
|
||||
{
|
||||
int handle = int(proxy - m_pHandles);
|
||||
int handle = int(proxy-m_pHandles);
|
||||
btAssert(handle >= 0 && handle < m_maxHandles);
|
||||
if (handle == m_LastHandleIndex)
|
||||
if(handle == m_LastHandleIndex)
|
||||
{
|
||||
m_LastHandleIndex--;
|
||||
}
|
||||
@@ -79,18 +89,20 @@ protected:
|
||||
m_numHandles--;
|
||||
}
|
||||
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
bool m_ownsPairCache;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
bool m_ownsPairCache;
|
||||
|
||||
int m_invalidPair;
|
||||
int m_invalidPair;
|
||||
|
||||
inline btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy)
|
||||
|
||||
|
||||
inline btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy)
|
||||
{
|
||||
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
|
||||
return proxy0;
|
||||
}
|
||||
|
||||
inline const btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy) const
|
||||
inline const btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy) const
|
||||
{
|
||||
const btSimpleBroadphaseProxy* proxy0 = static_cast<const btSimpleBroadphaseProxy*>(proxy);
|
||||
return proxy0;
|
||||
@@ -99,50 +111,61 @@ protected:
|
||||
///reset broadphase internal structures, to ensure determinism/reproducability
|
||||
virtual void resetPool(btDispatcher* dispatcher);
|
||||
|
||||
void validate();
|
||||
|
||||
void validate();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
btSimpleBroadphase(int maxProxies = 16384, btOverlappingPairCache* overlappingPairCache = 0);
|
||||
btSimpleBroadphase(int maxProxies=16384,btOverlappingPairCache* overlappingPairCache=0);
|
||||
virtual ~btSimpleBroadphase();
|
||||
|
||||
static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0, btSimpleBroadphaseProxy* proxy1);
|
||||
|
||||
virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher);
|
||||
static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1);
|
||||
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
virtual void getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const;
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
|
||||
|
||||
virtual void rayTest(const btVector3& rayFrom, const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin = btVector3(0, 0, 0), const btVector3& aabbMax = btVector3(0, 0, 0));
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
|
||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||
|
||||
btOverlappingPairCache* getOverlappingPairCache()
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
|
||||
virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
|
||||
|
||||
virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0));
|
||||
virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
|
||||
|
||||
btOverlappingPairCache* getOverlappingPairCache()
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1);
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
|
||||
///getAabb returns the axis aligned bounding box in the 'global' coordinate frame
|
||||
///will add some transform later
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin, btVector3& aabbMax) const
|
||||
virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
|
||||
{
|
||||
aabbMin.setValue(-BT_LARGE_FLOAT, -BT_LARGE_FLOAT, -BT_LARGE_FLOAT);
|
||||
aabbMax.setValue(BT_LARGE_FLOAT, BT_LARGE_FLOAT, BT_LARGE_FLOAT);
|
||||
aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
|
||||
aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
|
||||
}
|
||||
|
||||
virtual void printStats()
|
||||
virtual void printStats()
|
||||
{
|
||||
// printf("btSimpleBroadphase.h\n");
|
||||
// printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
|
||||
// printf("btSimpleBroadphase.h\n");
|
||||
// printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //BT_SIMPLE_BROADPHASE_H
|
||||
|
||||
|
||||
#endif //BT_SIMPLE_BROADPHASE_H
|
||||
|
||||
|
@@ -18,162 +18,145 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
|
||||
SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere, btTriangleShape* triangle, btScalar contactBreakingThreshold)
|
||||
: m_sphere(sphere),
|
||||
m_triangle(triangle),
|
||||
m_contactBreakingThreshold(contactBreakingThreshold)
|
||||
|
||||
SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold)
|
||||
:m_sphere(sphere),
|
||||
m_triangle(triangle),
|
||||
m_contactBreakingThreshold(contactBreakingThreshold)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input, Result& output, class btIDebugDraw* debugDraw, bool swapResults)
|
||||
void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults)
|
||||
{
|
||||
|
||||
(void)debugDraw;
|
||||
const btTransform& transformA = input.m_transformA;
|
||||
const btTransform& transformB = input.m_transformB;
|
||||
|
||||
btVector3 point, normal;
|
||||
btVector3 point,normal;
|
||||
btScalar timeOfImpact = btScalar(1.);
|
||||
btScalar depth = btScalar(0.);
|
||||
// output.m_distance = btScalar(BT_LARGE_FLOAT);
|
||||
// output.m_distance = btScalar(BT_LARGE_FLOAT);
|
||||
//move sphere into triangle space
|
||||
btTransform sphereInTr = transformB.inverseTimes(transformA);
|
||||
btTransform sphereInTr = transformB.inverseTimes(transformA);
|
||||
|
||||
if (collide(sphereInTr.getOrigin(), point, normal, depth, timeOfImpact, m_contactBreakingThreshold))
|
||||
if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold))
|
||||
{
|
||||
if (swapResults)
|
||||
{
|
||||
btVector3 normalOnB = transformB.getBasis() * normal;
|
||||
btVector3 normalOnB = transformB.getBasis()*normal;
|
||||
btVector3 normalOnA = -normalOnB;
|
||||
btVector3 pointOnA = transformB * point + normalOnB * depth;
|
||||
output.addContactPoint(normalOnA, pointOnA, depth);
|
||||
}
|
||||
else
|
||||
btVector3 pointOnA = transformB*point+normalOnB*depth;
|
||||
output.addContactPoint(normalOnA,pointOnA,depth);
|
||||
} else
|
||||
{
|
||||
output.addContactPoint(transformB.getBasis() * normal, transformB * point, depth);
|
||||
output.addContactPoint(transformB.getBasis()*normal,transformB*point,depth);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// See also geometrictools.com
|
||||
// Basic idea: D = |p - (lo + t0*lv)| where t0 = lv . (p - lo) / lv . lv
|
||||
btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to, const btVector3& p, btVector3& nearest);
|
||||
btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest);
|
||||
|
||||
btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to, const btVector3& p, btVector3& nearest)
|
||||
{
|
||||
btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest) {
|
||||
btVector3 diff = p - from;
|
||||
btVector3 v = to - from;
|
||||
btScalar t = v.dot(diff);
|
||||
|
||||
if (t > 0)
|
||||
{
|
||||
|
||||
if (t > 0) {
|
||||
btScalar dotVV = v.dot(v);
|
||||
if (t < dotVV)
|
||||
{
|
||||
if (t < dotVV) {
|
||||
t /= dotVV;
|
||||
diff -= t * v;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff -= t*v;
|
||||
} else {
|
||||
t = 1;
|
||||
diff -= v;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
t = 0;
|
||||
|
||||
nearest = from + t * v;
|
||||
return diff.dot(diff);
|
||||
nearest = from + t*v;
|
||||
return diff.dot(diff);
|
||||
}
|
||||
|
||||
bool SphereTriangleDetector::facecontains(const btVector3& p, const btVector3* vertices, btVector3& normal)
|
||||
{
|
||||
bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal) {
|
||||
btVector3 lp(p);
|
||||
btVector3 lnormal(normal);
|
||||
|
||||
|
||||
return pointInTriangle(vertices, lnormal, &lp);
|
||||
}
|
||||
|
||||
bool SphereTriangleDetector::collide(const btVector3& sphereCenter, btVector3& point, btVector3& resultNormal, btScalar& depth, btScalar& timeOfImpact, btScalar contactBreakingThreshold)
|
||||
bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
|
||||
{
|
||||
const btVector3* vertices = &m_triangle->getVertexPtr(0);
|
||||
|
||||
const btVector3* vertices = &m_triangle->getVertexPtr(0);
|
||||
|
||||
btScalar radius = m_sphere->getRadius();
|
||||
btScalar radiusWithThreshold = radius + contactBreakingThreshold;
|
||||
|
||||
btVector3 normal = (vertices[1] - vertices[0]).cross(vertices[2] - vertices[0]);
|
||||
btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
|
||||
normal.normalize();
|
||||
btVector3 p1ToCentre = sphereCenter - vertices[0];
|
||||
btScalar distanceFromPlane = p1ToCentre.dot(normal);
|
||||
|
||||
btScalar l2 = normal.length2();
|
||||
if (distanceFromPlane < btScalar(0.))
|
||||
{
|
||||
//triangle facing the other way
|
||||
distanceFromPlane *= btScalar(-1.);
|
||||
normal *= btScalar(-1.);
|
||||
}
|
||||
|
||||
bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold;
|
||||
|
||||
// Check for contact / intersection
|
||||
bool hasContact = false;
|
||||
btVector3 contactPoint;
|
||||
if (isInsideContactPlane) {
|
||||
if (facecontains(sphereCenter,vertices,normal)) {
|
||||
// Inside the contact wedge - touches a point on the shell plane
|
||||
hasContact = true;
|
||||
contactPoint = sphereCenter - normal*distanceFromPlane;
|
||||
} else {
|
||||
// Could be inside one of the contact capsules
|
||||
btScalar contactCapsuleRadiusSqr = radiusWithThreshold*radiusWithThreshold;
|
||||
btVector3 nearestOnEdge;
|
||||
for (int i = 0; i < m_triangle->getNumEdges(); i++) {
|
||||
|
||||
btVector3 pa;
|
||||
btVector3 pb;
|
||||
|
||||
m_triangle->getEdge(i,pa,pb);
|
||||
|
||||
if (l2 >= SIMD_EPSILON * SIMD_EPSILON)
|
||||
{
|
||||
normal /= btSqrt(l2);
|
||||
|
||||
btVector3 p1ToCentre = sphereCenter - vertices[0];
|
||||
btScalar distanceFromPlane = p1ToCentre.dot(normal);
|
||||
|
||||
if (distanceFromPlane < btScalar(0.))
|
||||
{
|
||||
//triangle facing the other way
|
||||
distanceFromPlane *= btScalar(-1.);
|
||||
normal *= btScalar(-1.);
|
||||
}
|
||||
|
||||
bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold;
|
||||
|
||||
// Check for contact / intersection
|
||||
|
||||
if (isInsideContactPlane)
|
||||
{
|
||||
if (facecontains(sphereCenter, vertices, normal))
|
||||
{
|
||||
// Inside the contact wedge - touches a point on the shell plane
|
||||
hasContact = true;
|
||||
contactPoint = sphereCenter - normal * distanceFromPlane;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Could be inside one of the contact capsules
|
||||
btScalar contactCapsuleRadiusSqr = radiusWithThreshold * radiusWithThreshold;
|
||||
btScalar minDistSqr = contactCapsuleRadiusSqr;
|
||||
btVector3 nearestOnEdge;
|
||||
for (int i = 0; i < m_triangle->getNumEdges(); i++)
|
||||
{
|
||||
btVector3 pa;
|
||||
btVector3 pb;
|
||||
|
||||
m_triangle->getEdge(i, pa, pb);
|
||||
|
||||
btScalar distanceSqr = SegmentSqrDistance(pa, pb, sphereCenter, nearestOnEdge);
|
||||
if (distanceSqr < minDistSqr)
|
||||
{
|
||||
// Yep, we're inside a capsule, and record the capsule with smallest distance
|
||||
minDistSqr = distanceSqr;
|
||||
hasContact = true;
|
||||
contactPoint = nearestOnEdge;
|
||||
}
|
||||
btScalar distanceSqr = SegmentSqrDistance(pa,pb,sphereCenter, nearestOnEdge);
|
||||
if (distanceSqr < contactCapsuleRadiusSqr) {
|
||||
// Yep, we're inside a capsule
|
||||
hasContact = true;
|
||||
contactPoint = nearestOnEdge;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasContact)
|
||||
{
|
||||
if (hasContact) {
|
||||
btVector3 contactToCentre = sphereCenter - contactPoint;
|
||||
btScalar distanceSqr = contactToCentre.length2();
|
||||
|
||||
if (distanceSqr < radiusWithThreshold * radiusWithThreshold)
|
||||
if (distanceSqr < radiusWithThreshold*radiusWithThreshold)
|
||||
{
|
||||
if (distanceSqr > SIMD_EPSILON)
|
||||
if (distanceSqr>SIMD_EPSILON)
|
||||
{
|
||||
btScalar distance = btSqrt(distanceSqr);
|
||||
resultNormal = contactToCentre;
|
||||
resultNormal.normalize();
|
||||
point = contactPoint;
|
||||
depth = -(radius - distance);
|
||||
}
|
||||
else
|
||||
depth = -(radius-distance);
|
||||
} else
|
||||
{
|
||||
resultNormal = normal;
|
||||
point = contactPoint;
|
||||
@@ -182,34 +165,36 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter, btVector3& p
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SphereTriangleDetector::pointInTriangle(const btVector3 vertices[], const btVector3& normal, btVector3* p)
|
||||
|
||||
bool SphereTriangleDetector::pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p )
|
||||
{
|
||||
const btVector3* p1 = &vertices[0];
|
||||
const btVector3* p2 = &vertices[1];
|
||||
const btVector3* p3 = &vertices[2];
|
||||
|
||||
btVector3 edge1(*p2 - *p1);
|
||||
btVector3 edge2(*p3 - *p2);
|
||||
btVector3 edge3(*p1 - *p3);
|
||||
btVector3 edge1( *p2 - *p1 );
|
||||
btVector3 edge2( *p3 - *p2 );
|
||||
btVector3 edge3( *p1 - *p3 );
|
||||
|
||||
btVector3 p1_to_p(*p - *p1);
|
||||
btVector3 p2_to_p(*p - *p2);
|
||||
btVector3 p3_to_p(*p - *p3);
|
||||
|
||||
btVector3 edge1_normal(edge1.cross(normal));
|
||||
btVector3 edge2_normal(edge2.cross(normal));
|
||||
btVector3 edge3_normal(edge3.cross(normal));
|
||||
btVector3 p1_to_p( *p - *p1 );
|
||||
btVector3 p2_to_p( *p - *p2 );
|
||||
btVector3 p3_to_p( *p - *p3 );
|
||||
|
||||
btVector3 edge1_normal( edge1.cross(normal));
|
||||
btVector3 edge2_normal( edge2.cross(normal));
|
||||
btVector3 edge3_normal( edge3.cross(normal));
|
||||
|
||||
btScalar r1, r2, r3;
|
||||
r1 = edge1_normal.dot(p1_to_p);
|
||||
r2 = edge2_normal.dot(p2_to_p);
|
||||
r3 = edge3_normal.dot(p3_to_p);
|
||||
if ((r1 > 0 && r2 > 0 && r3 > 0) ||
|
||||
(r1 <= 0 && r2 <= 0 && r3 <= 0))
|
||||
r1 = edge1_normal.dot( p1_to_p );
|
||||
r2 = edge2_normal.dot( p2_to_p );
|
||||
r3 = edge3_normal.dot( p3_to_p );
|
||||
if ( ( r1 > 0 && r2 > 0 && r3 > 0 ) ||
|
||||
( r1 <= 0 && r2 <= 0 && r3 <= 0 ) )
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
@@ -18,26 +18,34 @@ subject to the following restrictions:
|
||||
|
||||
#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
|
||||
|
||||
|
||||
|
||||
class btSphereShape;
|
||||
class btTriangleShape;
|
||||
|
||||
|
||||
|
||||
/// sphere-triangle to match the btDiscreteCollisionDetectorInterface
|
||||
struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface
|
||||
{
|
||||
virtual void getClosestPoints(const ClosestPointInput& input, Result& output, class btIDebugDraw* debugDraw, bool swapResults = false);
|
||||
virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
|
||||
|
||||
SphereTriangleDetector(btSphereShape* sphere, btTriangleShape* triangle, btScalar contactBreakingThreshold);
|
||||
SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle, btScalar contactBreakingThreshold);
|
||||
|
||||
virtual ~SphereTriangleDetector(){};
|
||||
virtual ~SphereTriangleDetector() {};
|
||||
|
||||
bool collide(const btVector3& sphereCenter, btVector3& point, btVector3& resultNormal, btScalar& depth, btScalar& timeOfImpact, btScalar contactBreakingThreshold);
|
||||
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold);
|
||||
|
||||
private:
|
||||
bool pointInTriangle(const btVector3 vertices[], const btVector3& normal, btVector3* p);
|
||||
bool facecontains(const btVector3& p, const btVector3* vertices, btVector3& normal);
|
||||
|
||||
|
||||
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
||||
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
||||
|
||||
btSphereShape* m_sphere;
|
||||
btTriangleShape* m_triangle;
|
||||
btScalar m_contactBreakingThreshold;
|
||||
btScalar m_contactBreakingThreshold;
|
||||
|
||||
};
|
||||
#endif //BT_SPHERE_TRIANGLE_DETECTOR_H
|
||||
#endif //BT_SPHERE_TRIANGLE_DETECTOR_H
|
||||
|
||||
|
@@ -17,31 +17,31 @@ subject to the following restrictions:
|
||||
#include "btCollisionDispatcher.h"
|
||||
#include "btCollisionObject.h"
|
||||
|
||||
btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||
: btCollisionAlgorithm(ci)
|
||||
btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci)
|
||||
:btCollisionAlgorithm(ci)
|
||||
//,
|
||||
//m_colObj0(0),
|
||||
//m_colObj1(0)
|
||||
{
|
||||
}
|
||||
btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper*, const btCollisionObjectWrapper*)
|
||||
: btCollisionAlgorithm(ci)
|
||||
btActivatingCollisionAlgorithm::btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* ,const btCollisionObjectWrapper* )
|
||||
:btCollisionAlgorithm(ci)
|
||||
//,
|
||||
//m_colObj0(0),
|
||||
//m_colObj1(0)
|
||||
{
|
||||
// if (ci.m_dispatcher1->needsCollision(colObj0,colObj1))
|
||||
// {
|
||||
// m_colObj0 = colObj0;
|
||||
// m_colObj1 = colObj1;
|
||||
//
|
||||
// m_colObj0->activate();
|
||||
// m_colObj1->activate();
|
||||
// }
|
||||
// if (ci.m_dispatcher1->needsCollision(colObj0,colObj1))
|
||||
// {
|
||||
// m_colObj0 = colObj0;
|
||||
// m_colObj1 = colObj1;
|
||||
//
|
||||
// m_colObj0->activate();
|
||||
// m_colObj1->activate();
|
||||
// }
|
||||
}
|
||||
|
||||
btActivatingCollisionAlgorithm::~btActivatingCollisionAlgorithm()
|
||||
{
|
||||
// m_colObj0->activate();
|
||||
// m_colObj1->activate();
|
||||
// m_colObj0->activate();
|
||||
// m_colObj1->activate();
|
||||
}
|
||||
|
@@ -21,15 +21,16 @@ subject to the following restrictions:
|
||||
///This class is not enabled yet (work-in-progress) to more aggressively activate objects.
|
||||
class btActivatingCollisionAlgorithm : public btCollisionAlgorithm
|
||||
{
|
||||
// btCollisionObject* m_colObj0;
|
||||
// btCollisionObject* m_colObj1;
|
||||
|
||||
protected:
|
||||
btActivatingCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
|
||||
|
||||
btActivatingCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
|
||||
// btCollisionObject* m_colObj0;
|
||||
// btCollisionObject* m_colObj1;
|
||||
|
||||
public:
|
||||
|
||||
btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci);
|
||||
|
||||
btActivatingCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
|
||||
|
||||
virtual ~btActivatingCollisionAlgorithm();
|
||||
|
||||
};
|
||||
#endif //__BT_ACTIVATING_COLLISION_ALGORITHM_H
|
||||
#endif //__BT_ACTIVATING_COLLISION_ALGORITHM_H
|
||||
|
@@ -26,55 +26,61 @@ subject to the following restrictions:
|
||||
|
||||
#define USE_PERSISTENT_CONTACTS 1
|
||||
|
||||
btBox2dBox2dCollisionAlgorithm::btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf, const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* obj0Wrap, const btCollisionObjectWrapper* obj1Wrap)
|
||||
: btActivatingCollisionAlgorithm(ci, obj0Wrap, obj1Wrap),
|
||||
m_ownManifold(false),
|
||||
m_manifoldPtr(mf)
|
||||
btBox2dBox2dCollisionAlgorithm::btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* obj0Wrap,const btCollisionObjectWrapper* obj1Wrap)
|
||||
: btActivatingCollisionAlgorithm(ci,obj0Wrap,obj1Wrap),
|
||||
m_ownManifold(false),
|
||||
m_manifoldPtr(mf)
|
||||
{
|
||||
if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0Wrap->getCollisionObject(), obj1Wrap->getCollisionObject()))
|
||||
if (!m_manifoldPtr && m_dispatcher->needsCollision(obj0Wrap->getCollisionObject(),obj1Wrap->getCollisionObject()))
|
||||
{
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(obj0Wrap->getCollisionObject(), obj1Wrap->getCollisionObject());
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(obj0Wrap->getCollisionObject(),obj1Wrap->getCollisionObject());
|
||||
m_ownManifold = true;
|
||||
}
|
||||
}
|
||||
|
||||
btBox2dBox2dCollisionAlgorithm::~btBox2dBox2dCollisionAlgorithm()
|
||||
{
|
||||
|
||||
if (m_ownManifold)
|
||||
{
|
||||
if (m_manifoldPtr)
|
||||
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void b2CollidePolygons(btManifoldResult* manifold, const btBox2dShape* polyA, const btTransform& xfA, const btBox2dShape* polyB, const btTransform& xfB);
|
||||
|
||||
void b2CollidePolygons(btManifoldResult* manifold, const btBox2dShape* polyA, const btTransform& xfA, const btBox2dShape* polyB, const btTransform& xfB);
|
||||
|
||||
//#include <stdio.h>
|
||||
void btBox2dBox2dCollisionAlgorithm::processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
|
||||
void btBox2dBox2dCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||
{
|
||||
if (!m_manifoldPtr)
|
||||
return;
|
||||
|
||||
|
||||
const btBox2dShape* box0 = (const btBox2dShape*)body0Wrap->getCollisionShape();
|
||||
const btBox2dShape* box1 = (const btBox2dShape*)body1Wrap->getCollisionShape();
|
||||
|
||||
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||
|
||||
b2CollidePolygons(resultOut, box0, body0Wrap->getWorldTransform(), box1, body1Wrap->getWorldTransform());
|
||||
b2CollidePolygons(resultOut,box0,body0Wrap->getWorldTransform(),box1,body1Wrap->getWorldTransform());
|
||||
|
||||
// refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
|
||||
if (m_ownManifold)
|
||||
{
|
||||
resultOut->refreshContactPoints();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btScalar btBox2dBox2dCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/, btCollisionObject* /*body1*/, const btDispatcherInfo& /*dispatchInfo*/, btManifoldResult* /*resultOut*/)
|
||||
btScalar btBox2dBox2dCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/)
|
||||
{
|
||||
//not yet
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
|
||||
struct ClipVertex
|
||||
{
|
||||
btVector3 v;
|
||||
@@ -83,16 +89,16 @@ struct ClipVertex
|
||||
//b2ContactID id;
|
||||
};
|
||||
|
||||
#define b2Dot(a, b) (a).dot(b)
|
||||
#define b2Mul(a, b) (a) * (b)
|
||||
#define b2MulT(a, b) (a).transpose() * (b)
|
||||
#define b2Cross(a, b) (a).cross(b)
|
||||
#define btCrossS(a, s) btVector3(s* a.getY(), -s* a.getX(), 0.f)
|
||||
#define b2Dot(a,b) (a).dot(b)
|
||||
#define b2Mul(a,b) (a)*(b)
|
||||
#define b2MulT(a,b) (a).transpose()*(b)
|
||||
#define b2Cross(a,b) (a).cross(b)
|
||||
#define btCrossS(a,s) btVector3(s * a.getY(), -s * a.getX(),0.f)
|
||||
|
||||
int b2_maxManifoldPoints = 2;
|
||||
int b2_maxManifoldPoints =2;
|
||||
|
||||
static int ClipSegmentToLine(ClipVertex vOut[2], ClipVertex vIn[2],
|
||||
const btVector3& normal, btScalar offset)
|
||||
const btVector3& normal, btScalar offset)
|
||||
{
|
||||
// Start with no output points
|
||||
int numOut = 0;
|
||||
@@ -127,7 +133,7 @@ static int ClipSegmentToLine(ClipVertex vOut[2], ClipVertex vIn[2],
|
||||
|
||||
// Find the separation between poly1 and poly2 for a give edge normal on poly1.
|
||||
static btScalar EdgeSeparation(const btBox2dShape* poly1, const btTransform& xf1, int edge1,
|
||||
const btBox2dShape* poly2, const btTransform& xf2)
|
||||
const btBox2dShape* poly2, const btTransform& xf2)
|
||||
{
|
||||
const btVector3* vertices1 = poly1->getVertices();
|
||||
const btVector3* normals1 = poly1->getNormals();
|
||||
@@ -145,8 +151,8 @@ static btScalar EdgeSeparation(const btBox2dShape* poly1, const btTransform& xf1
|
||||
int index = 0;
|
||||
btScalar minDot = BT_LARGE_FLOAT;
|
||||
|
||||
if (count2 > 0)
|
||||
index = (int)normal1.minDot(vertices2, count2, minDot);
|
||||
if( count2 > 0 )
|
||||
index = (int) normal1.minDot( vertices2, count2, minDot);
|
||||
|
||||
btVector3 v1 = b2Mul(xf1, vertices1[edge1]);
|
||||
btVector3 v2 = b2Mul(xf2, vertices2[index]);
|
||||
@@ -156,8 +162,8 @@ static btScalar EdgeSeparation(const btBox2dShape* poly1, const btTransform& xf1
|
||||
|
||||
// Find the max separation between poly1 and poly2 using edge normals from poly1.
|
||||
static btScalar FindMaxSeparation(int* edgeIndex,
|
||||
const btBox2dShape* poly1, const btTransform& xf1,
|
||||
const btBox2dShape* poly2, const btTransform& xf2)
|
||||
const btBox2dShape* poly1, const btTransform& xf1,
|
||||
const btBox2dShape* poly2, const btTransform& xf2)
|
||||
{
|
||||
int count1 = poly1->getVertexCount();
|
||||
const btVector3* normals1 = poly1->getNormals();
|
||||
@@ -169,8 +175,8 @@ static btScalar FindMaxSeparation(int* edgeIndex,
|
||||
// Find edge normal on poly1 that has the largest projection onto d.
|
||||
int edge = 0;
|
||||
btScalar maxDot;
|
||||
if (count1 > 0)
|
||||
edge = (int)dLocal1.maxDot(normals1, count1, maxDot);
|
||||
if( count1 > 0 )
|
||||
edge = (int) dLocal1.maxDot( normals1, count1, maxDot);
|
||||
|
||||
// Get the separation for the edge normal.
|
||||
btScalar s = EdgeSeparation(poly1, xf1, edge, poly2, xf2);
|
||||
@@ -218,7 +224,7 @@ static btScalar FindMaxSeparation(int* edgeIndex,
|
||||
}
|
||||
|
||||
// Perform a local search for the best edge normal.
|
||||
for (;;)
|
||||
for ( ; ; )
|
||||
{
|
||||
if (increment == -1)
|
||||
edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1;
|
||||
@@ -279,14 +285,14 @@ static void FindIncidentEdge(ClipVertex c[2],
|
||||
int i2 = i1 + 1 < count2 ? i1 + 1 : 0;
|
||||
|
||||
c[0].v = b2Mul(xf2, vertices2[i1]);
|
||||
// c[0].id.features.referenceEdge = (unsigned char)edge1;
|
||||
// c[0].id.features.incidentEdge = (unsigned char)i1;
|
||||
// c[0].id.features.incidentVertex = 0;
|
||||
// c[0].id.features.referenceEdge = (unsigned char)edge1;
|
||||
// c[0].id.features.incidentEdge = (unsigned char)i1;
|
||||
// c[0].id.features.incidentVertex = 0;
|
||||
|
||||
c[1].v = b2Mul(xf2, vertices2[i2]);
|
||||
// c[1].id.features.referenceEdge = (unsigned char)edge1;
|
||||
// c[1].id.features.incidentEdge = (unsigned char)i2;
|
||||
// c[1].id.features.incidentVertex = 1;
|
||||
// c[1].id.features.referenceEdge = (unsigned char)edge1;
|
||||
// c[1].id.features.incidentEdge = (unsigned char)i2;
|
||||
// c[1].id.features.incidentVertex = 1;
|
||||
}
|
||||
|
||||
// Find edge normal of max separation on A - return if separating axis is found
|
||||
@@ -297,9 +303,10 @@ static void FindIncidentEdge(ClipVertex c[2],
|
||||
|
||||
// The normal points from 1 to 2
|
||||
void b2CollidePolygons(btManifoldResult* manifold,
|
||||
const btBox2dShape* polyA, const btTransform& xfA,
|
||||
const btBox2dShape* polyB, const btTransform& xfB)
|
||||
const btBox2dShape* polyA, const btTransform& xfA,
|
||||
const btBox2dShape* polyB, const btTransform& xfB)
|
||||
{
|
||||
|
||||
int edgeA = 0;
|
||||
btScalar separationA = FindMaxSeparation(&edgeA, polyA, xfA, polyB, xfB);
|
||||
if (separationA > 0.0f)
|
||||
@@ -310,10 +317,10 @@ void b2CollidePolygons(btManifoldResult* manifold,
|
||||
if (separationB > 0.0f)
|
||||
return;
|
||||
|
||||
const btBox2dShape* poly1; // reference poly
|
||||
const btBox2dShape* poly2; // incident poly
|
||||
const btBox2dShape* poly1; // reference poly
|
||||
const btBox2dShape* poly2; // incident poly
|
||||
btTransform xf1, xf2;
|
||||
int edge1; // reference edge
|
||||
int edge1; // reference edge
|
||||
unsigned char flip;
|
||||
const btScalar k_relativeTol = 0.98f;
|
||||
const btScalar k_absoluteTol = 0.001f;
|
||||
@@ -345,13 +352,14 @@ void b2CollidePolygons(btManifoldResult* manifold,
|
||||
const btVector3* vertices1 = poly1->getVertices();
|
||||
|
||||
btVector3 v11 = vertices1[edge1];
|
||||
btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1 + 1] : vertices1[0];
|
||||
btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1+1] : vertices1[0];
|
||||
|
||||
//btVector3 dv = v12 - v11;
|
||||
btVector3 sideNormal = b2Mul(xf1.getBasis(), v12 - v11);
|
||||
sideNormal.normalize();
|
||||
btVector3 frontNormal = btCrossS(sideNormal, 1.0f);
|
||||
|
||||
|
||||
|
||||
v11 = b2Mul(xf1, v11);
|
||||
v12 = b2Mul(xf1, v12);
|
||||
|
||||
@@ -361,12 +369,13 @@ void b2CollidePolygons(btManifoldResult* manifold,
|
||||
|
||||
// Clip incident edge against extruded edge1 side edges.
|
||||
ClipVertex clipPoints1[2];
|
||||
clipPoints1[0].v.setValue(0, 0, 0);
|
||||
clipPoints1[1].v.setValue(0, 0, 0);
|
||||
clipPoints1[0].v.setValue(0,0,0);
|
||||
clipPoints1[1].v.setValue(0,0,0);
|
||||
|
||||
ClipVertex clipPoints2[2];
|
||||
clipPoints2[0].v.setValue(0, 0, 0);
|
||||
clipPoints2[1].v.setValue(0, 0, 0);
|
||||
clipPoints2[0].v.setValue(0,0,0);
|
||||
clipPoints2[1].v.setValue(0,0,0);
|
||||
|
||||
|
||||
int np;
|
||||
|
||||
@@ -377,7 +386,7 @@ void b2CollidePolygons(btManifoldResult* manifold,
|
||||
return;
|
||||
|
||||
// Clip to negative box side 1
|
||||
np = ClipSegmentToLine(clipPoints2, clipPoints1, sideNormal, sideOffset2);
|
||||
np = ClipSegmentToLine(clipPoints2, clipPoints1, sideNormal, sideOffset2);
|
||||
|
||||
if (np < 2)
|
||||
{
|
||||
@@ -394,18 +403,19 @@ void b2CollidePolygons(btManifoldResult* manifold,
|
||||
|
||||
if (separation <= 0.0f)
|
||||
{
|
||||
|
||||
//b2ManifoldPoint* cp = manifold->points + pointCount;
|
||||
//btScalar separation = separation;
|
||||
//cp->localPoint1 = b2MulT(xfA, clipPoints2[i].v);
|
||||
//cp->localPoint2 = b2MulT(xfB, clipPoints2[i].v);
|
||||
|
||||
manifold->addContactPoint(-manifoldNormal, clipPoints2[i].v, separation);
|
||||
manifold->addContactPoint(-manifoldNormal,clipPoints2[i].v,separation);
|
||||
|
||||
// cp->id = clipPoints2[i].id;
|
||||
// cp->id.features.flip = flip;
|
||||
// cp->id = clipPoints2[i].id;
|
||||
// cp->id.features.flip = flip;
|
||||
++pointCount;
|
||||
}
|
||||
}
|
||||
|
||||
// manifold->pointCount = pointCount;}
|
||||
// manifold->pointCount = pointCount;}
|
||||
}
|
||||
|
@@ -26,22 +26,22 @@ class btPersistentManifold;
|
||||
///box-box collision detection
|
||||
class btBox2dBox2dCollisionAlgorithm : public btActivatingCollisionAlgorithm
|
||||
{
|
||||
bool m_ownManifold;
|
||||
btPersistentManifold* m_manifoldPtr;
|
||||
|
||||
bool m_ownManifold;
|
||||
btPersistentManifold* m_manifoldPtr;
|
||||
|
||||
public:
|
||||
btBox2dBox2dCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||
: btActivatingCollisionAlgorithm(ci) {}
|
||||
|
||||
virtual void processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
|
||||
virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||
|
||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0, btCollisionObject* body1, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut);
|
||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||
|
||||
btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf, const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap);
|
||||
btBox2dBox2dCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
|
||||
|
||||
virtual ~btBox2dBox2dCollisionAlgorithm();
|
||||
|
||||
virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
|
||||
virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
|
||||
{
|
||||
if (m_manifoldPtr && m_ownManifold)
|
||||
{
|
||||
@@ -49,15 +49,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
struct CreateFunc : public btCollisionAlgorithmCreateFunc
|
||||
|
||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||
{
|
||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap)
|
||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
|
||||
{
|
||||
int bbsize = sizeof(btBox2dBox2dCollisionAlgorithm);
|
||||
void* ptr = ci.m_dispatcher1->allocateCollisionAlgorithm(bbsize);
|
||||
return new (ptr) btBox2dBox2dCollisionAlgorithm(0, ci, body0Wrap, body1Wrap);
|
||||
return new(ptr) btBox2dBox2dCollisionAlgorithm(0,ci,body0Wrap,body1Wrap);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif //BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
|
||||
#endif //BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
|
||||
|
||||
|
@@ -21,14 +21,14 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
|
||||
#define USE_PERSISTENT_CONTACTS 1
|
||||
|
||||
btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf, const btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap)
|
||||
: btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap),
|
||||
m_ownManifold(false),
|
||||
m_manifoldPtr(mf)
|
||||
btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
|
||||
: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
|
||||
m_ownManifold(false),
|
||||
m_manifoldPtr(mf)
|
||||
{
|
||||
if (!m_manifoldPtr && m_dispatcher->needsCollision(body0Wrap->getCollisionObject(), body1Wrap->getCollisionObject()))
|
||||
if (!m_manifoldPtr && m_dispatcher->needsCollision(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject()))
|
||||
{
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(), body1Wrap->getCollisionObject());
|
||||
m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
|
||||
m_ownManifold = true;
|
||||
}
|
||||
}
|
||||
@@ -42,27 +42,30 @@ btBoxBoxCollisionAlgorithm::~btBoxBoxCollisionAlgorithm()
|
||||
}
|
||||
}
|
||||
|
||||
void btBoxBoxCollisionAlgorithm::processCollision(const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
|
||||
void btBoxBoxCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||
{
|
||||
if (!m_manifoldPtr)
|
||||
return;
|
||||
|
||||
|
||||
const btBoxShape* box0 = (btBoxShape*)body0Wrap->getCollisionShape();
|
||||
const btBoxShape* box1 = (btBoxShape*)body1Wrap->getCollisionShape();
|
||||
|
||||
|
||||
|
||||
/// report a contact. internally this will be kept persistent, and contact reduction is done
|
||||
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||
#ifndef USE_PERSISTENT_CONTACTS
|
||||
#ifndef USE_PERSISTENT_CONTACTS
|
||||
m_manifoldPtr->clearManifold();
|
||||
#endif //USE_PERSISTENT_CONTACTS
|
||||
#endif //USE_PERSISTENT_CONTACTS
|
||||
|
||||
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
||||
input.m_maximumDistanceSquared = BT_LARGE_FLOAT;
|
||||
input.m_transformA = body0Wrap->getWorldTransform();
|
||||
input.m_transformB = body1Wrap->getWorldTransform();
|
||||
|
||||
btBoxBoxDetector detector(box0, box1);
|
||||
detector.getClosestPoints(input, *resultOut, dispatchInfo.m_debugDraw);
|
||||
btBoxBoxDetector detector(box0,box1);
|
||||
detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
|
||||
|
||||
#ifdef USE_PERSISTENT_CONTACTS
|
||||
// refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
|
||||
@@ -70,10 +73,11 @@ void btBoxBoxCollisionAlgorithm::processCollision(const btCollisionObjectWrapper
|
||||
{
|
||||
resultOut->refreshContactPoints();
|
||||
}
|
||||
#endif //USE_PERSISTENT_CONTACTS
|
||||
#endif //USE_PERSISTENT_CONTACTS
|
||||
|
||||
}
|
||||
|
||||
btScalar btBoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/, btCollisionObject* /*body1*/, const btDispatcherInfo& /*dispatchInfo*/, btManifoldResult* /*resultOut*/)
|
||||
btScalar btBoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/,btCollisionObject* /*body1*/,const btDispatcherInfo& /*dispatchInfo*/,btManifoldResult* /*resultOut*/)
|
||||
{
|
||||
//not yet
|
||||
return 1.f;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user