mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
update bullet so it actually works
Moved the addSourceDirectory for physics/Bullet into the Engine/Source/CMakeLists.txt file that way it can actually appear where we expect it to in the solution explorer.
This commit is contained in:
parent
c7be48130a
commit
13fa178cf6
5986 changed files with 1811270 additions and 453803 deletions
7
Engine/lib/bullet/.ci/docker/env.list
Normal file
7
Engine/lib/bullet/.ci/docker/env.list
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
TRAVIS_OS_NAME
|
||||||
|
TRAVIS_PULL_REQUEST
|
||||||
|
|
||||||
|
BUILD_NAME
|
||||||
|
CC
|
||||||
|
CXX
|
||||||
|
SUDO
|
||||||
19
Engine/lib/bullet/.ci/docker/ubuntu-bionic
Normal file
19
Engine/lib/bullet/.ci/docker/ubuntu-bionic
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
FROM ubuntu:bionic
|
||||||
|
|
||||||
|
RUN apt-get update -qq
|
||||||
|
RUN apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
clang \
|
||||||
|
cmake \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
libgl-dev \
|
||||||
|
libglu-dev \
|
||||||
|
libpython3-dev \
|
||||||
|
lsb-release \
|
||||||
|
pkg-config \
|
||||||
|
python3 \
|
||||||
|
python3-dev \
|
||||||
|
python3-distutils \
|
||||||
|
software-properties-common \
|
||||||
|
sudo
|
||||||
18
Engine/lib/bullet/.ci/docker/ubuntu-xenial
Normal file
18
Engine/lib/bullet/.ci/docker/ubuntu-xenial
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
FROM ubuntu:xenial
|
||||||
|
|
||||||
|
RUN apt-get update -qq
|
||||||
|
RUN apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
clang \
|
||||||
|
cmake \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
libgl-dev \
|
||||||
|
libglu-dev \
|
||||||
|
libpython3-dev \
|
||||||
|
lsb-release \
|
||||||
|
pkg-config \
|
||||||
|
python3 \
|
||||||
|
python3-dev \
|
||||||
|
software-properties-common \
|
||||||
|
sudo
|
||||||
31
Engine/lib/bullet/.ci/script.sh
Normal file
31
Engine/lib/bullet/.ci/script.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
echo "CXX="$CXX
|
||||||
|
echo "CC="$CC
|
||||||
|
if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y python3
|
||||||
|
$SUDO apt-get install -y python3-pip
|
||||||
|
$SUDO apt-get install python3-dev
|
||||||
|
$SUDO pip3 install -U wheel
|
||||||
|
$SUDO pip3 install -U setuptools
|
||||||
|
python3 setup.py install --user
|
||||||
|
python3 examples/pybullet/unittests/unittests.py --verbose
|
||||||
|
python3 examples/pybullet/unittests/userDataTest.py --verbose
|
||||||
|
python3 examples/pybullet/unittests/saveRestoreStateTest.py --verbose
|
||||||
|
fi
|
||||||
|
cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror
|
||||||
|
make -j8
|
||||||
|
ctest -j8 --output-on-failure
|
||||||
|
|
||||||
|
# Build again with double precision
|
||||||
|
cmake . -G "Unix Makefiles" -DUSE_DOUBLE_PRECISION=ON #-DCMAKE_CXX_FLAGS=-Werror
|
||||||
|
make -j8
|
||||||
|
ctest -j8 --output-on-failure
|
||||||
|
|
||||||
|
# Build again with shared libraries
|
||||||
|
cmake . -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON
|
||||||
|
make -j8
|
||||||
|
ctest -j8 --output-on-failure
|
||||||
|
$SUDO make install
|
||||||
38
Engine/lib/bullet/.github/workflows/cmake.yml
vendored
Normal file
38
Engine/lib/bullet/.github/workflows/cmake.yml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
name: CMake
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
# The CMake configure and build commands are platform agnostic and should work equally
|
||||||
|
# well on Windows or Mac. You can convert this to a matrix build if you need
|
||||||
|
# cross-platform coverage.
|
||||||
|
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
# Build your program with the given configuration
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: ${{github.workspace}}/build
|
||||||
|
# Execute tests defined by the CMake configuration.
|
||||||
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
|
run: ctest -C ${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
42
Engine/lib/bullet/.gitignore
vendored
Normal file
42
Engine/lib/bullet/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
/bin
|
||||||
|
/build3/gmake
|
||||||
|
/build3/vs2010
|
||||||
|
/build_cmake/
|
||||||
|
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# Pip
|
||||||
|
pip-selfcheck.json
|
||||||
|
*.whl
|
||||||
|
*.egg
|
||||||
|
*.egg-info
|
||||||
|
|
||||||
|
# Setuptools
|
||||||
|
/build
|
||||||
|
/dist
|
||||||
|
*.eggs
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
CMakeFiles/
|
||||||
|
CMakeCache.txt
|
||||||
|
cmake_install.cmake
|
||||||
|
CTestTestFile.cmake
|
||||||
|
|
||||||
|
# Visual Studio build files
|
||||||
|
*.vcxproj
|
||||||
|
*.vcxproj.filters
|
||||||
|
*.sln
|
||||||
|
|
||||||
|
# Apple Finder metadata
|
||||||
|
*.DS_Store
|
||||||
|
|
||||||
|
# vim temp files
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
cmake-build-debug/
|
||||||
5
Engine/lib/bullet/.style.yapf
Normal file
5
Engine/lib/bullet/.style.yapf
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[style]
|
||||||
|
based_on_style = google
|
||||||
|
column_limit = 99
|
||||||
|
indent_width = 2
|
||||||
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
language: cpp
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
- clang
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- python3
|
|
||||||
|
|
||||||
script:
|
|
||||||
- echo "CXX="$CXX
|
|
||||||
- echo "CC="$CC
|
|
||||||
- cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror
|
|
||||||
- make -j8
|
|
||||||
- ctest -j8 --output-on-failure
|
|
||||||
# Build again with double precision
|
|
||||||
- cmake . -G "Unix Makefiles" -DUSE_DOUBLE_PRECISION=ON #-DCMAKE_CXX_FLAGS=-Werror
|
|
||||||
- make -j8
|
|
||||||
- ctest -j8 --output-on-failure
|
|
||||||
# Build again with shared libraries
|
|
||||||
- cmake . -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON
|
|
||||||
- make -j8
|
|
||||||
- ctest -j8 --output-on-failure
|
|
||||||
- sudo make install
|
|
||||||
|
|
@ -2,17 +2,21 @@ Bullet Physics is created by Erwin Coumans with contributions from the following
|
||||||
|
|
||||||
AMD
|
AMD
|
||||||
Apple
|
Apple
|
||||||
|
Yunfei Bai
|
||||||
Steve Baker
|
Steve Baker
|
||||||
Gino van den Bergen
|
Gino van den Bergen
|
||||||
|
Jeff Bingham
|
||||||
Nicola Candussi
|
Nicola Candussi
|
||||||
Erin Catto
|
Erin Catto
|
||||||
Lawrence Chai
|
Lawrence Chai
|
||||||
Erwin Coumans
|
Erwin Coumans
|
||||||
Christer Ericson
|
|
||||||
Disney Animation
|
Disney Animation
|
||||||
|
Benjamin Ellenberger
|
||||||
|
Christer Ericson
|
||||||
Google
|
Google
|
||||||
Dirk Gregorius
|
Dirk Gregorius
|
||||||
Marcus Hennix
|
Marcus Hennix
|
||||||
|
Jasmine Hsu
|
||||||
MBSim Development Team
|
MBSim Development Team
|
||||||
Takahiro Harada
|
Takahiro Harada
|
||||||
Simon Hobbs
|
Simon Hobbs
|
||||||
|
|
@ -20,6 +24,7 @@ John Hsu
|
||||||
Ole Kniemeyer
|
Ole Kniemeyer
|
||||||
Jay Lee
|
Jay Lee
|
||||||
Francisco Leon
|
Francisco Leon
|
||||||
|
lunkhound
|
||||||
Vsevolod Klementjev
|
Vsevolod Klementjev
|
||||||
Phil Knight
|
Phil Knight
|
||||||
John McCutchan
|
John McCutchan
|
||||||
|
|
@ -32,9 +37,9 @@ Russel Smith
|
||||||
Sony
|
Sony
|
||||||
Jakub Stephien
|
Jakub Stephien
|
||||||
Marten Svanfeldt
|
Marten Svanfeldt
|
||||||
|
Jie Tan
|
||||||
Pierre Terdiman
|
Pierre Terdiman
|
||||||
Steven Thompson
|
Steven Thompson
|
||||||
Tamas Umenhoffer
|
Tamas Umenhoffer
|
||||||
Yunfei Bai
|
|
||||||
|
|
||||||
If your name is missing, please send an email to erwin.coumans@gmail.com or file an issue at http://github.com/bulletphysics/bullet3
|
If your name is missing, please send an email to erwin.coumans@gmail.com or file an issue at http://github.com/bulletphysics/bullet3
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 2.4.3)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
|
cmake_policy(SET CMP0017 NEW)
|
||||||
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
|
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
|
||||||
SET(MSVC_INCREMENTAL_DEFAULT ON)
|
SET(MSVC_INCREMENTAL_DEFAULT ON)
|
||||||
|
|
||||||
PROJECT(BULLET_PHYSICS)
|
PROJECT(BULLET_PHYSICS)
|
||||||
SET(BULLET_VERSION 2.85)
|
FILE (STRINGS "VERSION" BULLET_VERSION)
|
||||||
|
|
||||||
IF(COMMAND cmake_policy)
|
IF(COMMAND cmake_policy)
|
||||||
cmake_policy(SET CMP0003 NEW)
|
cmake_policy(SET CMP0003 NEW)
|
||||||
|
|
@ -15,7 +15,6 @@ IF(COMMAND cmake_policy)
|
||||||
endif(POLICY CMP0042)
|
endif(POLICY CMP0042)
|
||||||
ENDIF(COMMAND cmake_policy)
|
ENDIF(COMMAND cmake_policy)
|
||||||
|
|
||||||
|
|
||||||
IF (NOT CMAKE_BUILD_TYPE)
|
IF (NOT CMAKE_BUILD_TYPE)
|
||||||
# SET(CMAKE_BUILD_TYPE "Debug")
|
# SET(CMAKE_BUILD_TYPE "Debug")
|
||||||
SET(CMAKE_BUILD_TYPE "Release")
|
SET(CMAKE_BUILD_TYPE "Release")
|
||||||
|
|
@ -25,11 +24,41 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
|
||||||
#MESSAGE("CMAKE_CXX_FLAGS_DEBUG="+${CMAKE_CXX_FLAGS_DEBUG})
|
#MESSAGE("CMAKE_CXX_FLAGS_DEBUG="+${CMAKE_CXX_FLAGS_DEBUG})
|
||||||
|
|
||||||
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
|
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
|
||||||
|
SET(CLAMP_VELOCITIES "0" CACHE STRING "Clamp rigid bodies' velocity to this value, if larger than zero. Useful to prevent floating point errors or in general runaway velocities in complex scenarios")
|
||||||
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
|
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
|
||||||
OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF)
|
OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF)
|
||||||
|
OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" ON)
|
||||||
|
OPTION(USE_OPENVR "Use OpenVR for virtual reality" OFF)
|
||||||
|
|
||||||
|
OPTION(ENABLE_VHACD "Use VHACD in BulletRobotics and pybullet" ON)
|
||||||
|
|
||||||
|
OPTION(BULLET2_MULTITHREADING "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF)
|
||||||
|
IF (BULLET2_MULTITHREADING)
|
||||||
|
OPTION(BULLET2_USE_OPEN_MP_MULTITHREADING "Build Bullet 2 with support for multi-threading with OpenMP (requires a compiler with OpenMP support)" OFF)
|
||||||
|
OPTION(BULLET2_USE_TBB_MULTITHREADING "Build Bullet 2 with support for multi-threading with Intel Threading Building Blocks (requires the TBB library to be already installed)" OFF)
|
||||||
|
IF (MSVC)
|
||||||
|
OPTION(BULLET2_USE_PPL_MULTITHREADING "Build Bullet 2 with support for multi-threading with Microsoft Parallel Patterns Library (requires MSVC compiler)" OFF)
|
||||||
|
ENDIF (MSVC)
|
||||||
|
ENDIF (BULLET2_MULTITHREADING)
|
||||||
|
|
||||||
|
|
||||||
|
IF(NOT WIN32)
|
||||||
|
SET(DL ${CMAKE_DL_LIBS})
|
||||||
|
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
MESSAGE("Linux")
|
||||||
|
SET(OSDEF -D_LINUX)
|
||||||
|
ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
IF(APPLE)
|
||||||
|
MESSAGE("Apple")
|
||||||
|
SET(OSDEF -D_DARWIN)
|
||||||
|
ELSE(APPLE)
|
||||||
|
MESSAGE("BSD?")
|
||||||
|
SET(OSDEF -D_BSD)
|
||||||
|
ENDIF(APPLE)
|
||||||
|
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
|
ENDIF(NOT WIN32)
|
||||||
|
|
||||||
OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
|
OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
|
||||||
OPTION(USE_CUSTOM_VECTOR_MATH "Use custom vectormath library" OFF)
|
|
||||||
|
|
||||||
#statically linking VC++ isn't supported for WindowsPhone/WindowsStore
|
#statically linking VC++ isn't supported for WindowsPhone/WindowsStore
|
||||||
IF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
|
IF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
|
||||||
|
|
@ -37,6 +66,7 @@ IF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL Window
|
||||||
ELSE ()
|
ELSE ()
|
||||||
OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" OFF)
|
OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" OFF)
|
||||||
ENDIF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
|
ENDIF (CMAKE_SYSTEM_NAME STREQUAL WindowsPhone OR CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
|
||||||
|
OPTION(USE_MSVC_RELEASE_RUNTIME_ALWAYS "Use MSVC Release Runtime Library even in Debug" OFF)
|
||||||
|
|
||||||
#SET(CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:NO")
|
#SET(CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:NO")
|
||||||
#SET(CMAKE_EXE_LINKER_FLAGS "/STACK:10000000 /INCREMENTAL:NO")
|
#SET(CMAKE_EXE_LINKER_FLAGS "/STACK:10000000 /INCREMENTAL:NO")
|
||||||
|
|
@ -49,11 +79,11 @@ IF(MSVC)
|
||||||
#MESSAGE("MSVC_INCREMENTAL_DEFAULT"+${MSVC_INCREMENTAL_DEFAULT})
|
#MESSAGE("MSVC_INCREMENTAL_DEFAULT"+${MSVC_INCREMENTAL_DEFAULT})
|
||||||
SET( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:NO")
|
SET( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:NO")
|
||||||
|
|
||||||
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
|
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
|
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
|
||||||
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
||||||
|
|
||||||
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
|
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 "${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
|
SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
|
||||||
STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 "${CMAKE_EXTRA_LINK_FLAGS}")
|
STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 "${CMAKE_EXTRA_LINK_FLAGS}")
|
||||||
|
|
@ -68,7 +98,7 @@ IF(MSVC)
|
||||||
ENDIF (NOT USE_MSVC_INCREMENTAL_LINKING)
|
ENDIF (NOT USE_MSVC_INCREMENTAL_LINKING)
|
||||||
|
|
||||||
IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
#We statically link to reduce dependancies
|
#We statically link to reduce dependencies
|
||||||
FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO )
|
FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO )
|
||||||
IF(${flag_var} MATCHES "/MD")
|
IF(${flag_var} MATCHES "/MD")
|
||||||
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
|
|
@ -79,19 +109,79 @@ IF(MSVC)
|
||||||
ENDFOREACH(flag_var)
|
ENDFOREACH(flag_var)
|
||||||
ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
|
|
||||||
|
IF (USE_MSVC_RELEASE_RUNTIME_ALWAYS)
|
||||||
|
FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO )
|
||||||
|
IF(${flag_var} MATCHES "/MDd")
|
||||||
|
STRING(REGEX REPLACE "/MDd" "/MD" ${flag_var} "${${flag_var}}")
|
||||||
|
ENDIF(${flag_var} MATCHES "/MDd")
|
||||||
|
IF(${flag_var} MATCHES "/MTd")
|
||||||
|
STRING(REGEX REPLACE "/MTd" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
|
ENDIF(${flag_var} MATCHES "/MTd")
|
||||||
|
# Need to remove _DEBUG too otherwise things like _ITERATOR_DEBUG_LEVEL mismatch
|
||||||
|
IF(${flag_var} MATCHES "-D_DEBUG")
|
||||||
|
STRING(REGEX REPLACE "-D_DEBUG" "" ${flag_var} "${${flag_var}}")
|
||||||
|
ENDIF(${flag_var} MATCHES "-D_DEBUG")
|
||||||
|
ENDFOREACH(flag_var)
|
||||||
|
ENDIF (USE_MSVC_RELEASE_RUNTIME_ALWAYS)
|
||||||
|
|
||||||
IF (CMAKE_CL_64)
|
IF (CMAKE_CL_64)
|
||||||
ADD_DEFINITIONS(-D_WIN64)
|
ADD_DEFINITIONS(-D_WIN64)
|
||||||
ELSE()
|
ELSE()
|
||||||
OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option" ON)
|
OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option" OFF)
|
||||||
|
option(USE_MSVC_SSE2 "Compile your program with SSE2 instructions" ON)
|
||||||
|
|
||||||
IF (USE_MSVC_SSE)
|
IF (USE_MSVC_SSE)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
IF (USE_MSVC_SSE2)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
option(USE_MSVC_AVX "Compile your program with AVX instructions" OFF)
|
||||||
|
|
||||||
|
IF(USE_MSVC_AVX)
|
||||||
|
add_definitions(/arch:AVX)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
|
OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
|
||||||
IF (USE_MSVC_FAST_FLOATINGPOINT)
|
IF (USE_MSVC_FAST_FLOATINGPOINT)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
OPTION(USE_MSVC_STRING_POOLING "Use MSVC /GF string pooling option" ON)
|
||||||
|
IF (USE_MSVC_STRING_POOLING)
|
||||||
|
SET(CMAKE_C_FLAGS "/GF ${CMAKE_C_FLAGS}")
|
||||||
|
SET(CMAKE_CXX_FLAGS "/GF ${CMAKE_CXX_FLAGS}")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
OPTION(USE_MSVC_FUNCTION_LEVEL_LINKING "Use MSVC /Gy function level linking option" ON)
|
||||||
|
IF(USE_MSVC_FUNCTION_LEVEL_LINKING)
|
||||||
|
SET(CMAKE_C_FLAGS "/Gy ${CMAKE_C_FLAGS}")
|
||||||
|
SET(CMAKE_CXX_FLAGS "/Gy ${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF")
|
||||||
|
ENDIF(USE_MSVC_FUNCTION_LEVEL_LINKING)
|
||||||
|
|
||||||
|
OPTION(USE_MSVC_EXEPTIONS "Use MSVC C++ exceptions option" OFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OPTION(USE_MSVC_COMDAT_FOLDING "Use MSVC /OPT:ICF COMDAT folding option" ON)
|
||||||
|
|
||||||
|
IF(USE_MSVC_COMDAT_FOLDING)
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:ICF")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:ICF")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
OPTION(USE_MSVC_DISABLE_RTTI "Use MSVC /GR- disabled RTTI flags option" ON)
|
||||||
|
IF(USE_MSVC_DISABLE_RTTI)
|
||||||
|
STRING(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
|
||||||
|
SET(CMAKE_C_FLAGS "/GR- ${CMAKE_C_FLAGS}")
|
||||||
|
SET(CMAKE_CXX_FLAGS "/GR- ${CMAKE_CXX_FLAGS}")
|
||||||
|
ENDIF(USE_MSVC_DISABLE_RTTI)
|
||||||
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|
||||||
|
|
@ -141,15 +231,58 @@ IF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
||||||
ADD_DEFINITIONS( -DBT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
ADD_DEFINITIONS( -DBT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
||||||
ENDIF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
ENDIF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
||||||
|
|
||||||
|
IF (CLAMP_VELOCITIES)
|
||||||
|
ADD_DEFINITIONS( -DBT_CLAMP_VELOCITY_TO=${CLAMP_VELOCITIES})
|
||||||
|
ENDIF (CLAMP_VELOCITIES)
|
||||||
|
|
||||||
IF (USE_DOUBLE_PRECISION)
|
IF (USE_DOUBLE_PRECISION)
|
||||||
ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
|
ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
|
||||||
SET( BULLET_DOUBLE_DEF "-DBT_USE_DOUBLE_PRECISION")
|
SET( BULLET_DOUBLE_DEF "-DBT_USE_DOUBLE_PRECISION")
|
||||||
ENDIF (USE_DOUBLE_PRECISION)
|
ENDIF (USE_DOUBLE_PRECISION)
|
||||||
|
|
||||||
|
IF (NOT USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
|
||||||
|
ADD_DEFINITIONS(-DSKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF(USE_GRAPHICAL_BENCHMARK)
|
IF(USE_GRAPHICAL_BENCHMARK)
|
||||||
ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK)
|
ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK)
|
||||||
ENDIF (USE_GRAPHICAL_BENCHMARK)
|
ENDIF (USE_GRAPHICAL_BENCHMARK)
|
||||||
|
|
||||||
|
IF(BULLET2_MULTITHREADING)
|
||||||
|
ADD_DEFINITIONS( -DBT_THREADSAFE=1 )
|
||||||
|
IF (NOT MSVC)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
ENDIF (NOT MSVC)
|
||||||
|
IF (NOT WIN32)
|
||||||
|
FIND_PACKAGE(Threads)
|
||||||
|
LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} )
|
||||||
|
ENDIF (NOT WIN32)
|
||||||
|
ENDIF (BULLET2_MULTITHREADING)
|
||||||
|
|
||||||
|
IF (BULLET2_USE_OPEN_MP_MULTITHREADING)
|
||||||
|
ADD_DEFINITIONS("-DBT_USE_OPENMP=1")
|
||||||
|
IF (MSVC)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
|
||||||
|
ELSE (MSVC)
|
||||||
|
# GCC, Clang
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
|
||||||
|
ENDIF (MSVC)
|
||||||
|
ENDIF (BULLET2_USE_OPEN_MP_MULTITHREADING)
|
||||||
|
|
||||||
|
IF (BULLET2_USE_TBB_MULTITHREADING)
|
||||||
|
SET (BULLET2_TBB_INCLUDE_DIR "not found" CACHE PATH "Directory for Intel TBB includes.")
|
||||||
|
SET (BULLET2_TBB_LIB_DIR "not found" CACHE PATH "Directory for Intel TBB libraries.")
|
||||||
|
find_library(TBB_LIBRARY tbb PATHS ${BULLET2_TBB_LIB_DIR})
|
||||||
|
find_library(TBBMALLOC_LIBRARY tbbmalloc PATHS ${BULLET2_TBB_LIB_DIR})
|
||||||
|
ADD_DEFINITIONS("-DBT_USE_TBB=1")
|
||||||
|
INCLUDE_DIRECTORIES( ${BULLET2_TBB_INCLUDE_DIR} )
|
||||||
|
LINK_LIBRARIES( ${TBB_LIBRARY} ${TBBMALLOC_LIBRARY} )
|
||||||
|
ENDIF (BULLET2_USE_TBB_MULTITHREADING)
|
||||||
|
|
||||||
|
IF (BULLET2_USE_PPL_MULTITHREADING)
|
||||||
|
ADD_DEFINITIONS("-DBT_USE_PPL=1")
|
||||||
|
ENDIF (BULLET2_USE_PPL_MULTITHREADING)
|
||||||
|
|
||||||
IF (WIN32)
|
IF (WIN32)
|
||||||
OPTION(USE_GLUT "Use Glut" ON)
|
OPTION(USE_GLUT "Use Glut" ON)
|
||||||
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
||||||
|
|
@ -190,25 +323,46 @@ ENDIF (OPENGL_FOUND)
|
||||||
#FIND_PACKAGE(GLU)
|
#FIND_PACKAGE(GLU)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IF (APPLE)
|
IF (APPLE)
|
||||||
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON)
|
OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON)
|
||||||
|
|
||||||
OPTION(BUILD_PYBULLET "Set when you want to build pybullet (experimental Python bindings for Bullet)" OFF)
|
# Optional Python configuration
|
||||||
|
# Will not probe environment for Python configuration (which can abort the
|
||||||
|
# build process) unless you explicitly turn on BUILD_PYBULLET.
|
||||||
|
OPTION(BUILD_PYBULLET "Set when you want to build pybullet (Python bindings for Bullet)" OFF)
|
||||||
|
IF(BUILD_PYBULLET)
|
||||||
|
SET(PYTHON_VERSION_PYBULLET "" CACHE STRING "Python version pybullet will use.")
|
||||||
|
SET(Python_ADDITIONAL_VERSIONS 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.7.12 2.7.10 2.7.3 )
|
||||||
|
SET_PROPERTY(CACHE PYTHON_VERSION_PYBULLET PROPERTY STRINGS ${Python_ADDITIONAL_VERSIONS})
|
||||||
|
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build3/cmake ${CMAKE_MODULE_PATH})
|
||||||
|
OPTION(EXACT_PYTHON_VERSION "Require Python and match PYTHON_VERSION_PYBULLET exactly, e.g. 2.7.12" OFF)
|
||||||
|
IF(EXACT_PYTHON_VERSION)
|
||||||
|
set(EXACT_PYTHON_VERSION_FLAG EXACT REQUIRED)
|
||||||
|
ENDIF(EXACT_PYTHON_VERSION)
|
||||||
|
# first find the python interpreter
|
||||||
|
FIND_PACKAGE(PythonInterp ${PYTHON_VERSION_PYBULLET} ${EXACT_PYTHON_VERSION_FLAG})
|
||||||
|
# python library should exactly match that of the interpreter
|
||||||
|
# the following can result in fatal error if you don't have the right python configuration
|
||||||
|
FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
|
||||||
|
ENDIF(BUILD_PYBULLET)
|
||||||
|
|
||||||
|
OPTION(BUILD_ENET "Set when you want to build apps with enet UDP networking support" ON)
|
||||||
|
OPTION(BUILD_CLSOCKET "Set when you want to build apps with enet TCP networking support" ON)
|
||||||
|
|
||||||
|
|
||||||
IF(BUILD_PYBULLET)
|
IF(BUILD_PYBULLET)
|
||||||
|
|
||||||
FIND_PACKAGE(PythonLibs)
|
FIND_PACKAGE(PythonLibs)
|
||||||
|
|
||||||
OPTION(BUILD_PYBULLET_NUMPY "Set when you want to build pybullet with NumPy support" OFF)
|
OPTION(BUILD_PYBULLET_NUMPY "Set when you want to build pybullet with NumPy support" OFF)
|
||||||
|
OPTION(BUILD_PYBULLET_ENET "Set when you want to build pybullet with enet UDP networking support" ON)
|
||||||
|
OPTION(BUILD_PYBULLET_CLSOCKET "Set when you want to build pybullet with enet TCP networking support" ON)
|
||||||
|
|
||||||
|
OPTION(BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK "Set when you want to use the Python Framework on Mac" OFF)
|
||||||
|
|
||||||
IF(BUILD_PYBULLET_NUMPY)
|
IF(BUILD_PYBULLET_NUMPY)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/build3/cmake)
|
|
||||||
#include(FindNumPy)
|
#include(FindNumPy)
|
||||||
FIND_PACKAGE(NumPy)
|
FIND_PACKAGE(NumPy)
|
||||||
if (PYTHON_NUMPY_FOUND)
|
if (PYTHON_NUMPY_FOUND)
|
||||||
|
|
@ -218,15 +372,34 @@ IF(BUILD_PYBULLET)
|
||||||
message("NumPy not found")
|
message("NumPy not found")
|
||||||
endif()
|
endif()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
OPTION(BUILD_PYBULLET "Set when you want to build pybullet (experimental Python bindings for Bullet)" OFF)
|
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared Libs" FORCE)
|
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared Libs" FORCE)
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
SET(BUILD_SHARED_LIBS ON CACHE BOOL "Shared Libs" FORCE)
|
SET(BUILD_SHARED_LIBS ON CACHE BOOL "Shared Libs" FORCE)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
IF(APPLE)
|
||||||
|
OPTION(BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK "Set when you want to use the Python Framework on Mac" ON)
|
||||||
|
IF(NOT BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK)
|
||||||
|
add_definitions(-DB3_NO_PYTHON_FRAMEWORK)
|
||||||
|
ENDIF(NOT BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK)
|
||||||
|
OPTION(BUILD_PYBULLET_SHOW_PY_VERSION "Set when you want to show the PY_MAJOR_VERSION and PY_MAJOR_VERSION using #pragme message." OFF)
|
||||||
|
IF(BUILD_PYBULLET_SHOW_PY_VERSION)
|
||||||
|
add_definitions(-DB3_DUMP_PYTHON_VERSION)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
ENDIF(APPLE)
|
||||||
|
|
||||||
ENDIF(BUILD_PYBULLET)
|
ENDIF(BUILD_PYBULLET)
|
||||||
|
|
||||||
|
IF(NOT WIN32 AND NOT APPLE)
|
||||||
|
OPTION(BUILD_EGL "Build OpenGL/EGL" ON)
|
||||||
|
IF(BUILD_EGL)
|
||||||
|
ADD_DEFINITIONS(-DBT_USE_EGL)
|
||||||
|
ENDIF(BUILD_EGL)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(BUILD_BULLET3)
|
IF(BUILD_BULLET3)
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
MESSAGE("Mac OSX Version is ${_CURRENT_OSX_VERSION}")
|
MESSAGE("Mac OSX Version is ${_CURRENT_OSX_VERSION}")
|
||||||
|
|
@ -259,6 +432,7 @@ IF(BUILD_BULLET2_DEMOS)
|
||||||
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/examples AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/examples)
|
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/examples AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/examples)
|
||||||
SUBDIRS(examples)
|
SUBDIRS(examples)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
ENDIF(BUILD_BULLET2_DEMOS)
|
ENDIF(BUILD_BULLET2_DEMOS)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -269,7 +443,6 @@ IF(BUILD_EXTRAS)
|
||||||
ENDIF(BUILD_EXTRAS)
|
ENDIF(BUILD_EXTRAS)
|
||||||
|
|
||||||
|
|
||||||
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
|
|
||||||
|
|
||||||
SUBDIRS(src)
|
SUBDIRS(src)
|
||||||
|
|
||||||
|
|
@ -284,7 +457,15 @@ ELSE()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
IF(INSTALL_LIBS)
|
IF(INSTALL_LIBS)
|
||||||
|
#INSTALL of other files requires CMake 2.6
|
||||||
|
IF(BUILD_EXTRAS)
|
||||||
|
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
||||||
|
OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" ON)
|
||||||
|
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
||||||
|
ENDIF(BUILD_EXTRAS)
|
||||||
|
|
||||||
SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
|
SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
|
||||||
SET (LIB_DESTINATION "lib${LIB_SUFFIX}" CACHE STRING "Library directory name")
|
SET (LIB_DESTINATION "lib${LIB_SUFFIX}" CACHE STRING "Library directory name")
|
||||||
## the following are directories where stuff will be installed to
|
## the following are directories where stuff will be installed to
|
||||||
|
|
@ -298,12 +479,8 @@ IF(INSTALL_LIBS)
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${PKGCONFIG_INSTALL_PREFIX})
|
${PKGCONFIG_INSTALL_PREFIX})
|
||||||
ENDIF(NOT MSVC)
|
ENDIF(NOT MSVC)
|
||||||
ENDIF(INSTALL_LIBS)
|
ENDIF()
|
||||||
|
|
||||||
#INSTALL of other files requires CMake 2.6
|
|
||||||
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
|
||||||
OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF)
|
|
||||||
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
|
|
||||||
|
|
||||||
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" ON)
|
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" ON)
|
||||||
|
|
||||||
|
|
@ -313,10 +490,10 @@ IF (BUILD_UNIT_TESTS)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
set (BULLET_CONFIG_CMAKE_PATH lib${LIB_SUFFIX}/cmake/bullet )
|
set (BULLET_CONFIG_CMAKE_PATH lib${LIB_SUFFIX}/cmake/bullet )
|
||||||
|
list (APPEND BULLET_DEFINITIONS ${BULLET_DOUBLE_DEF})
|
||||||
list (APPEND BULLET_LIBRARIES LinearMath)
|
list (APPEND BULLET_LIBRARIES LinearMath)
|
||||||
IF(BUILD_BULLET3)
|
list (APPEND BULLET_LIBRARIES Bullet3Common)
|
||||||
list (APPEND BULLET_LIBRARIES BulletInverseDynamics)
|
list (APPEND BULLET_LIBRARIES BulletInverseDynamics)
|
||||||
ENDIF(BUILD_BULLET3)
|
|
||||||
list (APPEND BULLET_LIBRARIES BulletCollision)
|
list (APPEND BULLET_LIBRARIES BulletCollision)
|
||||||
list (APPEND BULLET_LIBRARIES BulletDynamics)
|
list (APPEND BULLET_LIBRARIES BulletDynamics)
|
||||||
list (APPEND BULLET_LIBRARIES BulletSoftBody)
|
list (APPEND BULLET_LIBRARIES BulletSoftBody)
|
||||||
|
|
@ -325,7 +502,11 @@ configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/BulletConfig.cmake.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
|
||||||
@ONLY ESCAPE_QUOTES
|
@ONLY ESCAPE_QUOTES
|
||||||
)
|
)
|
||||||
|
OPTION(INSTALL_CMAKE_FILES "Install generated CMake files" ON)
|
||||||
|
|
||||||
|
IF (INSTALL_CMAKE_FILES)
|
||||||
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/UseBullet.cmake
|
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/UseBullet.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
|
||||||
DESTINATION ${BULLET_CONFIG_CMAKE_PATH}
|
DESTINATION ${BULLET_CONFIG_CMAKE_PATH}
|
||||||
)
|
)
|
||||||
|
ENDIF (INSTALL_CMAKE_FILES)
|
||||||
|
|
|
||||||
317
Engine/lib/bullet/Extras/BulletRobotics/CMakeLists.txt
Normal file
317
Engine/lib/bullet/Extras/BulletRobotics/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,317 @@
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
|
||||||
|
)
|
||||||
|
ADD_DEFINITIONS(-DSTATIC_LINK_SPD_PLUGIN)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SET(BulletRobotics_INCLUDES
|
||||||
|
../../examples/CommonInterfaces/Common2dCanvasInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonCallbacks.h
|
||||||
|
../../examples/CommonInterfaces/CommonCameraInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonExampleInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonFileIOInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonGraphicsAppInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonGUIHelperInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonMultiBodyBase.h
|
||||||
|
../../examples/CommonInterfaces/CommonParameterInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonRenderInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonRigidBodyBase.h
|
||||||
|
../../examples/CommonInterfaces/CommonWindowInterface.h
|
||||||
|
|
||||||
|
../../examples/OpenGLWindow/SimpleCamera.h
|
||||||
|
|
||||||
|
../../examples/TinyRenderer/geometry.h
|
||||||
|
../../examples/TinyRenderer/model.h
|
||||||
|
../../examples/TinyRenderer/tgaimage.h
|
||||||
|
../../examples/TinyRenderer/our_gl.h
|
||||||
|
../../examples/TinyRenderer/TinyRenderer.h
|
||||||
|
|
||||||
|
../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.h
|
||||||
|
../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h
|
||||||
|
../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h
|
||||||
|
../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h
|
||||||
|
../../examples/SharedMemory/IKTrajectoryHelper.h
|
||||||
|
../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.h
|
||||||
|
../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.h
|
||||||
|
../../examples/SharedMemory/InProcessMemory.h
|
||||||
|
../../examples/SharedMemory/PhysicsServer.h
|
||||||
|
../../examples/SharedMemory/PhysicsClient.h
|
||||||
|
../../examples/SharedMemory/PhysicsServerSharedMemory.h
|
||||||
|
../../examples/SharedMemory/PhysicsDirect.h
|
||||||
|
../../examples/SharedMemory/PhysicsDirectC_API.h
|
||||||
|
../../examples/SharedMemory/PhysicsServerCommandProcessor.h
|
||||||
|
../../examples/SharedMemory/b3PluginManager.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientSharedMemory.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientC_API.h
|
||||||
|
../../examples/SharedMemory/SharedMemoryPublic.h
|
||||||
|
../../examples/SharedMemory/Win32SharedMemory.h
|
||||||
|
../../examples/SharedMemory/PosixSharedMemory.h
|
||||||
|
|
||||||
|
../../examples/Utils/b3ResourcePath.h
|
||||||
|
../../examples/Utils/RobotLoggingUtil.h
|
||||||
|
../../examples/Utils/b3Clock.h
|
||||||
|
../../examples/Utils/b3ResourcePath.h
|
||||||
|
../../examples/Utils/ChromeTraceUtil.h
|
||||||
|
../../examples/Utils/b3ERPCFMHelper.hpp
|
||||||
|
../../examples/Utils/b3ReferenceFrameHelper.hpp
|
||||||
|
|
||||||
|
../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.h
|
||||||
|
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
|
||||||
|
../../examples/ThirdPartyLibs/stb_image/stb_image.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Jacobian.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR2.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR3.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR4.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/MatrixRmn.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Node.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Tree.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/VectorRn.h
|
||||||
|
|
||||||
|
../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h
|
||||||
|
../../examples/Importers/ImportObjDemo/LoadMeshFromObj.h
|
||||||
|
../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h
|
||||||
|
../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDF2Bullet.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/UrdfParser.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/urdfStringSplit.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDFImporterInterface.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDFJointTypes.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/SDFAudioTypes.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/UrdfRenderingInterface.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/MultiBodyCreationInterface.h
|
||||||
|
../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h
|
||||||
|
|
||||||
|
../../examples/MultiThreading/b3PosixThreadSupport.h
|
||||||
|
../../examples/MultiThreading/b3Win32ThreadSupport.h
|
||||||
|
../../examples/MultiThreading/b3ThreadSupportInterface.h
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(BulletRobotics_SRCS ${BulletRobotics_INCLUDES}
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/Shape.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/Shape.h
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/RBDUtil.h
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/RBDModel.h
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/KinTree.h
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.cpp
|
||||||
|
../../examples/SharedMemory/plugins/stablePDPlugin/BulletConversion.h
|
||||||
|
|
||||||
|
../../examples/OpenGLWindow/SimpleCamera.cpp
|
||||||
|
|
||||||
|
../../examples/TinyRenderer/geometry.cpp
|
||||||
|
../../examples/TinyRenderer/model.cpp
|
||||||
|
../../examples/TinyRenderer/tgaimage.cpp
|
||||||
|
../../examples/TinyRenderer/our_gl.cpp
|
||||||
|
../../examples/TinyRenderer/TinyRenderer.cpp
|
||||||
|
|
||||||
|
../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp
|
||||||
|
../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp
|
||||||
|
../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp
|
||||||
|
../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp
|
||||||
|
../../examples/SharedMemory/IKTrajectoryHelper.cpp
|
||||||
|
../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp
|
||||||
|
../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp
|
||||||
|
../../examples/SharedMemory/InProcessMemory.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsClient.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsServer.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsServerSharedMemory.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsDirect.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsDirectC_API.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp
|
||||||
|
../../examples/SharedMemory/b3PluginManager.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsClientSharedMemory.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsClientC_API.cpp
|
||||||
|
../../examples/SharedMemory/Win32SharedMemory.cpp
|
||||||
|
../../examples/SharedMemory/PosixSharedMemory.cpp
|
||||||
|
|
||||||
|
../../examples/Utils/b3ResourcePath.cpp
|
||||||
|
../../examples/Utils/RobotLoggingUtil.cpp
|
||||||
|
../../examples/Utils/b3Clock.cpp
|
||||||
|
../../examples/Utils/b3ResourcePath.cpp
|
||||||
|
../../examples/Utils/ChromeTraceUtil.cpp
|
||||||
|
|
||||||
|
../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
|
||||||
|
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
|
||||||
|
../../examples/ThirdPartyLibs/stb_image/stb_image.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Misc.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Node.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Tree.cpp
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp
|
||||||
|
|
||||||
|
../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp
|
||||||
|
../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp
|
||||||
|
../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp
|
||||||
|
../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp
|
||||||
|
../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp
|
||||||
|
../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp
|
||||||
|
../../examples/Importers/ImportURDFDemo/UrdfParser.cpp
|
||||||
|
../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp
|
||||||
|
../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp
|
||||||
|
|
||||||
|
../../examples/MultiThreading/b3PosixThreadSupport.cpp
|
||||||
|
../../examples/MultiThreading/b3Win32ThreadSupport.cpp
|
||||||
|
../../examples/MultiThreading/b3ThreadSupportInterface.cpp
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(ENABLE_VHACD)
|
||||||
|
ADD_DEFINITIONS(-DBT_ENABLE_VHACD)
|
||||||
|
SET(BulletRobotics_SRCS ${BulletRobotics_SRCS}
|
||||||
|
../../Extras/VHACD/test/src/main_vhacd.cpp
|
||||||
|
../../Extras/VHACD/src/VHACD.cpp
|
||||||
|
../../Extras/VHACD/src/vhacdICHull.cpp
|
||||||
|
../../Extras/VHACD/src/vhacdManifoldMesh.cpp
|
||||||
|
../../Extras/VHACD/src/vhacdMesh.cpp
|
||||||
|
../../Extras/VHACD/src/vhacdVolume.cpp
|
||||||
|
)
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
../../Extras/VHACD/inc
|
||||||
|
../../Extras/VHACD/public
|
||||||
|
)
|
||||||
|
ENDIF(ENABLE_VHACD)
|
||||||
|
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET)
|
||||||
|
ENDIF(BUILD_CLSOCKET)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
IF(BUILD_ENET)
|
||||||
|
ADD_DEFINITIONS(-DWIN32 -DBT_ENABLE_ENET)
|
||||||
|
ENDIF(BUILD_ENET)
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
ADD_DEFINITIONS(-DWIN32)
|
||||||
|
ENDIF(BUILD_CLSOCKET)
|
||||||
|
|
||||||
|
ELSE(WIN32)
|
||||||
|
IF(BUILD_ENET)
|
||||||
|
ADD_DEFINITIONS(-DHAS_SOCKLEN_T -DBT_ENABLE_ENET)
|
||||||
|
ENDIF(BUILD_ENET)
|
||||||
|
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
ADD_DEFINITIONS(${OSDEF})
|
||||||
|
ENDIF(BUILD_CLSOCKET)
|
||||||
|
|
||||||
|
IF(NOT APPLE)
|
||||||
|
FIND_PACKAGE(Threads)
|
||||||
|
LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} )
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
IF(BUILD_ENET)
|
||||||
|
set(BulletRobotics_ENET_INCLUDES
|
||||||
|
../../examples/SharedMemory/PhysicsClientUDP.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientUDP_C_API.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/win32.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/unix.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/callbacks.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/list.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/protocol.h
|
||||||
|
)
|
||||||
|
set(BulletRobotics_ENET_SRCS
|
||||||
|
../../examples/SharedMemory/PhysicsClientUDP.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsClientUDP_C_API.cpp
|
||||||
|
../../examples/ThirdPartyLibs/enet/win32.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/unix.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/callbacks.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/compress.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/host.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/list.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/packet.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/peer.c
|
||||||
|
../../examples/ThirdPartyLibs/enet/protocol.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(BulletRobotics_INCLUDES
|
||||||
|
${BulletRobotics_INCLUDES}
|
||||||
|
${BulletRobotics_ENET_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(BulletRobotics_SRCS
|
||||||
|
${BulletRobotics_SRCS}
|
||||||
|
${BulletRobotics_ENET_INCLUDES}
|
||||||
|
${BulletRobotics_ENET_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDIF(BUILD_ENET)
|
||||||
|
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
set(BulletRobotics_CLSOCKET_SRCS
|
||||||
|
../../examples/SharedMemory/PhysicsClientTCP.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsClientTCP_C_API.cpp
|
||||||
|
../../examples/ThirdPartyLibs/clsocket/src/SimpleSocket.cpp
|
||||||
|
../../examples/ThirdPartyLibs/clsocket/src/ActiveSocket.cpp
|
||||||
|
../../examples/ThirdPartyLibs/clsocket/src/PassiveSocket.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(BulletRobotics_SRCS
|
||||||
|
${BulletRobotics_SRCS}
|
||||||
|
${BulletRobotics_CLSOCKET_SRCS}
|
||||||
|
)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DPHYSICS_SERVER_DIRECT)
|
||||||
|
|
||||||
|
|
||||||
|
ADD_LIBRARY(BulletRobotics ${BulletRobotics_SRCS})
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES VERSION ${BULLET_VERSION})
|
||||||
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES SOVERSION ${BULLET_VERSION})
|
||||||
|
|
||||||
|
IF (BUILD_SHARED_LIBS)
|
||||||
|
TARGET_LINK_LIBRARIES(BulletRobotics BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics LinearMath Bullet3Common)
|
||||||
|
ENDIF (BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSTALL (
|
||||||
|
DIRECTORY ${CMAKE_SOURCE_DIR}/examples/
|
||||||
|
DESTINATION include/bullet
|
||||||
|
FILES_MATCHING PATTERN "*.h*")
|
||||||
|
|
||||||
|
INSTALL(TARGETS
|
||||||
|
BulletRobotics
|
||||||
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
|
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES FRAMEWORK true)
|
||||||
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES PUBLIC_HEADER "PhysicsClientC_API.h" )
|
||||||
|
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
|
||||||
|
IF(NOT MSVC)
|
||||||
|
SET(PKGCONFIG_INSTALL_PREFIX "lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet_robotics.pc.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics.pc @ONLY)
|
||||||
|
INSTALL(
|
||||||
|
FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics.pc
|
||||||
|
DESTINATION
|
||||||
|
${PKGCONFIG_INSTALL_PREFIX}
|
||||||
|
)
|
||||||
|
ENDIF(NOT MSVC)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
Name: bullet_robotics
|
||||||
|
Description: Bullet extras that include several utilities for robotics including a urdf parser
|
||||||
|
Requires: bullet
|
||||||
|
Version: @BULLET_VERSION@
|
||||||
|
Libs: -L@CMAKE_INSTALL_PREFIX@/@LIB_DESTINATION@ -lBulletRobotics
|
||||||
|
Cflags: @BULLET_DOUBLE_DEF@ -I@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@ -I@CMAKE_INSTALL_PREFIX@/include/bullet_robotics
|
||||||
183
Engine/lib/bullet/Extras/BulletRobotics/premake4.lua
Normal file
183
Engine/lib/bullet/Extras/BulletRobotics/premake4.lua
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
|
||||||
|
|
||||||
|
project ("BulletRobotics")
|
||||||
|
language "C++"
|
||||||
|
kind "StaticLib"
|
||||||
|
|
||||||
|
includedirs {"../../src", "../../examples",
|
||||||
|
"../../examples/ThirdPartyLibs"}
|
||||||
|
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
||||||
|
hasCL = findOpenCL("clew")
|
||||||
|
|
||||||
|
links{"BulletExampleBrowserLib","gwen", "BulletFileLoader","BulletWorldImporter","OpenGL_Window","BulletSoftBody", "BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision","LinearMath","BussIK", "Bullet3Common"}
|
||||||
|
initOpenGL()
|
||||||
|
initGlew()
|
||||||
|
|
||||||
|
includedirs {
|
||||||
|
"../../src",
|
||||||
|
"../../examples",
|
||||||
|
"../../examples/SharedMemory",
|
||||||
|
"../ThirdPartyLibs",
|
||||||
|
"../ThirdPartyLibs/enet/include",
|
||||||
|
"../ThirdPartyLibs/clsocket/src",
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.is("MacOSX") then
|
||||||
|
-- targetextension {"so"}
|
||||||
|
links{"Cocoa.framework","Python"}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if not _OPTIONS["no-enet"] then
|
||||||
|
|
||||||
|
includedirs {"../../examples/ThirdPartyLibs/enet/include"}
|
||||||
|
|
||||||
|
if os.is("Windows") then
|
||||||
|
-- targetextension {"dylib"}
|
||||||
|
defines { "WIN32" }
|
||||||
|
links {"Ws2_32","Winmm"}
|
||||||
|
end
|
||||||
|
if os.is("Linux") then
|
||||||
|
end
|
||||||
|
if os.is("MacOSX") then
|
||||||
|
end
|
||||||
|
|
||||||
|
links {"enet"}
|
||||||
|
|
||||||
|
files {
|
||||||
|
"../../examples/SharedMemory/PhysicsClientUDP.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientUDP.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientUDP_C_API.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientUDP_C_API.h",
|
||||||
|
}
|
||||||
|
defines {"BT_ENABLE_ENET"}
|
||||||
|
end
|
||||||
|
|
||||||
|
if not _OPTIONS["no-clsocket"] then
|
||||||
|
|
||||||
|
includedirs {"../../examples/ThirdPartyLibs/clsocket/src"}
|
||||||
|
|
||||||
|
if os.is("Windows") then
|
||||||
|
defines { "WIN32" }
|
||||||
|
links {"Ws2_32","Winmm"}
|
||||||
|
end
|
||||||
|
if os.is("Linux") then
|
||||||
|
defines {"_LINUX"}
|
||||||
|
end
|
||||||
|
if os.is("MacOSX") then
|
||||||
|
defines {"_DARWIN"}
|
||||||
|
end
|
||||||
|
|
||||||
|
links {"clsocket"}
|
||||||
|
|
||||||
|
files {
|
||||||
|
"../../examples/SharedMemory/RemoteGUIHelperTCP.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientTCP.cpp",
|
||||||
|
"../../examples/SharedMemory/GraphicsServerExample.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientTCP.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientTCP_C_API.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientTCP_C_API.h",
|
||||||
|
}
|
||||||
|
defines {"BT_ENABLE_CLSOCKET"}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
files {
|
||||||
|
"../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp",
|
||||||
|
"../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp",
|
||||||
|
"../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h",
|
||||||
|
"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp",
|
||||||
|
"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h",
|
||||||
|
"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp",
|
||||||
|
"../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h",
|
||||||
|
"../../examples/SharedMemory/IKTrajectoryHelper.cpp",
|
||||||
|
"../../examples/SharedMemory/IKTrajectoryHelper.h",
|
||||||
|
"../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp",
|
||||||
|
"../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp",
|
||||||
|
"../../examples/SharedMemory/RemoteGUIHelper.cpp",
|
||||||
|
"../../examples/OpenGLWindow/SimpleCamera.cpp",
|
||||||
|
"../../examples/OpenGLWindow/SimpleCamera.h",
|
||||||
|
"../../examples/TinyRenderer/geometry.cpp",
|
||||||
|
"../../examples/TinyRenderer/model.cpp",
|
||||||
|
"../../examples/TinyRenderer/tgaimage.cpp",
|
||||||
|
"../../examples/TinyRenderer/our_gl.cpp",
|
||||||
|
"../../examples/TinyRenderer/TinyRenderer.cpp",
|
||||||
|
"../../examples/SharedMemory/InProcessMemory.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClient.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClient.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsServer.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsServer.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsServerSharedMemory.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsServerSharedMemory.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsDirect.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsDirect.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsDirectC_API.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsDirectC_API.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsServerCommandProcessor.h",
|
||||||
|
"../../examples/SharedMemory/b3PluginManager.cpp",
|
||||||
|
"../../examples/SharedMemory/b3PluginManager.h",
|
||||||
|
|
||||||
|
"../../examples/SharedMemory/PhysicsClientSharedMemory.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientSharedMemory.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.cpp",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.h",
|
||||||
|
"../../examples/SharedMemory/PhysicsClientC_API.cpp",
|
||||||
|
|
||||||
|
"../../examples/SharedMemory/PhysicsClientC_API.h",
|
||||||
|
"../../examples/SharedMemory/SharedMemoryPublic.h",
|
||||||
|
|
||||||
|
"../../examples/SharedMemory/Win32SharedMemory.cpp",
|
||||||
|
"../../examples/SharedMemory/Win32SharedMemory.h",
|
||||||
|
"../../examples/SharedMemory/PosixSharedMemory.cpp",
|
||||||
|
"../../examples/SharedMemory/PosixSharedMemory.h",
|
||||||
|
|
||||||
|
"../../examples/Utils/b3ResourcePath.cpp",
|
||||||
|
"../../examples/Utils/b3ResourcePath.h",
|
||||||
|
"../../examples/Utils/RobotLoggingUtil.cpp",
|
||||||
|
"../../examples/Utils/RobotLoggingUtil.h",
|
||||||
|
"../../examples/Utils/b3Clock.cpp",
|
||||||
|
"../../examples/Utils/b3ResourcePath.cpp",
|
||||||
|
"../../examples/Utils/b3ERPCFMHelper.hpp",
|
||||||
|
"../../examples/Utils/b3ReferenceFrameHelper.hpp",
|
||||||
|
"../../examples/Utils/ChromeTraceUtil.cpp",
|
||||||
|
|
||||||
|
"../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
|
||||||
|
|
||||||
|
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
|
||||||
|
|
||||||
|
"../../examples/ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||||
|
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/Jacobian.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/LinearR2.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/LinearR3.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/LinearR4.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/MatrixRmn.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/Misc.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/Node.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/Tree.cpp",
|
||||||
|
"../../examples/ThirdPartyLibs/BussIK/VectorRn.cpp",
|
||||||
|
|
||||||
|
"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
|
||||||
|
"../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp",
|
||||||
|
"../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
|
||||||
|
"../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.cpp",
|
||||||
|
"../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp",
|
||||||
|
"../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp",
|
||||||
|
"../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp",
|
||||||
|
"../../examples/Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||||
|
"../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
||||||
|
"../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||||
|
|
||||||
|
"../../examples/MultiThreading/b3PosixThreadSupport.cpp",
|
||||||
|
"../../examples/MultiThreading/b3Win32ThreadSupport.cpp",
|
||||||
|
"../../examples/MultiThreading/b3ThreadSupportInterface.cpp",
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_OPTIONS["enable_static_vr_plugin"]) then
|
||||||
|
files {"../../examples/SharedMemory/plugins/vrSyncPlugin/vrSyncPlugin.cpp"}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
196
Engine/lib/bullet/Extras/BulletRoboticsGUI/CMakeLists.txt
Normal file
196
Engine/lib/bullet/Extras/BulletRoboticsGUI/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,196 @@
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(BulletRoboticsGUI_INCLUDES
|
||||||
|
../../examples/CommonInterfaces/Common2dCanvasInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonCallbacks.h
|
||||||
|
../../examples/CommonInterfaces/CommonCameraInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonExampleInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonFileIOInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonGraphicsAppInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonGUIHelperInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonMultiBodyBase.h
|
||||||
|
../../examples/CommonInterfaces/CommonParameterInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonRenderInterface.h
|
||||||
|
../../examples/CommonInterfaces/CommonRigidBodyBase.h
|
||||||
|
../../examples/CommonInterfaces/CommonWindowInterface.h
|
||||||
|
|
||||||
|
../../examples/OpenGLWindow/SimpleCamera.h
|
||||||
|
|
||||||
|
../../examples/TinyRenderer/geometry.h
|
||||||
|
../../examples/TinyRenderer/model.h
|
||||||
|
../../examples/TinyRenderer/tgaimage.h
|
||||||
|
../../examples/TinyRenderer/our_gl.h
|
||||||
|
../../examples/TinyRenderer/TinyRenderer.h
|
||||||
|
|
||||||
|
../../examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.h
|
||||||
|
../../examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h
|
||||||
|
../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h
|
||||||
|
../../examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h
|
||||||
|
../../examples/SharedMemory/IKTrajectoryHelper.h
|
||||||
|
../../examples/SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.h
|
||||||
|
../../examples/SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.h
|
||||||
|
../../examples/SharedMemory/InProcessMemory.h
|
||||||
|
../../examples/SharedMemory/PhysicsServer.h
|
||||||
|
../../examples/SharedMemory/PhysicsClient.h
|
||||||
|
../../examples/SharedMemory/PhysicsServerSharedMemory.h
|
||||||
|
../../examples/SharedMemory/PhysicsDirect.h
|
||||||
|
../../examples/SharedMemory/PhysicsDirectC_API.h
|
||||||
|
../../examples/SharedMemory/PhysicsServerCommandProcessor.h
|
||||||
|
../../examples/SharedMemory/b3PluginManager.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientSharedMemory.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientSharedMemory_C_API.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientC_API.h
|
||||||
|
../../examples/SharedMemory/SharedMemoryPublic.h
|
||||||
|
../../examples/SharedMemory/Win32SharedMemory.h
|
||||||
|
../../examples/SharedMemory/PosixSharedMemory.h
|
||||||
|
|
||||||
|
../../examples/Utils/b3ResourcePath.h
|
||||||
|
../../examples/Utils/RobotLoggingUtil.h
|
||||||
|
../../examples/Utils/b3Clock.h
|
||||||
|
../../examples/Utils/b3ResourcePath.h
|
||||||
|
../../examples/Utils/ChromeTraceUtil.h
|
||||||
|
../../examples/Utils/b3ERPCFMHelper.hpp
|
||||||
|
../../examples/Utils/b3ReferenceFrameHelper.hpp
|
||||||
|
|
||||||
|
../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.h
|
||||||
|
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
|
||||||
|
../../examples/ThirdPartyLibs/stb_image/stb_image.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Jacobian.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR2.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR3.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/LinearR4.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/MatrixRmn.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Node.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/Tree.h
|
||||||
|
../../examples/ThirdPartyLibs/BussIK/VectorRn.h
|
||||||
|
|
||||||
|
../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h
|
||||||
|
../../examples/Importers/ImportObjDemo/LoadMeshFromObj.h
|
||||||
|
../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h
|
||||||
|
../../examples/Importers/ImportMJCFDemo/BulletMJCFImporter.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDF2Bullet.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/UrdfParser.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/urdfStringSplit.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDFImporterInterface.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/URDFJointTypes.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/SDFAudioTypes.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/UrdfRenderingInterface.h
|
||||||
|
../../examples/Importers/ImportURDFDemo/MultiBodyCreationInterface.h
|
||||||
|
../../examples/Importers/ImportMeshUtility/b3ImportMeshUtility.h
|
||||||
|
|
||||||
|
../../examples/MultiThreading/b3PosixThreadSupport.h
|
||||||
|
../../examples/MultiThreading/b3Win32ThreadSupport.h
|
||||||
|
../../examples/MultiThreading/b3ThreadSupportInterface.h
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(BulletRoboticsGUI_SRCS ${BulletRoboticsGUI_INCLUDES}
|
||||||
|
../../examples/ExampleBrowser/InProcessExampleBrowser.cpp
|
||||||
|
../../examples/SharedMemory/GraphicsServerExample.cpp
|
||||||
|
../../examples/SharedMemory/GraphicsClientExample.cpp
|
||||||
|
../../examples/SharedMemory/RemoteGUIHelper.cpp
|
||||||
|
../../examples/SharedMemory/RemoteGUIHelperTCP.cpp
|
||||||
|
../../examples/SharedMemory/GraphicsServerExample.h
|
||||||
|
../../examples/SharedMemory/GraphicsClientExample.h
|
||||||
|
../../examples/SharedMemory/RemoteGUIHelper.h
|
||||||
|
../../examples/SharedMemory/GraphicsSharedMemoryCommands.h
|
||||||
|
../../examples/SharedMemory/GraphicsSharedMemoryPublic.h
|
||||||
|
../../examples/SharedMemory/PhysicsServerExample.cpp
|
||||||
|
../../examples/SharedMemory/PhysicsServerExampleBullet2.cpp
|
||||||
|
../../examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
ADD_DEFINITIONS(-DBT_ENABLE_CLSOCKET)
|
||||||
|
ENDIF(BUILD_CLSOCKET)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
IF(BUILD_ENET)
|
||||||
|
ADD_DEFINITIONS(-DWIN32 -DBT_ENABLE_ENET)
|
||||||
|
ENDIF(BUILD_ENET)
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
ADD_DEFINITIONS(-DWIN32)
|
||||||
|
ENDIF(BUILD_CLSOCKET)
|
||||||
|
|
||||||
|
ELSE(WIN32)
|
||||||
|
IF(BUILD_ENET)
|
||||||
|
ADD_DEFINITIONS(-DHAS_SOCKLEN_T -DBT_ENABLE_ENET)
|
||||||
|
ENDIF(BUILD_ENET)
|
||||||
|
|
||||||
|
IF(BUILD_CLSOCKET)
|
||||||
|
ADD_DEFINITIONS(${OSDEF})
|
||||||
|
ENDIF(BUILD_CLSOCKET)
|
||||||
|
|
||||||
|
IF(NOT APPLE)
|
||||||
|
FIND_PACKAGE(Threads)
|
||||||
|
LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} )
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
IF(BUILD_ENET)
|
||||||
|
set(BulletRoboticsGUI_ENET_INCLUDES
|
||||||
|
../../examples/SharedMemory/PhysicsClientUDP.h
|
||||||
|
../../examples/SharedMemory/PhysicsClientUDP_C_API.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/win32.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/unix.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/callbacks.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/list.h
|
||||||
|
../../examples/ThirdPartyLibs/enet/include/enet/protocol.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(BulletRoboticsGUI_INCLUDES
|
||||||
|
${BulletRoboticsGUI_INCLUDES}
|
||||||
|
${BulletRoboticsGUI_ENET_INCLUDES}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ENDIF(BUILD_ENET)
|
||||||
|
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DPHYSICS_SERVER_DIRECT)
|
||||||
|
|
||||||
|
|
||||||
|
ADD_LIBRARY(BulletRoboticsGUI ${BulletRoboticsGUI_SRCS})
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(BulletRoboticsGUI PROPERTIES VERSION ${BULLET_VERSION})
|
||||||
|
SET_TARGET_PROPERTIES(BulletRoboticsGUI PROPERTIES SOVERSION ${BULLET_VERSION})
|
||||||
|
|
||||||
|
IF (BUILD_SHARED_LIBS)
|
||||||
|
TARGET_LINK_LIBRARIES(BulletRoboticsGUI BulletExampleBrowserLib BulletRobotics BulletInverseDynamicsUtils BulletWorldImporter BulletFileLoader BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamics LinearMath Bullet3Common)
|
||||||
|
ENDIF (BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSTALL(TARGETS
|
||||||
|
BulletRoboticsGUI
|
||||||
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
|
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES FRAMEWORK true)
|
||||||
|
SET_TARGET_PROPERTIES(BulletRobotics PROPERTIES PUBLIC_HEADER "PhysicsClientC_API.h" )
|
||||||
|
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
|
|
||||||
|
IF(NOT MSVC)
|
||||||
|
SET(PKGCONFIG_INSTALL_PREFIX "lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
|
||||||
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet_robotics_gui.pc.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics_gui.pc @ONLY)
|
||||||
|
INSTALL(
|
||||||
|
FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/bullet_robotics_gui.pc
|
||||||
|
DESTINATION
|
||||||
|
${PKGCONFIG_INSTALL_PREFIX}
|
||||||
|
)
|
||||||
|
ENDIF(NOT MSVC)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
Name: bullet_robotics_gui
|
||||||
|
Description: Bullet GUI extras for robotics
|
||||||
|
Requires: bullet
|
||||||
|
Version: @BULLET_VERSION@
|
||||||
|
Libs: -L@CMAKE_INSTALL_PREFIX@/@LIB_DESTINATION@ -lBulletRoboticsGUI
|
||||||
|
Cflags: @BULLET_DOUBLE_DEF@ -I@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@ -I@CMAKE_INSTALL_PREFIX@/include/bullet_robotics_gui
|
||||||
|
|
@ -1,8 +1,37 @@
|
||||||
SUBDIRS( Serialize ConvexDecomposition HACD GIMPACTUtils )
|
OPTION(BUILD_INVERSE_DYNAMIC_EXTRA "Build InverseDynamic extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_BULLET_ROBOTICS_GUI_EXTRA "Build BulletRoboticsGUI extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_BULLET_ROBOTICS_EXTRA "Build BulletRobotics extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_OBJ2SDF_EXTRA "Build obj2sdf extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_SERIALIZE_EXTRA "Build Serialize extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_CONVEX_DECOMPOSITION_EXTRA "Build ConvexDecomposition extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_HACD_EXTRA "Build HACD extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
OPTION(BUILD_GIMPACTUTILS_EXTRA "Build GIMPACTUtils extra module, only applied when BUILD_EXTRAS is ON" ON)
|
||||||
|
|
||||||
IF(BUILD_BULLET3)
|
IF(BUILD_INVERSE_DYNAMIC_EXTRA)
|
||||||
SUBDIRS( InverseDynamics )
|
SUBDIRS( InverseDynamics )
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
IF(BUILD_BULLET_ROBOTICS_GUI_EXTRA)
|
||||||
|
SUBDIRS( BulletRoboticsGUI )
|
||||||
|
ENDIF()
|
||||||
|
IF(BUILD_BULLET_ROBOTICS_EXTRA)
|
||||||
|
SUBDIRS( BulletRobotics )
|
||||||
|
ENDIF()
|
||||||
|
IF(BUILD_OBJ2SDF_EXTRA)
|
||||||
|
SUBDIRS( obj2sdf )
|
||||||
|
ENDIF()
|
||||||
|
IF(BUILD_SERIALIZE_EXTRA)
|
||||||
|
SUBDIRS( Serialize )
|
||||||
|
ENDIF()
|
||||||
|
IF(BUILD_CONVEX_DECOMPOSITION_EXTRA)
|
||||||
|
SUBDIRS( ConvexDecomposition )
|
||||||
|
ENDIF()
|
||||||
|
IF(BUILD_HACD_EXTRA)
|
||||||
|
SUBDIRS( HACD )
|
||||||
|
ENDIF()
|
||||||
|
IF(BUILD_GIMPACTUTILS_EXTRA)
|
||||||
|
SUBDIRS( GIMPACTUtils )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
|
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,10 @@ IF (INSTALL_EXTRA_LIBS)
|
||||||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS ConvexDecomposition DESTINATION .)
|
INSTALL(TARGETS ConvexDecomposition DESTINATION .)
|
||||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS ConvexDecomposition DESTINATION lib${LIB_SUFFIX})
|
INSTALL(TARGETS ConvexDecomposition
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
|
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||||
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ unsigned int MAXDEPTH = 8 ;
|
||||||
float CONCAVE_PERCENT = 1.0f;
|
float CONCAVE_PERCENT = 1.0f;
|
||||||
float MERGE_PERCENT = 2.0f;
|
float MERGE_PERCENT = 2.0f;
|
||||||
|
|
||||||
CHull::CHull(const ConvexResult &result)
|
CHull::CHull(const ConvexDecomposition::ConvexResult &result)
|
||||||
{
|
{
|
||||||
mResult = new ConvexResult(result);
|
mResult = new ConvexDecomposition::ConvexResult(result);
|
||||||
mVolume = computeMeshVolume(result.mHullVertices, result.mHullTcount, result.mHullIndices);
|
mVolume = computeMeshVolume(result.mHullVertices, result.mHullTcount, result.mHullIndices);
|
||||||
|
|
||||||
mDiagonal = getBoundingRegion(result.mHullVcount, result.mHullVertices, sizeof(float) * 3, mMin, mMax);
|
mDiagonal = getBoundingRegion(result.mHullVcount, result.mHullVertices, sizeof(float) * 3, mMin, mMax);
|
||||||
|
|
@ -34,8 +34,6 @@ CHull::CHull(const ConvexResult &result)
|
||||||
mMax[0] += dx;
|
mMax[0] += dx;
|
||||||
mMax[1] += dy;
|
mMax[1] += dy;
|
||||||
mMax[2] += dz;
|
mMax[2] += dz;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CHull::~CHull(void)
|
CHull::~CHull(void)
|
||||||
|
|
@ -48,9 +46,6 @@ bool CHull::overlap(const CHull &h) const
|
||||||
return overlapAABB(mMin, mMax, h.mMin, h.mMax);
|
return overlapAABB(mMin, mMax, h.mMin, h.mMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConvexBuilder::ConvexBuilder(ConvexDecompInterface *callback)
|
ConvexBuilder::ConvexBuilder(ConvexDecompInterface *callback)
|
||||||
{
|
{
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
|
|
@ -81,7 +76,7 @@ bool ConvexBuilder::isDuplicate(unsigned int i1,unsigned int i2,unsigned int i3,
|
||||||
return dcount == 3;
|
return dcount == 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvexBuilder::getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &indices)
|
void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector &indices)
|
||||||
{
|
{
|
||||||
unsigned int *src = cr.mHullIndices;
|
unsigned int *src = cr.mHullIndices;
|
||||||
|
|
||||||
|
|
@ -122,13 +117,11 @@ void ConvexBuilder::getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &i
|
||||||
indices.push_back(i3);
|
indices.push_back(i3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CHull *ConvexBuilder::canMerge(CHull *a, CHull *b)
|
CHull *ConvexBuilder::canMerge(CHull *a, CHull *b)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!a->overlap(*b)) return 0; // if their AABB's (with a little slop) don't overlap, then return.
|
if (!a->overlap(*b)) return 0; // if their AABB's (with a little slop) don't overlap, then return.
|
||||||
|
|
||||||
CHull *ret = 0;
|
CHull *ret = 0;
|
||||||
|
|
@ -154,33 +147,31 @@ CHull * ConvexBuilder::canMerge(CHull *a,CHull *b)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HullResult hresult;
|
ConvexDecomposition::HullResult hresult;
|
||||||
HullLibrary hl;
|
ConvexDecomposition::HullLibrary hl;
|
||||||
HullDesc desc;
|
ConvexDecomposition::HullDesc desc;
|
||||||
|
|
||||||
desc.SetHullFlag(QF_TRIANGLES);
|
desc.SetHullFlag(ConvexDecomposition::QF_TRIANGLES);
|
||||||
|
|
||||||
desc.mVcount = vcount;
|
desc.mVcount = vcount;
|
||||||
desc.mVertices = vertices;
|
desc.mVertices = vertices;
|
||||||
desc.mVertexStride = sizeof(float) * 3;
|
desc.mVertexStride = sizeof(float) * 3;
|
||||||
|
|
||||||
HullError hret = hl.CreateConvexHull(desc,hresult);
|
ConvexDecomposition::HullError hret = hl.CreateConvexHull(desc, hresult);
|
||||||
|
|
||||||
if ( hret == QE_OK )
|
if (hret == ConvexDecomposition::QE_OK)
|
||||||
{
|
{
|
||||||
|
|
||||||
float combineVolume = computeMeshVolume(hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
|
float combineVolume = computeMeshVolume(hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
|
||||||
float sumVolume = a->mVolume + b->mVolume;
|
float sumVolume = a->mVolume + b->mVolume;
|
||||||
|
|
||||||
float percent = (sumVolume * 100) / combineVolume;
|
float percent = (sumVolume * 100) / combineVolume;
|
||||||
if (percent >= (100.0f - MERGE_PERCENT))
|
if (percent >= (100.0f - MERGE_PERCENT))
|
||||||
{
|
{
|
||||||
ConvexResult cr(hresult.mNumOutputVertices, hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
|
ConvexDecomposition::ConvexResult cr(hresult.mNumOutputVertices, hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
|
||||||
ret = new CHull(cr);
|
ret = new CHull(cr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vl_releaseVertexLookup(vc);
|
Vl_releaseVertexLookup(vc);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -188,14 +179,12 @@ CHull * ConvexBuilder::canMerge(CHull *a,CHull *b)
|
||||||
|
|
||||||
bool ConvexBuilder::combineHulls(void)
|
bool ConvexBuilder::combineHulls(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool combine = false;
|
bool combine = false;
|
||||||
|
|
||||||
sortChulls(mChulls); // sort the convex hulls, largest volume to least...
|
sortChulls(mChulls); // sort the convex hulls, largest volume to least...
|
||||||
|
|
||||||
CHullVector output; // the output hulls...
|
CHullVector output; // the output hulls...
|
||||||
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < mChulls.size() && !combine; ++i)
|
for (i = 0; i < mChulls.size() && !combine; ++i)
|
||||||
|
|
@ -209,15 +198,12 @@ bool ConvexBuilder::combineHulls(void)
|
||||||
|
|
||||||
if (cr != match) // don't try to merge a hull with itself, that be stoopid
|
if (cr != match) // don't try to merge a hull with itself, that be stoopid
|
||||||
{
|
{
|
||||||
|
|
||||||
CHull *merge = canMerge(cr, match); // if we can merge these two....
|
CHull *merge = canMerge(cr, match); // if we can merge these two....
|
||||||
|
|
||||||
if (merge)
|
if (merge)
|
||||||
{
|
{
|
||||||
|
|
||||||
output.push_back(merge);
|
output.push_back(merge);
|
||||||
|
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
while (i != mChulls.size())
|
while (i != mChulls.size())
|
||||||
{
|
{
|
||||||
|
|
@ -245,7 +231,6 @@ bool ConvexBuilder::combineHulls(void)
|
||||||
{
|
{
|
||||||
output.push_back(cr);
|
output.push_back(cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (combine)
|
if (combine)
|
||||||
|
|
@ -255,24 +240,21 @@ bool ConvexBuilder::combineHulls(void)
|
||||||
output.clear();
|
output.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return combine;
|
return combine;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ConvexBuilder::process(const DecompDesc &desc)
|
unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int ret = 0;
|
unsigned int ret = 0;
|
||||||
|
|
||||||
MAXDEPTH = desc.mDepth;
|
MAXDEPTH = desc.mDepth;
|
||||||
CONCAVE_PERCENT = desc.mCpercent;
|
CONCAVE_PERCENT = desc.mCpercent;
|
||||||
MERGE_PERCENT = desc.mPpercent;
|
MERGE_PERCENT = desc.mPpercent;
|
||||||
|
|
||||||
|
|
||||||
calcConvexDecomposition(desc.mVcount, desc.mVertices, desc.mTcount, desc.mIndices, this, 0, 0);
|
calcConvexDecomposition(desc.mVcount, desc.mVertices, desc.mTcount, desc.mIndices, this, 0, 0);
|
||||||
|
|
||||||
|
while (combineHulls())
|
||||||
while ( combineHulls() ); // keep combinging hulls until I can't combine any more...
|
; // keep combinging hulls until I can't combine any more...
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < mChulls.size(); i++)
|
for (i = 0; i < mChulls.size(); i++)
|
||||||
|
|
@ -282,13 +264,13 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
|
||||||
// before we hand it back to the application, we need to regenerate the hull based on the
|
// before we hand it back to the application, we need to regenerate the hull based on the
|
||||||
// limits given by the user.
|
// limits given by the user.
|
||||||
|
|
||||||
const ConvexResult &c = *cr->mResult; // the high resolution hull...
|
const ConvexDecomposition::ConvexResult &c = *cr->mResult; // the high resolution hull...
|
||||||
|
|
||||||
HullResult result;
|
ConvexDecomposition::HullResult result;
|
||||||
HullLibrary hl;
|
ConvexDecomposition::HullLibrary hl;
|
||||||
HullDesc hdesc;
|
ConvexDecomposition::HullDesc hdesc;
|
||||||
|
|
||||||
hdesc.SetHullFlag(QF_TRIANGLES);
|
hdesc.SetHullFlag(ConvexDecomposition::QF_TRIANGLES);
|
||||||
|
|
||||||
hdesc.mVcount = c.mHullVcount;
|
hdesc.mVcount = c.mHullVcount;
|
||||||
hdesc.mVertices = c.mHullVertices;
|
hdesc.mVertices = c.mHullVertices;
|
||||||
|
|
@ -298,14 +280,14 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
|
||||||
if (desc.mSkinWidth)
|
if (desc.mSkinWidth)
|
||||||
{
|
{
|
||||||
hdesc.mSkinWidth = desc.mSkinWidth;
|
hdesc.mSkinWidth = desc.mSkinWidth;
|
||||||
hdesc.SetHullFlag(QF_SKIN_WIDTH); // do skin width computation.
|
hdesc.SetHullFlag(ConvexDecomposition::QF_SKIN_WIDTH); // do skin width computation.
|
||||||
}
|
}
|
||||||
|
|
||||||
HullError ret = hl.CreateConvexHull(hdesc,result);
|
ConvexDecomposition::HullError ret = hl.CreateConvexHull(hdesc, result);
|
||||||
|
|
||||||
if ( ret == QE_OK )
|
if (ret == ConvexDecomposition::QE_OK)
|
||||||
{
|
{
|
||||||
ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
|
ConvexDecomposition::ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
|
||||||
|
|
||||||
r.mHullVolume = computeMeshVolume(result.mOutputVertices, result.mNumFaces, result.mIndices); // the volume of the hull.
|
r.mHullVolume = computeMeshVolume(result.mOutputVertices, result.mNumFaces, result.mIndices); // the volume of the hull.
|
||||||
|
|
||||||
|
|
@ -321,13 +303,11 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
|
||||||
r.mSphereRadius = computeBoundingSphere(result.mNumOutputVertices, result.mOutputVertices, r.mSphereCenter);
|
r.mSphereRadius = computeBoundingSphere(result.mNumOutputVertices, result.mOutputVertices, r.mSphereCenter);
|
||||||
r.mSphereVolume = fm_sphereVolume(r.mSphereRadius);
|
r.mSphereVolume = fm_sphereVolume(r.mSphereRadius);
|
||||||
|
|
||||||
|
|
||||||
mCallback->ConvexDecompResult(r);
|
mCallback->ConvexDecompResult(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
hl.ReleaseResult(result);
|
hl.ReleaseResult(result);
|
||||||
|
|
||||||
|
|
||||||
delete cr;
|
delete cr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,7 +318,6 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ConvexBuilder::ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color)
|
void ConvexBuilder::ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color)
|
||||||
{
|
{
|
||||||
mCallback->ConvexDebugTri(p1, p2, p3, color);
|
mCallback->ConvexDebugTri(p1, p2, p3, color);
|
||||||
|
|
@ -358,7 +337,7 @@ void ConvexBuilder::ConvexDebugBound(const float *bmin,const float *bmax,unsigne
|
||||||
mCallback->ConvexDebugBound(bmin, bmax, color);
|
mCallback->ConvexDebugBound(bmin, bmax, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvexBuilder::ConvexDecompResult(ConvexResult &result)
|
void ConvexBuilder::ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
|
||||||
{
|
{
|
||||||
CHull *ch = new CHull(result);
|
CHull *ch = new CHull(result);
|
||||||
mChulls.push_back(ch);
|
mChulls.push_back(ch);
|
||||||
|
|
@ -369,5 +348,3 @@ void ConvexBuilder::sortChulls(CHullVector &hulls)
|
||||||
hulls.quickSort(CHullSort());
|
hulls.quickSort(CHullSort());
|
||||||
//hulls.heapSort(CHullSort());
|
//hulls.heapSort(CHullSort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "ConvexDecomposition.h"
|
#include "ConvexDecomposition.h"
|
||||||
#include "vlookup.h"
|
#include "vlookup.h"
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
|
||||||
using namespace ConvexDecomposition;
|
|
||||||
|
|
||||||
|
|
||||||
class CHull
|
class CHull
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CHull(const ConvexResult &result);
|
CHull(const ConvexDecomposition::ConvexResult &result);
|
||||||
|
|
||||||
~CHull(void);
|
~CHull(void);
|
||||||
|
|
||||||
|
|
@ -56,42 +52,38 @@ public:
|
||||||
float mMax[3];
|
float mMax[3];
|
||||||
float mVolume;
|
float mVolume;
|
||||||
float mDiagonal; // long edge..
|
float mDiagonal; // long edge..
|
||||||
ConvexResult *mResult;
|
ConvexDecomposition::ConvexResult *mResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Usage: std::sort( list.begin(), list.end(), StringSortRef() );
|
// Usage: std::sort( list.begin(), list.end(), StringSortRef() );
|
||||||
class CHullSort
|
class CHullSort
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline bool operator()(const CHull *a, const CHull *b) const
|
inline bool operator()(const CHull *a, const CHull *b) const
|
||||||
{
|
{
|
||||||
return a->mVolume < b->mVolume;
|
return a->mVolume < b->mVolume;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef btAlignedObjectArray<CHull *> CHullVector;
|
typedef btAlignedObjectArray<CHull *> CHullVector;
|
||||||
|
|
||||||
|
class ConvexBuilder : public ConvexDecomposition::ConvexDecompInterface
|
||||||
|
|
||||||
class ConvexBuilder : public ConvexDecompInterface
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConvexBuilder(ConvexDecompInterface *callback);
|
ConvexBuilder(ConvexDecomposition::ConvexDecompInterface *callback);
|
||||||
|
|
||||||
virtual ~ConvexBuilder(void);
|
virtual ~ConvexBuilder(void);
|
||||||
|
|
||||||
bool isDuplicate(unsigned int i1, unsigned int i2, unsigned int i3,
|
bool isDuplicate(unsigned int i1, unsigned int i2, unsigned int i3,
|
||||||
unsigned int ci1, unsigned int ci2, unsigned int ci3);
|
unsigned int ci1, unsigned int ci2, unsigned int ci3);
|
||||||
|
|
||||||
void getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &indices);
|
void getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector &indices);
|
||||||
|
|
||||||
CHull *canMerge(CHull *a, CHull *b);
|
CHull *canMerge(CHull *a, CHull *b);
|
||||||
|
|
||||||
bool combineHulls(void);
|
bool combineHulls(void);
|
||||||
|
|
||||||
unsigned int process(const DecompDesc &desc);
|
unsigned int process(const ConvexDecomposition::DecompDesc &desc);
|
||||||
|
|
||||||
virtual void ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color);
|
virtual void ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color);
|
||||||
|
|
||||||
|
|
@ -100,7 +92,7 @@ public:
|
||||||
|
|
||||||
virtual void ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color);
|
virtual void ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color);
|
||||||
|
|
||||||
virtual void ConvexDecompResult(ConvexResult &result);
|
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result);
|
||||||
|
|
||||||
void sortChulls(CHullVector &hulls);
|
void sortChulls(CHullVector &hulls);
|
||||||
|
|
||||||
|
|
@ -109,4 +101,3 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //CONVEX_BUILDER_H
|
#endif //CONVEX_BUILDER_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -56,14 +55,10 @@
|
||||||
#define SHOW_MESH 0
|
#define SHOW_MESH 0
|
||||||
#define MAKE_MESH 1
|
#define MAKE_MESH 1
|
||||||
|
|
||||||
|
|
||||||
using namespace ConvexDecomposition;
|
using namespace ConvexDecomposition;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
class FaceTri
|
class FaceTri
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -79,10 +74,8 @@ public:
|
||||||
Vector3d mP2;
|
Vector3d mP2;
|
||||||
Vector3d mP3;
|
Vector3d mP3;
|
||||||
Vector3d mNormal;
|
Vector3d mNormal;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void addTri(VertexLookup vl, UintVector &list, const Vector3d &p1, const Vector3d &p2, const Vector3d &p3)
|
void addTri(VertexLookup vl, UintVector &list, const Vector3d &p1, const Vector3d &p2, const Vector3d &p3)
|
||||||
{
|
{
|
||||||
unsigned int i1 = Vl_getIndex(vl, p1.Ptr());
|
unsigned int i1 = Vl_getIndex(vl, p1.Ptr());
|
||||||
|
|
@ -99,7 +92,6 @@ void addTri(VertexLookup vl,UintVector &list,const Vector3d &p1,const Vector3d &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void calcConvexDecomposition(unsigned int vcount,
|
void calcConvexDecomposition(unsigned int vcount,
|
||||||
const float *vertices,
|
const float *vertices,
|
||||||
unsigned int tcount,
|
unsigned int tcount,
|
||||||
|
|
@ -109,15 +101,12 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
unsigned int depth)
|
unsigned int depth)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
float plane[4];
|
float plane[4];
|
||||||
|
|
||||||
bool split = false;
|
bool split = false;
|
||||||
|
|
||||||
|
|
||||||
if (depth < MAXDEPTH)
|
if (depth < MAXDEPTH)
|
||||||
{
|
{
|
||||||
|
|
||||||
float volume;
|
float volume;
|
||||||
float c = computeConcavity(vcount, vertices, tcount, indices, callback, plane, volume);
|
float c = computeConcavity(vcount, vertices, tcount, indices, callback, plane, volume);
|
||||||
|
|
||||||
|
|
@ -132,12 +121,10 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
{
|
{
|
||||||
split = true;
|
split = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth >= MAXDEPTH || !split)
|
if (depth >= MAXDEPTH || !split)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
HullResult result;
|
HullResult result;
|
||||||
|
|
@ -154,14 +141,11 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
|
|
||||||
if (ret == QE_OK)
|
if (ret == QE_OK)
|
||||||
{
|
{
|
||||||
|
|
||||||
ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
|
ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
|
||||||
|
|
||||||
|
|
||||||
callback->ConvexDecompResult(r);
|
callback->ConvexDecompResult(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static unsigned int colors[8] =
|
static unsigned int colors[8] =
|
||||||
|
|
@ -173,8 +157,7 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
0x00FFFF,
|
0x00FFFF,
|
||||||
0xFF00FF,
|
0xFF00FF,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xFF8040
|
0xFF8040};
|
||||||
};
|
|
||||||
|
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
|
|
@ -190,7 +173,6 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tcount; i++)
|
for (unsigned int i = 0; i < tcount; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int i1 = *source++;
|
unsigned int i1 = *source++;
|
||||||
unsigned int i2 = *source++;
|
unsigned int i2 = *source++;
|
||||||
unsigned int i3 = *source++;
|
unsigned int i3 = *source++;
|
||||||
|
|
@ -198,13 +180,11 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
FaceTri t(vertices, i1, i2, i3);
|
FaceTri t(vertices, i1, i2, i3);
|
||||||
|
|
||||||
callback->ConvexDebugTri(t.mP1.Ptr(), t.mP2.Ptr(), t.mP3.Ptr(), color);
|
callback->ConvexDebugTri(t.mP1.Ptr(), t.mP2.Ptr(), t.mP3.Ptr(), color);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hl.ReleaseResult(result);
|
hl.ReleaseResult(result);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UintVector ifront;
|
UintVector ifront;
|
||||||
|
|
@ -213,7 +193,6 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
VertexLookup vfront = Vl_createVertexLookup();
|
VertexLookup vfront = Vl_createVertexLookup();
|
||||||
VertexLookup vback = Vl_createVertexLookup();
|
VertexLookup vback = Vl_createVertexLookup();
|
||||||
|
|
||||||
|
|
||||||
bool showmesh = false;
|
bool showmesh = false;
|
||||||
#if SHOW_MESH
|
#if SHOW_MESH
|
||||||
showmesh = true;
|
showmesh = true;
|
||||||
|
|
@ -279,7 +258,6 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
|
|
||||||
addTri(vfront, ifront, front[0], front[1], front[2]);
|
addTri(vfront, ifront, front[0], front[1], front[2]);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -306,7 +284,6 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
addTri(vfront, ifront, front[0], front[1], front[2]);
|
addTri(vfront, ifront, front[0], front[1], front[2]);
|
||||||
addTri(vback, iback, back[0], back[1], back[2]);
|
addTri(vback, iback, back[0], back[1], back[2]);
|
||||||
|
|
||||||
|
|
||||||
if (fcount == 4)
|
if (fcount == 4)
|
||||||
{
|
{
|
||||||
addTri(vfront, ifront, front[0], front[2], front[3]);
|
addTri(vfront, ifront, front[0], front[2], front[3]);
|
||||||
|
|
@ -346,7 +323,6 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
unsigned int tcount = ifront.size() / 3;
|
unsigned int tcount = ifront.size() / 3;
|
||||||
|
|
||||||
calcConvexDecomposition(vcount, vertices, tcount, &ifront[0], callback, masterVolume, depth + 1);
|
calcConvexDecomposition(vcount, vertices, tcount, &ifront[0], callback, masterVolume, depth + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ifront.clear();
|
ifront.clear();
|
||||||
|
|
@ -360,16 +336,11 @@ void calcConvexDecomposition(unsigned int vcount,
|
||||||
unsigned int tcount = iback.size() / 3;
|
unsigned int tcount = iback.size() / 3;
|
||||||
|
|
||||||
calcConvexDecomposition(vcount, vertices, tcount, &iback[0], callback, masterVolume, depth + 1);
|
calcConvexDecomposition(vcount, vertices, tcount, &iback[0], callback, masterVolume, depth + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iback.clear();
|
iback.clear();
|
||||||
Vl_releaseVertexLookup(vback);
|
Vl_releaseVertexLookup(vback);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ConvexDecomposition
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <memory.h> //memcpy
|
#include <memory.h> //memcpy
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -44,20 +43,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern unsigned int MAXDEPTH;
|
extern unsigned int MAXDEPTH;
|
||||||
extern float CONCAVE_PERCENT;
|
extern float CONCAVE_PERCENT;
|
||||||
extern float MERGE_PERCENT;
|
extern float MERGE_PERCENT;
|
||||||
|
|
||||||
|
|
||||||
typedef btAlignedObjectArray<unsigned int> UintVector;
|
typedef btAlignedObjectArray<unsigned int> UintVector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConvexResult
|
class ConvexResult
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -93,7 +86,6 @@ namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
mHullIndices = 0;
|
mHullIndices = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConvexResult(const ConvexResult &r)
|
ConvexResult(const ConvexResult &r)
|
||||||
|
|
@ -143,9 +135,6 @@ namespace ConvexDecomposition
|
||||||
float mSphereRadius; // radius and center of best fit sphere
|
float mSphereRadius; // radius and center of best fit sphere
|
||||||
float mSphereCenter[3];
|
float mSphereCenter[3];
|
||||||
float mSphereVolume; // volume of the best fit sphere
|
float mSphereVolume; // volume of the best fit sphere
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConvexDecompInterface
|
class ConvexDecompInterface
|
||||||
|
|
@ -158,9 +147,6 @@ namespace ConvexDecomposition
|
||||||
virtual void ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color){};
|
virtual void ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color){};
|
||||||
|
|
||||||
virtual void ConvexDecompResult(ConvexResult &result) = 0;
|
virtual void ConvexDecompResult(ConvexResult &result) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// just to avoid passing a zillion parameters to the method the
|
// just to avoid passing a zillion parameters to the method the
|
||||||
|
|
@ -198,13 +184,11 @@ namespace ConvexDecomposition
|
||||||
float mSkinWidth; // a skin width to apply to the output hulls.
|
float mSkinWidth; // a skin width to apply to the output hulls.
|
||||||
|
|
||||||
ConvexDecompInterface *mCallback; // the interface to receive back the results.
|
ConvexDecompInterface *mCallback; // the interface to receive back the results.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// perform approximate convex decomposition on a mesh.
|
// perform approximate convex decomposition on a mesh.
|
||||||
unsigned int performConvexDecomposition(const DecompDesc &desc); // returns the number of hulls produced.
|
unsigned int performConvexDecomposition(const DecompDesc &desc); // returns the number of hulls produced.
|
||||||
|
|
||||||
|
|
||||||
void calcConvexDecomposition(unsigned int vcount,
|
void calcConvexDecomposition(unsigned int vcount,
|
||||||
const float *vertices,
|
const float *vertices,
|
||||||
unsigned int tcount,
|
unsigned int tcount,
|
||||||
|
|
@ -213,8 +197,6 @@ namespace ConvexDecomposition
|
||||||
float masterVolume,
|
float masterVolume,
|
||||||
unsigned int depth);
|
unsigned int depth);
|
||||||
|
|
||||||
|
} // namespace ConvexDecomposition
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
19
Engine/lib/bullet/Extras/ConvexDecomposition/LICENSE.txt
Normal file
19
Engine/lib/bullet/Extras/ConvexDecomposition/LICENSE.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
|
www.physicstools.org
|
||||||
|
All rights reserved.
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||||
|
that the following conditions are met:
|
||||||
|
Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
and the following disclaimer.
|
||||||
|
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.
|
||||||
|
Neither the name of the Open Dynamics Framework Group 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 INTEL 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.
|
||||||
|
|
@ -52,13 +52,16 @@
|
||||||
|
|
||||||
namespace BestFit
|
namespace BestFit
|
||||||
{
|
{
|
||||||
|
|
||||||
class Vec3
|
class Vec3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Vec3(void){};
|
Vec3(void){};
|
||||||
Vec3(float _x,float _y,float _z) { x = _x; y = _y; z = _z; };
|
Vec3(float _x, float _y, float _z)
|
||||||
|
{
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
z = _z;
|
||||||
|
};
|
||||||
|
|
||||||
float dot(const Vec3 &v)
|
float dot(const Vec3 &v)
|
||||||
{
|
{
|
||||||
|
|
@ -70,12 +73,9 @@ public:
|
||||||
float z;
|
float z;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Eigen
|
class Eigen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
void DecrSortEigenStuff(void)
|
void DecrSortEigenStuff(void)
|
||||||
{
|
{
|
||||||
Tridiagonal(); //diagonalize the matrix.
|
Tridiagonal(); //diagonalize the matrix.
|
||||||
|
|
@ -247,7 +247,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuaranteeRotation(void)
|
void GuaranteeRotation(void)
|
||||||
{
|
{
|
||||||
if (!m_bIsRotation)
|
if (!m_bIsRotation)
|
||||||
|
|
@ -266,12 +265,10 @@ public:
|
||||||
bool m_bIsRotation;
|
bool m_bIsRotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace BestFit
|
||||||
|
|
||||||
|
|
||||||
using namespace BestFit;
|
using namespace BestFit;
|
||||||
|
|
||||||
|
|
||||||
bool getBestFitPlane(unsigned int vcount,
|
bool getBestFitPlane(unsigned int vcount,
|
||||||
const float *points,
|
const float *points,
|
||||||
unsigned int vstride,
|
unsigned int vstride,
|
||||||
|
|
@ -292,7 +289,6 @@ bool getBestFitPlane(unsigned int vcount,
|
||||||
|
|
||||||
for (unsigned int i = 0; i < vcount; i++)
|
for (unsigned int i = 0; i < vcount; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float *p = (const float *)source;
|
const float *p = (const float *)source;
|
||||||
|
|
||||||
float w = 1;
|
float w = 1;
|
||||||
|
|
@ -320,7 +316,6 @@ bool getBestFitPlane(unsigned int vcount,
|
||||||
kOrigin.y *= recip;
|
kOrigin.y *= recip;
|
||||||
kOrigin.z *= recip;
|
kOrigin.z *= recip;
|
||||||
|
|
||||||
|
|
||||||
float fSumXX = 0;
|
float fSumXX = 0;
|
||||||
float fSumXY = 0;
|
float fSumXY = 0;
|
||||||
float fSumXZ = 0;
|
float fSumXZ = 0;
|
||||||
|
|
@ -329,7 +324,6 @@ bool getBestFitPlane(unsigned int vcount,
|
||||||
float fSumYZ = 0;
|
float fSumYZ = 0;
|
||||||
float fSumZZ = 0;
|
float fSumZZ = 0;
|
||||||
|
|
||||||
|
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
const char *source = (const char *)points;
|
const char *source = (const char *)points;
|
||||||
|
|
@ -337,7 +331,6 @@ bool getBestFitPlane(unsigned int vcount,
|
||||||
|
|
||||||
for (unsigned int i = 0; i < vcount; i++)
|
for (unsigned int i = 0; i < vcount; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float *p = (const float *)source;
|
const float *p = (const float *)source;
|
||||||
|
|
||||||
float w = 1;
|
float w = 1;
|
||||||
|
|
@ -363,7 +356,6 @@ bool getBestFitPlane(unsigned int vcount,
|
||||||
fSumYZ += kDiff.y * kDiff.z;
|
fSumYZ += kDiff.y * kDiff.z;
|
||||||
fSumZZ += kDiff.z * kDiff.z;
|
fSumZZ += kDiff.z * kDiff.z;
|
||||||
|
|
||||||
|
|
||||||
source += vstride;
|
source += vstride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -409,11 +401,8 @@ bool getBestFitPlane(unsigned int vcount,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float getBoundingRegion(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax) // returns the diagonal distance
|
float getBoundingRegion(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax) // returns the diagonal distance
|
||||||
{
|
{
|
||||||
|
|
||||||
const unsigned char *source = (const unsigned char *)points;
|
const unsigned char *source = (const unsigned char *)points;
|
||||||
|
|
||||||
bmin[0] = points[0];
|
bmin[0] = points[0];
|
||||||
|
|
@ -424,7 +413,6 @@ float getBoundingRegion(unsigned int vcount,const float *points,unsigned int pst
|
||||||
bmax[1] = points[1];
|
bmax[1] = points[1];
|
||||||
bmax[2] = points[2];
|
bmax[2] = points[2];
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int i = 1; i < vcount; i++)
|
for (unsigned int i = 1; i < vcount; i++)
|
||||||
{
|
{
|
||||||
source += pstride;
|
source += pstride;
|
||||||
|
|
@ -437,7 +425,6 @@ float getBoundingRegion(unsigned int vcount,const float *points,unsigned int pst
|
||||||
if (p[0] > bmax[0]) bmax[0] = p[0];
|
if (p[0] > bmax[0]) bmax[0] = p[0];
|
||||||
if (p[1] > bmax[1]) bmax[1] = p[1];
|
if (p[1] > bmax[1]) bmax[1] = p[1];
|
||||||
if (p[2] > bmax[2]) bmax[2] = p[2];
|
if (p[2] > bmax[2]) bmax[2] = p[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float dx = bmax[0] - bmin[0];
|
float dx = bmax[0] - bmin[0];
|
||||||
|
|
@ -445,10 +432,8 @@ float getBoundingRegion(unsigned int vcount,const float *points,unsigned int pst
|
||||||
float dz = bmax[2] - bmin[2];
|
float dz = bmax[2] - bmin[2];
|
||||||
|
|
||||||
return sqrtf(dx * dx + dy * dy + dz * dz);
|
return sqrtf(dx * dx + dy * dy + dz * dz);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool overlapAABB(const float *bmin1, const float *bmax1, const float *bmin2, const float *bmax2) // return true if the two AABB's overlap.
|
bool overlapAABB(const float *bmin1, const float *bmax1, const float *bmin2, const float *bmax2) // return true if the two AABB's overlap.
|
||||||
{
|
{
|
||||||
if (bmax2[0] < bmin1[0]) return false; // if the maximum is less than our minimum on any axis
|
if (bmax2[0] < bmin1[0]) return false; // if the maximum is less than our minimum on any axis
|
||||||
|
|
@ -459,8 +444,5 @@ bool overlapAABB(const float *bmin1,const float *bmax1,const float *bmin2,const
|
||||||
if (bmin2[1] > bmax1[1]) return false; // if the minimum is greater than our maximum on any axis
|
if (bmin2[1] > bmax1[1]) return false; // if the minimum is greater than our maximum on any axis
|
||||||
if (bmin2[2] > bmax1[2]) return false; // if the minimum is greater than our maximum on any axis
|
if (bmin2[2] > bmax1[2]) return false; // if the minimum is greater than our maximum on any axis
|
||||||
|
|
||||||
|
|
||||||
return true; // the extents overlap
|
return true; // the extents overlap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// This routine was released in 'snippet' form
|
// This routine was released in 'snippet' form
|
||||||
// by John W. Ratcliff mailto:jratcliff@infiniplex.net
|
// by John W. Ratcliff mailto:jratcliff@infiniplex.net
|
||||||
// on March 22, 2006.
|
// on March 22, 2006.
|
||||||
|
|
@ -58,7 +57,6 @@ bool getBestFitPlane(unsigned int vcount, // number of input data points
|
||||||
unsigned int wstride, // weight stride for each vertex.
|
unsigned int wstride, // weight stride for each vertex.
|
||||||
float *plane);
|
float *plane);
|
||||||
|
|
||||||
|
|
||||||
float getBoundingRegion(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax); // returns the diagonal distance
|
float getBoundingRegion(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax); // returns the diagonal distance
|
||||||
bool overlapAABB(const float *bmin1, const float *bmax1, const float *bmin2, const float *bmax2); // return true if the two AABB's overlap.
|
bool overlapAABB(const float *bmin1, const float *bmax1, const float *bmin2, const float *bmax2); // return true if the two AABB's overlap.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ void computeOBB(unsigned int vcount,const float *points,unsigned int pstride,flo
|
||||||
src += pstride;
|
src += pstride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sides[0] = bmax[0];
|
sides[0] = bmax[0];
|
||||||
sides[1] = bmax[1];
|
sides[1] = bmax[1];
|
||||||
sides[2] = bmax[2];
|
sides[2] = bmax[2];
|
||||||
|
|
@ -81,12 +80,10 @@ void computeOBB(unsigned int vcount,const float *points,unsigned int pstride,flo
|
||||||
sides[0] *= 2.0f;
|
sides[0] *= 2.0f;
|
||||||
sides[1] *= 2.0f;
|
sides[1] *= 2.0f;
|
||||||
sides[2] *= 2.0f;
|
sides[2] *= 2.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeBestFitOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, float *matrix)
|
void computeBestFitOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, float *matrix)
|
||||||
{
|
{
|
||||||
|
|
||||||
float bmin[3];
|
float bmin[3];
|
||||||
float bmax[3];
|
float bmax[3];
|
||||||
|
|
||||||
|
|
@ -110,7 +107,6 @@ void computeBestFitOBB(unsigned int vcount,const float *points,unsigned int pstr
|
||||||
|
|
||||||
while (sweep >= 1)
|
while (sweep >= 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
float stepsize = sweep / steps;
|
float stepsize = sweep / steps;
|
||||||
|
|
@ -156,7 +152,6 @@ void computeBestFitOBB(unsigned int vcount,const float *points,unsigned int pstr
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
|
|
||||||
ax = angle[0];
|
ax = angle[0];
|
||||||
ay = angle[1];
|
ay = angle[1];
|
||||||
az = angle[2];
|
az = angle[2];
|
||||||
|
|
@ -167,7 +162,5 @@ void computeBestFitOBB(unsigned int vcount,const float *points,unsigned int pstr
|
||||||
{
|
{
|
||||||
break; // no improvement, so just
|
break; // no improvement, so just
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void computeBestFitOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, float *matrix);
|
void computeBestFitOBB(unsigned int vcount, const float *points, unsigned int pstride, float *sides, float *matrix);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
class HullResult
|
class HullResult
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -63,7 +62,6 @@ enum HullFlag
|
||||||
QF_DEFAULT = 0
|
QF_DEFAULT = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class HullDesc
|
class HullDesc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -128,14 +126,12 @@ enum HullError
|
||||||
class HullLibrary
|
class HullLibrary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HullError CreateConvexHull(const HullDesc &desc, // describes the input request
|
HullError CreateConvexHull(const HullDesc &desc, // describes the input request
|
||||||
HullResult &result); // contains the resulst
|
HullResult &result); // contains the resulst
|
||||||
|
|
||||||
HullError ReleaseResult(HullResult &result); // release memory allocated for this result, we are done with it.
|
HullError ReleaseResult(HullResult &result); // release memory allocated for this result, we are done with it.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void BringOutYourDead(const float *verts, unsigned int vcount, float *overts, unsigned int &ocount, unsigned int *indices, unsigned indexcount);
|
void BringOutYourDead(const float *verts, unsigned int vcount, float *overts, unsigned int &ocount, unsigned int *indices, unsigned indexcount);
|
||||||
|
|
||||||
bool CleanupVertices(unsigned int svcount,
|
bool CleanupVertices(unsigned int svcount,
|
||||||
|
|
@ -147,7 +143,6 @@ private:
|
||||||
float *scale);
|
float *scale);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace ConvexDecomposition
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#pragma warning(disable : 4786)
|
#pragma warning(disable : 4786)
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
@ -45,8 +44,6 @@
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
const float DEG_TO_RAD = ((2.0f * 3.14152654f) / 360.0f);
|
const float DEG_TO_RAD = ((2.0f * 3.14152654f) / 360.0f);
|
||||||
const float RAD_TO_DEG = (360.0f / (2.0f * 3.141592654f));
|
const float RAD_TO_DEG = (360.0f / (2.0f * 3.141592654f));
|
||||||
|
|
||||||
|
|
@ -95,28 +92,36 @@ public:
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
Vector3d &operator=(const Vector3d &A) // ASSIGNMENT (=)
|
Vector3d &operator=(const Vector3d &A) // ASSIGNMENT (=)
|
||||||
{ x=A.x; y=A.y; z=A.z;
|
{
|
||||||
return(*this); };
|
x = A.x;
|
||||||
|
y = A.y;
|
||||||
|
z = A.z;
|
||||||
|
return (*this);
|
||||||
|
};
|
||||||
|
|
||||||
Vector3d operator+(const Vector3d &A) const // ADDITION (+)
|
Vector3d operator+(const Vector3d &A) const // ADDITION (+)
|
||||||
{ Vector3d Sum(x+A.x, y+A.y, z+A.z);
|
{
|
||||||
return(Sum); };
|
Vector3d Sum(x + A.x, y + A.y, z + A.z);
|
||||||
|
return (Sum);
|
||||||
|
};
|
||||||
|
|
||||||
Vector3d operator-(const Vector3d &A) const // SUBTRACTION (-)
|
Vector3d operator-(const Vector3d &A) const // SUBTRACTION (-)
|
||||||
{ Vector3d Diff(x-A.x, y-A.y, z-A.z);
|
{
|
||||||
return(Diff); };
|
Vector3d Diff(x - A.x, y - A.y, z - A.z);
|
||||||
|
return (Diff);
|
||||||
|
};
|
||||||
|
|
||||||
Vector3d operator*(const float s) const // MULTIPLY BY SCALAR (*)
|
Vector3d operator*(const float s) const // MULTIPLY BY SCALAR (*)
|
||||||
{ Vector3d Scaled(x*s, y*s, z*s);
|
{
|
||||||
return(Scaled); };
|
Vector3d Scaled(x * s, y * s, z * s);
|
||||||
|
return (Scaled);
|
||||||
|
};
|
||||||
|
|
||||||
Vector3d operator+(const float s) const // ADD CONSTANT TO ALL 3 COMPONENTS (*)
|
Vector3d operator+(const float s) const // ADD CONSTANT TO ALL 3 COMPONENTS (*)
|
||||||
{ Vector3d Scaled(x+s, y+s, z+s);
|
{
|
||||||
return(Scaled); };
|
Vector3d Scaled(x + s, y + s, z + s);
|
||||||
|
return (Scaled);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Vector3d operator/(const float s) const // DIVIDE BY SCALAR (/)
|
Vector3d operator/(const float s) const // DIVIDE BY SCALAR (/)
|
||||||
{
|
{
|
||||||
|
|
@ -126,27 +131,52 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void operator/=(float A) // ACCUMULATED VECTOR ADDITION (/=)
|
void operator/=(float A) // ACCUMULATED VECTOR ADDITION (/=)
|
||||||
{ x/=A; y/=A; z/=A; };
|
{
|
||||||
|
x /= A;
|
||||||
|
y /= A;
|
||||||
|
z /= A;
|
||||||
|
};
|
||||||
|
|
||||||
void operator+=(const Vector3d A) // ACCUMULATED VECTOR ADDITION (+=)
|
void operator+=(const Vector3d A) // ACCUMULATED VECTOR ADDITION (+=)
|
||||||
{ x+=A.x; y+=A.y; z+=A.z; };
|
{
|
||||||
|
x += A.x;
|
||||||
|
y += A.y;
|
||||||
|
z += A.z;
|
||||||
|
};
|
||||||
void operator-=(const Vector3d A) // ACCUMULATED VECTOR SUBTRACTION (+=)
|
void operator-=(const Vector3d A) // ACCUMULATED VECTOR SUBTRACTION (+=)
|
||||||
{ x-=A.x; y-=A.y; z-=A.z; };
|
{
|
||||||
|
x -= A.x;
|
||||||
|
y -= A.y;
|
||||||
|
z -= A.z;
|
||||||
|
};
|
||||||
void operator*=(const float s) // ACCUMULATED SCALAR MULTIPLICATION (*=) (bpc 4/24/2000)
|
void operator*=(const float s) // ACCUMULATED SCALAR MULTIPLICATION (*=) (bpc 4/24/2000)
|
||||||
{x*=s; y*=s; z*=s;}
|
{
|
||||||
|
x *= s;
|
||||||
|
y *= s;
|
||||||
|
z *= s;
|
||||||
|
}
|
||||||
|
|
||||||
void operator+=(const float A) // ACCUMULATED VECTOR ADDITION (+=)
|
void operator+=(const float A) // ACCUMULATED VECTOR ADDITION (+=)
|
||||||
{ x+=A; y+=A; z+=A; };
|
{
|
||||||
|
x += A;
|
||||||
|
y += A;
|
||||||
|
z += A;
|
||||||
|
};
|
||||||
|
|
||||||
Vector3d operator-(void) const // NEGATION (-)
|
Vector3d operator-(void) const // NEGATION (-)
|
||||||
{ Vector3d Negated(-x, -y, -z);
|
{
|
||||||
return(Negated); };
|
Vector3d Negated(-x, -y, -z);
|
||||||
|
return (Negated);
|
||||||
|
};
|
||||||
|
|
||||||
float operator[](const int i) const // ALLOWS VECTOR ACCESS AS AN ARRAY.
|
float operator[](const int i) const // ALLOWS VECTOR ACCESS AS AN ARRAY.
|
||||||
{ return( (i==0)?x:((i==1)?y:z) ); };
|
{
|
||||||
|
return ((i == 0) ? x : ((i == 1) ? y : z));
|
||||||
|
};
|
||||||
float &operator[](const int i)
|
float &operator[](const int i)
|
||||||
{ return( (i==0)?x:((i==1)?y:z) ); };
|
{
|
||||||
|
return ((i == 0) ? x : ((i == 1) ? y : z));
|
||||||
|
};
|
||||||
//
|
//
|
||||||
|
|
||||||
// accessor methods.
|
// accessor methods.
|
||||||
|
|
@ -173,7 +203,6 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float ComputeNormal(const Vector3d &A,
|
float ComputeNormal(const Vector3d &A,
|
||||||
const Vector3d &B,
|
const Vector3d &B,
|
||||||
const Vector3d &C)
|
const Vector3d &C)
|
||||||
|
|
@ -210,7 +239,6 @@ public:
|
||||||
return mag;
|
return mag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ScaleSumScale(float c0, float c1, const Vector3d &pos)
|
void ScaleSumScale(float c0, float c1, const Vector3d &pos)
|
||||||
{
|
{
|
||||||
x = (x * c0) + (pos.x * c1);
|
x = (x * c0) + (pos.x * c1);
|
||||||
|
|
@ -246,7 +274,6 @@ public:
|
||||||
z = (float)p[2];
|
z = (float)p[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Set(float a, float b, float c)
|
void Set(float a, float b, float c)
|
||||||
{
|
{
|
||||||
x = a;
|
x = a;
|
||||||
|
|
@ -262,7 +289,6 @@ public:
|
||||||
const float *Ptr() const { return &x; }
|
const float *Ptr() const { return &x; }
|
||||||
float *Ptr() { return &x; }
|
float *Ptr() { return &x; }
|
||||||
|
|
||||||
|
|
||||||
// return -(*this).
|
// return -(*this).
|
||||||
Vector3d negative(void) const
|
Vector3d negative(void) const
|
||||||
{
|
{
|
||||||
|
|
@ -335,8 +361,6 @@ public:
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Computes the reflection vector between two vectors.*/
|
/** Computes the reflection vector between two vectors.*/
|
||||||
void Reflection(const Vector3d &a, const Vector3d &b) // compute reflection vector.
|
void Reflection(const Vector3d &a, const Vector3d &b) // compute reflection vector.
|
||||||
{
|
{
|
||||||
|
|
@ -366,7 +390,6 @@ public:
|
||||||
return float(sqrt(x * x + y * y + z * z));
|
return float(sqrt(x * x + y * y + z * z));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
float ComputePlane(const Vector3d &A,
|
float ComputePlane(const Vector3d &A,
|
||||||
const Vector3d &B,
|
const Vector3d &B,
|
||||||
const Vector3d &C)
|
const Vector3d &C)
|
||||||
|
|
@ -400,19 +423,16 @@ public:
|
||||||
y = vw_y * mag;
|
y = vw_y * mag;
|
||||||
z = vw_z * mag;
|
z = vw_z * mag;
|
||||||
|
|
||||||
|
|
||||||
float D = 0.0f - ((x * A.x) + (y * A.y) + (z * A.z));
|
float D = 0.0f - ((x * A.x) + (y * A.y) + (z * A.z));
|
||||||
|
|
||||||
return D;
|
return D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float FastLength(void) const // length of vector.
|
float FastLength(void) const // length of vector.
|
||||||
{
|
{
|
||||||
return float(sqrtf(x * x + y * y + z * z));
|
return float(sqrtf(x * x + y * y + z * z));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
float FasterLength(void) const // length of vector.
|
float FasterLength(void) const // length of vector.
|
||||||
{
|
{
|
||||||
return float(sqrtf(x * x + y * y + z * z));
|
return float(sqrtf(x * x + y * y + z * z));
|
||||||
|
|
@ -442,7 +462,6 @@ public:
|
||||||
return d.FasterLength();
|
return d.FasterLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float DistanceXY(const Vector3d &a) const
|
float DistanceXY(const Vector3d &a) const
|
||||||
{
|
{
|
||||||
float dx = a.x - x;
|
float dx = a.x - x;
|
||||||
|
|
@ -523,15 +542,11 @@ public:
|
||||||
return d;
|
return d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float Dot(const Vector3d &a) const // computes dot product.
|
float Dot(const Vector3d &a) const // computes dot product.
|
||||||
{
|
{
|
||||||
return (x * a.x + y * a.y + z * a.z);
|
return (x * a.x + y * a.y + z * a.z);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Vector3d Cross(const Vector3d &other) const
|
Vector3d Cross(const Vector3d &other) const
|
||||||
{
|
{
|
||||||
Vector3d result(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
|
Vector3d result(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
|
||||||
|
|
@ -662,7 +677,6 @@ public:
|
||||||
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
|
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// test to see if this point is inside the triangle specified by
|
// test to see if this point is inside the triangle specified by
|
||||||
// these three points on the X/Y plane.
|
// these three points on the X/Y plane.
|
||||||
bool PointInTriXZ(const Vector3d &p1,
|
bool PointInTriXZ(const Vector3d &p1,
|
||||||
|
|
@ -863,7 +877,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
|
|
||||||
float x;
|
float x;
|
||||||
|
|
@ -871,7 +884,6 @@ public:
|
||||||
float z;
|
float z;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Vector2d
|
class Vector2d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -889,7 +901,6 @@ public:
|
||||||
y = t[1];
|
y = t[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Vector2d(float a, float b) // construct with initial point.
|
Vector2d(float a, float b) // construct with initial point.
|
||||||
{
|
{
|
||||||
x = a;
|
x = a;
|
||||||
|
|
@ -982,7 +993,6 @@ public:
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
float Dot(const Vector2d &a) const // computes dot product.
|
float Dot(const Vector2d &a) const // computes dot product.
|
||||||
{
|
{
|
||||||
return (x * a.x + y * a.y);
|
return (x * a.x + y * a.y);
|
||||||
|
|
@ -1087,7 +1097,6 @@ public:
|
||||||
y = ((to.y - from.y) * slerp) + from.y;
|
y = ((to.y - from.y) * slerp) + from.y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Cross(const Vector2d &a, const Vector2d &b) // cross two vectors result in this one.
|
void Cross(const Vector2d &a, const Vector2d &b) // cross two vectors result in this one.
|
||||||
{
|
{
|
||||||
x = a.y * b.x - a.x * b.y;
|
x = a.y * b.x - a.x * b.y;
|
||||||
|
|
@ -1142,7 +1151,6 @@ public:
|
||||||
return l;
|
return l;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
};
|
};
|
||||||
|
|
@ -1158,13 +1166,12 @@ public:
|
||||||
// JWR Test for the intersection of two lines.
|
// JWR Test for the intersection of two lines.
|
||||||
|
|
||||||
bool Intersect(const Line &src, Vector3d §);
|
bool Intersect(const Line &src, Vector3d §);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector3d mP1;
|
Vector3d mP1;
|
||||||
Vector3d mP2;
|
Vector3d mP2;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<Vector3d> Vector3dVector;
|
typedef std::vector<Vector3d> Vector3dVector;
|
||||||
typedef std::vector<Vector2d> Vector2dVector;
|
typedef std::vector<Vector2d> Vector2dVector;
|
||||||
|
|
||||||
|
|
@ -1180,6 +1187,6 @@ inline Vector2d operator * (float s, const Vector2d &v )
|
||||||
return (Scaled);
|
return (Scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace ConvexDecomposition
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
#include "cd_wavefront.h"
|
#include "cd_wavefront.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace ConvexDecomposition;
|
using namespace ConvexDecomposition;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
|
@ -75,7 +74,6 @@ using namespace ConvexDecomposition;
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef std::vector<int> IntVector;
|
typedef std::vector<int> IntVector;
|
||||||
typedef std::vector<float> FloatVector;
|
typedef std::vector<float> FloatVector;
|
||||||
|
|
||||||
|
|
@ -168,7 +166,6 @@ public:
|
||||||
mHard[(int)c] = ST_HARD;
|
mHard[(int)c] = ST_HARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetCommentSymbol(char c) // comment character, treated as 'end of string'
|
void SetCommentSymbol(char c) // comment character, treated as 'end of string'
|
||||||
{
|
{
|
||||||
mHard[(int)c] = ST_EOS;
|
mHard[(int)c] = ST_EOS;
|
||||||
|
|
@ -179,8 +176,7 @@ public:
|
||||||
mHard[(int)c] = ST_DATA;
|
mHard[(int)c] = ST_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DefaultSymbols(void); // set up default symbols for hard separator and comment symbol of the '#' character.
|
||||||
void DefaultSymbols(void); // set up default symbols for hard seperator and comment symbol of the '#' character.
|
|
||||||
|
|
||||||
bool EOS(char c)
|
bool EOS(char c)
|
||||||
{
|
{
|
||||||
|
|
@ -197,13 +193,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
inline char *AddHard(int &argc, const char **argv, char *foo);
|
inline char *AddHard(int &argc, const char **argv, char *foo);
|
||||||
inline bool IsHard(char c);
|
inline bool IsHard(char c);
|
||||||
inline char *SkipSpaces(char *foo);
|
inline char *SkipSpaces(char *foo);
|
||||||
inline bool IsWhiteSpace(char c);
|
inline bool IsWhiteSpace(char c);
|
||||||
inline bool IsNonSeparator(char c); // non seperator,neither hard nor soft
|
inline bool IsNonSeparator(char c); // non separator, neither hard nor soft
|
||||||
|
|
||||||
bool mMyAlloc; // whether or not *I* allocated the buffer and am responsible for deleting it.
|
bool mMyAlloc; // whether or not *I* allocated the buffer and am responsible for deleting it.
|
||||||
char *mData; // ascii data to parse.
|
char *mData; // ascii data to parse.
|
||||||
|
|
@ -226,7 +220,6 @@ void InPlaceParser::SetFile(const char *fname)
|
||||||
mLen = 0;
|
mLen = 0;
|
||||||
mMyAlloc = false;
|
mMyAlloc = false;
|
||||||
|
|
||||||
|
|
||||||
FILE *fph = fopen(fname, "rb");
|
FILE *fph = fopen(fname, "rb");
|
||||||
if (fph)
|
if (fph)
|
||||||
{
|
{
|
||||||
|
|
@ -298,7 +291,6 @@ bool InPlaceParser::IsNonSeparator(char c)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InPlaceParser::ProcessLine(int lineno, char *line, InPlaceParserInterface *callback)
|
int InPlaceParser::ProcessLine(int lineno, char *line, InPlaceParserInterface *callback)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
@ -310,7 +302,6 @@ int InPlaceParser::ProcessLine(int lineno,char *line,InPlaceParserInterface *cal
|
||||||
|
|
||||||
while (!EOS(*foo) && argc < MAXARGS)
|
while (!EOS(*foo) && argc < MAXARGS)
|
||||||
{
|
{
|
||||||
|
|
||||||
foo = SkipSpaces(foo); // skip any leading spaces
|
foo = SkipSpaces(foo); // skip any leading spaces
|
||||||
|
|
||||||
if (EOS(*foo)) break;
|
if (EOS(*foo)) break;
|
||||||
|
|
@ -331,7 +322,6 @@ int InPlaceParser::ProcessLine(int lineno,char *line,InPlaceParserInterface *cal
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
foo = AddHard(argc, argv, foo); // add any hard separators, skip any spaces
|
foo = AddHard(argc, argv, foo); // add any hard separators, skip any spaces
|
||||||
|
|
||||||
if (IsNonSeparator(*foo)) // add non-hard argument.
|
if (IsNonSeparator(*foo)) // add non-hard argument.
|
||||||
|
|
@ -400,7 +390,6 @@ int InPlaceParser::Parse(InPlaceParserInterface *callback) // returns true if e
|
||||||
char *foo = mData;
|
char *foo = mData;
|
||||||
char *begin = foo;
|
char *begin = foo;
|
||||||
|
|
||||||
|
|
||||||
while (*foo)
|
while (*foo)
|
||||||
{
|
{
|
||||||
if (*foo == 10 || *foo == 13)
|
if (*foo == 10 || *foo == 13)
|
||||||
|
|
@ -431,7 +420,6 @@ int InPlaceParser::Parse(InPlaceParserInterface *callback) // returns true if e
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InPlaceParser::DefaultSymbols(void)
|
void InPlaceParser::DefaultSymbols(void)
|
||||||
{
|
{
|
||||||
SetHardSeparator(',');
|
SetHardSeparator(',');
|
||||||
|
|
@ -445,19 +433,17 @@ void InPlaceParser::DefaultSymbols(void)
|
||||||
SetCommentSymbol('#');
|
SetCommentSymbol('#');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char **InPlaceParser::GetArglist(char *line, int &count) // convert source string into an arg list, this is a destructive parse.
|
const char **InPlaceParser::GetArglist(char *line, int &count) // convert source string into an arg list, this is a destructive parse.
|
||||||
{
|
{
|
||||||
const char **ret = 0;
|
const char **ret = 0;
|
||||||
|
|
||||||
const char *argv[MAXARGS];
|
static const char *argv[MAXARGS];
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
|
|
||||||
char *foo = line;
|
char *foo = line;
|
||||||
|
|
||||||
while (!EOS(*foo) && argc < MAXARGS)
|
while (!EOS(*foo) && argc < MAXARGS)
|
||||||
{
|
{
|
||||||
|
|
||||||
foo = SkipSpaces(foo); // skip any leading spaces
|
foo = SkipSpaces(foo); // skip any leading spaces
|
||||||
|
|
||||||
if (EOS(*foo)) break;
|
if (EOS(*foo)) break;
|
||||||
|
|
@ -478,7 +464,6 @@ const char ** InPlaceParser::GetArglist(char *line,int &count) // convert source
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
foo = AddHard(argc, argv, foo); // add any hard separators, skip any spaces
|
foo = AddHard(argc, argv, foo); // add any hard separators, skip any spaces
|
||||||
|
|
||||||
if (IsNonSeparator(*foo)) // add non-hard argument.
|
if (IsNonSeparator(*foo)) // add non-hard argument.
|
||||||
|
|
@ -548,29 +533,24 @@ public:
|
||||||
float mTexel[2];
|
float mTexel[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GeometryInterface
|
class GeometryInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3) {}
|
virtual void NodeTriangle(const GeometryVertex *v1, const GeometryVertex *v2, const GeometryVertex *v3) {}
|
||||||
|
|
||||||
virtual ~GeometryInterface() {}
|
virtual ~GeometryInterface() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/******************** Obj.h ********************************/
|
/******************** Obj.h ********************************/
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
|
||||||
|
|
||||||
class OBJ : public InPlaceParserInterface
|
class OBJ : public InPlaceParserInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int LoadMesh(const char *fname, GeometryInterface *callback);
|
int LoadMesh(const char *fname, GeometryInterface *callback);
|
||||||
int ParseLine(int lineno, int argc, const char **argv); // return TRUE to continue parsing, return FALSE to abort parsing process
|
int ParseLine(int lineno, int argc, const char **argv); // return TRUE to continue parsing, return FALSE to abort parsing process
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void getVertex(GeometryVertex &v, const char *face) const;
|
void getVertex(GeometryVertex &v, const char *face) const;
|
||||||
|
|
||||||
FloatVector mVerts;
|
FloatVector mVerts;
|
||||||
|
|
@ -580,7 +560,6 @@ private:
|
||||||
GeometryInterface *mCallback;
|
GeometryInterface *mCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/******************** Obj.cpp ********************************/
|
/******************** Obj.cpp ********************************/
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
|
@ -599,7 +578,6 @@ int OBJ::LoadMesh(const char *fname,GeometryInterface *iface)
|
||||||
|
|
||||||
ipp.Parse(this);
|
ipp.Parse(this);
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -637,7 +615,6 @@ void OBJ::getVertex(GeometryVertex &v,const char *face) const
|
||||||
|
|
||||||
v.mTexel[0] = t[0];
|
v.mTexel[0] = t[0];
|
||||||
v.mTexel[1] = t[1];
|
v.mTexel[1] = t[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *normal = strstr(texel + 1, "/");
|
const char *normal = strstr(texel + 1, "/");
|
||||||
|
|
@ -658,14 +635,12 @@ void OBJ::getVertex(GeometryVertex &v,const char *face) const
|
||||||
|
|
||||||
if (index >= 0 && index < (int)(mVerts.size() / 3))
|
if (index >= 0 && index < (int)(mVerts.size() / 3))
|
||||||
{
|
{
|
||||||
|
|
||||||
const float *p = &mVerts[index * 3];
|
const float *p = &mVerts[index * 3];
|
||||||
|
|
||||||
v.mPos[0] = p[0];
|
v.mPos[0] = p[0];
|
||||||
v.mPos[1] = p[1];
|
v.mPos[1] = p[1];
|
||||||
v.mPos[2] = p[2];
|
v.mPos[2] = p[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OBJ::ParseLine(int lineno, int argc, const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process
|
int OBJ::ParseLine(int lineno, int argc, const char **argv) // return TRUE to continue parsing, return FALSE to abort parsing process
|
||||||
|
|
@ -751,7 +726,6 @@ int OBJ::ParseLine(int lineno,int argc,const char **argv) // return TRUE to con
|
||||||
mCallback->NodeTriangle(&v[0], &v[i], &v[i + 1]);
|
mCallback->NodeTriangle(&v[0], &v[i], &v[i + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -759,16 +733,11 @@ int OBJ::ParseLine(int lineno,int argc,const char **argv) // return TRUE to con
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BuildMesh : public GeometryInterface
|
class BuildMesh : public GeometryInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int getIndex(const float *p)
|
int getIndex(const float *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
int vcount = mVertices.size() / 3;
|
int vcount = mVertices.size() / 3;
|
||||||
|
|
||||||
if (vcount > 0)
|
if (vcount > 0)
|
||||||
|
|
@ -805,7 +774,6 @@ private:
|
||||||
IntVector mIndices;
|
IntVector mIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
WavefrontObj::WavefrontObj(void)
|
WavefrontObj::WavefrontObj(void)
|
||||||
{
|
{
|
||||||
mVertexCount = 0;
|
mVertexCount = 0;
|
||||||
|
|
@ -822,7 +790,6 @@ WavefrontObj::~WavefrontObj(void)
|
||||||
|
|
||||||
unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj returns number of triangles that were loaded. Data is persists until the class is destructed.
|
unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj returns number of triangles that were loaded. Data is persists until the class is destructed.
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int ret = 0;
|
unsigned int ret = 0;
|
||||||
|
|
||||||
delete[] mVertices;
|
delete[] mVertices;
|
||||||
|
|
@ -832,14 +799,12 @@ unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj re
|
||||||
mVertexCount = 0;
|
mVertexCount = 0;
|
||||||
mTriCount = 0;
|
mTriCount = 0;
|
||||||
|
|
||||||
|
|
||||||
BuildMesh bm;
|
BuildMesh bm;
|
||||||
|
|
||||||
OBJ obj;
|
OBJ obj;
|
||||||
|
|
||||||
obj.LoadMesh(fname, &bm);
|
obj.LoadMesh(fname, &bm);
|
||||||
|
|
||||||
|
|
||||||
const FloatVector &vlist = bm.GetVertices();
|
const FloatVector &vlist = bm.GetVertices();
|
||||||
const IntVector &indices = bm.GetIndices();
|
const IntVector &indices = bm.GetIndices();
|
||||||
if (vlist.size())
|
if (vlist.size())
|
||||||
|
|
@ -853,8 +818,7 @@ unsigned int WavefrontObj::loadObj(const char *fname) // load a wavefront obj re
|
||||||
ret = mTriCount;
|
ret = mTriCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace ConvexDecomposition
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
#ifndef CD_WAVEFRONT_OBJ_H
|
#ifndef CD_WAVEFRONT_OBJ_H
|
||||||
|
|
||||||
|
|
||||||
#define CD_WAVEFRONT_OBJ_H
|
#define CD_WAVEFRONT_OBJ_H
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -38,14 +36,11 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
class WavefrontObj
|
class WavefrontObj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WavefrontObj(void);
|
WavefrontObj(void);
|
||||||
~WavefrontObj(void);
|
~WavefrontObj(void);
|
||||||
|
|
||||||
|
|
@ -57,6 +52,6 @@ public:
|
||||||
float *mVertices;
|
float *mVertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace ConvexDecomposition
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,11 @@
|
||||||
#include "splitplane.h"
|
#include "splitplane.h"
|
||||||
#include "ConvexDecomposition.h"
|
#include "ConvexDecomposition.h"
|
||||||
|
|
||||||
|
|
||||||
#define WSCALE 4
|
#define WSCALE 4
|
||||||
#define CONCAVE_THRESH 0.05f
|
#define CONCAVE_THRESH 0.05f
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int getDebugColor(void)
|
unsigned int getDebugColor(void)
|
||||||
{
|
{
|
||||||
static unsigned int colors[8] =
|
static unsigned int colors[8] =
|
||||||
|
|
@ -67,8 +65,7 @@ unsigned int getDebugColor(void)
|
||||||
0x00FFFF,
|
0x00FFFF,
|
||||||
0xFF00FF,
|
0xFF00FF,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xFF8040
|
0xFF8040};
|
||||||
};
|
|
||||||
|
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
|
|
@ -81,7 +78,6 @@ unsigned int getDebugColor(void)
|
||||||
unsigned int color = colors[count];
|
unsigned int color = colors[count];
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Wpoint
|
class Wpoint
|
||||||
|
|
@ -99,7 +95,6 @@ public:
|
||||||
|
|
||||||
typedef std::vector<Wpoint> WpointVector;
|
typedef std::vector<Wpoint> WpointVector;
|
||||||
|
|
||||||
|
|
||||||
static inline float DistToPt(const float *p, const float *plane)
|
static inline float DistToPt(const float *p, const float *plane)
|
||||||
{
|
{
|
||||||
float x = p[0];
|
float x = p[0];
|
||||||
|
|
@ -109,10 +104,8 @@ static inline float DistToPt(const float *p,const float *plane)
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void intersect(const float *p1, const float *p2, float *split, const float *plane)
|
static void intersect(const float *p1, const float *p2, float *split, const float *plane)
|
||||||
{
|
{
|
||||||
|
|
||||||
float dp1 = DistToPt(p1, plane);
|
float dp1 = DistToPt(p1, plane);
|
||||||
|
|
||||||
float dir[3];
|
float dir[3];
|
||||||
|
|
@ -131,7 +124,6 @@ static void intersect(const float *p1,const float *p2,float *split,const float *
|
||||||
split[2] = (dir[2] * t) + p1[2];
|
split[2] = (dir[2] * t) + p1[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class CTri
|
class CTri
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -190,7 +182,6 @@ public:
|
||||||
{
|
{
|
||||||
unsigned int indices[8 * 3];
|
unsigned int indices[8 * 3];
|
||||||
|
|
||||||
|
|
||||||
unsigned int tcount = 0;
|
unsigned int tcount = 0;
|
||||||
|
|
||||||
addTri(indices, 0, 1, 2, tcount);
|
addTri(indices, 0, 1, 2, tcount);
|
||||||
|
|
@ -239,7 +230,6 @@ public:
|
||||||
const float *p3 = &vertices[i3 * 3];
|
const float *p3 = &vertices[i3 * 3];
|
||||||
|
|
||||||
callback->ConvexDebugTri(p1, p2, p3, color);
|
callback->ConvexDebugTri(p1, p2, p3, color);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +237,6 @@ public:
|
||||||
float v = computeMeshVolume(mP1.Ptr(), tcount, indices);
|
float v = computeMeshVolume(mP1.Ptr(), tcount, indices);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float raySect(const Vector3d &p, const Vector3d &dir, Vector3d §) const
|
float raySect(const Vector3d &p, const Vector3d &dir, Vector3d §) const
|
||||||
|
|
@ -264,7 +253,6 @@ public:
|
||||||
intersect(p.Ptr(), dest.Ptr(), sect.Ptr(), plane);
|
intersect(p.Ptr(), dest.Ptr(), sect.Ptr(), plane);
|
||||||
|
|
||||||
return sect.Distance(p); // return the intersection distance.
|
return sect.Distance(p); // return the intersection distance.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float planeDistance(const Vector3d &p) const
|
float planeDistance(const Vector3d &p) const
|
||||||
|
|
@ -277,7 +265,6 @@ public:
|
||||||
plane[3] = mPlaneD;
|
plane[3] = mPlaneD;
|
||||||
|
|
||||||
return DistToPt(p.Ptr(), plane);
|
return DistToPt(p.Ptr(), plane);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool samePlane(const CTri &t) const
|
bool samePlane(const CTri &t) const
|
||||||
|
|
@ -333,7 +320,6 @@ public:
|
||||||
|
|
||||||
void addWeighted(WpointVector &list, ConvexDecompInterface *callback)
|
void addWeighted(WpointVector &list, ConvexDecompInterface *callback)
|
||||||
{
|
{
|
||||||
|
|
||||||
Wpoint p1(mP1, mC1);
|
Wpoint p1(mP1, mC1);
|
||||||
Wpoint p2(mP2, mC2);
|
Wpoint p2(mP2, mC2);
|
||||||
Wpoint p3(mP3, mC3);
|
Wpoint p3(mP3, mC3);
|
||||||
|
|
@ -387,9 +373,6 @@ public:
|
||||||
callback->ConvexDebugPoint( np3.Ptr(), 0.01F, 0XFF00FF );
|
callback->ConvexDebugPoint( np3.Ptr(), 0.01F, 0XFF00FF );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3d mP1;
|
Vector3d mP1;
|
||||||
|
|
@ -414,7 +397,6 @@ typedef std::vector< CTri > CTriVector;
|
||||||
|
|
||||||
bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callback, const CTriVector &input_mesh)
|
bool featureMatch(CTri &m, const CTriVector &tris, ConvexDecompInterface *callback, const CTriVector &input_mesh)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
float neardot = 0.707f;
|
float neardot = 0.707f;
|
||||||
|
|
@ -429,12 +411,10 @@ bool featureMatch(CTri &m,const CTriVector &tris,ConvexDecompInterface *callback
|
||||||
|
|
||||||
CTri nearest;
|
CTri nearest;
|
||||||
|
|
||||||
|
|
||||||
for (i = tris.begin(); i != tris.end(); ++i)
|
for (i = tris.begin(); i != tris.end(); ++i)
|
||||||
{
|
{
|
||||||
const CTri &t = (*i);
|
const CTri &t = (*i);
|
||||||
|
|
||||||
|
|
||||||
//gLog->Display(" HullPlane: %0.4f,%0.4f,%0.4f %0.4f\r\n", t.mNormal.x, t.mNormal.y, t.mNormal.z, t.mPlaneD );
|
//gLog->Display(" HullPlane: %0.4f,%0.4f,%0.4f %0.4f\r\n", t.mNormal.x, t.mNormal.y, t.mNormal.z, t.mPlaneD );
|
||||||
|
|
||||||
if (t.samePlane(m))
|
if (t.samePlane(m))
|
||||||
|
|
@ -448,14 +428,12 @@ bool featureMatch(CTri &m,const CTriVector &tris,ConvexDecompInterface *callback
|
||||||
|
|
||||||
if (dot > neardot)
|
if (dot > neardot)
|
||||||
{
|
{
|
||||||
|
|
||||||
float d1 = t.planeDistance(m.mP1);
|
float d1 = t.planeDistance(m.mP1);
|
||||||
float d2 = t.planeDistance(m.mP2);
|
float d2 = t.planeDistance(m.mP2);
|
||||||
float d3 = t.planeDistance(m.mP3);
|
float d3 = t.planeDistance(m.mP3);
|
||||||
|
|
||||||
if (d1 > 0.001f || d2 > 0.001f || d3 > 0.001f) // can't be near coplaner!
|
if (d1 > 0.001f || d2 > 0.001f || d3 > 0.001f) // can't be near coplaner!
|
||||||
{
|
{
|
||||||
|
|
||||||
neardot = dot;
|
neardot = dot;
|
||||||
|
|
||||||
Vector3d n1, n2, n3;
|
Vector3d n1, n2, n3;
|
||||||
|
|
@ -468,7 +446,6 @@ bool featureMatch(CTri &m,const CTriVector &tris,ConvexDecompInterface *callback
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -509,7 +486,6 @@ bool featureMatch(CTri &m,const CTriVector &tris,ConvexDecompInterface *callback
|
||||||
callback->ConvexDebugTri( m.mP2.Ptr(), m.mP2.Ptr(), m.mNear2.Ptr(), 0xFFFF00 );
|
callback->ConvexDebugTri( m.mP2.Ptr(), m.mP2.Ptr(), m.mNear2.Ptr(), 0xFFFF00 );
|
||||||
callback->ConvexDebugTri( m.mP3.Ptr(), m.mP3.Ptr(), m.mNear3.Ptr(), 0xFFFF00 );
|
callback->ConvexDebugTri( m.mP3.Ptr(), m.mP3.Ptr(), m.mNear3.Ptr(), 0xFFFF00 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -526,7 +502,6 @@ bool isFeatureTri(CTri &t,CTriVector &flist,float fc,ConvexDecompInterface *call
|
||||||
|
|
||||||
if (t.mProcessed == 0) // if not already processed
|
if (t.mProcessed == 0) // if not already processed
|
||||||
{
|
{
|
||||||
|
|
||||||
float c = t.mConcavity / fc; // must be within 80% of the concavity of the parent.
|
float c = t.mConcavity / fc; // must be within 80% of the concavity of the parent.
|
||||||
|
|
||||||
if (c > 0.85f)
|
if (c > 0.85f)
|
||||||
|
|
@ -562,7 +537,6 @@ bool isFeatureTri(CTri &t,CTriVector &flist,float fc,ConvexDecompInterface *call
|
||||||
{
|
{
|
||||||
t.mProcessed = 1; // eliminated for this feature, but might be valid for the next one..
|
t.mProcessed = 1; // eliminated for this feature, but might be valid for the next one..
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -575,8 +549,6 @@ float computeConcavity(unsigned int vcount,
|
||||||
float *plane, // plane equation to split on
|
float *plane, // plane equation to split on
|
||||||
float &volume)
|
float &volume)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
float cret = 0;
|
float cret = 0;
|
||||||
volume = 1;
|
volume = 1;
|
||||||
|
|
||||||
|
|
@ -588,7 +560,6 @@ float computeConcavity(unsigned int vcount,
|
||||||
desc.mMaxVertices = 256;
|
desc.mMaxVertices = 256;
|
||||||
desc.SetHullFlag(QF_TRIANGLES);
|
desc.SetHullFlag(QF_TRIANGLES);
|
||||||
|
|
||||||
|
|
||||||
desc.mVcount = vcount;
|
desc.mVcount = vcount;
|
||||||
desc.mVertices = vertices;
|
desc.mVertices = vertices;
|
||||||
desc.mVertexStride = sizeof(float) * 3;
|
desc.mVertexStride = sizeof(float) * 3;
|
||||||
|
|
@ -645,10 +616,8 @@ float computeConcavity(unsigned int vcount,
|
||||||
|
|
||||||
const unsigned int *src = indices;
|
const unsigned int *src = indices;
|
||||||
|
|
||||||
|
|
||||||
float maxc = 0;
|
float maxc = 0;
|
||||||
|
|
||||||
|
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
CTriVector input_mesh;
|
CTriVector input_mesh;
|
||||||
|
|
@ -657,7 +626,6 @@ float computeConcavity(unsigned int vcount,
|
||||||
const unsigned int *src = indices;
|
const unsigned int *src = indices;
|
||||||
for (unsigned int i = 0; i < tcount; i++)
|
for (unsigned int i = 0; i < tcount; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int i1 = *src++;
|
unsigned int i1 = *src++;
|
||||||
unsigned int i2 = *src++;
|
unsigned int i2 = *src++;
|
||||||
unsigned int i3 = *src++;
|
unsigned int i3 = *src++;
|
||||||
|
|
@ -675,7 +643,6 @@ float computeConcavity(unsigned int vcount,
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tcount; i++)
|
for (unsigned int i = 0; i < tcount; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int i1 = *src++;
|
unsigned int i1 = *src++;
|
||||||
unsigned int i2 = *src++;
|
unsigned int i2 = *src++;
|
||||||
unsigned int i3 = *src++;
|
unsigned int i3 = *src++;
|
||||||
|
|
@ -690,7 +657,6 @@ float computeConcavity(unsigned int vcount,
|
||||||
|
|
||||||
if (t.mConcavity > CONCAVE_THRESH)
|
if (t.mConcavity > CONCAVE_THRESH)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (t.mConcavity > maxc)
|
if (t.mConcavity > maxc)
|
||||||
{
|
{
|
||||||
maxc = t.mConcavity;
|
maxc = t.mConcavity;
|
||||||
|
|
@ -701,10 +667,10 @@ float computeConcavity(unsigned int vcount,
|
||||||
totalVolume += v;
|
totalVolume += v;
|
||||||
ftris.push_back(t);
|
ftris.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if ( ftris.size() && 0 )
|
if ( ftris.size() && 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -759,6 +725,7 @@ float computeConcavity(unsigned int vcount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int color = getDebugColor();
|
unsigned int color = getDebugColor();
|
||||||
|
|
@ -786,10 +753,9 @@ float computeConcavity(unsigned int vcount,
|
||||||
|
|
||||||
hl.ReleaseResult(result);
|
hl.ReleaseResult(result);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return cret;
|
return cret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ConvexDecomposition
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,8 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConvexDecompInterface;
|
class ConvexDecompInterface;
|
||||||
|
|
||||||
// compute's how 'concave' this object is and returns the total volume of the
|
// compute's how 'concave' this object is and returns the total volume of the
|
||||||
|
|
@ -53,8 +50,6 @@ float computeConcavity(unsigned int vcount,
|
||||||
float *plane,
|
float *plane,
|
||||||
float &volume);
|
float &volume);
|
||||||
|
|
||||||
|
} // namespace ConvexDecomposition
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "fitsphere.h"
|
#include "fitsphere.h"
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -71,7 +70,6 @@ static inline void Copy(float *dest,const float *source)
|
||||||
|
|
||||||
float computeBoundingSphere(unsigned int vcount, const float *points, float *center)
|
float computeBoundingSphere(unsigned int vcount, const float *points, float *center)
|
||||||
{
|
{
|
||||||
|
|
||||||
float mRadius;
|
float mRadius;
|
||||||
float mRadius2;
|
float mRadius2;
|
||||||
|
|
||||||
|
|
@ -145,7 +143,6 @@ float computeBoundingSphere(unsigned int vcount,const float *points,float *cente
|
||||||
Copy(dia2, zmax);
|
Copy(dia2, zmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* dia1,dia2 is a diameter of initial sphere */
|
/* dia1,dia2 is a diameter of initial sphere */
|
||||||
/* calc initial center */
|
/* calc initial center */
|
||||||
center[0] = (dia1[0] + dia2[0]) * 0.5f;
|
center[0] = (dia1[0] + dia2[0]) * 0.5f;
|
||||||
|
|
@ -198,5 +195,3 @@ float computeBoundingSphere(unsigned int vcount,const float *points,float *cente
|
||||||
|
|
||||||
return mRadius;
|
return mRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float computeBoundingSphere(unsigned int vcount, const float *points, float *center);
|
float computeBoundingSphere(unsigned int vcount, const float *points, float *center);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -43,7 +42,6 @@
|
||||||
|
|
||||||
void fm_inverseRT(const float *matrix, const float *pos, float *t) // inverse rotate translate the point.
|
void fm_inverseRT(const float *matrix, const float *pos, float *t) // inverse rotate translate the point.
|
||||||
{
|
{
|
||||||
|
|
||||||
float _x = pos[0] - matrix[3 * 4 + 0];
|
float _x = pos[0] - matrix[3 * 4 + 0];
|
||||||
float _y = pos[1] - matrix[3 * 4 + 1];
|
float _y = pos[1] - matrix[3 * 4 + 1];
|
||||||
float _z = pos[2] - matrix[3 * 4 + 2];
|
float _z = pos[2] - matrix[3 * 4 + 2];
|
||||||
|
|
@ -53,10 +51,8 @@ void fm_inverseRT(const float *matrix,const float *pos,float *t) // inverse rota
|
||||||
t[0] = (matrix[0 * 4 + 0] * _x) + (matrix[0 * 4 + 1] * _y) + (matrix[0 * 4 + 2] * _z);
|
t[0] = (matrix[0 * 4 + 0] * _x) + (matrix[0 * 4 + 1] * _y) + (matrix[0 * 4 + 2] * _z);
|
||||||
t[1] = (matrix[1 * 4 + 0] * _x) + (matrix[1 * 4 + 1] * _y) + (matrix[1 * 4 + 2] * _z);
|
t[1] = (matrix[1 * 4 + 0] * _x) + (matrix[1 * 4 + 1] * _y) + (matrix[1 * 4 + 2] * _z);
|
||||||
t[2] = (matrix[2 * 4 + 0] * _x) + (matrix[2 * 4 + 1] * _y) + (matrix[2 * 4 + 2] * _z);
|
t[2] = (matrix[2 * 4 + 0] * _x) + (matrix[2 * 4 + 1] * _y) + (matrix[2 * 4 + 2] * _z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fm_identity(float *matrix) // set 4x4 matrix to identity.
|
void fm_identity(float *matrix) // set 4x4 matrix to identity.
|
||||||
{
|
{
|
||||||
matrix[0 * 4 + 0] = 1;
|
matrix[0 * 4 + 0] = 1;
|
||||||
|
|
@ -79,7 +75,6 @@ void fm_identity(float *matrix) // set 4x4 matrix to identity.
|
||||||
matrix[0 * 4 + 3] = 0;
|
matrix[0 * 4 + 3] = 0;
|
||||||
matrix[1 * 4 + 3] = 0;
|
matrix[1 * 4 + 3] = 0;
|
||||||
matrix[2 * 4 + 3] = 0;
|
matrix[2 * 4 + 3] = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fm_eulerMatrix(float ax, float ay, float az, float *matrix) // convert euler (in radians) to a dest 4x4 matrix (translation set to zero)
|
void fm_eulerMatrix(float ax, float ay, float az, float *matrix) // convert euler (in radians) to a dest 4x4 matrix (translation set to zero)
|
||||||
|
|
@ -91,7 +86,6 @@ void fm_eulerMatrix(float ax,float ay,float az,float *matrix) // convert euler (
|
||||||
|
|
||||||
void fm_getAABB(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax)
|
void fm_getAABB(unsigned int vcount, const float *points, unsigned int pstride, float *bmin, float *bmax)
|
||||||
{
|
{
|
||||||
|
|
||||||
const unsigned char *source = (const unsigned char *)points;
|
const unsigned char *source = (const unsigned char *)points;
|
||||||
|
|
||||||
bmin[0] = points[0];
|
bmin[0] = points[0];
|
||||||
|
|
@ -102,7 +96,6 @@ void fm_getAABB(unsigned int vcount,const float *points,unsigned int pstride,flo
|
||||||
bmax[1] = points[1];
|
bmax[1] = points[1];
|
||||||
bmax[2] = points[2];
|
bmax[2] = points[2];
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int i = 1; i < vcount; i++)
|
for (unsigned int i = 1; i < vcount; i++)
|
||||||
{
|
{
|
||||||
source += pstride;
|
source += pstride;
|
||||||
|
|
@ -115,11 +108,9 @@ void fm_getAABB(unsigned int vcount,const float *points,unsigned int pstride,flo
|
||||||
if (p[0] > bmax[0]) bmax[0] = p[0];
|
if (p[0] > bmax[0]) bmax[0] = p[0];
|
||||||
if (p[1] > bmax[1]) bmax[1] = p[1];
|
if (p[1] > bmax[1]) bmax[1] = p[1];
|
||||||
if (p[2] > bmax[2]) bmax[2] = p[2];
|
if (p[2] > bmax[2]) bmax[2] = p[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fm_eulerToQuat(float roll, float pitch, float yaw, float *quat) // convert euler angles to quaternion.
|
void fm_eulerToQuat(float roll, float pitch, float yaw, float *quat) // convert euler angles to quaternion.
|
||||||
{
|
{
|
||||||
roll *= 0.5f;
|
roll *= 0.5f;
|
||||||
|
|
@ -147,7 +138,6 @@ void fm_eulerToQuat(float roll,float pitch,float yaw,float *quat) // convert eul
|
||||||
|
|
||||||
void fm_quatToMatrix(const float *quat, float *matrix) // convert quaterinion rotation to matrix, zeros out the translation component.
|
void fm_quatToMatrix(const float *quat, float *matrix) // convert quaterinion rotation to matrix, zeros out the translation component.
|
||||||
{
|
{
|
||||||
|
|
||||||
float xx = quat[0] * quat[0];
|
float xx = quat[0] * quat[0];
|
||||||
float yy = quat[1] * quat[1];
|
float yy = quat[1] * quat[1];
|
||||||
float zz = quat[2] * quat[2];
|
float zz = quat[2] * quat[2];
|
||||||
|
|
@ -173,10 +163,8 @@ void fm_quatToMatrix(const float *quat,float *matrix) // convert quaterinion rot
|
||||||
matrix[3 * 4 + 0] = matrix[3 * 4 + 1] = matrix[3 * 4 + 2] = 0.0f;
|
matrix[3 * 4 + 0] = matrix[3 * 4 + 1] = matrix[3 * 4 + 2] = 0.0f;
|
||||||
matrix[0 * 4 + 3] = matrix[1 * 4 + 3] = matrix[2 * 4 + 3] = 0.0f;
|
matrix[0 * 4 + 3] = matrix[1 * 4 + 3] = matrix[2 * 4 + 3] = 0.0f;
|
||||||
matrix[3 * 4 + 3] = 1.0f;
|
matrix[3 * 4 + 3] = 1.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fm_quatRotate(const float *quat, const float *v, float *r) // rotate a vector directly by a quaternion.
|
void fm_quatRotate(const float *quat, const float *v, float *r) // rotate a vector directly by a quaternion.
|
||||||
{
|
{
|
||||||
float left[4];
|
float left[4];
|
||||||
|
|
@ -189,10 +177,8 @@ void fm_quatRotate(const float *quat,const float *v,float *r) // rotate a vector
|
||||||
r[0] = (left[3] * -quat[0]) + (quat[3] * left[0]) + (left[1] * -quat[2]) - (-quat[1] * left[2]);
|
r[0] = (left[3] * -quat[0]) + (quat[3] * left[0]) + (left[1] * -quat[2]) - (-quat[1] * left[2]);
|
||||||
r[1] = (left[3] * -quat[1]) + (quat[3] * left[1]) + (left[2] * -quat[0]) - (-quat[2] * left[0]);
|
r[1] = (left[3] * -quat[1]) + (quat[3] * left[1]) + (left[2] * -quat[0]) - (-quat[2] * left[0]);
|
||||||
r[2] = (left[3] * -quat[2]) + (quat[3] * left[2]) + (left[0] * -quat[1]) - (-quat[0] * left[1]);
|
r[2] = (left[3] * -quat[2]) + (quat[3] * left[2]) + (left[0] * -quat[1]) - (-quat[0] * left[1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fm_getTranslation(const float *matrix, float *t)
|
void fm_getTranslation(const float *matrix, float *t)
|
||||||
{
|
{
|
||||||
t[0] = matrix[3 * 4 + 0];
|
t[0] = matrix[3 * 4 + 0];
|
||||||
|
|
@ -202,7 +188,6 @@ void fm_getTranslation(const float *matrix,float *t)
|
||||||
|
|
||||||
void fm_matrixToQuat(const float *matrix, float *quat) // convert the 3x3 portion of a 4x4 matrix into a quaterion as x,y,z,w
|
void fm_matrixToQuat(const float *matrix, float *quat) // convert the 3x3 portion of a 4x4 matrix into a quaterion as x,y,z,w
|
||||||
{
|
{
|
||||||
|
|
||||||
float tr = matrix[0 * 4 + 0] + matrix[1 * 4 + 1] + matrix[2 * 4 + 2];
|
float tr = matrix[0 * 4 + 0] + matrix[1 * 4 + 1] + matrix[2 * 4 + 2];
|
||||||
|
|
||||||
// check the diagonal
|
// check the diagonal
|
||||||
|
|
@ -215,7 +200,6 @@ void fm_matrixToQuat(const float *matrix,float *quat) // convert the 3x3 portion
|
||||||
quat[0] = (matrix[1 * 4 + 2] - matrix[2 * 4 + 1]) * s;
|
quat[0] = (matrix[1 * 4 + 2] - matrix[2 * 4 + 1]) * s;
|
||||||
quat[1] = (matrix[2 * 4 + 0] - matrix[0 * 4 + 2]) * s;
|
quat[1] = (matrix[2 * 4 + 0] - matrix[0 * 4 + 2]) * s;
|
||||||
quat[2] = (matrix[0 * 4 + 1] - matrix[1 * 4 + 0]) * s;
|
quat[2] = (matrix[0 * 4 + 1] - matrix[1 * 4 + 0]) * s;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -246,11 +230,8 @@ void fm_matrixToQuat(const float *matrix,float *quat) // convert the 3x3 portion
|
||||||
quat[2] = qa[2];
|
quat[2] = qa[2];
|
||||||
quat[3] = qa[3];
|
quat[3] = qa[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float fm_sphereVolume(float radius) // return's the volume of a sphere of this radius (4/3 PI * R cubed )
|
float fm_sphereVolume(float radius) // return's the volume of a sphere of this radius (4/3 PI * R cubed )
|
||||||
{
|
{
|
||||||
return (4.0f / 3.0f) * FM_PI * radius * radius * radius;
|
return (4.0f / 3.0f) * FM_PI * radius * radius * radius;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// a set of routines that last you do common 3d math
|
// a set of routines that last you do common 3d math
|
||||||
// operations without any vector, matrix, or quaternion
|
// operations without any vector, matrix, or quaternion
|
||||||
// classes or templates.
|
// classes or templates.
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ float computeMeshVolume(const float *vertices,unsigned int tcount,const unsigned
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tcount; i++, indices += 3)
|
for (unsigned int i = 0; i < tcount; i++, indices += 3)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float *p1 = &vertices[indices[0] * 3];
|
const float *p1 = &vertices[indices[0] * 3];
|
||||||
const float *p2 = &vertices[indices[1] * 3];
|
const float *p2 = &vertices[indices[1] * 3];
|
||||||
const float *p3 = &vertices[indices[2] * 3];
|
const float *p3 = &vertices[indices[2] * 3];
|
||||||
|
|
@ -60,7 +59,6 @@ float computeMeshVolume(const float *vertices,unsigned int tcount,const unsigned
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void CrossProduct(const float *a, const float *b, float *cross)
|
inline void CrossProduct(const float *a, const float *b, float *cross)
|
||||||
{
|
{
|
||||||
cross[0] = a[1] * b[2] - a[2] * b[1];
|
cross[0] = a[1] * b[2] - a[2] * b[1];
|
||||||
|
|
@ -115,7 +113,6 @@ float computeMeshVolume2(const float *vertices,unsigned int tcount,const unsigne
|
||||||
const float *p0 = vertices;
|
const float *p0 = vertices;
|
||||||
for (unsigned int i = 0; i < tcount; i++, indices += 3)
|
for (unsigned int i = 0; i < tcount; i++, indices += 3)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float *p1 = &vertices[indices[0] * 3];
|
const float *p1 = &vertices[indices[0] * 3];
|
||||||
const float *p2 = &vertices[indices[1] * 3];
|
const float *p2 = &vertices[indices[1] * 3];
|
||||||
const float *p3 = &vertices[indices[2] * 3];
|
const float *p3 = &vertices[indices[2] * 3];
|
||||||
|
|
@ -125,4 +122,3 @@ float computeMeshVolume2(const float *vertices,unsigned int tcount,const unsigne
|
||||||
|
|
||||||
return volume * (1.0f / 6.0f);
|
return volume * (1.0f / 6.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,7 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float computeMeshVolume(const float *vertices, unsigned int tcount, const unsigned int *indices);
|
float computeMeshVolume(const float *vertices, unsigned int tcount, const unsigned int *indices);
|
||||||
float computeMeshVolume2(const float *vertices, unsigned int tcount, const unsigned int *indices);
|
float computeMeshVolume2(const float *vertices, unsigned int tcount, const unsigned int *indices);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,8 @@ static inline float DistToPt(const float *p,const float *plane)
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PlaneTriResult getSidePlane(const float *p, const float *plane, float epsilon)
|
static PlaneTriResult getSidePlane(const float *p, const float *plane, float epsilon)
|
||||||
{
|
{
|
||||||
|
|
||||||
float d = DistToPt(p, plane);
|
float d = DistToPt(p, plane);
|
||||||
|
|
||||||
if ((d + epsilon) > 0)
|
if ((d + epsilon) > 0)
|
||||||
|
|
@ -73,11 +71,9 @@ static void add(const float *p,float *dest,unsigned int tstride,unsigned int &pc
|
||||||
assert(pcount <= 4);
|
assert(pcount <= 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// assumes that the points are on opposite sides of the plane!
|
// assumes that the points are on opposite sides of the plane!
|
||||||
static void intersect(const float *p1, const float *p2, float *split, const float *plane)
|
static void intersect(const float *p1, const float *p2, float *split, const float *plane)
|
||||||
{
|
{
|
||||||
|
|
||||||
float dp1 = DistToPt(p1, plane);
|
float dp1 = DistToPt(p1, plane);
|
||||||
|
|
||||||
float dir[3];
|
float dir[3];
|
||||||
|
|
@ -94,7 +90,6 @@ static void intersect(const float *p1,const float *p2,float *split,const float *
|
||||||
split[0] = (dir[0] * t) + p1[0];
|
split[0] = (dir[0] * t) + p1[0];
|
||||||
split[1] = (dir[1] * t) + p1[1];
|
split[1] = (dir[1] * t) + p1[1];
|
||||||
split[2] = (dir[2] * t) + p1[2];
|
split[2] = (dir[2] * t) + p1[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaneTriResult planeTriIntersection(const float *plane, // the plane equation in Ax+By+Cz+D format
|
PlaneTriResult planeTriIntersection(const float *plane, // the plane equation in Ax+By+Cz+D format
|
||||||
|
|
@ -116,7 +111,6 @@ PlaneTriResult planeTriIntersection(const float *plane, // the plane equation
|
||||||
const float *p2 = (const float *)(tsource + tstride);
|
const float *p2 = (const float *)(tsource + tstride);
|
||||||
const float *p3 = (const float *)(tsource + tstride * 2);
|
const float *p3 = (const float *)(tsource + tstride * 2);
|
||||||
|
|
||||||
|
|
||||||
PlaneTriResult r1 = getSidePlane(p1, plane, epsilon); // compute the side of the plane each vertex is on
|
PlaneTriResult r1 = getSidePlane(p1, plane, epsilon); // compute the side of the plane each vertex is on
|
||||||
PlaneTriResult r2 = getSidePlane(p2, plane, epsilon);
|
PlaneTriResult r2 = getSidePlane(p2, plane, epsilon);
|
||||||
PlaneTriResult r3 = getSidePlane(p3, plane, epsilon);
|
PlaneTriResult r3 = getSidePlane(p3, plane, epsilon);
|
||||||
|
|
@ -161,13 +155,11 @@ PlaneTriResult planeTriIntersection(const float *plane, // the plane equation
|
||||||
|
|
||||||
if (r1 == PTR_FRONT)
|
if (r1 == PTR_FRONT)
|
||||||
{
|
{
|
||||||
|
|
||||||
add(p1, front, tstride, fcount);
|
add(p1, front, tstride, fcount);
|
||||||
add(split, front, tstride, fcount);
|
add(split, front, tstride, fcount);
|
||||||
|
|
||||||
add(split, back, tstride, bcount);
|
add(split, back, tstride, bcount);
|
||||||
add(p2, back, tstride, bcount);
|
add(p2, back, tstride, bcount);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -177,7 +169,6 @@ PlaneTriResult planeTriIntersection(const float *plane, // the plane equation
|
||||||
add(split, front, tstride, fcount);
|
add(split, front, tstride, fcount);
|
||||||
add(p2, front, tstride, fcount);
|
add(p2, front, tstride, fcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next test ray segment P2 to P3
|
// Next test ray segment P2 to P3
|
||||||
|
|
@ -232,7 +223,5 @@ PlaneTriResult planeTriIntersection(const float *plane, // the plane equation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return PTR_SPLIT;
|
return PTR_SPLIT;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum PlaneTriResult
|
enum PlaneTriResult
|
||||||
{
|
{
|
||||||
PTR_FRONT,
|
PTR_FRONT,
|
||||||
|
|
@ -54,5 +52,4 @@ PlaneTriResult planeTriIntersection(const float *plane, // the plane equation
|
||||||
float *back, // the triangle in back of the plane
|
float *back, // the triangle in back of the plane
|
||||||
unsigned int &bcount); // the number of vertices in the 'back' triangle.
|
unsigned int &bcount); // the number of vertices in the 'back' triangle.
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
kind "StaticLib"
|
kind "StaticLib"
|
||||||
|
|
||||||
includedirs {".","../../src"}
|
includedirs {".","../../src"}
|
||||||
|
if os.is("Linux") then
|
||||||
|
buildoptions{"-fPIC"}
|
||||||
|
end
|
||||||
files {
|
files {
|
||||||
"**.cpp",
|
"**.cpp",
|
||||||
"**.h"
|
"**.h"
|
||||||
|
|
|
||||||
|
|
@ -41,15 +41,12 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
/* a = b - c */
|
/* a = b - c */
|
||||||
#define vector(a, b, c) \
|
#define vector(a, b, c) \
|
||||||
(a)[0] = (b)[0] - (c)[0]; \
|
(a)[0] = (b)[0] - (c)[0]; \
|
||||||
(a)[1] = (b)[1] - (c)[1]; \
|
(a)[1] = (b)[1] - (c)[1]; \
|
||||||
(a)[2] = (b)[2] - (c)[2];
|
(a)[2] = (b)[2] - (c)[2];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define innerProduct(v, q) \
|
#define innerProduct(v, q) \
|
||||||
((v)[0] * (q)[0] + \
|
((v)[0] * (q)[0] + \
|
||||||
(v)[1] * (q)[1] + \
|
(v)[1] * (q)[1] + \
|
||||||
|
|
@ -62,7 +59,6 @@
|
||||||
|
|
||||||
bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t)
|
bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t)
|
||||||
{
|
{
|
||||||
|
|
||||||
float e1[3], e2[3], h[3], s[3], q[3];
|
float e1[3], e2[3], h[3], s[3], q[3];
|
||||||
float a, f, u, v;
|
float a, f, u, v;
|
||||||
|
|
||||||
|
|
@ -95,7 +91,6 @@ bool rayIntersectsTriangle(const float *p,const float *d,const float *v0,const f
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool lineIntersectsTriangle(const float *rayStart, const float *rayEnd, const float *p1, const float *p2, const float *p3, float *sect)
|
bool lineIntersectsTriangle(const float *rayStart, const float *rayEnd, const float *p1, const float *p2, const float *p3, float *sect)
|
||||||
{
|
{
|
||||||
float dir[3];
|
float dir[3];
|
||||||
|
|
@ -111,7 +106,6 @@ bool lineIntersectsTriangle(const float *rayStart,const float *rayEnd,const floa
|
||||||
dir[1] *= r;
|
dir[1] *= r;
|
||||||
dir[2] *= r;
|
dir[2] *= r;
|
||||||
|
|
||||||
|
|
||||||
float t;
|
float t;
|
||||||
|
|
||||||
bool ret = rayIntersectsTriangle(rayStart, dir, p1, p2, p3, t);
|
bool ret = rayIntersectsTriangle(rayStart, dir, p1, p2, p3, t);
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// returns true if the ray intersects the triangle.
|
// returns true if the ray intersects the triangle.
|
||||||
bool lineIntersectsTriangle(const float *rayStart, const float *rayEnd, const float *p1, const float *p2, const float *p3, float *sect);
|
bool lineIntersectsTriangle(const float *rayStart, const float *rayEnd, const float *p1, const float *p2, const float *p3, float *sect);
|
||||||
bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t);
|
bool rayIntersectsTriangle(const float *p, const float *d, const float *v0, const float *v1, const float *v2, float &t);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -53,10 +52,8 @@
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
static void computePlane(const float *A, const float *B, const float *C, float *plane)
|
static void computePlane(const float *A, const float *B, const float *C, float *plane)
|
||||||
{
|
{
|
||||||
|
|
||||||
float vx = (B[0] - C[0]);
|
float vx = (B[0] - C[0]);
|
||||||
float vy = (B[1] - C[1]);
|
float vy = (B[1] - C[1]);
|
||||||
float vz = (B[2] - C[2]);
|
float vz = (B[2] - C[2]);
|
||||||
|
|
@ -84,14 +81,12 @@ static void computePlane(const float *A,const float *B,const float *C,float *pla
|
||||||
float y = vw_y * mag;
|
float y = vw_y * mag;
|
||||||
float z = vw_z * mag;
|
float z = vw_z * mag;
|
||||||
|
|
||||||
|
|
||||||
float D = 0.0f - ((x * A[0]) + (y * A[1]) + (z * A[2]));
|
float D = 0.0f - ((x * A[0]) + (y * A[1]) + (z * A[2]));
|
||||||
|
|
||||||
plane[0] = x;
|
plane[0] = x;
|
||||||
plane[1] = y;
|
plane[1] = y;
|
||||||
plane[2] = z;
|
plane[2] = z;
|
||||||
plane[3] = D;
|
plane[3] = D;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Rect3d
|
class Rect3d
|
||||||
|
|
@ -101,7 +96,6 @@ public:
|
||||||
|
|
||||||
Rect3d(const float *bmin, const float *bmax)
|
Rect3d(const float *bmin, const float *bmax)
|
||||||
{
|
{
|
||||||
|
|
||||||
mMin[0] = bmin[0];
|
mMin[0] = bmin[0];
|
||||||
mMin[1] = bmin[1];
|
mMin[1] = bmin[1];
|
||||||
mMin[2] = bmin[2];
|
mMin[2] = bmin[2];
|
||||||
|
|
@ -109,7 +103,6 @@ public:
|
||||||
mMax[0] = bmax[0];
|
mMax[0] = bmax[0];
|
||||||
mMax[1] = bmax[1];
|
mMax[1] = bmax[1];
|
||||||
mMax[2] = bmax[2];
|
mMax[2] = bmax[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMin(const float *bmin)
|
void SetMin(const float *bmin)
|
||||||
|
|
@ -200,14 +193,12 @@ bool computeSplitPlane(unsigned int vcount,
|
||||||
if (p[0] > bmax[0]) bmax[0] = p[0];
|
if (p[0] > bmax[0]) bmax[0] = p[0];
|
||||||
if (p[1] > bmax[1]) bmax[1] = p[1];
|
if (p[1] > bmax[1]) bmax[1] = p[1];
|
||||||
if (p[2] > bmax[2]) bmax[2] = p[2];
|
if (p[2] > bmax[2]) bmax[2] = p[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float dx = bmax[0] - bmin[0];
|
float dx = bmax[0] - bmin[0];
|
||||||
float dy = bmax[1] - bmin[1];
|
float dy = bmax[1] - bmin[1];
|
||||||
float dz = bmax[2] - bmin[2];
|
float dz = bmax[2] - bmin[2];
|
||||||
|
|
||||||
|
|
||||||
float laxis = dx;
|
float laxis = dx;
|
||||||
|
|
||||||
unsigned int axis = 0;
|
unsigned int axis = 0;
|
||||||
|
|
@ -238,7 +229,6 @@ bool computeSplitPlane(unsigned int vcount,
|
||||||
|
|
||||||
splitRect(axis, b, b1, b2, p1);
|
splitRect(axis, b, b1, b2, p1);
|
||||||
|
|
||||||
|
|
||||||
// callback->ConvexDebugBound(b1.mMin,b1.mMax,0x00FF00);
|
// callback->ConvexDebugBound(b1.mMin,b1.mMax,0x00FF00);
|
||||||
// callback->ConvexDebugBound(b2.mMin,b2.mMax,0xFFFF00);
|
// callback->ConvexDebugBound(b2.mMin,b2.mMax,0xFFFF00);
|
||||||
|
|
||||||
|
|
@ -299,8 +289,6 @@ bool computeSplitPlane(unsigned int vcount,
|
||||||
computePlane(p1, p2, p3, plane);
|
computePlane(p1, p2, p3, plane);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ConvexDecomposition
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,8 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace ConvexDecomposition
|
namespace ConvexDecomposition
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConvexDecompInterface;
|
class ConvexDecompInterface;
|
||||||
|
|
||||||
bool computeSplitPlane(unsigned int vcount,
|
bool computeSplitPlane(unsigned int vcount,
|
||||||
|
|
@ -53,7 +50,6 @@ bool computeSplitPlane(unsigned int vcount,
|
||||||
ConvexDecompInterface *callback,
|
ConvexDecompInterface *callback,
|
||||||
float *plane);
|
float *plane);
|
||||||
|
|
||||||
|
} // namespace ConvexDecomposition
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -107,14 +106,10 @@
|
||||||
// You could easily modify this code to support other vertex
|
// You could easily modify this code to support other vertex
|
||||||
// formats with any number of interpolants.
|
// formats with any number of interpolants.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "vlookup.h"
|
#include "vlookup.h"
|
||||||
|
|
||||||
namespace Vlookup
|
namespace Vlookup
|
||||||
{
|
{
|
||||||
|
|
||||||
class VertexPosition
|
class VertexPosition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -133,7 +128,6 @@ public:
|
||||||
mPos[0] = p[0];
|
mPos[0] = p[0];
|
||||||
mPos[1] = p[1];
|
mPos[1] = p[1];
|
||||||
mPos[2] = p[2];
|
mPos[2] = p[2];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float GetX(void) const { return mPos[0]; };
|
float GetX(void) const { return mPos[0]; };
|
||||||
|
|
@ -177,7 +171,6 @@ struct VertexID
|
||||||
class VertexLess
|
class VertexLess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool operator()(VertexID v1, VertexID v2) const;
|
bool operator()(VertexID v1, VertexID v2) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -189,7 +182,8 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Type> class VertexPool
|
template <class Type>
|
||||||
|
class VertexPool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::set<VertexID, VertexLess> VertexSet;
|
typedef std::set<VertexID, VertexLess> VertexSet;
|
||||||
|
|
@ -210,7 +204,6 @@ public:
|
||||||
return idx;
|
return idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const float *GetPos(int idx) const
|
const float *GetPos(int idx) const
|
||||||
{
|
{
|
||||||
return mVtxs[idx].mPos;
|
return mVtxs[idx].mPos;
|
||||||
|
|
@ -245,7 +238,6 @@ public:
|
||||||
return mVtxs.size();
|
return mVtxs.size();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Type *getBuffer(void)
|
Type *getBuffer(void)
|
||||||
{
|
{
|
||||||
return &mVtxs[0];
|
return &mVtxs[0];
|
||||||
|
|
@ -257,10 +249,8 @@ private:
|
||||||
Tracker mTracker;
|
Tracker mTracker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool VertexLess::operator()(VertexID v1, VertexID v2) const
|
bool VertexLess::operator()(VertexID v1, VertexID v2) const
|
||||||
{
|
{
|
||||||
|
|
||||||
const VertexPosition &a = Get(v1);
|
const VertexPosition &a = Get(v1);
|
||||||
const VertexPosition &b = Get(v2);
|
const VertexPosition &b = Get(v2);
|
||||||
|
|
||||||
|
|
@ -282,14 +272,10 @@ bool VertexLess::operator()(VertexID v1,VertexID v2) const
|
||||||
if (izA < izB) return true;
|
if (izA < izB) return true;
|
||||||
if (izA > izB) return false;
|
if (izA > izB) return false;
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Vlookup
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace Vlookup;
|
using namespace Vlookup;
|
||||||
|
|
||||||
|
|
@ -318,7 +304,6 @@ const float * Vl_getVertices(VertexLookup vlook)
|
||||||
return vp->GetPos(0);
|
return vp->GetPos(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int Vl_getVcount(VertexLookup vlook)
|
unsigned int Vl_getVcount(VertexLookup vlook)
|
||||||
{
|
{
|
||||||
VertexPool<VertexPosition> *vp = (VertexPool<VertexPosition> *)vlook;
|
VertexPool<VertexPosition> *vp = (VertexPool<VertexPosition> *)vlook;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#define VLOOKUP_H
|
#define VLOOKUP_H
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Copyright (c) 2004 Open Dynamics Framework Group
|
Copyright (c) 2004 Open Dynamics Framework Group
|
||||||
www.physicstools.org
|
www.physicstools.org
|
||||||
|
|
@ -37,7 +36,6 @@
|
||||||
// http://www.amillionpixels.us
|
// http://www.amillionpixels.us
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// CodeSnippet provided by John W. Ratcliff
|
// CodeSnippet provided by John W. Ratcliff
|
||||||
// on March 23, 2006.
|
// on March 23, 2006.
|
||||||
//
|
//
|
||||||
|
|
@ -105,7 +103,6 @@
|
||||||
// Uses an STL set to create an index table for a bunch of vertex positions
|
// Uses an STL set to create an index table for a bunch of vertex positions
|
||||||
// used typically to re-index a collection of raw triangle data.
|
// used typically to re-index a collection of raw triangle data.
|
||||||
|
|
||||||
|
|
||||||
typedef void *VertexLookup;
|
typedef void *VertexLookup;
|
||||||
|
|
||||||
VertexLookup Vl_createVertexLookup(void);
|
VertexLookup Vl_createVertexLookup(void);
|
||||||
|
|
@ -115,5 +112,4 @@ unsigned int Vl_getIndex(VertexLookup vlook,const float *pos); // get index.
|
||||||
const float *Vl_getVertices(VertexLookup vlook);
|
const float *Vl_getVertices(VertexLookup vlook);
|
||||||
unsigned int Vl_getVcount(VertexLookup vlook);
|
unsigned int Vl_getVcount(VertexLookup vlook);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,10 @@ IF (INSTALL_EXTRA_LIBS)
|
||||||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS GIMPACTUtils DESTINATION .)
|
INSTALL(TARGETS GIMPACTUtils DESTINATION .)
|
||||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS GIMPACTUtils DESTINATION lib${LIB_SUFFIX})
|
INSTALL(TARGETS GIMPACTUtils
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
|
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||||
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||||
|
|
|
||||||
11
Engine/lib/bullet/Extras/GIMPACTUtils/LICENSE.txt
Normal file
11
Engine/lib/bullet/Extras/GIMPACTUtils/LICENSE.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
|
||||||
|
email: projectileman@yahoo.com
|
||||||
|
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.
|
||||||
|
|
@ -30,7 +30,6 @@ protected:
|
||||||
|
|
||||||
btAlignedObjectArray<btCollisionShape*> m_convexShapes;
|
btAlignedObjectArray<btCollisionShape*> m_convexShapes;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int mBaseCount;
|
int mBaseCount;
|
||||||
int mHullCount;
|
int mHullCount;
|
||||||
|
|
@ -52,26 +51,22 @@ public:
|
||||||
btCollisionShape* shape = m_convexShapes[i];
|
btCollisionShape* shape = m_convexShapes[i];
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult& result)
|
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult& result)
|
||||||
{
|
{
|
||||||
|
|
||||||
//calc centroid, to shift vertices around center of mass
|
//calc centroid, to shift vertices around center of mass
|
||||||
btVector3 centroid(0, 0, 0);
|
btVector3 centroid(0, 0, 0);
|
||||||
btAlignedObjectArray<btVector3> vertices;
|
btAlignedObjectArray<btVector3> vertices;
|
||||||
|
|
||||||
if (m_transformSubShapes)
|
if (m_transformSubShapes)
|
||||||
{
|
{
|
||||||
|
|
||||||
//const unsigned int *src = result.mHullIndices;
|
//const unsigned int *src = result.mHullIndices;
|
||||||
for (unsigned int i = 0; i < result.mHullVcount; i++)
|
for (unsigned int i = 0; i < result.mHullVcount; i++)
|
||||||
{
|
{
|
||||||
btVector3 vertex(result.mHullVertices[i * 3], result.mHullVertices[i * 3 + 1], result.mHullVertices[i * 3 + 2]);
|
btVector3 vertex(result.mHullVertices[i * 3], result.mHullVertices[i * 3 + 1], result.mHullVertices[i * 3 + 2]);
|
||||||
|
|
||||||
centroid += vertex;
|
centroid += vertex;
|
||||||
|
|
||||||
}
|
}
|
||||||
centroid *= 1.f / (float(result.mHullVcount));
|
centroid *= 1.f / (float(result.mHullVcount));
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +120,6 @@ public:
|
||||||
btGImpactMeshShapePart::TrimeshPrimitiveManager* trimeshInterface =
|
btGImpactMeshShapePart::TrimeshPrimitiveManager* trimeshInterface =
|
||||||
m_compoundShape->getTrimeshInterface(part);
|
m_compoundShape->getTrimeshInterface(part);
|
||||||
|
|
||||||
|
|
||||||
trimeshInterface->lock();
|
trimeshInterface->lock();
|
||||||
|
|
||||||
//collect vertices
|
//collect vertices
|
||||||
|
|
@ -141,12 +135,10 @@ public:
|
||||||
vertices.push_back(vec[2]);
|
vertices.push_back(vec[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//collect indices
|
//collect indices
|
||||||
btAlignedObjectArray<unsigned int> indices;
|
btAlignedObjectArray<unsigned int> indices;
|
||||||
indices.reserve(trimeshInterface->get_primitive_count() * 3);
|
indices.reserve(trimeshInterface->get_primitive_count() * 3);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < trimeshInterface->get_primitive_count(); i++)
|
for (int i = 0; i < trimeshInterface->get_primitive_count(); i++)
|
||||||
{
|
{
|
||||||
unsigned int i0, i1, i2;
|
unsigned int i0, i1, i2;
|
||||||
|
|
@ -158,15 +150,12 @@ public:
|
||||||
|
|
||||||
trimeshInterface->unlock();
|
trimeshInterface->unlock();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int depth = 5;
|
unsigned int depth = 5;
|
||||||
float cpercent = 5;
|
float cpercent = 5;
|
||||||
float ppercent = 15;
|
float ppercent = 15;
|
||||||
unsigned int maxv = 16;
|
unsigned int maxv = 16;
|
||||||
float skinWidth = 0.0f;
|
float skinWidth = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
ConvexDecomposition::DecompDesc desc;
|
ConvexDecomposition::DecompDesc desc;
|
||||||
desc.mVcount = trimeshInterface->get_vertex_count();
|
desc.mVcount = trimeshInterface->get_vertex_count();
|
||||||
desc.mVertices = &vertices[0];
|
desc.mVertices = &vertices[0];
|
||||||
|
|
@ -184,17 +173,10 @@ public:
|
||||||
ConvexBuilder cb(desc.mCallback);
|
ConvexBuilder cb(desc.mCallback);
|
||||||
cb.process(desc);
|
cb.process(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void btGImpactConvexDecompositionShape::buildConvexDecomposition(bool transformSubShapes)
|
void btGImpactConvexDecompositionShape::buildConvexDecomposition(bool transformSubShapes)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_decomposition = new GIM_ConvexDecomposition(this, transformSubShapes);
|
m_decomposition = new GIM_ConvexDecomposition(this, transformSubShapes);
|
||||||
|
|
||||||
int part_count = m_trimeshInterfaces.size();
|
int part_count = m_trimeshInterfaces.size();
|
||||||
|
|
@ -212,7 +194,6 @@ btGImpactConvexDecompositionShape::~btGImpactConvexDecompositionShape()
|
||||||
}
|
}
|
||||||
void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const
|
void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
int part_count = m_trimeshInterfaces.size();
|
int part_count = m_trimeshInterfaces.size();
|
||||||
for (int part = 0; part < part_count; part++)
|
for (int part = 0; part < part_count; part++)
|
||||||
{
|
{
|
||||||
|
|
@ -225,7 +206,6 @@ void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback*
|
||||||
|
|
||||||
btPrimitiveTriangle triangle;
|
btPrimitiveTriangle triangle;
|
||||||
|
|
||||||
|
|
||||||
int i = trimeshInterface->get_primitive_count();
|
int i = trimeshInterface->get_primitive_count();
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
|
|
@ -235,6 +215,4 @@ void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback*
|
||||||
|
|
||||||
trimeshInterface->unlock();
|
trimeshInterface->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,8 @@ subject to the following restrictions:
|
||||||
#ifndef GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
|
#ifndef GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
|
||||||
#define GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
|
#define GIMPACT_CONVEX_DECOMPOSITION_SHAPE_H
|
||||||
|
|
||||||
|
|
||||||
#include "BulletCollision/Gimpact/btGImpactShape.h" // box tree class
|
#include "BulletCollision/Gimpact/btGImpactShape.h" // box tree class
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! This class creates a decomposition from a trimesh.
|
//! This class creates a decomposition from a trimesh.
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
|
|
@ -41,15 +38,14 @@ protected:
|
||||||
class GIM_ConvexDecomposition* m_decomposition;
|
class GIM_ConvexDecomposition* m_decomposition;
|
||||||
|
|
||||||
void buildConvexDecomposition(bool transformSubShapes);
|
void buildConvexDecomposition(bool transformSubShapes);
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
btGImpactConvexDecompositionShape(
|
btGImpactConvexDecompositionShape(
|
||||||
btStridingMeshInterface* meshInterface,
|
btStridingMeshInterface* meshInterface,
|
||||||
const btVector3& mesh_scale,
|
const btVector3& mesh_scale,
|
||||||
btScalar margin = btScalar(0.01), bool children_has_transform = true)
|
btScalar margin = btScalar(0.01), bool children_has_transform = true)
|
||||||
: btGImpactCompoundShape(children_has_transform)
|
: btGImpactCompoundShape(children_has_transform)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_collisionMargin = margin;
|
m_collisionMargin = margin;
|
||||||
|
|
||||||
btGImpactMeshShapePart::TrimeshPrimitiveManager triInterface;
|
btGImpactMeshShapePart::TrimeshPrimitiveManager triInterface;
|
||||||
|
|
@ -78,10 +74,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
|
virtual void processAllTriangles(btTriangleCallback* callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //GIMPACT_MESH_SHAPE_H
|
#endif //GIMPACT_MESH_SHAPE_H
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,11 @@ IF (INSTALL_EXTRA_LIBS)
|
||||||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS HACD DESTINATION .)
|
INSTALL(TARGETS HACD DESTINATION .)
|
||||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS HACD DESTINATION lib${LIB_SUFFIX})
|
INSTALL(TARGETS HACD
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
|
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||||
|
|
||||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.inl" PATTERN
|
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.inl" PATTERN
|
||||||
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||||
|
|
|
||||||
13
Engine/lib/bullet/Extras/HACD/LICENSE.txt
Normal file
13
Engine/lib/bullet/Extras/HACD/LICENSE.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
Copyright (c) 2011 Khaled Mamou (kmamou at gmail dot com)
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
|
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. The names of the contributors may not 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.
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
namespace HACD
|
namespace HACD
|
||||||
{
|
{
|
||||||
//! CircularListElement class.
|
//! CircularListElement class.
|
||||||
template < typename T > class CircularListElement
|
template <typename T>
|
||||||
|
class CircularListElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T& GetData() { return m_data; }
|
T& GetData() { return m_data; }
|
||||||
|
|
@ -34,6 +35,7 @@ namespace HACD
|
||||||
CircularListElement(void) {}
|
CircularListElement(void) {}
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~CircularListElement(void) {}
|
~CircularListElement(void) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_data;
|
T m_data;
|
||||||
CircularListElement<T>* m_next;
|
CircularListElement<T>* m_next;
|
||||||
|
|
@ -42,9 +44,9 @@ namespace HACD
|
||||||
CircularListElement(const CircularListElement& rhs);
|
CircularListElement(const CircularListElement& rhs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! CircularList class.
|
//! CircularList class.
|
||||||
template < typename T > class CircularList
|
template <typename T>
|
||||||
|
class CircularList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CircularListElement<T>*& GetHead() { return m_head; }
|
CircularListElement<T>*& GetHead() { return m_head; }
|
||||||
|
|
@ -59,7 +61,11 @@ namespace HACD
|
||||||
CircularListElement<T>* Add(const T& data);
|
CircularListElement<T>* Add(const T& data);
|
||||||
bool Next();
|
bool Next();
|
||||||
bool Prev();
|
bool Prev();
|
||||||
void Clear() { while(Delete());};
|
void Clear()
|
||||||
|
{
|
||||||
|
while (Delete())
|
||||||
|
;
|
||||||
|
};
|
||||||
const CircularList& operator=(const CircularList& rhs);
|
const CircularList& operator=(const CircularList& rhs);
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CircularList()
|
CircularList()
|
||||||
|
|
@ -70,11 +76,11 @@ namespace HACD
|
||||||
CircularList(const CircularList& rhs);
|
CircularList(const CircularList& rhs);
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CircularList(void) { Clear(); };
|
virtual ~CircularList(void) { Clear(); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircularListElement<T>* m_head; //!< a pointer to the head of the circular list
|
CircularListElement<T>* m_head; //!< a pointer to the head of the circular list
|
||||||
size_t m_size; //!< number of element in the circular list
|
size_t m_size; //!< number of element in the circular list
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace HACD
|
||||||
#include "hacdCircularList.inl"
|
#include "hacdCircularList.inl"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
#include "hacdGraph.h"
|
#include "hacdGraph.h"
|
||||||
namespace HACD
|
namespace HACD
|
||||||
{
|
{
|
||||||
|
|
||||||
GraphEdge::GraphEdge()
|
GraphEdge::GraphEdge()
|
||||||
{
|
{
|
||||||
m_convexHull = 0;
|
m_convexHull = 0;
|
||||||
|
|
@ -207,7 +206,6 @@ namespace HACD
|
||||||
const GraphVertex& currentVertex = m_vertices[v];
|
const GraphVertex& currentVertex = m_vertices[v];
|
||||||
if (!m_vertices[v].m_deleted)
|
if (!m_vertices[v].m_deleted)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::cout << currentVertex.m_name << "\t";
|
std::cout << currentVertex.m_name << "\t";
|
||||||
std::set<long>::const_iterator ed(currentVertex.m_edges.begin());
|
std::set<long>::const_iterator ed(currentVertex.m_edges.begin());
|
||||||
std::set<long>::const_iterator itEnd(currentVertex.m_edges.end());
|
std::set<long>::const_iterator itEnd(currentVertex.m_edges.end());
|
||||||
|
|
@ -289,4 +287,4 @@ namespace HACD
|
||||||
}
|
}
|
||||||
return static_cast<long>(m_nCCs);
|
return static_cast<long>(m_nCCs);
|
||||||
}
|
}
|
||||||
}
|
} // namespace HACD
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ namespace HACD
|
||||||
bool DeleteEdge(long name);
|
bool DeleteEdge(long name);
|
||||||
GraphVertex();
|
GraphVertex();
|
||||||
~GraphVertex() { delete m_convexHull; };
|
~GraphVertex() { delete m_convexHull; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long m_name;
|
long m_name;
|
||||||
long m_cc;
|
long m_cc;
|
||||||
|
|
@ -56,7 +57,6 @@ namespace HACD
|
||||||
ICHull* m_convexHull;
|
ICHull* m_convexHull;
|
||||||
std::set<unsigned long long> m_boudaryEdges;
|
std::set<unsigned long long> m_boudaryEdges;
|
||||||
|
|
||||||
|
|
||||||
friend class GraphEdge;
|
friend class GraphEdge;
|
||||||
friend class Graph;
|
friend class Graph;
|
||||||
friend class HACD;
|
friend class HACD;
|
||||||
|
|
@ -67,6 +67,7 @@ namespace HACD
|
||||||
public:
|
public:
|
||||||
GraphEdge();
|
GraphEdge();
|
||||||
~GraphEdge() { delete m_convexHull; };
|
~GraphEdge() { delete m_convexHull; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long m_name;
|
long m_name;
|
||||||
long m_v1;
|
long m_v1;
|
||||||
|
|
@ -81,8 +82,6 @@ namespace HACD
|
||||||
std::set<unsigned long long> m_boudaryEdges;
|
std::set<unsigned long long> m_boudaryEdges;
|
||||||
bool m_deleted;
|
bool m_deleted;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
friend class GraphVertex;
|
friend class GraphVertex;
|
||||||
friend class Graph;
|
friend class Graph;
|
||||||
friend class HACD;
|
friend class HACD;
|
||||||
|
|
@ -116,5 +115,5 @@ namespace HACD
|
||||||
|
|
||||||
friend class HACD;
|
friend class HACD;
|
||||||
};
|
};
|
||||||
}
|
} // namespace HACD
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,6 @@ namespace HACD
|
||||||
}
|
}
|
||||||
if (distC1C2 <= m_ccConnectDist && t1 > 0 && t2 > 0)
|
if (distC1C2 <= m_ccConnectDist && t1 > 0 && t2 > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_graph.AddEdge(t1, t2);
|
m_graph.AddEdge(t1, t2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -268,7 +267,6 @@ namespace HACD
|
||||||
distMin = distance;
|
distMin = distance;
|
||||||
faceIndex = f1;
|
faceIndex = f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (faceIndex < m_nTriangles)
|
if (faceIndex < m_nTriangles)
|
||||||
|
|
@ -308,12 +306,18 @@ namespace HACD
|
||||||
x = m_points[v].X();
|
x = m_points[v].X();
|
||||||
y = m_points[v].Y();
|
y = m_points[v].Y();
|
||||||
z = m_points[v].Z();
|
z = m_points[v].Z();
|
||||||
if ( x < min.X()) min.X() = x;
|
if (x < min.X())
|
||||||
else if ( x > max.X()) max.X() = x;
|
min.X() = x;
|
||||||
if ( y < min.Y()) min.Y() = y;
|
else if (x > max.X())
|
||||||
else if ( y > max.Y()) max.Y() = y;
|
max.X() = x;
|
||||||
if ( z < min.Z()) min.Z() = z;
|
if (y < min.Y())
|
||||||
else if ( z > max.Z()) max.Z() = z;
|
min.Y() = y;
|
||||||
|
else if (y > max.Y())
|
||||||
|
max.Y() = y;
|
||||||
|
if (z < min.Z())
|
||||||
|
min.Z() = z;
|
||||||
|
else if (z > max.Z())
|
||||||
|
max.Z() = z;
|
||||||
}
|
}
|
||||||
m_barycenter /= static_cast<Real>(m_nPoints);
|
m_barycenter /= static_cast<Real>(m_nPoints);
|
||||||
m_diag = (max - min).GetNorm();
|
m_diag = (max - min).GetNorm();
|
||||||
|
|
@ -535,7 +539,8 @@ namespace HACD
|
||||||
for (; itBE != itBEEnd; ++itBE)
|
for (; itBE != itBEEnd; ++itBE)
|
||||||
{
|
{
|
||||||
perimeter += (m_points[static_cast<long>((*itBE) >> 32)] -
|
perimeter += (m_points[static_cast<long>((*itBE) >> 32)] -
|
||||||
m_points[static_cast<long>((*itBE) & 0xFFFFFFFFULL)]).GetNorm();
|
m_points[static_cast<long>((*itBE) & 0xFFFFFFFFULL)])
|
||||||
|
.GetNorm();
|
||||||
}
|
}
|
||||||
surf = gV1.m_surf + gV2.m_surf;
|
surf = gV1.m_surf + gV2.m_surf;
|
||||||
}
|
}
|
||||||
|
|
@ -597,11 +602,9 @@ namespace HACD
|
||||||
}
|
}
|
||||||
currentEdge = m_pqueue.top();
|
currentEdge = m_pqueue.top();
|
||||||
m_pqueue.pop();
|
m_pqueue.pop();
|
||||||
}
|
} while (m_graph.m_edges[currentEdge.m_name].m_deleted ||
|
||||||
while ( m_graph.m_edges[currentEdge.m_name].m_deleted ||
|
|
||||||
m_graph.m_edges[currentEdge.m_name].m_error != currentEdge.m_priority);
|
m_graph.m_edges[currentEdge.m_name].m_error != currentEdge.m_priority);
|
||||||
|
|
||||||
|
|
||||||
if (m_graph.m_edges[currentEdge.m_name].m_concavity < m_concavity && !done)
|
if (m_graph.m_edges[currentEdge.m_name].m_concavity < m_concavity && !done)
|
||||||
{
|
{
|
||||||
globalConcavity = std::max<double>(globalConcavity, m_graph.m_edges[currentEdge.m_name].m_concavity);
|
globalConcavity = std::max<double>(globalConcavity, m_graph.m_edges[currentEdge.m_name].m_concavity);
|
||||||
|
|
@ -663,7 +666,6 @@ namespace HACD
|
||||||
sprintf(msg, "# clusters = %lu \t C = %f\n", static_cast<unsigned long>(m_nClusters), globalConcavity);
|
sprintf(msg, "# clusters = %lu \t C = %f\n", static_cast<unsigned long>(m_nClusters), globalConcavity);
|
||||||
(*m_callBack)(msg, progress, globalConcavity, m_graph.GetNVertices());
|
(*m_callBack)(msg, progress, globalConcavity, m_graph.GetNVertices());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HACD::Compute(bool fullCH, bool exportDistPoints)
|
bool HACD::Compute(bool fullCH, bool exportDistPoints)
|
||||||
|
|
@ -846,6 +848,4 @@ namespace HACD
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace HACD
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ namespace HACD
|
||||||
class reservable_priority_queue : public std::priority_queue<_Ty, _Container, _Pr>
|
class reservable_priority_queue : public std::priority_queue<_Ty, _Container, _Pr>
|
||||||
{
|
{
|
||||||
typedef typename std::priority_queue<_Ty, _Container, _Pr>::size_type size_type;
|
typedef typename std::priority_queue<_Ty, _Container, _Pr>::size_type size_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
reservable_priority_queue(size_type capacity = 0) { reserve(capacity); };
|
reservable_priority_queue(size_type capacity = 0) { reserve(capacity); };
|
||||||
void reserve(size_type capacity) { this->c.reserve(capacity); }
|
void reserve(size_type capacity) { this->c.reserve(capacity); }
|
||||||
|
|
@ -55,6 +56,7 @@ namespace HACD
|
||||||
}
|
}
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~GraphEdgePriorityQueue(void) {}
|
~GraphEdgePriorityQueue(void) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long m_name; //!< edge name
|
long m_name; //!< edge name
|
||||||
Real m_priority; //!< priority
|
Real m_priority; //!< priority
|
||||||
|
|
@ -78,7 +80,6 @@ namespace HACD
|
||||||
class HACD
|
class HACD
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Gives the triangles partitionas an array of size m_nTriangles where the i-th element specifies the cluster to which belong the i-th triangle
|
//! Gives the triangles partitionas an array of size m_nTriangles where the i-th element specifies the cluster to which belong the i-th triangle
|
||||||
//! @return triangles partition
|
//! @return triangles partition
|
||||||
const long *GetPartition() const { return m_partition; }
|
const long *GetPartition() const { return m_partition; }
|
||||||
|
|
@ -213,8 +214,10 @@ namespace HACD
|
||||||
//! @return edge's index
|
//! @return edge's index
|
||||||
static unsigned long long GetEdgeIndex(unsigned long long a, unsigned long long b)
|
static unsigned long long GetEdgeIndex(unsigned long long a, unsigned long long b)
|
||||||
{
|
{
|
||||||
if (a > b) return (a << 32) + b;
|
if (a > b)
|
||||||
else return (b << 32) + a;
|
return (a << 32) + b;
|
||||||
|
else
|
||||||
|
return (b << 32) + a;
|
||||||
}
|
}
|
||||||
//! Computes the concavity of a cluster.
|
//! Computes the concavity of a cluster.
|
||||||
//! @param ch the cluster's convex-hull
|
//! @param ch the cluster's convex-hull
|
||||||
|
|
@ -269,14 +272,14 @@ namespace HACD
|
||||||
size_t m_nVerticesPerCH; //>! maximum number of vertices per convex-hull
|
size_t m_nVerticesPerCH; //>! maximum number of vertices per convex-hull
|
||||||
reservable_priority_queue<GraphEdgePriorityQueue,
|
reservable_priority_queue<GraphEdgePriorityQueue,
|
||||||
std::vector<GraphEdgePriorityQueue>,
|
std::vector<GraphEdgePriorityQueue>,
|
||||||
std::greater<std::vector<GraphEdgePriorityQueue>::value_type> > m_pqueue; //!> priority queue
|
std::greater<std::vector<GraphEdgePriorityQueue>::value_type> >
|
||||||
|
m_pqueue; //!> priority queue
|
||||||
HACD(const HACD &rhs);
|
HACD(const HACD &rhs);
|
||||||
CallBackFunction m_callBack; //>! call-back function
|
CallBackFunction m_callBack; //>! call-back function
|
||||||
long *m_partition; //>! array of size m_nTriangles where the i-th element specifies the cluster to which belong the i-th triangle
|
long *m_partition; //>! array of size m_nTriangles where the i-th element specifies the cluster to which belong the i-th triangle
|
||||||
bool m_addFacesPoints; //>! specifies whether to add faces points or not
|
bool m_addFacesPoints; //>! specifies whether to add faces points or not
|
||||||
bool m_addExtraDistPoints; //>! specifies whether to add extra points for concave shapes or not
|
bool m_addExtraDistPoints; //>! specifies whether to add extra points for concave shapes or not
|
||||||
bool m_addNeighboursDistPoints; //>! specifies whether to add extra points from adjacent clusters or not
|
bool m_addNeighboursDistPoints; //>! specifies whether to add extra points from adjacent clusters or not
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
} // namespace HACD
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,6 @@ namespace HACD
|
||||||
vHead->GetData().m_name = id;
|
vHead->GetData().m_name = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ICHullError ICHull::DoubleTriangle()
|
ICHullError ICHull::DoubleTriangle()
|
||||||
|
|
@ -415,8 +414,7 @@ namespace HACD
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bary += vBary->GetData().m_pos;
|
bary += vBary->GetData().m_pos;
|
||||||
}
|
} while ((vBary = vBary->GetNext()) != v0);
|
||||||
while ( (vBary = vBary->GetNext()) != v0);
|
|
||||||
bary /= static_cast<Real>(vertices.GetSize());
|
bary /= static_cast<Real>(vertices.GetSize());
|
||||||
|
|
||||||
// Compute the normal to the plane
|
// Compute the normal to the plane
|
||||||
|
|
@ -469,13 +467,20 @@ namespace HACD
|
||||||
e2 = fold->GetData().m_edges[0];
|
e2 = fold->GetData().m_edges[0];
|
||||||
index = 1;
|
index = 1;
|
||||||
}
|
}
|
||||||
e0->GetData().m_vertices[0] = v0; e0->GetData().m_vertices[1] = v1;
|
e0->GetData().m_vertices[0] = v0;
|
||||||
e1->GetData().m_vertices[0] = v1; e1->GetData().m_vertices[1] = v2;
|
e0->GetData().m_vertices[1] = v1;
|
||||||
e2->GetData().m_vertices[0] = v2; e2->GetData().m_vertices[1] = v0;
|
e1->GetData().m_vertices[0] = v1;
|
||||||
|
e1->GetData().m_vertices[1] = v2;
|
||||||
|
e2->GetData().m_vertices[0] = v2;
|
||||||
|
e2->GetData().m_vertices[1] = v0;
|
||||||
// create the new face
|
// create the new face
|
||||||
CircularListElement<TMMTriangle> *f = m_mesh.AddTriangle();
|
CircularListElement<TMMTriangle> *f = m_mesh.AddTriangle();
|
||||||
f->GetData().m_edges[0] = e0; f->GetData().m_edges[1] = e1; f->GetData().m_edges[2] = e2;
|
f->GetData().m_edges[0] = e0;
|
||||||
f->GetData().m_vertices[0] = v0; f->GetData().m_vertices[1] = v1; f->GetData().m_vertices[2] = v2;
|
f->GetData().m_edges[1] = e1;
|
||||||
|
f->GetData().m_edges[2] = e2;
|
||||||
|
f->GetData().m_vertices[0] = v0;
|
||||||
|
f->GetData().m_vertices[1] = v1;
|
||||||
|
f->GetData().m_vertices[2] = v2;
|
||||||
// link edges to face f
|
// link edges to face f
|
||||||
e0->GetData().m_triangles[index] = e1->GetData().m_triangles[index] = e2->GetData().m_triangles[index] = f;
|
e0->GetData().m_triangles[index] = e1->GetData().m_triangles[index] = e2->GetData().m_triangles[index] = f;
|
||||||
return f;
|
return f;
|
||||||
|
|
@ -551,8 +556,7 @@ namespace HACD
|
||||||
visible = true;
|
visible = true;
|
||||||
}
|
}
|
||||||
f = f->GetNext();
|
f = f->GetNext();
|
||||||
}
|
} while (f != fHead);
|
||||||
while (f != fHead);
|
|
||||||
|
|
||||||
if (m_trianglesToDelete.size() == m_mesh.m_triangles.GetSize())
|
if (m_trianglesToDelete.size() == m_mesh.m_triangles.GetSize())
|
||||||
{
|
{
|
||||||
|
|
@ -610,8 +614,7 @@ namespace HACD
|
||||||
m_edgesToUpdate.push_back(e);
|
m_edgesToUpdate.push_back(e);
|
||||||
}
|
}
|
||||||
e = tmp;
|
e = tmp;
|
||||||
}
|
} while (e != eHead);
|
||||||
while (e != eHead);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool ICHull::MakeCCW(CircularListElement<TMMTriangle> *f,
|
bool ICHull::MakeCCW(CircularListElement<TMMTriangle> *f,
|
||||||
|
|
@ -633,7 +636,8 @@ namespace HACD
|
||||||
long i; // index of e->m_vertices[0] in fv
|
long i; // index of e->m_vertices[0] in fv
|
||||||
CircularListElement<TMMVertex> *v0 = e->GetData().m_vertices[0];
|
CircularListElement<TMMVertex> *v0 = e->GetData().m_vertices[0];
|
||||||
CircularListElement<TMMVertex> *v1 = e->GetData().m_vertices[1];
|
CircularListElement<TMMVertex> *v1 = e->GetData().m_vertices[1];
|
||||||
for(i = 0; fv->GetData().m_vertices[i] != v0; i++);
|
for (i = 0; fv->GetData().m_vertices[i] != v0; i++)
|
||||||
|
;
|
||||||
|
|
||||||
if (fv->GetData().m_vertices[(i + 1) % 3] != e->GetData().m_vertices[1])
|
if (fv->GetData().m_vertices[(i + 1) % 3] != e->GetData().m_vertices[1])
|
||||||
{
|
{
|
||||||
|
|
@ -757,8 +761,7 @@ namespace HACD
|
||||||
v->GetData().m_onHull = false;
|
v->GetData().m_onHull = false;
|
||||||
v = v->GetPrev();
|
v = v->GetPrev();
|
||||||
}
|
}
|
||||||
}
|
} while (v->GetData().m_tag && v != vHead);
|
||||||
while (v->GetData().m_tag && v != vHead);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void ICHull::Clear()
|
void ICHull::Clear()
|
||||||
|
|
@ -1014,6 +1017,4 @@ namespace HACD
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace HACD
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ namespace HACD
|
||||||
CircularListElement<TMMEdge> *e,
|
CircularListElement<TMMEdge> *e,
|
||||||
CircularListElement<TMMVertex> *v);
|
CircularListElement<TMMVertex> *v);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const long sc_dummyIndex;
|
static const long sc_dummyIndex;
|
||||||
static const double sc_distMin;
|
static const double sc_distMin;
|
||||||
|
|
@ -110,11 +111,10 @@ namespace HACD
|
||||||
Vec3<Real> m_normal;
|
Vec3<Real> m_normal;
|
||||||
bool m_isFlat;
|
bool m_isFlat;
|
||||||
|
|
||||||
|
|
||||||
ICHull(const ICHull &rhs);
|
ICHull(const ICHull &rhs);
|
||||||
|
|
||||||
friend class HACD;
|
friend class HACD;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace HACD
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
#include "hacdManifoldMesh.h"
|
#include "hacdManifoldMesh.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
namespace HACD
|
namespace HACD
|
||||||
{
|
{
|
||||||
Material::Material(void)
|
Material::Material(void)
|
||||||
|
|
@ -91,7 +90,6 @@ namespace HACD
|
||||||
m_vertices.Next();
|
m_vertices.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t nE = m_edges.GetSize();
|
size_t nE = m_edges.GetSize();
|
||||||
std::cout << "edges (" << nE << ")" << std::endl;
|
std::cout << "edges (" << nE << ")" << std::endl;
|
||||||
for (size_t e = 0; e < nE; e++)
|
for (size_t e = 0; e < nE; e++)
|
||||||
|
|
@ -183,7 +181,8 @@ namespace HACD
|
||||||
fout << " ccw TRUE" << std::endl;
|
fout << " ccw TRUE" << std::endl;
|
||||||
fout << " solid TRUE" << std::endl;
|
fout << " solid TRUE" << std::endl;
|
||||||
fout << " convex TRUE" << std::endl;
|
fout << " convex TRUE" << std::endl;
|
||||||
if (GetNVertices() > 0) {
|
if (GetNVertices() > 0)
|
||||||
|
{
|
||||||
fout << " coord DEF co Coordinate {" << std::endl;
|
fout << " coord DEF co Coordinate {" << std::endl;
|
||||||
fout << " point [" << std::endl;
|
fout << " point [" << std::endl;
|
||||||
for (size_t v = 0; v < nV; v++)
|
for (size_t v = 0; v < nV; v++)
|
||||||
|
|
@ -198,7 +197,8 @@ namespace HACD
|
||||||
fout << " ]" << std::endl;
|
fout << " ]" << std::endl;
|
||||||
fout << " }" << std::endl;
|
fout << " }" << std::endl;
|
||||||
}
|
}
|
||||||
if (GetNTriangles() > 0) {
|
if (GetNTriangles() > 0)
|
||||||
|
{
|
||||||
fout << " coordIndex [ " << std::endl;
|
fout << " coordIndex [ " << std::endl;
|
||||||
for (size_t f = 0; f < nT; f++)
|
for (size_t f = 0; f < nT; f++)
|
||||||
{
|
{
|
||||||
|
|
@ -259,7 +259,6 @@ namespace HACD
|
||||||
{
|
{
|
||||||
mesh.m_edges.GetData().m_id = e;
|
mesh.m_edges.GetData().m_id = e;
|
||||||
mesh.m_edges.Next();
|
mesh.m_edges.Next();
|
||||||
|
|
||||||
}
|
}
|
||||||
for (size_t f = 0; f < nT; f++)
|
for (size_t f = 0; f < nT; f++)
|
||||||
{
|
{
|
||||||
|
|
@ -346,7 +345,6 @@ namespace HACD
|
||||||
delete[] vertexMap;
|
delete[] vertexMap;
|
||||||
delete[] edgeMap;
|
delete[] edgeMap;
|
||||||
delete[] triangleMap;
|
delete[] triangleMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
long IntersectRayTriangle(const Vec3<double> &P0, const Vec3<double> &dir,
|
long IntersectRayTriangle(const Vec3<double> &P0, const Vec3<double> &dir,
|
||||||
const Vec3<double> &V0, const Vec3<double> &V1,
|
const Vec3<double> &V0, const Vec3<double> &V1,
|
||||||
|
|
@ -445,10 +443,12 @@ namespace HACD
|
||||||
w0 = P0 - V0;
|
w0 = P0 - V0;
|
||||||
a = -n * w0;
|
a = -n * w0;
|
||||||
b = n * dir;
|
b = n * dir;
|
||||||
if (fabs(b) <= 0.0) { // ray is parallel to triangle plane
|
if (fabs(b) <= 0.0)
|
||||||
|
{ // ray is parallel to triangle plane
|
||||||
if (a == 0.0) // ray lies in triangle plane
|
if (a == 0.0) // ray lies in triangle plane
|
||||||
return 2;
|
return 2;
|
||||||
else return 0; // ray disjoint from plane
|
else
|
||||||
|
return 0; // ray disjoint from plane
|
||||||
}
|
}
|
||||||
|
|
||||||
// get intersect point of ray with triangle plane
|
// get intersect point of ray with triangle plane
|
||||||
|
|
@ -480,7 +480,6 @@ namespace HACD
|
||||||
return 1; // I is in T
|
return 1; // I is in T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TMMesh::CheckConsistancy()
|
bool TMMesh::CheckConsistancy()
|
||||||
{
|
{
|
||||||
size_t nE = m_edges.GetSize();
|
size_t nE = m_edges.GetSize();
|
||||||
|
|
@ -536,12 +535,18 @@ namespace HACD
|
||||||
x = m_vertices.GetHead()->GetData().m_pos.X();
|
x = m_vertices.GetHead()->GetData().m_pos.X();
|
||||||
y = m_vertices.GetHead()->GetData().m_pos.Y();
|
y = m_vertices.GetHead()->GetData().m_pos.Y();
|
||||||
z = m_vertices.GetHead()->GetData().m_pos.Z();
|
z = m_vertices.GetHead()->GetData().m_pos.Z();
|
||||||
if ( x < min.X()) min.X() = x;
|
if (x < min.X())
|
||||||
else if ( x > max.X()) max.X() = x;
|
min.X() = x;
|
||||||
if ( y < min.Y()) min.Y() = y;
|
else if (x > max.X())
|
||||||
else if ( y > max.Y()) max.Y() = y;
|
max.X() = x;
|
||||||
if ( z < min.Z()) min.Z() = z;
|
if (y < min.Y())
|
||||||
else if ( z > max.Z()) max.Z() = z;
|
min.Y() = y;
|
||||||
|
else if (y > max.Y())
|
||||||
|
max.Y() = y;
|
||||||
|
if (z < min.Z())
|
||||||
|
min.Z() = z;
|
||||||
|
else if (z > max.Z())
|
||||||
|
max.Z() = z;
|
||||||
m_vertices.Next();
|
m_vertices.Next();
|
||||||
}
|
}
|
||||||
m_barycenter /= static_cast<Real>(nV);
|
m_barycenter /= static_cast<Real>(nV);
|
||||||
|
|
@ -574,4 +579,4 @@ namespace HACD
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} // namespace HACD
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ namespace HACD
|
||||||
m_computed(computed),
|
m_computed(computed),
|
||||||
m_distOnly(distOnly){};
|
m_distOnly(distOnly){};
|
||||||
~DPoint(){};
|
~DPoint(){};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Real m_dist;
|
Real m_dist;
|
||||||
bool m_computed;
|
bool m_computed;
|
||||||
|
|
@ -94,13 +95,13 @@ namespace HACD
|
||||||
public:
|
public:
|
||||||
TMMEdge(void);
|
TMMEdge(void);
|
||||||
~TMMEdge(void);
|
~TMMEdge(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_id;
|
size_t m_id;
|
||||||
CircularListElement<TMMTriangle> *m_triangles[2];
|
CircularListElement<TMMTriangle> *m_triangles[2];
|
||||||
CircularListElement<TMMVertex> *m_vertices[2];
|
CircularListElement<TMMVertex> *m_vertices[2];
|
||||||
CircularListElement<TMMTriangle> *m_newFace;
|
CircularListElement<TMMTriangle> *m_newFace;
|
||||||
|
|
||||||
|
|
||||||
TMMEdge(const TMMEdge &rhs);
|
TMMEdge(const TMMEdge &rhs);
|
||||||
|
|
||||||
friend class HACD;
|
friend class HACD;
|
||||||
|
|
@ -116,6 +117,7 @@ namespace HACD
|
||||||
public:
|
public:
|
||||||
TMMTriangle(void);
|
TMMTriangle(void);
|
||||||
~TMMTriangle(void);
|
~TMMTriangle(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_id;
|
size_t m_id;
|
||||||
CircularListElement<TMMEdge> *m_edges[3];
|
CircularListElement<TMMEdge> *m_edges[3];
|
||||||
|
|
@ -153,7 +155,6 @@ namespace HACD
|
||||||
class TMMesh
|
class TMMesh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Returns the number of vertices>
|
//! Returns the number of vertices>
|
||||||
inline size_t GetNVertices() const { return m_vertices.GetSize(); }
|
inline size_t GetNVertices() const { return m_vertices.GetSize(); }
|
||||||
//! Returns the number of edges
|
//! Returns the number of edges
|
||||||
|
|
@ -246,5 +247,5 @@ namespace HACD
|
||||||
const Vec3<double> &p3, const Vec3<double> &p4,
|
const Vec3<double> &p3, const Vec3<double> &p4,
|
||||||
Vec3<double> &pa, Vec3<double> &pb,
|
Vec3<double> &pa, Vec3<double> &pb,
|
||||||
double &mua, double &mub);
|
double &mua, double &mub);
|
||||||
}
|
} // namespace HACD
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@ namespace HACD
|
||||||
{
|
{
|
||||||
typedef double Real;
|
typedef double Real;
|
||||||
//! Vector dim 3.
|
//! Vector dim 3.
|
||||||
template < typename T > class Vec3
|
template <typename T>
|
||||||
|
class Vec3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T& X();
|
T& X();
|
||||||
|
|
@ -62,6 +63,6 @@ namespace HACD
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T Volume(const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c, const Vec3<T>& d);
|
const T Volume(const Vec3<T>& a, const Vec3<T>& b, const Vec3<T>& c, const Vec3<T>& d);
|
||||||
|
|
||||||
}
|
} // namespace HACD
|
||||||
#include "hacdVector.inl" // template implementation
|
#include "hacdVector.inl" // template implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
kind "StaticLib"
|
kind "StaticLib"
|
||||||
|
|
||||||
includedirs {"."}
|
includedirs {"."}
|
||||||
|
if os.is("Linux") then
|
||||||
|
buildoptions{"-fPIC"}
|
||||||
|
end
|
||||||
files {
|
files {
|
||||||
"**.cpp",
|
"**.cpp",
|
||||||
"**.h"
|
"**.h"
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,3 @@
|
||||||
#include "User2InternalIndex.hpp"
|
#include "User2InternalIndex.hpp"
|
||||||
|
|
||||||
#endif //BULLET_INVERSE_DYNAMICS_UTILS_COMMON_H
|
#endif //BULLET_INVERSE_DYNAMICS_UTILS_COMMON_H
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,10 @@ IF (INSTALL_EXTRA_LIBS)
|
||||||
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS BulletInverseDynamicsUtils DESTINATION .)
|
INSTALL(TARGETS BulletInverseDynamicsUtils DESTINATION .)
|
||||||
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
|
||||||
INSTALL(TARGETS BulletInverseDynamicsUtils DESTINATION lib${LIB_SUFFIX})
|
INSTALL(TARGETS BulletInverseDynamicsUtils
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
||||||
|
ARCHIVE DESTINATION lib${LIB_SUFFIX})
|
||||||
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN
|
||||||
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE)
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,36 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
#define CHECK_NULLPTR() \
|
#define CHECK_NULLPTR() \
|
||||||
do { \
|
do \
|
||||||
if (m_reference == 0x0) { \
|
{ \
|
||||||
error_message("m_reference == 0x0\n"); \
|
if (m_reference == 0x0) \
|
||||||
|
{ \
|
||||||
|
bt_id_error_message("m_reference == 0x0\n"); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TRY(x) \
|
#define TRY(x) \
|
||||||
do { \
|
do \
|
||||||
if (x == -1) { \
|
{ \
|
||||||
error_message("error calling " #x "\n"); \
|
if (x == -1) \
|
||||||
|
{ \
|
||||||
|
bt_id_error_message("error calling " #x "\n"); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
CloneTreeCreator::CloneTreeCreator(const MultiBodyTree* reference) { m_reference = reference; }
|
CloneTreeCreator::CloneTreeCreator(const MultiBodyTree* reference)
|
||||||
|
{
|
||||||
|
m_reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
CloneTreeCreator::~CloneTreeCreator() {}
|
CloneTreeCreator::~CloneTreeCreator() {}
|
||||||
|
|
||||||
int CloneTreeCreator::getNumBodies(int* num_bodies) const {
|
int CloneTreeCreator::getNumBodies(int* num_bodies) const
|
||||||
|
{
|
||||||
CHECK_NULLPTR();
|
CHECK_NULLPTR();
|
||||||
*num_bodies = m_reference->numBodies();
|
*num_bodies = m_reference->numBodies();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -31,7 +40,8 @@ int CloneTreeCreator::getNumBodies(int* num_bodies) const {
|
||||||
int CloneTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
int CloneTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
||||||
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
||||||
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
||||||
mat33* body_I_body, int* user_int, void** user_ptr) const {
|
mat33* body_I_body, int* user_int, void** user_ptr) const
|
||||||
|
{
|
||||||
CHECK_NULLPTR();
|
CHECK_NULLPTR();
|
||||||
TRY(m_reference->getParentIndex(body_index, parent_index));
|
TRY(m_reference->getParentIndex(body_index, parent_index));
|
||||||
TRY(m_reference->getJointType(body_index, joint_type));
|
TRY(m_reference->getJointType(body_index, joint_type));
|
||||||
|
|
@ -46,4 +56,4 @@ int CloneTreeCreator::getBody(const int body_index, int* parent_index, JointType
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
#include "BulletInverseDynamics/IDConfig.hpp"
|
#include "BulletInverseDynamics/IDConfig.hpp"
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// Generate an identical multibody tree from a reference system.
|
/// Generate an identical multibody tree from a reference system.
|
||||||
class CloneTreeCreator : public MultiBodyTreeCreator {
|
class CloneTreeCreator : public MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor
|
/// ctor
|
||||||
/// @param reference the MultiBodyTree to clone
|
/// @param reference the MultiBodyTree to clone
|
||||||
|
|
@ -23,5 +25,5 @@ public:
|
||||||
private:
|
private:
|
||||||
const MultiBodyTree* m_reference;
|
const MultiBodyTree* m_reference;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif // CLONETREE_CREATOR_HPP_
|
#endif // CLONETREE_CREATOR_HPP_
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
#include "CoilCreator.hpp"
|
#include "CoilCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
CoilCreator::CoilCreator(int n) : m_num_bodies(n), m_parent(n) {
|
{
|
||||||
for (int i = 0; i < m_num_bodies; i++) {
|
CoilCreator::CoilCreator(int n) : m_num_bodies(n), m_parent(n)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_num_bodies; i++)
|
||||||
|
{
|
||||||
m_parent[i] = i - 1;
|
m_parent[i] = i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,7 +41,8 @@ CoilCreator::CoilCreator(int n) : m_num_bodies(n), m_parent(n) {
|
||||||
|
|
||||||
CoilCreator::~CoilCreator() {}
|
CoilCreator::~CoilCreator() {}
|
||||||
|
|
||||||
int CoilCreator::getNumBodies(int* num_bodies) const {
|
int CoilCreator::getNumBodies(int* num_bodies) const
|
||||||
|
{
|
||||||
*num_bodies = m_num_bodies;
|
*num_bodies = m_num_bodies;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -46,9 +50,11 @@ int CoilCreator::getNumBodies(int* num_bodies) const {
|
||||||
int CoilCreator::getBody(int body_index, int* parent_index, JointType* joint_type,
|
int CoilCreator::getBody(int body_index, int* parent_index, JointType* joint_type,
|
||||||
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
||||||
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
||||||
mat33* body_I_body, int* user_int, void** user_ptr) const {
|
mat33* body_I_body, int* user_int, void** user_ptr) const
|
||||||
if (body_index < 0 || body_index >= m_num_bodies) {
|
{
|
||||||
error_message("invalid body index %d\n", body_index);
|
if (body_index < 0 || body_index >= m_num_bodies)
|
||||||
|
{
|
||||||
|
bt_id_error_message("invalid body index %d\n", body_index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*parent_index = m_parent[body_index];
|
*parent_index = m_parent[body_index];
|
||||||
|
|
@ -64,4 +70,4 @@ int CoilCreator::getBody(int body_index, int* parent_index, JointType* joint_typ
|
||||||
*user_ptr = 0;
|
*user_ptr = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,16 @@
|
||||||
|
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// Creator class for building a "coil" system as intruduced as benchmark example in
|
/// Creator class for building a "coil" system as intruduced as benchmark example in
|
||||||
/// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n))
|
/// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n))
|
||||||
/// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.", The International
|
/// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.", The International
|
||||||
/// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628.
|
/// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628.
|
||||||
///
|
///
|
||||||
/// This is a serial chain, with an initial configuration resembling a coil.
|
/// This is a serial chain, with an initial configuration resembling a coil.
|
||||||
class CoilCreator : public MultiBodyTreeCreator {
|
class CoilCreator : public MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor.
|
/// ctor.
|
||||||
/// @param n the number of bodies in the system
|
/// @param n the number of bodies in the system
|
||||||
|
|
@ -36,5 +37,5 @@ private:
|
||||||
vec3 m_body_r_body_com;
|
vec3 m_body_r_body_com;
|
||||||
mat33 m_body_I_body;
|
mat33 m_body_I_body;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "DillCreator.hpp"
|
#include "DillCreator.hpp"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
DillCreator::DillCreator(int level)
|
DillCreator::DillCreator(int level)
|
||||||
: m_level(level),
|
: m_level(level),
|
||||||
m_num_bodies(BT_ID_POW(2, level))
|
m_num_bodies(BT_ID_POW(2, level))
|
||||||
|
|
@ -15,7 +15,8 @@ DillCreator::DillCreator(int level)
|
||||||
m_body_I_body.resize(m_num_bodies);
|
m_body_I_body.resize(m_num_bodies);
|
||||||
|
|
||||||
// generate names (for debugging)
|
// generate names (for debugging)
|
||||||
for (int i = 0; i < m_num_bodies; i++) {
|
for (int i = 0; i < m_num_bodies; i++)
|
||||||
|
{
|
||||||
m_parent[i] = i - 1;
|
m_parent[i] = i - 1;
|
||||||
|
|
||||||
// all z-axis (DH convention)
|
// all z-axis (DH convention)
|
||||||
|
|
@ -31,15 +32,17 @@ DillCreator::DillCreator(int level)
|
||||||
const idScalar a_DH = 0.0;
|
const idScalar a_DH = 0.0;
|
||||||
const idScalar alpha_DH = 0.0;
|
const idScalar alpha_DH = 0.0;
|
||||||
|
|
||||||
if (-1 == recurseDill(m_level, parent, d_DH, a_DH, alpha_DH)) {
|
if (-1 == recurseDill(m_level, parent, d_DH, a_DH, alpha_DH))
|
||||||
error_message("recurseDill failed\n");
|
{
|
||||||
|
bt_id_error_message("recurseDill failed\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DillCreator::~DillCreator() {}
|
DillCreator::~DillCreator() {}
|
||||||
|
|
||||||
int DillCreator::getNumBodies(int* num_bodies) const {
|
int DillCreator::getNumBodies(int* num_bodies) const
|
||||||
|
{
|
||||||
*num_bodies = m_num_bodies;
|
*num_bodies = m_num_bodies;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -47,9 +50,11 @@ int DillCreator::getNumBodies(int* num_bodies) const {
|
||||||
int DillCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
int DillCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
||||||
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
||||||
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
||||||
mat33* body_I_body, int* user_int, void** user_ptr) const {
|
mat33* body_I_body, int* user_int, void** user_ptr) const
|
||||||
if (body_index < 0 || body_index >= m_num_bodies) {
|
{
|
||||||
error_message("invalid body index %d\n", body_index);
|
if (body_index < 0 || body_index >= m_num_bodies)
|
||||||
|
{
|
||||||
|
bt_id_error_message("invalid body index %d\n", body_index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*parent_index = m_parent[body_index];
|
*parent_index = m_parent[body_index];
|
||||||
|
|
@ -67,14 +72,17 @@ int DillCreator::getBody(const int body_index, int* parent_index, JointType* joi
|
||||||
}
|
}
|
||||||
|
|
||||||
int DillCreator::recurseDill(const int level, const int parent, const idScalar d_DH_in,
|
int DillCreator::recurseDill(const int level, const int parent, const idScalar d_DH_in,
|
||||||
const idScalar a_DH_in, const idScalar alpha_DH_in) {
|
const idScalar a_DH_in, const idScalar alpha_DH_in)
|
||||||
if (level < 0) {
|
{
|
||||||
error_message("invalid level parameter (%d)\n", level);
|
if (level < 0)
|
||||||
|
{
|
||||||
|
bt_id_error_message("invalid level parameter (%d)\n", level);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current_body >= m_num_bodies || m_current_body < 0) {
|
if (m_current_body >= m_num_bodies || m_current_body < 0)
|
||||||
error_message("invalid body parameter (%d, num_bodies: %d)\n", m_current_body,
|
{
|
||||||
|
bt_id_error_message("invalid body parameter (%d, num_bodies: %d)\n", m_current_body,
|
||||||
m_num_bodies);
|
m_num_bodies);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -92,14 +100,16 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d
|
||||||
m_body_r_body_com[body](1) = 0;
|
m_body_r_body_com[body](1) = 0;
|
||||||
m_body_r_body_com[body](2) = 0;
|
m_body_r_body_com[body](2) = 0;
|
||||||
// initialization
|
// initialization
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
m_parent_r_parent_body_ref[body](i) = 0;
|
m_parent_r_parent_body_ref[body](i) = 0;
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
m_body_I_body[body](i, j) = 0.0;
|
m_body_I_body[body](i, j) = 0.0;
|
||||||
m_body_T_parent_ref[body](i, j) = 0.0;
|
m_body_T_parent_ref[body](i, j) = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const idScalar size_5 = pow(size, 5);
|
const idScalar size_5 = std::pow(size, 5);
|
||||||
m_body_I_body[body](0, 0) = size_5 / 0.2e6;
|
m_body_I_body[body](0, 0) = size_5 / 0.2e6;
|
||||||
m_body_I_body[body](1, 1) = size_5 * 403 / 1.2e6;
|
m_body_I_body[body](1, 1) = size_5 * 403 / 1.2e6;
|
||||||
m_body_I_body[body](2, 2) = m_body_I_body[body](1, 1);
|
m_body_I_body[body](2, 2) = m_body_I_body[body](1, 1);
|
||||||
|
|
@ -108,9 +118,11 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d
|
||||||
&m_body_T_parent_ref[body]);
|
&m_body_T_parent_ref[body]);
|
||||||
|
|
||||||
// attach "level" Dill systems of levels 1...level
|
// attach "level" Dill systems of levels 1...level
|
||||||
for (int i = 1; i <= level; i++) {
|
for (int i = 1; i <= level; i++)
|
||||||
|
{
|
||||||
idScalar d_DH = 0.01 * size;
|
idScalar d_DH = 0.01 * size;
|
||||||
if (i == level) {
|
if (i == level)
|
||||||
|
{
|
||||||
d_DH = 0.0;
|
d_DH = 0.0;
|
||||||
}
|
}
|
||||||
const idScalar a_DH = i * 0.1;
|
const idScalar a_DH = i * 0.1;
|
||||||
|
|
@ -121,4 +133,4 @@ int DillCreator::recurseDill(const int level, const int parent, const idScalar d
|
||||||
|
|
||||||
return 0; // ok!
|
return 0; // ok!
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@
|
||||||
|
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
|
|
||||||
/// Creator class for building a "Dill" system as intruduced as benchmark example in
|
/// Creator class for building a "Dill" system as intruduced as benchmark example in
|
||||||
/// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n))
|
/// Featherstone (1999), "A Divide-and-Conquer Articulated-Body Algorithm for Parallel O(log(n))
|
||||||
/// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.", The International
|
/// Calculation of Rigid-Body Dynamics. Part 2: Trees, Loops, and Accuracy.", The International
|
||||||
/// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628.
|
/// Journal of Robotics Research 18 (9): 876–892. doi : 10.1177 / 02783649922066628.
|
||||||
///
|
///
|
||||||
/// This is a self-similar branched tree, somewhat resembling a dill plant
|
/// This is a self-similar branched tree, somewhat resembling a dill plant
|
||||||
class DillCreator : public MultiBodyTreeCreator {
|
class DillCreator : public MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor
|
/// ctor
|
||||||
/// @param levels the number of dill levels
|
/// @param levels the number of dill levels
|
||||||
|
|
@ -43,5 +43,5 @@ private:
|
||||||
idArray<mat33>::type m_body_I_body;
|
idArray<mat33>::type m_body_I_body;
|
||||||
int m_current_body;
|
int m_current_body;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,8 @@
|
||||||
#include "BulletInverseDynamics/IDMath.hpp"
|
#include "BulletInverseDynamics/IDMath.hpp"
|
||||||
#include "IDRandomUtil.hpp"
|
#include "IDRandomUtil.hpp"
|
||||||
|
|
||||||
|
namespace btInverseDynamics
|
||||||
namespace btInverseDynamics {
|
{
|
||||||
|
|
||||||
// constants for random mass and inertia generation
|
// constants for random mass and inertia generation
|
||||||
// these are arbitrary positive values.
|
// these are arbitrary positive values.
|
||||||
static const float mass_min = 0.001;
|
static const float mass_min = 0.001;
|
||||||
|
|
@ -19,15 +18,18 @@ void randomInit(unsigned seed) { srand(seed); }
|
||||||
|
|
||||||
int randomInt(int low, int high) { return rand() % (high + 1 - low) + low; }
|
int randomInt(int low, int high) { return rand() % (high + 1 - low) + low; }
|
||||||
|
|
||||||
float randomFloat(float low, float high) {
|
float randomFloat(float low, float high)
|
||||||
|
{
|
||||||
return low + static_cast<float>(rand()) / RAND_MAX * (high - low);
|
return low + static_cast<float>(rand()) / RAND_MAX * (high - low);
|
||||||
}
|
}
|
||||||
|
|
||||||
float randomMass() { return randomFloat(mass_min, mass_max); }
|
float randomMass() { return randomFloat(mass_min, mass_max); }
|
||||||
|
|
||||||
vec3 randomInertiaPrincipal() {
|
vec3 randomInertiaPrincipal()
|
||||||
|
{
|
||||||
vec3 inertia;
|
vec3 inertia;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
inertia(0) = randomFloat(mass_min, mass_max);
|
inertia(0) = randomFloat(mass_min, mass_max);
|
||||||
inertia(1) = randomFloat(mass_min, mass_max);
|
inertia(1) = randomFloat(mass_min, mass_max);
|
||||||
inertia(2) = randomFloat(mass_min, mass_max);
|
inertia(2) = randomFloat(mass_min, mass_max);
|
||||||
|
|
@ -36,7 +38,8 @@ vec3 randomInertiaPrincipal() {
|
||||||
return inertia;
|
return inertia;
|
||||||
}
|
}
|
||||||
|
|
||||||
mat33 randomInertiaMatrix() {
|
mat33 randomInertiaMatrix()
|
||||||
|
{
|
||||||
// generate random valid inertia matrix by first getting valid components
|
// generate random valid inertia matrix by first getting valid components
|
||||||
// along major axes and then rotating by random amount
|
// along major axes and then rotating by random amount
|
||||||
vec3 principal = randomInertiaPrincipal();
|
vec3 principal = randomInertiaPrincipal();
|
||||||
|
|
@ -55,17 +58,19 @@ mat33 randomInertiaMatrix() {
|
||||||
return rot * inertia * rot.transpose();
|
return rot * inertia * rot.transpose();
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 randomAxis() {
|
vec3 randomAxis()
|
||||||
|
{
|
||||||
vec3 axis;
|
vec3 axis;
|
||||||
idScalar length;
|
idScalar length;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
axis(0) = randomFloat(-1.0, 1.0);
|
axis(0) = randomFloat(-1.0, 1.0);
|
||||||
axis(1) = randomFloat(-1.0, 1.0);
|
axis(1) = randomFloat(-1.0, 1.0);
|
||||||
axis(2) = randomFloat(-1.0, 1.0);
|
axis(2) = randomFloat(-1.0, 1.0);
|
||||||
|
|
||||||
length = std::sqrt(std::pow(axis(0), 2) + std::pow(axis(1), 2) + std::pow(axis(2), 2));
|
length = BT_ID_SQRT(BT_ID_POW(axis(0), 2) + BT_ID_POW(axis(1), 2) + BT_ID_POW(axis(2), 2));
|
||||||
} while (length < 0.01);
|
} while (length < 0.01);
|
||||||
|
|
||||||
return axis / length;
|
return axis / length;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#ifndef ID_RANDOM_UTIL_HPP_
|
#ifndef ID_RANDOM_UTIL_HPP_
|
||||||
#define ID_RANDOM_UTIL_HPP_
|
#define ID_RANDOM_UTIL_HPP_
|
||||||
#include "BulletInverseDynamics/IDConfig.hpp"
|
#include "BulletInverseDynamics/IDConfig.hpp"
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// seed random number generator using time()
|
/// seed random number generator using time()
|
||||||
void randomInit();
|
void randomInit();
|
||||||
/// seed random number generator with identical value to get repeatable results
|
/// seed random number generator with identical value to get repeatable results
|
||||||
|
|
@ -32,5 +33,5 @@ vec3 randomInertiaPrincipal();
|
||||||
mat33 randomInertiaMatrix();
|
mat33 randomInertiaMatrix();
|
||||||
/// generate a random unit vector
|
/// generate a random unit vector
|
||||||
vec3 randomAxis();
|
vec3 randomAxis();
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
12
Engine/lib/bullet/Extras/InverseDynamics/LICENSE.txt
Normal file
12
Engine/lib/bullet/Extras/InverseDynamics/LICENSE.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
http://bulletphysics.org
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
#include "MultiBodyNameMap.hpp"
|
#include "MultiBodyNameMap.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
MultiBodyNameMap::MultiBodyNameMap() {}
|
MultiBodyNameMap::MultiBodyNameMap() {}
|
||||||
|
|
||||||
int MultiBodyNameMap::addBody(const int index, const std::string& name) {
|
int MultiBodyNameMap::addBody(const int index, const std::string& name)
|
||||||
if (m_index_to_body_name.count(index) > 0) {
|
{
|
||||||
error_message("trying to add index %d again\n", index);
|
if (m_index_to_body_name.count(index) > 0)
|
||||||
|
{
|
||||||
|
bt_id_error_message("trying to add index %d again\n", index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (m_body_name_to_index.count(name) > 0) {
|
if (m_body_name_to_index.count(name) > 0)
|
||||||
error_message("trying to add name %s again\n", name.c_str());
|
{
|
||||||
|
bt_id_error_message("trying to add name %s again\n", name.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,13 +23,16 @@ int MultiBodyNameMap::addBody(const int index, const std::string& name) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiBodyNameMap::addJoint(const int index, const std::string& name) {
|
int MultiBodyNameMap::addJoint(const int index, const std::string& name)
|
||||||
if (m_index_to_joint_name.count(index) > 0) {
|
{
|
||||||
error_message("trying to add index %d again\n", index);
|
if (m_index_to_joint_name.count(index) > 0)
|
||||||
|
{
|
||||||
|
bt_id_error_message("trying to add index %d again\n", index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (m_joint_name_to_index.count(name) > 0) {
|
if (m_joint_name_to_index.count(name) > 0)
|
||||||
error_message("trying to add name %s again\n", name.c_str());
|
{
|
||||||
|
bt_id_error_message("trying to add name %s again\n", name.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,43 +42,51 @@ int MultiBodyNameMap::addJoint(const int index, const std::string& name) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiBodyNameMap::getBodyName(const int index, std::string* name) const {
|
int MultiBodyNameMap::getBodyName(const int index, std::string* name) const
|
||||||
|
{
|
||||||
std::map<int, std::string>::const_iterator it = m_index_to_body_name.find(index);
|
std::map<int, std::string>::const_iterator it = m_index_to_body_name.find(index);
|
||||||
if (it == m_index_to_body_name.end()) {
|
if (it == m_index_to_body_name.end())
|
||||||
error_message("index %d not known\n", index);
|
{
|
||||||
|
bt_id_error_message("index %d not known\n", index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*name = it->second;
|
*name = it->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiBodyNameMap::getJointName(const int index, std::string* name) const {
|
int MultiBodyNameMap::getJointName(const int index, std::string* name) const
|
||||||
|
{
|
||||||
std::map<int, std::string>::const_iterator it = m_index_to_joint_name.find(index);
|
std::map<int, std::string>::const_iterator it = m_index_to_joint_name.find(index);
|
||||||
if (it == m_index_to_joint_name.end()) {
|
if (it == m_index_to_joint_name.end())
|
||||||
error_message("index %d not known\n", index);
|
{
|
||||||
|
bt_id_error_message("index %d not known\n", index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*name = it->second;
|
*name = it->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiBodyNameMap::getBodyIndex(const std::string& name, int* index) const {
|
int MultiBodyNameMap::getBodyIndex(const std::string& name, int* index) const
|
||||||
|
{
|
||||||
std::map<std::string, int>::const_iterator it = m_body_name_to_index.find(name);
|
std::map<std::string, int>::const_iterator it = m_body_name_to_index.find(name);
|
||||||
if (it == m_body_name_to_index.end()) {
|
if (it == m_body_name_to_index.end())
|
||||||
error_message("name %s not known\n", name.c_str());
|
{
|
||||||
|
bt_id_error_message("name %s not known\n", name.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*index = it->second;
|
*index = it->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiBodyNameMap::getJointIndex(const std::string& name, int* index) const {
|
int MultiBodyNameMap::getJointIndex(const std::string& name, int* index) const
|
||||||
|
{
|
||||||
std::map<std::string, int>::const_iterator it = m_joint_name_to_index.find(name);
|
std::map<std::string, int>::const_iterator it = m_joint_name_to_index.find(name);
|
||||||
if (it == m_joint_name_to_index.end()) {
|
if (it == m_joint_name_to_index.end())
|
||||||
error_message("name %s not known\n", name.c_str());
|
{
|
||||||
|
bt_id_error_message("name %s not known\n", name.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*index = it->second;
|
*index = it->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// \brief The MultiBodyNameMap class
|
/// \brief The MultiBodyNameMap class
|
||||||
/// Utility class that stores a maps from body/joint indices to/from body and joint names
|
/// Utility class that stores a maps from body/joint indices to/from body and joint names
|
||||||
class MultiBodyNameMap {
|
class MultiBodyNameMap
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MultiBodyNameMap();
|
MultiBodyNameMap();
|
||||||
/// add a body to the map
|
/// add a body to the map
|
||||||
|
|
@ -50,5 +51,5 @@ private:
|
||||||
std::map<std::string, int> m_joint_name_to_index;
|
std::map<std::string, int> m_joint_name_to_index;
|
||||||
std::map<std::string, int> m_body_name_to_index;
|
std::map<std::string, int> m_body_name_to_index;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif // MULTIBODYNAMEMAP_HPP_
|
#endif // MULTIBODYNAMEMAP_HPP_
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator) {
|
MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator)
|
||||||
|
{
|
||||||
int num_bodies;
|
int num_bodies;
|
||||||
int parent_index;
|
int parent_index;
|
||||||
JointType joint_type;
|
JointType joint_type;
|
||||||
|
|
@ -16,8 +17,9 @@ MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator) {
|
||||||
void* user_ptr;
|
void* user_ptr;
|
||||||
|
|
||||||
MultiBodyTree* tree = new MultiBodyTree();
|
MultiBodyTree* tree = new MultiBodyTree();
|
||||||
if (0x0 == tree) {
|
if (0x0 == tree)
|
||||||
error_message("cannot allocate tree\n");
|
{
|
||||||
|
bt_id_error_message("cannot allocate tree\n");
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,20 +27,23 @@ MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator) {
|
||||||
tree->setAcceptInvalidMassParameters(false);
|
tree->setAcceptInvalidMassParameters(false);
|
||||||
|
|
||||||
// get number of bodies in the system
|
// get number of bodies in the system
|
||||||
if (-1 == creator.getNumBodies(&num_bodies)) {
|
if (-1 == creator.getNumBodies(&num_bodies))
|
||||||
error_message("getting body indices\n");
|
{
|
||||||
|
bt_id_error_message("getting body indices\n");
|
||||||
delete tree;
|
delete tree;
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get data for all bodies
|
// get data for all bodies
|
||||||
for (int index = 0; index < num_bodies; index++) {
|
for (int index = 0; index < num_bodies; index++)
|
||||||
|
{
|
||||||
// get body parameters from user callbacks
|
// get body parameters from user callbacks
|
||||||
if (-1 ==
|
if (-1 ==
|
||||||
creator.getBody(index, &parent_index, &joint_type, &body_r_parent_body_ref,
|
creator.getBody(index, &parent_index, &joint_type, &body_r_parent_body_ref,
|
||||||
&body_R_parent_ref, &body_axis_of_motion, &mass, &body_r_body_com,
|
&body_R_parent_ref, &body_axis_of_motion, &mass, &body_r_body_com,
|
||||||
&body_I_body, &user_int, &user_ptr)) {
|
&body_I_body, &user_int, &user_ptr))
|
||||||
error_message("getting data for body %d\n", index);
|
{
|
||||||
|
bt_id_error_message("getting data for body %d\n", index);
|
||||||
delete tree;
|
delete tree;
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
@ -46,19 +51,21 @@ MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator) {
|
||||||
if (-1 ==
|
if (-1 ==
|
||||||
tree->addBody(index, parent_index, joint_type, body_r_parent_body_ref,
|
tree->addBody(index, parent_index, joint_type, body_r_parent_body_ref,
|
||||||
body_R_parent_ref, body_axis_of_motion, mass, body_r_body_com,
|
body_R_parent_ref, body_axis_of_motion, mass, body_r_body_com,
|
||||||
body_I_body, user_int, user_ptr)) {
|
body_I_body, user_int, user_ptr))
|
||||||
error_message("adding body %d\n", index);
|
{
|
||||||
|
bt_id_error_message("adding body %d\n", index);
|
||||||
delete tree;
|
delete tree;
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// finalize initialization
|
// finalize initialization
|
||||||
if (-1 == tree->finalize()) {
|
if (-1 == tree->finalize())
|
||||||
error_message("building system\n");
|
{
|
||||||
|
bt_id_error_message("building system\n");
|
||||||
delete tree;
|
delete tree;
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@
|
||||||
#include "BulletInverseDynamics/MultiBodyTree.hpp"
|
#include "BulletInverseDynamics/MultiBodyTree.hpp"
|
||||||
#include "MultiBodyNameMap.hpp"
|
#include "MultiBodyNameMap.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// Interface class for initializing a MultiBodyTree instance.
|
/// Interface class for initializing a MultiBodyTree instance.
|
||||||
/// Data to be provided is modeled on the URDF specification.
|
/// Data to be provided is modeled on the URDF specification.
|
||||||
/// The user can derive from this class in order to programmatically
|
/// The user can derive from this class in order to programmatically
|
||||||
/// initialize a system.
|
/// initialize a system.
|
||||||
class MultiBodyTreeCreator {
|
class MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// the dtor
|
/// the dtor
|
||||||
virtual ~MultiBodyTreeCreator() {}
|
virtual ~MultiBodyTreeCreator() {}
|
||||||
|
|
@ -38,7 +40,7 @@ public:
|
||||||
/// @return A pointer to an allocated multibodytree instance, or
|
/// @return A pointer to an allocated multibodytree instance, or
|
||||||
/// 0x0 if an error occured.
|
/// 0x0 if an error occured.
|
||||||
MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator);
|
MultiBodyTree* CreateMultiBodyTree(const MultiBodyTreeCreator& creator);
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
||||||
// does urdf have gravity direction ??
|
// does urdf have gravity direction ??
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,56 +2,69 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
int writeGraphvizDotFile(const MultiBodyTree* tree, const MultiBodyNameMap* map,
|
int writeGraphvizDotFile(const MultiBodyTree* tree, const MultiBodyNameMap* map,
|
||||||
const char* filename) {
|
const char* filename)
|
||||||
if (0x0 == tree) {
|
{
|
||||||
error_message("tree pointer is null\n");
|
if (0x0 == tree)
|
||||||
|
{
|
||||||
|
bt_id_error_message("tree pointer is null\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (0x0 == filename) {
|
if (0x0 == filename)
|
||||||
error_message("filename is null\n");
|
{
|
||||||
|
bt_id_error_message("filename is null\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* fp = fopen(filename, "w");
|
FILE* fp = fopen(filename, "w");
|
||||||
if (NULL == fp) {
|
if (NULL == fp)
|
||||||
error_message("cannot open file %s for writing\n", filename);
|
{
|
||||||
|
bt_id_error_message("cannot open file %s for writing\n", filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf(fp, "// to generate postscript file, run dot -Tps %s -o %s.ps\n"
|
fprintf(fp,
|
||||||
|
"// to generate postscript file, run dot -Tps %s -o %s.ps\n"
|
||||||
"// details see graphviz documentation at http://graphviz.org\n"
|
"// details see graphviz documentation at http://graphviz.org\n"
|
||||||
"digraph tree {\n",
|
"digraph tree {\n",
|
||||||
filename, filename);
|
filename, filename);
|
||||||
|
|
||||||
for (int body = 0; body < tree->numBodies(); body++) {
|
for (int body = 0; body < tree->numBodies(); body++)
|
||||||
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
if (0x0 != map) {
|
if (0x0 != map)
|
||||||
if (-1 == map->getBodyName(body, &name)) {
|
{
|
||||||
error_message("can't get name of body %d\n", body);
|
if (-1 == map->getBodyName(body, &name))
|
||||||
|
{
|
||||||
|
bt_id_error_message("can't get name of body %d\n", body);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fprintf(fp, " %d [label=\"%d/%s\"];\n", body, body, name.c_str());
|
fprintf(fp, " %d [label=\"%d/%s\"];\n", body, body, name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int body = 0; body < tree->numBodies(); body++) {
|
for (int body = 0; body < tree->numBodies(); body++)
|
||||||
|
{
|
||||||
int parent;
|
int parent;
|
||||||
const char* joint_type;
|
const char* joint_type;
|
||||||
int qi;
|
int qi;
|
||||||
if (-1 == tree->getParentIndex(body, &parent)) {
|
if (-1 == tree->getParentIndex(body, &parent))
|
||||||
error_message("indexing error\n");
|
{
|
||||||
|
bt_id_error_message("indexing error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (-1 == tree->getJointTypeStr(body, &joint_type)) {
|
if (-1 == tree->getJointTypeStr(body, &joint_type))
|
||||||
error_message("indexing error\n");
|
{
|
||||||
|
bt_id_error_message("indexing error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (-1 == tree->getDoFOffset(body, &qi)) {
|
if (-1 == tree->getDoFOffset(body, &qi))
|
||||||
error_message("indexing error\n");
|
{
|
||||||
|
bt_id_error_message("indexing error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (-1 != parent) {
|
if (-1 != parent)
|
||||||
|
{
|
||||||
fprintf(fp, " %d -> %d [label= \"type:%s, q=%d\"];\n", parent, body,
|
fprintf(fp, " %d -> %d [label= \"type:%s, q=%d\"];\n", parent, body,
|
||||||
joint_type, qi);
|
joint_type, qi);
|
||||||
}
|
}
|
||||||
|
|
@ -61,4 +74,4 @@ int writeGraphvizDotFile(const MultiBodyTree* tree, const MultiBodyNameMap* map,
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
#include "BulletInverseDynamics/MultiBodyTree.hpp"
|
#include "BulletInverseDynamics/MultiBodyTree.hpp"
|
||||||
#include "MultiBodyNameMap.hpp"
|
#include "MultiBodyNameMap.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// generate a dot-file of the multibody tree for generating a graph using graphviz' dot tool
|
/// generate a dot-file of the multibody tree for generating a graph using graphviz' dot tool
|
||||||
/// @param tree the multibody tree
|
/// @param tree the multibody tree
|
||||||
/// @param map to add names of links (if 0x0, no names will be added)
|
/// @param map to add names of links (if 0x0, no names will be added)
|
||||||
|
|
@ -12,6 +13,6 @@ namespace btInverseDynamics {
|
||||||
/// @return 0 on success, -1 on error
|
/// @return 0 on success, -1 on error
|
||||||
int writeGraphvizDotFile(const MultiBodyTree* tree, const MultiBodyNameMap* map,
|
int writeGraphvizDotFile(const MultiBodyTree* tree, const MultiBodyNameMap* map,
|
||||||
const char* filename);
|
const char* filename);
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
||||||
#endif // MULTIBODYTREEDEBUGGRAPH_HPP
|
#endif // MULTIBODYTREEDEBUGGRAPH_HPP
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,17 @@
|
||||||
|
|
||||||
#include "IDRandomUtil.hpp"
|
#include "IDRandomUtil.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
RandomTreeCreator::RandomTreeCreator(const int max_bodies, bool random_seed) {
|
RandomTreeCreator::RandomTreeCreator(const int max_bodies, bool random_seed)
|
||||||
|
{
|
||||||
// seed generator
|
// seed generator
|
||||||
if(random_seed) {
|
if (random_seed)
|
||||||
|
{
|
||||||
randomInit(); // seeds with time()
|
randomInit(); // seeds with time()
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
randomInit(1); // seeds with 1
|
randomInit(1); // seeds with 1
|
||||||
}
|
}
|
||||||
m_num_bodies = randomInt(1, max_bodies);
|
m_num_bodies = randomInt(1, max_bodies);
|
||||||
|
|
@ -18,7 +22,8 @@ RandomTreeCreator::RandomTreeCreator(const int max_bodies, bool random_seed) {
|
||||||
|
|
||||||
RandomTreeCreator::~RandomTreeCreator() {}
|
RandomTreeCreator::~RandomTreeCreator() {}
|
||||||
|
|
||||||
int RandomTreeCreator::getNumBodies(int* num_bodies) const {
|
int RandomTreeCreator::getNumBodies(int* num_bodies) const
|
||||||
|
{
|
||||||
*num_bodies = m_num_bodies;
|
*num_bodies = m_num_bodies;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -26,14 +31,19 @@ int RandomTreeCreator::getNumBodies(int* num_bodies) const {
|
||||||
int RandomTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
int RandomTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
||||||
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
||||||
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
||||||
mat33* body_I_body, int* user_int, void** user_ptr) const {
|
mat33* body_I_body, int* user_int, void** user_ptr) const
|
||||||
if(0 == body_index) { //root body
|
{
|
||||||
|
if (0 == body_index)
|
||||||
|
{ //root body
|
||||||
*parent_index = -1;
|
*parent_index = -1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*parent_index = randomInt(0, body_index - 1);
|
*parent_index = randomInt(0, body_index - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (randomInt(0, 3)) {
|
switch (randomInt(0, 3))
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
*joint_type = FIXED;
|
*joint_type = FIXED;
|
||||||
break;
|
break;
|
||||||
|
|
@ -47,7 +57,7 @@ int RandomTreeCreator::getBody(const int body_index, int* parent_index, JointTyp
|
||||||
*joint_type = FLOATING;
|
*joint_type = FLOATING;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_message("randomInt() result out of range\n");
|
bt_id_error_message("randomInt() result out of range\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,4 +88,4 @@ int RandomTreeCreator::getBody(const int body_index, int* parent_index, JointTyp
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@
|
||||||
#include "BulletInverseDynamics/IDConfig.hpp"
|
#include "BulletInverseDynamics/IDConfig.hpp"
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// Generate a random MultiBodyTree with fixed or floating base and fixed, prismatic or revolute
|
/// Generate a random MultiBodyTree with fixed or floating base and fixed, prismatic or revolute
|
||||||
/// joints
|
/// joints
|
||||||
/// Uses a pseudo random number generator seeded from a random device.
|
/// Uses a pseudo random number generator seeded from a random device.
|
||||||
class RandomTreeCreator : public MultiBodyTreeCreator {
|
class RandomTreeCreator : public MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor
|
/// ctor
|
||||||
/// @param max_bodies maximum number of bodies
|
/// @param max_bodies maximum number of bodies
|
||||||
|
|
@ -27,5 +29,5 @@ public:
|
||||||
private:
|
private:
|
||||||
int m_num_bodies;
|
int m_num_bodies;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif // RANDOMTREE_CREATOR_HPP_
|
#endif // RANDOMTREE_CREATOR_HPP_
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// minimal "tree" (chain)
|
/// minimal "tree" (chain)
|
||||||
SimpleTreeCreator::SimpleTreeCreator(int dim) : m_num_bodies(dim) {
|
SimpleTreeCreator::SimpleTreeCreator(int dim) : m_num_bodies(dim)
|
||||||
|
{
|
||||||
m_mass = 1.0;
|
m_mass = 1.0;
|
||||||
m_body_T_parent_ref(0, 0) = 1;
|
m_body_T_parent_ref(0, 0) = 1;
|
||||||
m_body_T_parent_ref(0, 1) = 0;
|
m_body_T_parent_ref(0, 1) = 0;
|
||||||
|
|
@ -38,7 +40,8 @@ SimpleTreeCreator::SimpleTreeCreator(int dim) : m_num_bodies(dim) {
|
||||||
m_axis(1) = 0;
|
m_axis(1) = 0;
|
||||||
m_axis(2) = 1;
|
m_axis(2) = 1;
|
||||||
}
|
}
|
||||||
int SimpleTreeCreator::getNumBodies(int* num_bodies) const {
|
int SimpleTreeCreator::getNumBodies(int* num_bodies) const
|
||||||
|
{
|
||||||
*num_bodies = m_num_bodies;
|
*num_bodies = m_num_bodies;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -46,15 +49,20 @@ int SimpleTreeCreator::getNumBodies(int* num_bodies) const {
|
||||||
int SimpleTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
int SimpleTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
|
||||||
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
|
||||||
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
|
||||||
mat33* body_I_body, int* user_int, void** user_ptr) const {
|
mat33* body_I_body, int* user_int, void** user_ptr) const
|
||||||
|
{
|
||||||
*parent_index = body_index - 1;
|
*parent_index = body_index - 1;
|
||||||
if (body_index % 2) {
|
if (body_index % 2)
|
||||||
|
{
|
||||||
*joint_type = PRISMATIC;
|
*joint_type = PRISMATIC;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*joint_type = REVOLUTE;
|
*joint_type = REVOLUTE;
|
||||||
}
|
}
|
||||||
*parent_r_parent_body_ref = m_parent_r_parent_body_ref;
|
*parent_r_parent_body_ref = m_parent_r_parent_body_ref;
|
||||||
if (0 == body_index) {
|
if (0 == body_index)
|
||||||
|
{
|
||||||
(*parent_r_parent_body_ref)(2) = 1.0;
|
(*parent_r_parent_body_ref)(2) = 1.0;
|
||||||
}
|
}
|
||||||
*body_T_parent_ref = m_body_T_parent_ref;
|
*body_T_parent_ref = m_body_T_parent_ref;
|
||||||
|
|
@ -66,4 +74,4 @@ int SimpleTreeCreator::getBody(const int body_index, int* parent_index, JointTyp
|
||||||
*user_ptr = 0;
|
*user_ptr = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
|
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// minimal "tree" (chain)
|
/// minimal "tree" (chain)
|
||||||
class SimpleTreeCreator : public MultiBodyTreeCreator {
|
class SimpleTreeCreator : public MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor
|
/// ctor
|
||||||
/// @param dim number of bodies
|
/// @param dim number of bodies
|
||||||
|
|
@ -30,5 +31,5 @@ private:
|
||||||
mat33 m_body_I_body;
|
mat33 m_body_I_body;
|
||||||
vec3 m_axis;
|
vec3 m_axis;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif // SIMPLETREECREATOR_HPP_
|
#endif // SIMPLETREECREATOR_HPP_
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,18 @@
|
||||||
#include "User2InternalIndex.hpp"
|
#include "User2InternalIndex.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
User2InternalIndex::User2InternalIndex() : m_map_built(false) {}
|
User2InternalIndex::User2InternalIndex() : m_map_built(false) {}
|
||||||
|
|
||||||
void User2InternalIndex::addBody(const int body, const int parent) {
|
void User2InternalIndex::addBody(const int body, const int parent)
|
||||||
|
{
|
||||||
m_user_parent_index_map[body] = parent;
|
m_user_parent_index_map[body] = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
int User2InternalIndex::findRoot(int index) {
|
int User2InternalIndex::findRoot(int index)
|
||||||
if (0 == m_user_parent_index_map.count(index)) {
|
{
|
||||||
|
if (0 == m_user_parent_index_map.count(index))
|
||||||
|
{
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
return findRoot(m_user_parent_index_map[index]);
|
return findRoot(m_user_parent_index_map[index]);
|
||||||
|
|
@ -17,25 +21,33 @@ int User2InternalIndex::findRoot(int index) {
|
||||||
// modelled after URDF2Bullet.cpp:void ComputeParentIndices(const
|
// modelled after URDF2Bullet.cpp:void ComputeParentIndices(const
|
||||||
// URDFImporterInterface& u2b, URDF2BulletCachedData& cache, int urdfLinkIndex,
|
// URDFImporterInterface& u2b, URDF2BulletCachedData& cache, int urdfLinkIndex,
|
||||||
// int urdfParentIndex)
|
// int urdfParentIndex)
|
||||||
void User2InternalIndex::recurseIndexSets(const int user_body_index) {
|
void User2InternalIndex::recurseIndexSets(const int user_body_index)
|
||||||
|
{
|
||||||
m_user_to_internal[user_body_index] = m_current_index;
|
m_user_to_internal[user_body_index] = m_current_index;
|
||||||
m_current_index++;
|
m_current_index++;
|
||||||
for (size_t i = 0; i < m_user_child_indices[user_body_index].size(); i++) {
|
for (size_t i = 0; i < m_user_child_indices[user_body_index].size(); i++)
|
||||||
|
{
|
||||||
recurseIndexSets(m_user_child_indices[user_body_index][i]);
|
recurseIndexSets(m_user_child_indices[user_body_index][i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int User2InternalIndex::buildMapping() {
|
int User2InternalIndex::buildMapping()
|
||||||
|
{
|
||||||
// find root index
|
// find root index
|
||||||
int user_root_index = -1;
|
int user_root_index = -1;
|
||||||
for (std::map<int, int>::iterator it = m_user_parent_index_map.begin();
|
for (std::map<int, int>::iterator it = m_user_parent_index_map.begin();
|
||||||
it != m_user_parent_index_map.end(); it++) {
|
it != m_user_parent_index_map.end(); it++)
|
||||||
|
{
|
||||||
int current_root_index = findRoot(it->second);
|
int current_root_index = findRoot(it->second);
|
||||||
if (it == m_user_parent_index_map.begin()) {
|
if (it == m_user_parent_index_map.begin())
|
||||||
|
{
|
||||||
user_root_index = current_root_index;
|
user_root_index = current_root_index;
|
||||||
} else {
|
}
|
||||||
if (user_root_index != current_root_index) {
|
else
|
||||||
error_message("multiple roots (at least) %d and %d\n", user_root_index,
|
{
|
||||||
|
if (user_root_index != current_root_index)
|
||||||
|
{
|
||||||
|
bt_id_error_message("multiple roots (at least) %d and %d\n", user_root_index,
|
||||||
current_root_index);
|
current_root_index);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +56,8 @@ int User2InternalIndex::buildMapping() {
|
||||||
|
|
||||||
// build child index map
|
// build child index map
|
||||||
for (std::map<int, int>::iterator it = m_user_parent_index_map.begin();
|
for (std::map<int, int>::iterator it = m_user_parent_index_map.begin();
|
||||||
it != m_user_parent_index_map.end(); it++) {
|
it != m_user_parent_index_map.end(); it++)
|
||||||
|
{
|
||||||
m_user_child_indices[it->second].push_back(it->first);
|
m_user_child_indices[it->second].push_back(it->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +68,8 @@ int User2InternalIndex::buildMapping() {
|
||||||
|
|
||||||
// reverse mapping
|
// reverse mapping
|
||||||
for (std::map<int, int>::iterator it = m_user_to_internal.begin();
|
for (std::map<int, int>::iterator it = m_user_to_internal.begin();
|
||||||
it != m_user_to_internal.end(); it++) {
|
it != m_user_to_internal.end(); it++)
|
||||||
|
{
|
||||||
m_internal_to_user[it->second] = it->first;
|
m_internal_to_user[it->second] = it->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,37 +77,45 @@ int User2InternalIndex::buildMapping() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int User2InternalIndex::user2internal(const int user, int *internal) const {
|
int User2InternalIndex::user2internal(const int user, int *internal) const
|
||||||
|
{
|
||||||
if (!m_map_built) {
|
if (!m_map_built)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, int>::const_iterator it;
|
std::map<int, int>::const_iterator it;
|
||||||
it = m_user_to_internal.find(user);
|
it = m_user_to_internal.find(user);
|
||||||
if (it != m_user_to_internal.end()) {
|
if (it != m_user_to_internal.end())
|
||||||
|
{
|
||||||
*internal = it->second;
|
*internal = it->second;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
error_message("no user index %d\n", user);
|
else
|
||||||
|
{
|
||||||
|
bt_id_error_message("no user index %d\n", user);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int User2InternalIndex::internal2user(const int internal, int *user) const {
|
int User2InternalIndex::internal2user(const int internal, int *user) const
|
||||||
|
{
|
||||||
if (!m_map_built) {
|
if (!m_map_built)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, int>::const_iterator it;
|
std::map<int, int>::const_iterator it;
|
||||||
it = m_internal_to_user.find(internal);
|
it = m_internal_to_user.find(internal);
|
||||||
if (it != m_internal_to_user.end()) {
|
if (it != m_internal_to_user.end())
|
||||||
|
{
|
||||||
*user = it->second;
|
*user = it->second;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
}
|
||||||
error_message("no internal index %d\n", internal);
|
else
|
||||||
|
{
|
||||||
|
bt_id_error_message("no internal index %d\n", internal);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,12 @@
|
||||||
|
|
||||||
#include "BulletInverseDynamics/IDConfig.hpp"
|
#include "BulletInverseDynamics/IDConfig.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// Convert arbitrary indexing scheme to internal indexing
|
/// Convert arbitrary indexing scheme to internal indexing
|
||||||
/// used for MultiBodyTree
|
/// used for MultiBodyTree
|
||||||
class User2InternalIndex {
|
class User2InternalIndex
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// Ctor
|
/// Ctor
|
||||||
User2InternalIndex();
|
User2InternalIndex();
|
||||||
|
|
@ -41,6 +42,6 @@ private:
|
||||||
std::map<int, std::vector<int> > m_user_child_indices;
|
std::map<int, std::vector<int> > m_user_child_indices;
|
||||||
int m_current_index;
|
int m_current_index;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
||||||
#endif // USER2INTERNALINDEX_HPP
|
#endif // USER2INTERNALINDEX_HPP
|
||||||
|
|
|
||||||
|
|
@ -11,26 +11,30 @@
|
||||||
#include "../../examples/Importers/ImportURDFDemo/URDF2Bullet.h"
|
#include "../../examples/Importers/ImportURDFDemo/URDF2Bullet.h"
|
||||||
#include "../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h"
|
#include "../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h"
|
||||||
#include "../../examples/Importers/ImportURDFDemo/URDF2Bullet.h"
|
#include "../../examples/Importers/ImportURDFDemo/URDF2Bullet.h"
|
||||||
|
#include "../../examples/Utils/b3BulletDefaultFileIO.h"
|
||||||
/// Create a btMultiBody model from URDF.
|
/// Create a btMultiBody model from URDF.
|
||||||
/// This is adapted from Bullet URDF loader example
|
/// This is adapted from Bullet URDF loader example
|
||||||
class MyBtMultiBodyFromURDF {
|
class MyBtMultiBodyFromURDF
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor
|
/// ctor
|
||||||
/// @param gravity gravitational acceleration (in world frame)
|
/// @param gravity gravitational acceleration (in world frame)
|
||||||
/// @param base_fixed if true, the root body is treated as fixed,
|
/// @param base_fixed if true, the root body is treated as fixed,
|
||||||
/// if false, it is treated as floating
|
/// if false, it is treated as floating
|
||||||
MyBtMultiBodyFromURDF(const btVector3 &gravity, const bool base_fixed)
|
MyBtMultiBodyFromURDF(const btVector3 &gravity, const bool base_fixed)
|
||||||
: m_gravity(gravity), m_base_fixed(base_fixed) {
|
: m_gravity(gravity), m_base_fixed(base_fixed)
|
||||||
|
{
|
||||||
m_broadphase = 0x0;
|
m_broadphase = 0x0;
|
||||||
m_dispatcher = 0x0;
|
m_dispatcher = 0x0;
|
||||||
m_solver = 0x0;
|
m_solver = 0x0;
|
||||||
m_collisionConfiguration = 0x0;
|
m_collisionConfiguration = 0x0;
|
||||||
m_dynamicsWorld = 0x0;
|
m_dynamicsWorld = 0x0;
|
||||||
m_multibody = 0x0;
|
m_multibody = 0x0;
|
||||||
|
m_flag = 0x0;
|
||||||
}
|
}
|
||||||
/// dtor
|
/// dtor
|
||||||
~MyBtMultiBodyFromURDF() {
|
~MyBtMultiBodyFromURDF()
|
||||||
|
{
|
||||||
delete m_dynamicsWorld;
|
delete m_dynamicsWorld;
|
||||||
delete m_solver;
|
delete m_solver;
|
||||||
delete m_broadphase;
|
delete m_broadphase;
|
||||||
|
|
@ -40,21 +44,25 @@ public:
|
||||||
}
|
}
|
||||||
/// @param name path to urdf file
|
/// @param name path to urdf file
|
||||||
void setFileName(const std::string name) { m_filename = name; }
|
void setFileName(const std::string name) { m_filename = name; }
|
||||||
|
void setFlag(int flag) { m_flag = flag; }
|
||||||
/// load urdf file and build btMultiBody model
|
/// load urdf file and build btMultiBody model
|
||||||
void init() {
|
void init()
|
||||||
|
{
|
||||||
this->createEmptyDynamicsWorld();
|
this->createEmptyDynamicsWorld();
|
||||||
m_dynamicsWorld->setGravity(m_gravity);
|
m_dynamicsWorld->setGravity(m_gravity);
|
||||||
BulletURDFImporter urdf_importer(&m_nogfx,0);
|
b3BulletDefaultFileIO fileIO;
|
||||||
|
BulletURDFImporter urdf_importer(&m_nogfx, 0, &fileIO, 1, 0);
|
||||||
URDFImporterInterface &u2b(urdf_importer);
|
URDFImporterInterface &u2b(urdf_importer);
|
||||||
bool loadOk = u2b.loadURDF(m_filename.c_str(), m_base_fixed);
|
bool loadOk = u2b.loadURDF(m_filename.c_str(), m_base_fixed);
|
||||||
|
|
||||||
if (loadOk) {
|
if (loadOk)
|
||||||
|
{
|
||||||
btTransform identityTrans;
|
btTransform identityTrans;
|
||||||
identityTrans.setIdentity();
|
identityTrans.setIdentity();
|
||||||
MyMultiBodyCreator creation(&m_nogfx);
|
MyMultiBodyCreator creation(&m_nogfx);
|
||||||
const bool use_multibody = true;
|
const bool use_multibody = true;
|
||||||
ConvertURDF2Bullet(u2b, creation, identityTrans, m_dynamicsWorld, use_multibody,
|
ConvertURDF2Bullet(u2b, creation, identityTrans, m_dynamicsWorld, use_multibody,
|
||||||
u2b.getPathPrefix());
|
u2b.getPathPrefix(), m_flag);
|
||||||
m_multibody = creation.getBulletMultiBody();
|
m_multibody = creation.getBulletMultiBody();
|
||||||
m_dynamicsWorld->stepSimulation(1. / 240., 0);
|
m_dynamicsWorld->stepSimulation(1. / 240., 0);
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +72,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// internal utility function
|
// internal utility function
|
||||||
void createEmptyDynamicsWorld() {
|
void createEmptyDynamicsWorld()
|
||||||
|
{
|
||||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||||
|
|
||||||
/// use the default collision dispatcher. For parallel processing you can use a diffent
|
/// use the default collision dispatcher. For parallel processing you can use a diffent
|
||||||
|
|
@ -87,5 +96,6 @@ private:
|
||||||
btMultiBody *m_multibody;
|
btMultiBody *m_multibody;
|
||||||
const btVector3 m_gravity;
|
const btVector3 m_gravity;
|
||||||
const bool m_base_fixed;
|
const bool m_base_fixed;
|
||||||
|
int m_flag;
|
||||||
};
|
};
|
||||||
#endif // BTMULTIBODYFROMURDF_HPP
|
#endif // BTMULTIBODYFROMURDF_HPP
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
#include "btMultiBodyTreeCreator.hpp"
|
#include "btMultiBodyTreeCreator.hpp"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
btMultiBodyTreeCreator::btMultiBodyTreeCreator() : m_initialized(false) {}
|
btMultiBodyTreeCreator::btMultiBodyTreeCreator() : m_initialized(false) {}
|
||||||
|
|
||||||
int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const bool verbose) {
|
int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const bool verbose)
|
||||||
if (0x0 == btmb) {
|
{
|
||||||
error_message("cannot create MultiBodyTree from null pointer\n");
|
if (0x0 == btmb)
|
||||||
|
{
|
||||||
|
bt_id_error_message("cannot create MultiBodyTree from null pointer\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,12 +24,17 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
LinkData &link = m_data[0];
|
LinkData &link = m_data[0];
|
||||||
|
|
||||||
link.parent_index = -1;
|
link.parent_index = -1;
|
||||||
if (btmb->hasFixedBase()) {
|
if (btmb->hasFixedBase())
|
||||||
|
{
|
||||||
link.joint_type = FIXED;
|
link.joint_type = FIXED;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
link.joint_type = FLOATING;
|
link.joint_type = FLOATING;
|
||||||
}
|
}
|
||||||
btTransform transform(btmb->getBaseWorldTransform());
|
btTransform transform = (btmb->getBaseWorldTransform());
|
||||||
|
//compute inverse dynamics in body-fixed frame
|
||||||
|
transform.setIdentity();
|
||||||
|
|
||||||
link.parent_r_parent_body_ref(0) = transform.getOrigin()[0];
|
link.parent_r_parent_body_ref(0) = transform.getOrigin()[0];
|
||||||
link.parent_r_parent_body_ref(1) = transform.getOrigin()[1];
|
link.parent_r_parent_body_ref(1) = transform.getOrigin()[1];
|
||||||
|
|
@ -68,8 +75,10 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
// shift reference point to link origin (in joint axis)
|
// shift reference point to link origin (in joint axis)
|
||||||
mat33 tilde_r_com = tildeOperator(link.body_r_body_com);
|
mat33 tilde_r_com = tildeOperator(link.body_r_body_com);
|
||||||
link.body_I_body = link.body_I_body - link.mass * tilde_r_com * tilde_r_com;
|
link.body_I_body = link.body_I_body - link.mass * tilde_r_com * tilde_r_com;
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
id_printf("base: mass= %f, bt_inertia= [%f %f %f]\n"
|
{
|
||||||
|
id_printf(
|
||||||
|
"base: mass= %f, bt_inertia= [%f %f %f]\n"
|
||||||
"Io= [%f %f %f;\n"
|
"Io= [%f %f %f;\n"
|
||||||
" %f %f %f;\n"
|
" %f %f %f;\n"
|
||||||
" %f %f %f]\n",
|
" %f %f %f]\n",
|
||||||
|
|
@ -81,8 +90,10 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int bt_index = 0; bt_index < btmb->getNumLinks(); bt_index++) {
|
for (int bt_index = 0; bt_index < btmb->getNumLinks(); bt_index++)
|
||||||
if (verbose) {
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
id_printf("bt->id: converting link %d\n", bt_index);
|
id_printf("bt->id: converting link %d\n", bt_index);
|
||||||
}
|
}
|
||||||
const btMultibodyLink &bt_link = btmb->getLink(bt_index);
|
const btMultibodyLink &bt_link = btmb->getLink(bt_index);
|
||||||
|
|
@ -91,14 +102,16 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
link.parent_index = bt_link.m_parent + 1;
|
link.parent_index = bt_link.m_parent + 1;
|
||||||
|
|
||||||
link.mass = bt_link.m_mass;
|
link.mass = bt_link.m_mass;
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
id_printf("mass= %f\n", link.mass);
|
id_printf("mass= %f\n", link.mass);
|
||||||
}
|
}
|
||||||
// from this body's pivot to this body's com in this body's frame
|
// from this body's pivot to this body's com in this body's frame
|
||||||
link.body_r_body_com[0] = bt_link.m_dVector[0];
|
link.body_r_body_com[0] = bt_link.m_dVector[0];
|
||||||
link.body_r_body_com[1] = bt_link.m_dVector[1];
|
link.body_r_body_com[1] = bt_link.m_dVector[1];
|
||||||
link.body_r_body_com[2] = bt_link.m_dVector[2];
|
link.body_r_body_com[2] = bt_link.m_dVector[2];
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
id_printf("com= %f %f %f\n", link.body_r_body_com[0], link.body_r_body_com[1],
|
id_printf("com= %f %f %f\n", link.body_r_body_com[0], link.body_r_body_com[1],
|
||||||
link.body_r_body_com[2]);
|
link.body_r_body_com[2]);
|
||||||
}
|
}
|
||||||
|
|
@ -116,8 +129,10 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
mat33 tilde_r_com = tildeOperator(link.body_r_body_com);
|
mat33 tilde_r_com = tildeOperator(link.body_r_body_com);
|
||||||
link.body_I_body = link.body_I_body - link.mass * tilde_r_com * tilde_r_com;
|
link.body_I_body = link.body_I_body - link.mass * tilde_r_com * tilde_r_com;
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
id_printf("link %d: mass= %f, bt_inertia= [%f %f %f]\n"
|
{
|
||||||
|
id_printf(
|
||||||
|
"link %d: mass= %f, bt_inertia= [%f %f %f]\n"
|
||||||
"Io= [%f %f %f;\n"
|
"Io= [%f %f %f;\n"
|
||||||
" %f %f %f;\n"
|
" %f %f %f;\n"
|
||||||
" %f %f %f]\n",
|
" %f %f %f]\n",
|
||||||
|
|
@ -138,17 +153,21 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
link.body_T_parent_ref(2, 0) = basis[2][0];
|
link.body_T_parent_ref(2, 0) = basis[2][0];
|
||||||
link.body_T_parent_ref(2, 1) = basis[2][1];
|
link.body_T_parent_ref(2, 1) = basis[2][1];
|
||||||
link.body_T_parent_ref(2, 2) = basis[2][2];
|
link.body_T_parent_ref(2, 2) = basis[2][2];
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
id_printf("body_T_parent_ref= %f %f %f\n"
|
{
|
||||||
|
id_printf(
|
||||||
|
"body_T_parent_ref= %f %f %f\n"
|
||||||
" %f %f %f\n"
|
" %f %f %f\n"
|
||||||
" %f %f %f\n",
|
" %f %f %f\n",
|
||||||
basis[0][0], basis[0][1], basis[0][2], basis[1][0], basis[1][1], basis[1][2],
|
basis[0][0], basis[0][1], basis[0][2], basis[1][0], basis[1][1], basis[1][2],
|
||||||
basis[2][0], basis[2][1], basis[2][2]);
|
basis[2][0], basis[2][1], basis[2][2]);
|
||||||
}
|
}
|
||||||
switch (bt_link.m_jointType) {
|
switch (bt_link.m_jointType)
|
||||||
|
{
|
||||||
case btMultibodyLink::eRevolute:
|
case btMultibodyLink::eRevolute:
|
||||||
link.joint_type = REVOLUTE;
|
link.joint_type = REVOLUTE;
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
id_printf("type= revolute\n");
|
id_printf("type= revolute\n");
|
||||||
}
|
}
|
||||||
link.body_axis_of_motion(0) = bt_link.m_axes[0].m_topVec[0];
|
link.body_axis_of_motion(0) = bt_link.m_axes[0].m_topVec[0];
|
||||||
|
|
@ -164,7 +183,8 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
break;
|
break;
|
||||||
case btMultibodyLink::ePrismatic:
|
case btMultibodyLink::ePrismatic:
|
||||||
link.joint_type = PRISMATIC;
|
link.joint_type = PRISMATIC;
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
id_printf("type= prismatic\n");
|
id_printf("type= prismatic\n");
|
||||||
}
|
}
|
||||||
link.body_axis_of_motion(0) = bt_link.m_axes[0].m_bottomVec[0];
|
link.body_axis_of_motion(0) = bt_link.m_axes[0].m_bottomVec[0];
|
||||||
|
|
@ -182,10 +202,17 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
link.parent_r_parent_body_ref(2) = bt_link.m_eVector[2];
|
link.parent_r_parent_body_ref(2) = bt_link.m_eVector[2];
|
||||||
break;
|
break;
|
||||||
case btMultibodyLink::eSpherical:
|
case btMultibodyLink::eSpherical:
|
||||||
error_message("spherical joints not implemented\n");
|
link.joint_type = SPHERICAL;
|
||||||
return -1;
|
link.parent_r_parent_body_ref(0) = bt_link.m_eVector[0];
|
||||||
|
link.parent_r_parent_body_ref(1) = bt_link.m_eVector[1];
|
||||||
|
link.parent_r_parent_body_ref(2) = bt_link.m_eVector[2];
|
||||||
|
// random unit vector
|
||||||
|
link.body_axis_of_motion(0) = 0;
|
||||||
|
link.body_axis_of_motion(1) = 1;
|
||||||
|
link.body_axis_of_motion(2) = 0;
|
||||||
|
break;
|
||||||
case btMultibodyLink::ePlanar:
|
case btMultibodyLink::ePlanar:
|
||||||
error_message("planar joints not implemented\n");
|
bt_id_error_message("planar joints not implemented\n");
|
||||||
return -1;
|
return -1;
|
||||||
case btMultibodyLink::eFixed:
|
case btMultibodyLink::eFixed:
|
||||||
link.joint_type = FIXED;
|
link.joint_type = FIXED;
|
||||||
|
|
@ -201,22 +228,26 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
link.parent_r_parent_body_ref(2) = bt_link.m_eVector[2];
|
link.parent_r_parent_body_ref(2) = bt_link.m_eVector[2];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error_message("unknown btMultiBody::eFeatherstoneJointType %d\n",
|
bt_id_error_message("unknown btMultiBody::eFeatherstoneJointType %d\n",
|
||||||
bt_link.m_jointType);
|
bt_link.m_jointType);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (link.parent_index > 0) { // parent body isn't the root
|
if (link.parent_index > 0)
|
||||||
|
{ // parent body isn't the root
|
||||||
const btMultibodyLink &bt_parent_link = btmb->getLink(link.parent_index - 1);
|
const btMultibodyLink &bt_parent_link = btmb->getLink(link.parent_index - 1);
|
||||||
// from parent pivot to parent com, in parent frame
|
// from parent pivot to parent com, in parent frame
|
||||||
link.parent_r_parent_body_ref(0) += bt_parent_link.m_dVector[0];
|
link.parent_r_parent_body_ref(0) += bt_parent_link.m_dVector[0];
|
||||||
link.parent_r_parent_body_ref(1) += bt_parent_link.m_dVector[1];
|
link.parent_r_parent_body_ref(1) += bt_parent_link.m_dVector[1];
|
||||||
link.parent_r_parent_body_ref(2) += bt_parent_link.m_dVector[2];
|
link.parent_r_parent_body_ref(2) += bt_parent_link.m_dVector[2];
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// parent is root body. btMultiBody only knows 6-DoF or 0-DoF root bodies,
|
// parent is root body. btMultiBody only knows 6-DoF or 0-DoF root bodies,
|
||||||
// whose link frame is in the CoM (ie, no notion of a pivot point)
|
// whose link frame is in the CoM (ie, no notion of a pivot point)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
id_printf("parent_r_parent_body_ref= %f %f %f\n", link.parent_r_parent_body_ref[0],
|
id_printf("parent_r_parent_body_ref= %f %f %f\n", link.parent_r_parent_body_ref[0],
|
||||||
link.parent_r_parent_body_ref[1], link.parent_r_parent_body_ref[2]);
|
link.parent_r_parent_body_ref[1], link.parent_r_parent_body_ref[2]);
|
||||||
}
|
}
|
||||||
|
|
@ -227,9 +258,11 @@ int btMultiBodyTreeCreator::createFromBtMultiBody(const btMultiBody *btmb, const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int btMultiBodyTreeCreator::getNumBodies(int *num_bodies) const {
|
int btMultiBodyTreeCreator::getNumBodies(int *num_bodies) const
|
||||||
if (false == m_initialized) {
|
{
|
||||||
error_message("btMultiBody not converted yet\n");
|
if (false == m_initialized)
|
||||||
|
{
|
||||||
|
bt_id_error_message("btMultiBody not converted yet\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,14 +274,17 @@ int btMultiBodyTreeCreator::getBody(const int body_index, int *parent_index, Joi
|
||||||
vec3 *parent_r_parent_body_ref, mat33 *body_T_parent_ref,
|
vec3 *parent_r_parent_body_ref, mat33 *body_T_parent_ref,
|
||||||
vec3 *body_axis_of_motion, idScalar *mass,
|
vec3 *body_axis_of_motion, idScalar *mass,
|
||||||
vec3 *body_r_body_com, mat33 *body_I_body, int *user_int,
|
vec3 *body_r_body_com, mat33 *body_I_body, int *user_int,
|
||||||
void **user_ptr) const {
|
void **user_ptr) const
|
||||||
if (false == m_initialized) {
|
{
|
||||||
error_message("MultiBodyTree not created yet\n");
|
if (false == m_initialized)
|
||||||
|
{
|
||||||
|
bt_id_error_message("MultiBodyTree not created yet\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body_index < 0 || body_index >= static_cast<int>(m_data.size())) {
|
if (body_index < 0 || body_index >= static_cast<int>(m_data.size()))
|
||||||
error_message("index out of range (got %d but only %zu bodies)\n", body_index,
|
{
|
||||||
|
bt_id_error_message("index out of range (got %d but only %zu bodies)\n", body_index,
|
||||||
m_data.size());
|
m_data.size());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -267,4 +303,4 @@ int btMultiBodyTreeCreator::getBody(const int body_index, int *parent_index, Joi
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,12 @@
|
||||||
#include "MultiBodyTreeCreator.hpp"
|
#include "MultiBodyTreeCreator.hpp"
|
||||||
#include "BulletDynamics/Featherstone/btMultiBody.h"
|
#include "BulletDynamics/Featherstone/btMultiBody.h"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
/// MultiBodyTreeCreator implementation for converting
|
/// MultiBodyTreeCreator implementation for converting
|
||||||
/// a btMultiBody forward dynamics model into a MultiBodyTree inverse dynamics model
|
/// a btMultiBody forward dynamics model into a MultiBodyTree inverse dynamics model
|
||||||
class btMultiBodyTreeCreator : public MultiBodyTreeCreator {
|
class btMultiBodyTreeCreator : public MultiBodyTreeCreator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/// ctor
|
/// ctor
|
||||||
btMultiBodyTreeCreator();
|
btMultiBodyTreeCreator();
|
||||||
|
|
@ -32,7 +33,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// internal struct holding data extracted from btMultiBody
|
// internal struct holding data extracted from btMultiBody
|
||||||
struct LinkData {
|
struct LinkData
|
||||||
|
{
|
||||||
int parent_index;
|
int parent_index;
|
||||||
JointType joint_type;
|
JointType joint_type;
|
||||||
vec3 parent_r_parent_body_ref;
|
vec3 parent_r_parent_body_ref;
|
||||||
|
|
@ -45,6 +47,6 @@ private:
|
||||||
idArray<LinkData>::type m_data;
|
idArray<LinkData>::type m_data;
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
};
|
};
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
||||||
#endif // BTMULTIBODYTREECREATOR_HPP_
|
#endif // BTMULTIBODYTREECREATOR_HPP_
|
||||||
|
|
|
||||||
|
|
@ -8,20 +8,25 @@
|
||||||
#include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h"
|
#include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h"
|
||||||
#include "BulletDynamics/Featherstone/btMultiBodyPoint2Point.h"
|
#include "BulletDynamics/Featherstone/btMultiBodyPoint2Point.h"
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &gravity, bool verbose,
|
int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &gravity, bool verbose,
|
||||||
btMultiBody *btmb, MultiBodyTree *id_tree, double *pos_error,
|
btMultiBody *btmb, MultiBodyTree *id_tree, double *pos_error,
|
||||||
double *acc_error) {
|
double *acc_error)
|
||||||
// call function and return -1 if it does, printing an error_message
|
{
|
||||||
|
// call function and return -1 if it does, printing an bt_id_error_message
|
||||||
#define RETURN_ON_FAILURE(x) \
|
#define RETURN_ON_FAILURE(x) \
|
||||||
do { \
|
do \
|
||||||
if (-1 == x) { \
|
{ \
|
||||||
error_message("calling " #x "\n"); \
|
if (-1 == x) \
|
||||||
|
{ \
|
||||||
|
bt_id_error_message("calling " #x "\n"); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("\n ===================================== \n");
|
printf("\n ===================================== \n");
|
||||||
}
|
}
|
||||||
vecx joint_forces(q.size());
|
vecx joint_forces(q.size());
|
||||||
|
|
@ -50,38 +55,48 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
|
|
||||||
// remaining links
|
// remaining links
|
||||||
int q_index;
|
int q_index;
|
||||||
if (btmb->hasFixedBase()) {
|
if (btmb->hasFixedBase())
|
||||||
|
{
|
||||||
q_index = 0;
|
q_index = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
q_index = 6;
|
q_index = 6;
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("bt:num_links= %d, num_dofs= %d\n", btmb->getNumLinks(), btmb->getNumDofs());
|
printf("bt:num_links= %d, num_dofs= %d\n", btmb->getNumLinks(), btmb->getNumDofs());
|
||||||
}
|
}
|
||||||
for (int l = 0; l < btmb->getNumLinks(); l++) {
|
for (int l = 0; l < btmb->getNumLinks(); l++)
|
||||||
|
{
|
||||||
const btMultibodyLink &link = btmb->getLink(l);
|
const btMultibodyLink &link = btmb->getLink(l);
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("link %d, pos_var_count= %d, dof_count= %d\n", l, link.m_posVarCount,
|
printf("link %d, pos_var_count= %d, dof_count= %d\n", l, link.m_posVarCount,
|
||||||
link.m_dofCount);
|
link.m_dofCount);
|
||||||
}
|
}
|
||||||
if (link.m_posVarCount == 1) {
|
if (link.m_posVarCount == 1)
|
||||||
|
{
|
||||||
btmb->setJointPosMultiDof(l, &q(q_index));
|
btmb->setJointPosMultiDof(l, &q(q_index));
|
||||||
btmb->setJointVelMultiDof(l, &u(q_index));
|
btmb->setJointVelMultiDof(l, &u(q_index));
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("set q[%d]= %f, u[%d]= %f\n", q_index, q(q_index), q_index, u(q_index));
|
printf("set q[%d]= %f, u[%d]= %f\n", q_index, q(q_index), q_index, u(q_index));
|
||||||
}
|
}
|
||||||
q_index++;
|
q_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sanity check
|
// sanity check
|
||||||
if (q_index != q.size()) {
|
if (q_index != q.size())
|
||||||
error_message("error in number of dofs for btMultibody and MultiBodyTree\n");
|
{
|
||||||
|
bt_id_error_message("error in number of dofs for btMultibody and MultiBodyTree\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// run inverse dynamics to determine joint_forces for given q, u, dot_u
|
// run inverse dynamics to determine joint_forces for given q, u, dot_u
|
||||||
if (-1 == id_tree->calculateInverseDynamics(q, u, dot_u, &joint_forces)) {
|
if (-1 == id_tree->calculateInverseDynamics(q, u, dot_u, &joint_forces))
|
||||||
error_message("calculating inverse dynamics\n");
|
{
|
||||||
|
bt_id_error_message("calculating inverse dynamics\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,9 +110,11 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
// apply gravity forces for btMultiBody model. Must be done manually.
|
// apply gravity forces for btMultiBody model. Must be done manually.
|
||||||
btmb->addBaseForce(btmb->getBaseMass() * gravity);
|
btmb->addBaseForce(btmb->getBaseMass() * gravity);
|
||||||
|
|
||||||
for (int link = 0; link < btmb->getNumLinks(); link++) {
|
for (int link = 0; link < btmb->getNumLinks(); link++)
|
||||||
|
{
|
||||||
btmb->addLinkForce(link, gravity * btmb->getLinkMass(link));
|
btmb->addLinkForce(link, gravity * btmb->getLinkMass(link));
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("link %d, applying gravity %f %f %f\n", link,
|
printf("link %d, applying gravity %f %f %f\n", link,
|
||||||
gravity[0] * btmb->getLinkMass(link), gravity[1] * btmb->getLinkMass(link),
|
gravity[0] * btmb->getLinkMass(link), gravity[1] * btmb->getLinkMass(link),
|
||||||
gravity[2] * btmb->getLinkMass(link));
|
gravity[2] * btmb->getLinkMass(link));
|
||||||
|
|
@ -105,9 +122,12 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply generalized forces
|
// apply generalized forces
|
||||||
if (btmb->hasFixedBase()) {
|
if (btmb->hasFixedBase())
|
||||||
|
{
|
||||||
q_index = 0;
|
q_index = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vec3 base_force;
|
vec3 base_force;
|
||||||
base_force(0) = joint_forces(3);
|
base_force(0) = joint_forces(3);
|
||||||
base_force(1) = joint_forces(4);
|
base_force(1) = joint_forces(4);
|
||||||
|
|
@ -120,7 +140,8 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
|
|
||||||
btmb->addBaseForce(world_T_base * base_force);
|
btmb->addBaseForce(world_T_base * base_force);
|
||||||
btmb->addBaseTorque(world_T_base * base_moment);
|
btmb->addBaseTorque(world_T_base * base_moment);
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("base force from id: %f %f %f\n", joint_forces(3), joint_forces(4),
|
printf("base force from id: %f %f %f\n", joint_forces(3), joint_forces(4),
|
||||||
joint_forces(5));
|
joint_forces(5));
|
||||||
printf("base moment from id: %f %f %f\n", joint_forces(0), joint_forces(1),
|
printf("base moment from id: %f %f %f\n", joint_forces(0), joint_forces(1),
|
||||||
|
|
@ -129,10 +150,13 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
q_index = 6;
|
q_index = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int l = 0; l < btmb->getNumLinks(); l++) {
|
for (int l = 0; l < btmb->getNumLinks(); l++)
|
||||||
|
{
|
||||||
const btMultibodyLink &link = btmb->getLink(l);
|
const btMultibodyLink &link = btmb->getLink(l);
|
||||||
if (link.m_posVarCount == 1) {
|
if (link.m_posVarCount == 1)
|
||||||
if (verbose) {
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
printf("id:joint_force[%d]= %f, applied to link %d\n", q_index,
|
printf("id:joint_force[%d]= %f, applied to link %d\n", q_index,
|
||||||
joint_forces(q_index), l);
|
joint_forces(q_index), l);
|
||||||
}
|
}
|
||||||
|
|
@ -142,8 +166,9 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (q_index != q.size()) {
|
if (q_index != q.size())
|
||||||
error_message("error in number of dofs for btMultibody and MultiBodyTree\n");
|
{
|
||||||
|
bt_id_error_message("error in number of dofs for btMultibody and MultiBodyTree\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +176,7 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
btAlignedObjectArray<btQuaternion> world_to_local;
|
btAlignedObjectArray<btQuaternion> world_to_local;
|
||||||
btAlignedObjectArray<btVector3> local_origin;
|
btAlignedObjectArray<btVector3> local_origin;
|
||||||
btmb->forwardKinematics(world_to_local, local_origin);
|
btmb->forwardKinematics(world_to_local, local_origin);
|
||||||
btmb->computeAccelerationsArticulatedBodyAlgorithmMultiDof(dt, scratch_r, scratch_v, scratch_m, isConstraintPass);
|
btmb->computeAccelerationsArticulatedBodyAlgorithmMultiDof(dt, scratch_r, scratch_v, scratch_m, isConstraintPass, false, false);
|
||||||
|
|
||||||
// read generalized accelerations back from btMultiBody
|
// read generalized accelerations back from btMultiBody
|
||||||
// the mapping from scratch variables to accelerations is taken from the implementation
|
// the mapping from scratch variables to accelerations is taken from the implementation
|
||||||
|
|
@ -160,21 +185,29 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
btScalar *joint_accel = base_accel + 6;
|
btScalar *joint_accel = base_accel + 6;
|
||||||
*acc_error = 0;
|
*acc_error = 0;
|
||||||
int dot_u_offset = 0;
|
int dot_u_offset = 0;
|
||||||
if (btmb->hasFixedBase()) {
|
if (btmb->hasFixedBase())
|
||||||
|
{
|
||||||
dot_u_offset = 0;
|
dot_u_offset = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
dot_u_offset = 6;
|
dot_u_offset = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true == btmb->hasFixedBase()) {
|
if (true == btmb->hasFixedBase())
|
||||||
for (int i = 0; i < btmb->getNumDofs(); i++) {
|
{
|
||||||
if (verbose) {
|
for (int i = 0; i < btmb->getNumDofs(); i++)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
printf("bt:ddot_q[%d]= %f, id:ddot_q= %e, diff= %e\n", i, joint_accel[i],
|
printf("bt:ddot_q[%d]= %f, id:ddot_q= %e, diff= %e\n", i, joint_accel[i],
|
||||||
dot_u(i + dot_u_offset), joint_accel[i] - dot_u(i));
|
dot_u(i + dot_u_offset), joint_accel[i] - dot_u(i));
|
||||||
}
|
}
|
||||||
*acc_error += std::pow(joint_accel[i] - dot_u(i + dot_u_offset), 2);
|
*acc_error += BT_ID_POW(joint_accel[i] - dot_u(i + dot_u_offset), 2);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vec3 base_dot_omega;
|
vec3 base_dot_omega;
|
||||||
vec3 world_dot_omega;
|
vec3 world_dot_omega;
|
||||||
world_dot_omega(0) = base_accel[0];
|
world_dot_omega(0) = base_accel[0];
|
||||||
|
|
@ -191,50 +224,61 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
world_ddot_com(2) = base_accel[5];
|
world_ddot_com(2) = base_accel[5];
|
||||||
base_ddot_com = world_T_base.transpose() * world_ddot_com;
|
base_ddot_com = world_T_base.transpose() * world_ddot_com;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++)
|
||||||
if (verbose) {
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
printf("bt::base_dot_omega(%d)= %e dot_u[%d]= %e, diff= %e\n", i, base_dot_omega(i),
|
printf("bt::base_dot_omega(%d)= %e dot_u[%d]= %e, diff= %e\n", i, base_dot_omega(i),
|
||||||
i, dot_u[i], base_dot_omega(i) - dot_u[i]);
|
i, dot_u[i], base_dot_omega(i) - dot_u[i]);
|
||||||
}
|
}
|
||||||
*acc_error += std::pow(base_dot_omega(i) - dot_u(i), 2);
|
*acc_error += BT_ID_POW(base_dot_omega(i) - dot_u(i), 2);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++)
|
||||||
if (verbose) {
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
printf("bt::base_ddot_com(%d)= %e dot_u[%d]= %e, diff= %e\n", i, base_ddot_com(i),
|
printf("bt::base_ddot_com(%d)= %e dot_u[%d]= %e, diff= %e\n", i, base_ddot_com(i),
|
||||||
i, dot_u[i + 3], base_ddot_com(i) - dot_u[i + 3]);
|
i, dot_u[i + 3], base_ddot_com(i) - dot_u[i + 3]);
|
||||||
}
|
}
|
||||||
*acc_error += std::pow(base_ddot_com(i) - dot_u(i + 3), 2);
|
*acc_error += BT_ID_POW(base_ddot_com(i) - dot_u(i + 3), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < btmb->getNumDofs(); i++) {
|
for (int i = 0; i < btmb->getNumDofs(); i++)
|
||||||
if (verbose) {
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
printf("bt:ddot_q[%d]= %f, id:ddot_q= %e, diff= %e\n", i, joint_accel[i],
|
printf("bt:ddot_q[%d]= %f, id:ddot_q= %e, diff= %e\n", i, joint_accel[i],
|
||||||
dot_u(i + 6), joint_accel[i] - dot_u(i + 6));
|
dot_u(i + 6), joint_accel[i] - dot_u(i + 6));
|
||||||
}
|
}
|
||||||
*acc_error += std::pow(joint_accel[i] - dot_u(i + 6), 2);
|
*acc_error += BT_ID_POW(joint_accel[i] - dot_u(i + 6), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*acc_error = std::sqrt(*acc_error);
|
*acc_error = std::sqrt(*acc_error);
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("======dynamics-err: %e\n", *acc_error);
|
printf("======dynamics-err: %e\n", *acc_error);
|
||||||
}
|
}
|
||||||
*pos_error = 0.0;
|
*pos_error = 0.0;
|
||||||
|
|
||||||
{
|
{
|
||||||
mat33 world_T_body;
|
mat33 world_T_body;
|
||||||
if (-1 == id_tree->getBodyTransform(0, &world_T_body)) {
|
if (-1 == id_tree->getBodyTransform(0, &world_T_body))
|
||||||
error_message("getting transform for body %d\n", 0);
|
{
|
||||||
|
bt_id_error_message("getting transform for body %d\n", 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
vec3 world_com;
|
vec3 world_com;
|
||||||
if (-1 == id_tree->getBodyCoM(0, &world_com)) {
|
if (-1 == id_tree->getBodyCoM(0, &world_com))
|
||||||
error_message("getting com for body %d\n", 0);
|
{
|
||||||
|
bt_id_error_message("getting com for body %d\n", 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("id:com: %f %f %f\n", world_com(0), world_com(1), world_com(2));
|
printf("id:com: %f %f %f\n", world_com(0), world_com(1), world_com(2));
|
||||||
|
|
||||||
printf("id:transform: %f %f %f\n"
|
printf(
|
||||||
|
"id:transform: %f %f %f\n"
|
||||||
" %f %f %f\n"
|
" %f %f %f\n"
|
||||||
" %f %f %f\n",
|
" %f %f %f\n",
|
||||||
world_T_body(0, 0), world_T_body(0, 1), world_T_body(0, 2), world_T_body(1, 0),
|
world_T_body(0, 0), world_T_body(0, 1), world_T_body(0, 2), world_T_body(1, 0),
|
||||||
|
|
@ -243,15 +287,18 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int l = 0; l < btmb->getNumLinks(); l++) {
|
for (int l = 0; l < btmb->getNumLinks(); l++)
|
||||||
|
{
|
||||||
const btMultibodyLink &bt_link = btmb->getLink(l);
|
const btMultibodyLink &bt_link = btmb->getLink(l);
|
||||||
|
|
||||||
vec3 bt_origin = bt_link.m_cachedWorldTransform.getOrigin();
|
vec3 bt_origin = bt_link.m_cachedWorldTransform.getOrigin();
|
||||||
mat33 bt_basis = bt_link.m_cachedWorldTransform.getBasis();
|
mat33 bt_basis = bt_link.m_cachedWorldTransform.getBasis();
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("------------- link %d\n", l + 1);
|
printf("------------- link %d\n", l + 1);
|
||||||
printf("bt:com: %f %f %f\n", bt_origin(0), bt_origin(1), bt_origin(2));
|
printf("bt:com: %f %f %f\n", bt_origin(0), bt_origin(1), bt_origin(2));
|
||||||
printf("bt:transform: %f %f %f\n"
|
printf(
|
||||||
|
"bt:transform: %f %f %f\n"
|
||||||
" %f %f %f\n"
|
" %f %f %f\n"
|
||||||
" %f %f %f\n",
|
" %f %f %f\n",
|
||||||
bt_basis(0, 0), bt_basis(0, 1), bt_basis(0, 2), bt_basis(1, 0), bt_basis(1, 1),
|
bt_basis(0, 0), bt_basis(0, 1), bt_basis(0, 2), bt_basis(1, 0), bt_basis(1, 1),
|
||||||
|
|
@ -260,18 +307,22 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
mat33 id_world_T_body;
|
mat33 id_world_T_body;
|
||||||
vec3 id_world_com;
|
vec3 id_world_com;
|
||||||
|
|
||||||
if (-1 == id_tree->getBodyTransform(l + 1, &id_world_T_body)) {
|
if (-1 == id_tree->getBodyTransform(l + 1, &id_world_T_body))
|
||||||
error_message("getting transform for body %d\n", l);
|
{
|
||||||
|
bt_id_error_message("getting transform for body %d\n", l);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (-1 == id_tree->getBodyCoM(l + 1, &id_world_com)) {
|
if (-1 == id_tree->getBodyCoM(l + 1, &id_world_com))
|
||||||
error_message("getting com for body %d\n", l);
|
{
|
||||||
|
bt_id_error_message("getting com for body %d\n", l);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("id:com: %f %f %f\n", id_world_com(0), id_world_com(1), id_world_com(2));
|
printf("id:com: %f %f %f\n", id_world_com(0), id_world_com(1), id_world_com(2));
|
||||||
|
|
||||||
printf("id:transform: %f %f %f\n"
|
printf(
|
||||||
|
"id:transform: %f %f %f\n"
|
||||||
" %f %f %f\n"
|
" %f %f %f\n"
|
||||||
" %f %f %f\n",
|
" %f %f %f\n",
|
||||||
id_world_T_body(0, 0), id_world_T_body(0, 1), id_world_T_body(0, 2),
|
id_world_T_body(0, 0), id_world_T_body(0, 1), id_world_T_body(0, 2),
|
||||||
|
|
@ -280,7 +331,8 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
}
|
}
|
||||||
vec3 diff_com = bt_origin - id_world_com;
|
vec3 diff_com = bt_origin - id_world_com;
|
||||||
mat33 diff_basis = bt_basis - id_world_T_body;
|
mat33 diff_basis = bt_basis - id_world_T_body;
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("diff-com: %e %e %e\n", diff_com(0), diff_com(1), diff_com(2));
|
printf("diff-com: %e %e %e\n", diff_com(0), diff_com(1), diff_com(2));
|
||||||
|
|
||||||
printf("diff-transform: %e %e %e %e %e %e %e %e %e\n", diff_basis(0, 0),
|
printf("diff-transform: %e %e %e %e %e %e %e %e %e\n", diff_basis(0, 0),
|
||||||
|
|
@ -288,20 +340,22 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
|
||||||
diff_basis(1, 2), diff_basis(2, 0), diff_basis(2, 1), diff_basis(2, 2));
|
diff_basis(1, 2), diff_basis(2, 0), diff_basis(2, 1), diff_basis(2, 2));
|
||||||
}
|
}
|
||||||
double total_pos_err =
|
double total_pos_err =
|
||||||
std::sqrt(std::pow(diff_com(0), 2) + std::pow(diff_com(1), 2) +
|
BT_ID_SQRT(BT_ID_POW(diff_com(0), 2) + BT_ID_POW(diff_com(1), 2) +
|
||||||
std::pow(diff_com(2), 2) + std::pow(diff_basis(0, 0), 2) +
|
BT_ID_POW(diff_com(2), 2) + BT_ID_POW(diff_basis(0, 0), 2) +
|
||||||
std::pow(diff_basis(0, 1), 2) + std::pow(diff_basis(0, 2), 2) +
|
BT_ID_POW(diff_basis(0, 1), 2) + BT_ID_POW(diff_basis(0, 2), 2) +
|
||||||
std::pow(diff_basis(1, 0), 2) + std::pow(diff_basis(1, 1), 2) +
|
BT_ID_POW(diff_basis(1, 0), 2) + BT_ID_POW(diff_basis(1, 1), 2) +
|
||||||
std::pow(diff_basis(1, 2), 2) + std::pow(diff_basis(2, 0), 2) +
|
BT_ID_POW(diff_basis(1, 2), 2) + BT_ID_POW(diff_basis(2, 0), 2) +
|
||||||
std::pow(diff_basis(2, 1), 2) + std::pow(diff_basis(2, 2), 2));
|
BT_ID_POW(diff_basis(2, 1), 2) + BT_ID_POW(diff_basis(2, 2), 2));
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("======kin-pos-err: %e\n", total_pos_err);
|
printf("======kin-pos-err: %e\n", total_pos_err);
|
||||||
}
|
}
|
||||||
if (total_pos_err > *pos_error) {
|
if (total_pos_err > *pos_error)
|
||||||
|
{
|
||||||
*pos_error = total_pos_err;
|
*pos_error = total_pos_err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
class btMultiBody;
|
class btMultiBody;
|
||||||
class btVector3;
|
class btVector3;
|
||||||
|
|
||||||
namespace btInverseDynamics {
|
namespace btInverseDynamics
|
||||||
|
{
|
||||||
class MultiBodyTree;
|
class MultiBodyTree;
|
||||||
|
|
||||||
/// this function compares the forward dynamics computations implemented in btMultiBody to
|
/// this function compares the forward dynamics computations implemented in btMultiBody to
|
||||||
|
|
@ -31,5 +32,5 @@ class MultiBodyTree;
|
||||||
int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &gravity, bool verbose,
|
int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &gravity, bool verbose,
|
||||||
btMultiBody *btmb, MultiBodyTree *id_tree, double *pos_error,
|
btMultiBody *btmb, MultiBodyTree *id_tree, double *pos_error,
|
||||||
double *acc_error);
|
double *acc_error);
|
||||||
}
|
} // namespace btInverseDynamics
|
||||||
#endif // INVDYN_BULLET_COMPARISON_HPP
|
#endif // INVDYN_BULLET_COMPARISON_HPP
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
"../../src"
|
"../../src"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.is("Linux") then
|
||||||
|
buildoptions{"-fPIC"}
|
||||||
|
end
|
||||||
files {
|
files {
|
||||||
"*.cpp",
|
"*.cpp",
|
||||||
"*.hpp"
|
"*.hpp"
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ extern int DNAlen;
|
||||||
extern unsigned char DNAstr64[];
|
extern unsigned char DNAstr64[];
|
||||||
extern int DNAlen64;
|
extern int DNAlen64;
|
||||||
|
|
||||||
|
|
||||||
using namespace bParse;
|
using namespace bParse;
|
||||||
|
|
||||||
bBlenderFile::bBlenderFile(const char *fileName)
|
bBlenderFile::bBlenderFile(const char *fileName)
|
||||||
|
|
@ -36,8 +35,6 @@ bBlenderFile::bBlenderFile(const char* fileName)
|
||||||
mMain = new bMain(this, fileName, mVersion);
|
mMain = new bMain(this, fileName, mVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bBlenderFile::bBlenderFile(char *memoryBuffer, int len)
|
bBlenderFile::bBlenderFile(char *memoryBuffer, int len)
|
||||||
: bFile(memoryBuffer, len, "BLENDER"),
|
: bFile(memoryBuffer, len, "BLENDER"),
|
||||||
mMain(0)
|
mMain(0)
|
||||||
|
|
@ -45,13 +42,11 @@ mMain(0)
|
||||||
mMain = new bMain(this, "memoryBuf", mVersion);
|
mMain = new bMain(this, "memoryBuf", mVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bBlenderFile::~bBlenderFile()
|
bBlenderFile::~bBlenderFile()
|
||||||
{
|
{
|
||||||
delete mMain;
|
delete mMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bMain *bBlenderFile::getMain()
|
bMain *bBlenderFile::getMain()
|
||||||
{
|
{
|
||||||
return mMain;
|
return mMain;
|
||||||
|
|
@ -66,14 +61,11 @@ void bBlenderFile::parseData()
|
||||||
|
|
||||||
const bool swap = (mFlags & FD_ENDIAN_SWAP) != 0;
|
const bool swap = (mFlags & FD_ENDIAN_SWAP) != 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *dataPtr = mFileBuffer + mDataStart;
|
char *dataPtr = mFileBuffer + mDataStart;
|
||||||
|
|
||||||
bChunkInd dataChunk;
|
bChunkInd dataChunk;
|
||||||
dataChunk.code = 0;
|
dataChunk.code = 0;
|
||||||
|
|
||||||
|
|
||||||
//dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags);
|
//dataPtr += ChunkUtils::getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||||
int seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
int seek = getNextBlock(&dataChunk, dataPtr, mFlags);
|
||||||
//dataPtr += ChunkUtils::getOffset(mFlags);
|
//dataPtr += ChunkUtils::getOffset(mFlags);
|
||||||
|
|
@ -81,10 +73,6 @@ void bBlenderFile::parseData()
|
||||||
|
|
||||||
while (dataChunk.code != DNA1)
|
while (dataChunk.code != DNA1)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// one behind
|
// one behind
|
||||||
if (dataChunk.code == SDNA) break;
|
if (dataChunk.code == SDNA) break;
|
||||||
//if (dataChunk.code == DNA1) break;
|
//if (dataChunk.code == DNA1) break;
|
||||||
|
|
@ -118,7 +106,6 @@ void bBlenderFile::parseData()
|
||||||
if (seek < 0)
|
if (seek < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bBlenderFile::addDataBlock(char *dataBlock)
|
void bBlenderFile::addDataBlock(char *dataBlock)
|
||||||
|
|
@ -126,10 +113,6 @@ void bBlenderFile::addDataBlock(char* dataBlock)
|
||||||
mMain->addDatablock(dataBlock);
|
mMain->addDatablock(dataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 32 && 64 bit versions
|
// 32 && 64 bit versions
|
||||||
extern unsigned char DNAstr[];
|
extern unsigned char DNAstr[];
|
||||||
extern int DNAlen;
|
extern int DNAlen;
|
||||||
|
|
@ -137,14 +120,11 @@ extern int DNAlen;
|
||||||
//unsigned char DNAstr[]={0};
|
//unsigned char DNAstr[]={0};
|
||||||
//int DNAlen=0;
|
//int DNAlen=0;
|
||||||
|
|
||||||
|
|
||||||
extern unsigned char DNAstr64[];
|
extern unsigned char DNAstr64[];
|
||||||
extern int DNAlen64;
|
extern int DNAlen64;
|
||||||
|
|
||||||
|
|
||||||
void bBlenderFile::writeDNA(FILE *fp)
|
void bBlenderFile::writeDNA(FILE *fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
bChunkInd dataChunk;
|
bChunkInd dataChunk;
|
||||||
dataChunk.code = DNA1;
|
dataChunk.code = DNA1;
|
||||||
dataChunk.dna_nr = 0;
|
dataChunk.dna_nr = 0;
|
||||||
|
|
@ -192,14 +172,16 @@ int bBlenderFile::write(const char* fileName, bool fixupPointers)
|
||||||
if (endian)
|
if (endian)
|
||||||
{
|
{
|
||||||
header[7] = '_';
|
header[7] = '_';
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
header[7] = '-';
|
header[7] = '-';
|
||||||
}
|
}
|
||||||
if (VOID_IS_8)
|
if (VOID_IS_8)
|
||||||
{
|
{
|
||||||
header[8] = 'V';
|
header[8] = 'V';
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
header[8] = 'v';
|
header[8] = 'v';
|
||||||
}
|
}
|
||||||
|
|
@ -215,8 +197,8 @@ int bBlenderFile::write(const char* fileName, bool fixupPointers)
|
||||||
writeDNA(fp);
|
writeDNA(fp);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
printf("Error: cannot open file %s for writing\n", fileName);
|
printf("Error: cannot open file %s for writing\n", fileName);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -16,23 +16,19 @@ subject to the following restrictions:
|
||||||
#ifndef B_BLENDER_FILE_H
|
#ifndef B_BLENDER_FILE_H
|
||||||
#define B_BLENDER_FILE_H
|
#define B_BLENDER_FILE_H
|
||||||
|
|
||||||
|
|
||||||
#include "bFile.h"
|
#include "bFile.h"
|
||||||
|
|
||||||
namespace bParse {
|
namespace bParse
|
||||||
|
{
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
class bBlenderFile : public bFile
|
class bBlenderFile : public bFile
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bMain* mMain;
|
bMain* mMain;
|
||||||
|
|
||||||
bStructHandle* m_glob;
|
bStructHandle* m_glob;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bBlenderFile(const char* fileName);
|
bBlenderFile(const char* fileName);
|
||||||
|
|
||||||
bBlenderFile(char* memoryBuffer, int len);
|
bBlenderFile(char* memoryBuffer, int len);
|
||||||
|
|
@ -56,8 +52,7 @@ namespace bParse {
|
||||||
virtual void parseData();
|
virtual void parseData();
|
||||||
|
|
||||||
virtual void writeDNA(FILE* fp);
|
virtual void writeDNA(FILE* fp);
|
||||||
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
}; // namespace bParse
|
||||||
|
|
||||||
#endif //B_BLENDER_FILE_H
|
#endif //B_BLENDER_FILE_H
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ subject to the following restrictions:
|
||||||
|
|
||||||
using namespace bParse;
|
using namespace bParse;
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
bMain::bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion)
|
bMain::bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion)
|
||||||
: mFP(filePtr),
|
: mFP(filePtr),
|
||||||
|
|
@ -56,7 +55,6 @@ bMain::bMain(bBlenderFile *filePtr, const char *baseName, int fileVersion)
|
||||||
mData.insert(ID_SCRIPT, bListBasePtr());
|
mData.insert(ID_SCRIPT, bListBasePtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
bMain::~bMain()
|
bMain::~bMain()
|
||||||
{
|
{
|
||||||
|
|
@ -88,13 +86,9 @@ void bMain::addDatablock(void *allocated)
|
||||||
mPool.push_back((bStructHandle *)allocated);
|
mPool.push_back((bStructHandle *)allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
void bMain::linkList(void *listBasePtr)
|
void bMain::linkList(void *listBasePtr)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ListBase // local Blender::ListBase
|
struct ListBase // local Blender::ListBase
|
||||||
{
|
{
|
||||||
void *first;
|
void *first;
|
||||||
|
|
@ -107,7 +101,6 @@ void bMain::linkList(void *listBasePtr)
|
||||||
void *prev;
|
void *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ListBase *base = (ListBase *)listBasePtr;
|
ListBase *base = (ListBase *)listBasePtr;
|
||||||
|
|
||||||
if (!base || !base->first)
|
if (!base || !base->first)
|
||||||
|
|
@ -143,12 +136,10 @@ bListBasePtr* bMain::getListBasePtr(int listBaseCode)
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
bListBasePtr *bMain::_findCode(int code)
|
bListBasePtr *bMain::_findCode(int code)
|
||||||
{
|
{
|
||||||
|
|
||||||
bListBasePtr *lbPtr = mData.find(code);
|
bListBasePtr *lbPtr = mData.find(code);
|
||||||
return lbPtr;
|
return lbPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
bListBasePtr *bMain::getScene()
|
bListBasePtr *bMain::getScene()
|
||||||
{
|
{
|
||||||
|
|
@ -193,8 +184,6 @@ bListBasePtr *bMain::getCurve()
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
bListBasePtr *bMain::getMball()
|
bListBasePtr *bMain::getMball()
|
||||||
{
|
{
|
||||||
|
|
@ -222,7 +211,6 @@ bListBasePtr *bMain::getTex()
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
bListBasePtr *bMain::getImage()
|
bListBasePtr *bMain::getImage()
|
||||||
{
|
{
|
||||||
|
|
@ -295,7 +283,6 @@ bListBasePtr *bMain::getWorld()
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
bListBasePtr *bMain::getScreen()
|
bListBasePtr *bMain::getScreen()
|
||||||
{
|
{
|
||||||
|
|
@ -368,7 +355,6 @@ bListBasePtr *bMain::getAction()
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------//
|
// ------------------------------------------------------------//
|
||||||
bListBasePtr *bMain::getNodetree()
|
bListBasePtr *bMain::getNodetree()
|
||||||
{
|
{
|
||||||
|
|
@ -387,6 +373,4 @@ bListBasePtr *bMain::getBrush()
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//eof
|
//eof
|
||||||
|
|
|
||||||
|
|
@ -20,25 +20,19 @@ subject to the following restrictions:
|
||||||
#include "bChunk.h"
|
#include "bChunk.h"
|
||||||
#include "LinearMath/btHashMap.h"
|
#include "LinearMath/btHashMap.h"
|
||||||
|
|
||||||
|
|
||||||
namespace bParse
|
namespace bParse
|
||||||
{
|
{
|
||||||
class bDNA;
|
class bDNA;
|
||||||
|
|
||||||
class bBlenderFile;
|
class bBlenderFile;
|
||||||
};
|
}; // namespace bParse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace bParse {
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace bParse
|
||||||
|
{
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
|
|
||||||
typedef btHashMap<btHashInt, bListBasePtr> bMainDataMap;
|
typedef btHashMap<btHashInt, bListBasePtr> bMainDataMap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------- //
|
// ----------------------------------------------------- //
|
||||||
class bMain
|
class bMain
|
||||||
{
|
{
|
||||||
|
|
@ -52,9 +46,6 @@ namespace bParse {
|
||||||
|
|
||||||
bMainDataMap mData;
|
bMainDataMap mData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bListBasePtr *_findCode(int code);
|
bListBasePtr *_findCode(int code);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -66,7 +57,6 @@ namespace bParse {
|
||||||
|
|
||||||
bListBasePtr *getListBasePtr(int listBaseCode);
|
bListBasePtr *getListBasePtr(int listBaseCode);
|
||||||
|
|
||||||
|
|
||||||
bListBasePtr *getScene();
|
bListBasePtr *getScene();
|
||||||
bListBasePtr *getLibrary();
|
bListBasePtr *getLibrary();
|
||||||
bListBasePtr *getObject();
|
bListBasePtr *getObject();
|
||||||
|
|
@ -94,17 +84,13 @@ namespace bParse {
|
||||||
bListBasePtr *getNodetree();
|
bListBasePtr *getNodetree();
|
||||||
bListBasePtr *getBrush();
|
bListBasePtr *getBrush();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// tracking allocated memory
|
// tracking allocated memory
|
||||||
void addDatablock(void *allocated);
|
void addDatablock(void *allocated);
|
||||||
|
|
||||||
|
|
||||||
// --
|
// --
|
||||||
|
|
||||||
void linkList(void *listBasePtr);
|
void linkList(void *listBasePtr);
|
||||||
};
|
};
|
||||||
}
|
} // namespace bParse
|
||||||
|
|
||||||
|
|
||||||
#endif //__BMAIN_H__
|
#endif //__BMAIN_H__
|
||||||
|
|
|
||||||
|
|
@ -1406,6 +1406,5 @@ unsigned char DNAstr64[]= {
|
||||||
0, 20, 0, 98, 1, 5, 0, 98, 1, 0, 0, 98, 1, 1, 0, 12, 0, 111, 9, 4, 0, 112, 9, 4, 0, 20, 0, 99, 1, 9, 0, 99,
|
0, 20, 0, 98, 1, 5, 0, 98, 1, 0, 0, 98, 1, 1, 0, 12, 0, 111, 9, 4, 0, 112, 9, 4, 0, 20, 0, 99, 1, 9, 0, 99,
|
||||||
1, 0, 0, 99, 1, 1, 0, 12, 0, -128, 0, 98, 1, 113, 9, 4, 0, 20, 0, 2, 0, 110, 9, 2, 0, 114, 9, 7, 0, 94, 0, 0,
|
1, 0, 0, 99, 1, 1, 0, 12, 0, -128, 0, 98, 1, 113, 9, 4, 0, 20, 0, 2, 0, 110, 9, 2, 0, 114, 9, 7, 0, 94, 0, 0,
|
||||||
0, 115, 9, -70, 0, 5, 0, 12, 0, 125, 4, 4, 0, 20, 0, 2, 0, 116, 9, 2, 0, 117, 9, 9, 0, 118, 9, 69, 78, 68, 66, 0,
|
0, 115, 9, -70, 0, 5, 0, 12, 0, 125, 4, 4, 0, 20, 0, 2, 0, 116, 9, 2, 0, 117, 9, 9, 0, 118, 9, 69, 78, 68, 66, 0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
};
|
|
||||||
int DNAlen64 = sizeof(DNAstr64);
|
int DNAlen64 = sizeof(DNAstr64);
|
||||||
|
|
|
||||||
|
|
@ -1406,6 +1406,5 @@ unsigned char DNAstr[]= {
|
||||||
0, 20, 0, 98, 1, 5, 0, 98, 1, 0, 0, 98, 1, 1, 0, 12, 0, 111, 9, 4, 0, 112, 9, 4, 0, 20, 0, 99, 1, 9, 0, 99,
|
0, 20, 0, 98, 1, 5, 0, 98, 1, 0, 0, 98, 1, 1, 0, 12, 0, 111, 9, 4, 0, 112, 9, 4, 0, 20, 0, 99, 1, 9, 0, 99,
|
||||||
1, 0, 0, 99, 1, 1, 0, 12, 0, -128, 0, 98, 1, 113, 9, 4, 0, 20, 0, 2, 0, 110, 9, 2, 0, 114, 9, 7, 0, 94, 0, 0,
|
1, 0, 0, 99, 1, 1, 0, 12, 0, -128, 0, 98, 1, 113, 9, 4, 0, 20, 0, 2, 0, 110, 9, 2, 0, 114, 9, 7, 0, 94, 0, 0,
|
||||||
0, 115, 9, -70, 0, 5, 0, 12, 0, 125, 4, 4, 0, 20, 0, 2, 0, 116, 9, 2, 0, 117, 9, 9, 0, 118, 9, 69, 78, 68, 66, 0,
|
0, 115, 9, -70, 0, 5, 0, 12, 0, 125, 4, 4, 0, 20, 0, 2, 0, 116, 9, 2, 0, 117, 9, 9, 0, 118, 9, 69, 78, 68, 66, 0,
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
};
|
|
||||||
int DNAlen = sizeof(DNAstr);
|
int DNAlen = sizeof(DNAstr);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue