Compare commits
349 Commits
tmp-pointc
...
modifier-p
Author | SHA1 | Date | |
---|---|---|---|
13de8b171e | |||
fcbd53c3b0 | |||
9e76a641af | |||
5ecc239c0a | |||
b6764b9a31 | |||
76e9cdc90a | |||
8a971c9d91 | |||
09feff781c | |||
fb7cc1d275 | |||
0e18ea5b9c | |||
e7076c6d95 | |||
7961d27fdf | |||
bda924385f | |||
8eca2b4a1b | |||
686eaad84c | |||
5094397dab | |||
e57458470d | |||
dde592e622 | |||
1d8b4e4023 | |||
8b9ae6bc91 | |||
56e40dd168 | |||
e0efec00db | |||
d91adcf8b7 | |||
60a14bd8ef | |||
eefbd92981 | |||
6e577f8236 | |||
d86e97c757 | |||
49a5422500 | |||
deef89c17c | |||
1359bd34ce | |||
9063269462 | |||
1784982498 | |||
c14878923b | |||
cbc380d252 | |||
caae7fe9ef | |||
cf261540e6 | |||
7969a3384e | |||
bedf3550b1 | |||
a9e822484c | |||
d1b2dd6492 | |||
e8d028c0af | |||
6d3af8e647 | |||
37b3f18fec | |||
6a32b744b4 | |||
c7bc1e7778 | |||
9867d84628 | |||
6222f6a22c | |||
2e4d8aea50 | |||
75d676a089 | |||
d8f9baa063 | |||
342ef4e678 | |||
81b7dbc0a7 | |||
deed16e4b6 | |||
ab6afef863 | |||
17f03611ac | |||
91877e71df | |||
917d7a6cea | |||
29d40872c3 | |||
2beed7cbf7 | |||
ecb4861a78 | |||
b13e9f8147 | |||
7a2cd6f14b | |||
42cbeca9ec | |||
f33ed9b0b4 | |||
481315be8b | |||
b7cd5ffe84 | |||
71962eb62e | |||
2c88153ba6 | |||
d4de4ae278 | |||
a41c86bdce | |||
1de1dc4fe4 | |||
07237c9b7f | |||
1429fc674d | |||
c62aa8c0e7 | |||
4469d44ea2 | |||
02036767f2 | |||
d30f334e9b | |||
405180192a | |||
098b43769e | |||
faed15c2be | |||
2ba8002b36 | |||
57e8e174ff | |||
c5aa7f2c6e | |||
cf87438414 | |||
ec07b2f496 | |||
da0f59f55a | |||
6d49335137 | |||
391b4dfd37 | |||
33edd753dc | |||
57fc9ef717 | |||
8ef0a9fdea | |||
4464b99465 | |||
854461002c | |||
eac08d6562 | |||
c055fbf557 | |||
24da365d1c | |||
4f1aa83683 | |||
65ab18bc59 | |||
2972b185a5 | |||
45e46267a8 | |||
2000c3ed7a | |||
f9744e1153 | |||
f45d7e3fee | |||
e55a870430 | |||
25898b9799 | |||
4571ea1bdd | |||
5c19f23635 | |||
1fb95a08f9 | |||
07c55e2543 | |||
2c34d44d28 | |||
e9d8259d13 | |||
c4cbb499d5 | |||
a7e3bbabd2 | |||
726585cb37 | |||
6c05aa60c4 | |||
4c7c8efd0b | |||
909d497107 | |||
39555526ae | |||
d882ec322a | |||
7229f9a99e | |||
20da3ae1c5 | |||
a81b558d48 | |||
18cc24ded7 | |||
b3f7eb4a07 | |||
80446f237b | |||
b5a46211f4 | |||
f12a66817d | |||
f787b7f1ca | |||
aa369d9e4f | |||
f4636b0965 | |||
c45e1ef21b | |||
d9f542bbb0 | |||
94fb309372 | |||
dec9349a75 | |||
110c148773 | |||
3aef74bc1f | |||
6fa3e4151e | |||
e8a6759c1d | |||
1a2bca63ef | |||
54ac90625f | |||
460318257c | |||
330300659c | |||
bd5f7f7429 | |||
84eb739a0e | |||
55a385620e | |||
e46f4a7e45 | |||
ac943796d4 | |||
87ef42419d | |||
66eee8ca6e | |||
187c65becb | |||
bc252b3b1a | |||
bdeb0c310b | |||
6b44e0e71a | |||
86309bd7f8 | |||
04111faf67 | |||
38031a4a24 | |||
d83b93c1e1 | |||
df7407e451 | |||
![]() |
1d4411d1fd | ||
16a350cd49 | |||
a22a7f78a4 | |||
47b85fb664 | |||
e7fcfe7d64 | |||
6fe7bb5754 | |||
5ede1bea5e | |||
cc24695be7 | |||
ce8808ec07 | |||
b36e8b0d55 | |||
352b72791a | |||
c9feac0afb | |||
77a8f89a50 | |||
![]() |
2909c0e56f | ||
![]() |
02caa87e52 | ||
4bbfa924ad | |||
7f9131bcc5 | |||
4566f08679 | |||
25f854552e | |||
c392903942 | |||
01ef0eba9a | |||
3679a1f601 | |||
f8b6a2faad | |||
062d7c8e96 | |||
b05dadea6b | |||
b39e9bfca0 | |||
7a9aa8ad27 | |||
b2a4eb75ab | |||
202bdf1e99 | |||
57cbedf602 | |||
759da271df | |||
1e7e94588d | |||
00b45c3dce | |||
0af8fcee76 | |||
0dc1873477 | |||
17db2e69e9 | |||
93f8363516 | |||
9ced07fa76 | |||
c3475ebe61 | |||
e654a7d67f | |||
d191723756 | |||
c9fd25b070 | |||
1ac55cad30 | |||
966431c2dc | |||
5588497639 | |||
fbe9ee62cd | |||
3e43c5f2cc | |||
5b14027f54 | |||
8383fc55d5 | |||
482334aa98 | |||
7447c2ecaf | |||
d91078bb6e | |||
915fd3d088 | |||
338232c294 | |||
5eac872627 | |||
adad62e8d6 | |||
1035184c15 | |||
f3a2f735a2 | |||
a284ac3213 | |||
c128c65345 | |||
cdb0449e91 | |||
7fb4010137 | |||
513de8eaf6 | |||
db06fd9a01 | |||
2c19926cc2 | |||
01900f5e6c | |||
7714746e5c | |||
ce54157417 | |||
d20886e98d | |||
dfc62af147 | |||
a8036cc2a1 | |||
ac01b80221 | |||
191a565600 | |||
1651a5e52c | |||
24dfb057bd | |||
2fecab55f9 | |||
50154a52cb | |||
e60ad2867a | |||
4f5c607622 | |||
31690ad463 | |||
0f95127d1a | |||
5bf61c9d74 | |||
26b9436975 | |||
61dafc1afb | |||
6fb4816956 | |||
0c927243d0 | |||
5e0b359ac5 | |||
3b0f241e72 | |||
5a33f291f4 | |||
9d1c9e86c4 | |||
fc4d2d1e16 | |||
f8347075d0 | |||
184dbb396d | |||
fb58cc8dc9 | |||
824f80a5d7 | |||
e4043bb908 | |||
40dbb7fc31 | |||
1974b5b903 | |||
c5500b6af8 | |||
27717c5d0a | |||
bbeb31f4ce | |||
820350ac80 | |||
18f1d80a6c | |||
4884d9cd52 | |||
beeb650940 | |||
0dcc4fd780 | |||
6c655d6a50 | |||
014a575129 | |||
7cca282052 | |||
1e889f2705 | |||
45b6f746a3 | |||
dd723f5f89 | |||
8d2128009d | |||
bcf9daf155 | |||
cdfd743c93 | |||
2692ec06d1 | |||
105b0b7f6a | |||
babb028b84 | |||
1f669db7ae | |||
5071288adb | |||
53a3e88175 | |||
f2792cff11 | |||
63db01cd58 | |||
2bae660703 | |||
88ff68f011 | |||
5fc13d1112 | |||
274481620b | |||
98c289f5d8 | |||
a5184a82cb | |||
e21fc05b35 | |||
21a313eec2 | |||
50c747d234 | |||
4e8532c145 | |||
27a40b880e | |||
191ddaf577 | |||
92541ba2ad | |||
240fb4d8d1 | |||
e7458db4b4 | |||
172ac7896b | |||
aed38c2207 | |||
d9787141da | |||
3bd124d78e | |||
b47e8c1b94 | |||
e19f83294a | |||
29344fca44 | |||
fb22ae2387 | |||
23199693f9 | |||
2dc5d82ba8 | |||
d37df1a39d | |||
adb989768d | |||
fa9e1a5873 | |||
f60d614c5f | |||
42a030ccac | |||
c0f481c7f2 | |||
2814a1316f | |||
25f72d1d17 | |||
c4672ff3a8 | |||
fce2c12ca6 | |||
b5233a4f74 | |||
4d5a9b7755 | |||
cd9a64b9c0 | |||
3d9af1de8d | |||
c0d187d434 | |||
d0ba75544a | |||
94f986edd4 | |||
ecfae8a55b | |||
4ac54cf6b0 | |||
3221187dd5 | |||
f4d70b686d | |||
2c5795618b | |||
0b75c41afe | |||
5699058e54 | |||
8b073594d9 | |||
932f974532 | |||
8709a46e96 | |||
270b3d1a04 | |||
6e7873e54a | |||
042fab271f | |||
2d20d11b01 | |||
249c5663d8 | |||
bdabb02ee6 | |||
520b7b2887 | |||
bd307afbbe | |||
2374237762 | |||
b5ec14af68 | |||
f0e7dba4ff | |||
802be17ce7 | |||
4f4f08cee4 | |||
51ea1eea48 | |||
68c96b8bb2 | |||
a8bb0af673 |
43
.clang-tidy
43
.clang-tidy
@@ -1,43 +0,0 @@
|
|||||||
Checks: >
|
|
||||||
-*,
|
|
||||||
readability-*,
|
|
||||||
-readability-uppercase-literal-suffix,
|
|
||||||
-readability-magic-numbers,
|
|
||||||
-readability-isolate-declaration,
|
|
||||||
-readability-convert-member-functions-to-static,
|
|
||||||
-readability-implicit-bool-conversion,
|
|
||||||
-readability-avoid-const-params-in-decls,
|
|
||||||
-readability-simplify-boolean-expr,
|
|
||||||
-readability-make-member-function-const,
|
|
||||||
|
|
||||||
-readability-misleading-indentation,
|
|
||||||
|
|
||||||
-readability-else-after-return,
|
|
||||||
-readability-inconsistent-declaration-parameter-name,
|
|
||||||
-readability-redundant-preprocessor,
|
|
||||||
-readability-function-size,
|
|
||||||
-readability-function-size,
|
|
||||||
-readability-redundant-string-init,
|
|
||||||
-readability-redundant-member-init,
|
|
||||||
-readability-const-return-type,
|
|
||||||
-readability-static-accessed-through-instance,
|
|
||||||
-readability-redundant-declaration,
|
|
||||||
-readability-qualified-auto,
|
|
||||||
|
|
||||||
bugprone-*,
|
|
||||||
-bugprone-narrowing-conversions,
|
|
||||||
-bugprone-unhandled-self-assignment,
|
|
||||||
-bugprone-branch-clone,
|
|
||||||
-bugprone-macro-parentheses,
|
|
||||||
|
|
||||||
-bugprone-sizeof-expression,
|
|
||||||
-bugprone-integer-division,
|
|
||||||
-bugprone-incorrect-roundings,
|
|
||||||
-bugprone-suspicious-string-compare,
|
|
||||||
-bugprone-not-null-terminated-result,
|
|
||||||
-bugprone-suspicious-missing-comma,
|
|
||||||
-bugprone-parent-virtual-call,
|
|
||||||
-bugprone-infinite-loop,
|
|
||||||
-bugprone-copy-constructor-init,
|
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
|
@@ -278,6 +278,7 @@ option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd
|
|||||||
|
|
||||||
# Alembic support
|
# Alembic support
|
||||||
option(WITH_ALEMBIC "Enable Alembic Support" ON)
|
option(WITH_ALEMBIC "Enable Alembic Support" ON)
|
||||||
|
option(WITH_ALEMBIC_HDF5 "Enable Legacy Alembic Support (not officially supported)" OFF)
|
||||||
|
|
||||||
# Universal Scene Description support
|
# Universal Scene Description support
|
||||||
option(WITH_USD "Enable Universal Scene Description (USD) Support" ON)
|
option(WITH_USD "Enable Universal Scene Description (USD) Support" ON)
|
||||||
@@ -321,6 +322,14 @@ mark_as_advanced(WITH_SYSTEM_GLOG)
|
|||||||
# Freestyle
|
# Freestyle
|
||||||
option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
|
option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
|
||||||
|
|
||||||
|
# New object types
|
||||||
|
option(WITH_NEW_OBJECT_TYPES "Enable new hair and pointcloud objects (use for development only, don't save in files)" OFF)
|
||||||
|
mark_as_advanced(WITH_NEW_OBJECT_TYPES)
|
||||||
|
|
||||||
|
# New simulation data block
|
||||||
|
option(WITH_NEW_SIMULATION_TYPE "Enable simulation data block (use for development only, don't save in files)" OFF)
|
||||||
|
mark_as_advanced(WITH_NEW_SIMULATION_TYPE)
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
|
option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
|
||||||
@@ -362,7 +371,7 @@ option(WITH_CYCLES "Enable Cycles Render Engine" ON)
|
|||||||
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
|
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
|
||||||
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
|
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
|
||||||
option(WITH_CYCLES_OSL "Build Cycles with OSL support" ON)
|
option(WITH_CYCLES_OSL "Build Cycles with OSL support" ON)
|
||||||
option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON)
|
option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" OFF)
|
||||||
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
|
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
|
||||||
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
|
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
|
||||||
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
|
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
|
||||||
@@ -415,11 +424,6 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
|
|||||||
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
|
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
|
||||||
mark_as_advanced(WITH_ASSERT_ABORT)
|
mark_as_advanced(WITH_ASSERT_ABORT)
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
|
||||||
option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang)" OFF)
|
|
||||||
mark_as_advanced(WITH_CLANG_TIDY)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(WITH_BOOST "Enable features depending on boost" ON)
|
option(WITH_BOOST "Enable features depending on boost" ON)
|
||||||
option(WITH_TBB "Enable features depending on TBB (OpenVDB, OpenImageDenoise, sculpt multithreading)" ON)
|
option(WITH_TBB "Enable features depending on TBB (OpenVDB, OpenImageDenoise, sculpt multithreading)" ON)
|
||||||
|
|
||||||
@@ -651,7 +655,6 @@ if(WITH_BOOST AND NOT (WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
|
|||||||
set(WITH_BOOST OFF)
|
set(WITH_BOOST OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_and_warn_dependency(WITH_TBB WITH_CYCLES OFF)
|
|
||||||
set_and_warn_dependency(WITH_TBB WITH_USD OFF)
|
set_and_warn_dependency(WITH_TBB WITH_USD OFF)
|
||||||
set_and_warn_dependency(WITH_TBB WITH_OPENIMAGEDENOISE OFF)
|
set_and_warn_dependency(WITH_TBB WITH_OPENIMAGEDENOISE OFF)
|
||||||
set_and_warn_dependency(WITH_TBB WITH_OPENVDB OFF)
|
set_and_warn_dependency(WITH_TBB WITH_OPENVDB OFF)
|
||||||
@@ -1243,7 +1246,7 @@ endif()
|
|||||||
|
|
||||||
if(WITH_LIBMV)
|
if(WITH_LIBMV)
|
||||||
# We always have C++11 which includes unordered_map.
|
# We always have C++11 which includes unordered_map.
|
||||||
set(CERES_DEFINES "-DCERES_STD_UNORDERED_MAP;-DCERES_USE_CXX_THREADS")
|
set(CERES_DEFINES -DCERES_STD_UNORDERED_MAP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -1559,15 +1562,20 @@ if(WITH_PYTHON)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
|
# MSVC needs to be tested first, since clang on windows will
|
||||||
|
# match the compiler test below but clang-cl does not accept -std=c++11
|
||||||
|
# since it is on by default and cannot be turned off.
|
||||||
|
#
|
||||||
|
# Nothing special is needed, C++11 features are available by default.
|
||||||
elseif(
|
elseif(
|
||||||
CMAKE_COMPILER_IS_GNUCC OR
|
CMAKE_COMPILER_IS_GNUCC OR
|
||||||
CMAKE_C_COMPILER_ID MATCHES "Clang" OR
|
CMAKE_C_COMPILER_ID MATCHES "Clang" OR
|
||||||
CMAKE_C_COMPILER_ID MATCHES "Intel"
|
CMAKE_C_COMPILER_ID MATCHES "Intel"
|
||||||
)
|
)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
# TODO(sergey): Do we want c++11 or gnu-c++11 here?
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++17 build")
|
message(FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++11 build")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Visual Studio has all standards it supports available by default
|
# Visual Studio has all standards it supports available by default
|
||||||
|
10
GNUmakefile
10
GNUmakefile
@@ -32,7 +32,6 @@ Convenience Targets
|
|||||||
* debug: Build a debug binary.
|
* debug: Build a debug binary.
|
||||||
* full: Enable all supported dependencies & options.
|
* full: Enable all supported dependencies & options.
|
||||||
* lite: Disable non essential features for a smaller binary and faster build.
|
* lite: Disable non essential features for a smaller binary and faster build.
|
||||||
* release Complete build with all options enabled including CUDA and Optix, matching the releases on blender.org
|
|
||||||
* headless: Build without an interface (renderfarm or server automation).
|
* headless: Build without an interface (renderfarm or server automation).
|
||||||
* cycles: Build Cycles standalone only, without Blender.
|
* cycles: Build Cycles standalone only, without Blender.
|
||||||
* bpy: Build as a python module which can be loaded from python directly.
|
* bpy: Build as a python module which can be loaded from python directly.
|
||||||
@@ -142,10 +141,6 @@ Information
|
|||||||
endef
|
endef
|
||||||
# HELP_TEXT (end)
|
# HELP_TEXT (end)
|
||||||
|
|
||||||
# This makefile is not meant for Windows
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
$(error On Windows, use "cmd //c make.bat" instead of "make")
|
|
||||||
endif
|
|
||||||
|
|
||||||
# System Vars
|
# System Vars
|
||||||
OS:=$(shell uname -s)
|
OS:=$(shell uname -s)
|
||||||
@@ -212,10 +207,6 @@ ifneq "$(findstring lite, $(MAKECMDGOALS))" ""
|
|||||||
BUILD_DIR:=$(BUILD_DIR)_lite
|
BUILD_DIR:=$(BUILD_DIR)_lite
|
||||||
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake" $(CMAKE_CONFIG_ARGS)
|
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/blender_lite.cmake" $(CMAKE_CONFIG_ARGS)
|
||||||
endif
|
endif
|
||||||
ifneq "$(findstring release, $(MAKECMDGOALS))" ""
|
|
||||||
BUILD_DIR:=$(BUILD_DIR)_release
|
|
||||||
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/blender_release.cmake" $(CMAKE_CONFIG_ARGS)
|
|
||||||
endif
|
|
||||||
ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
|
ifneq "$(findstring cycles, $(MAKECMDGOALS))" ""
|
||||||
BUILD_DIR:=$(BUILD_DIR)_cycles
|
BUILD_DIR:=$(BUILD_DIR)_cycles
|
||||||
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake" $(CMAKE_CONFIG_ARGS)
|
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/cycles_standalone.cmake" $(CMAKE_CONFIG_ARGS)
|
||||||
@@ -326,7 +317,6 @@ all: .FORCE
|
|||||||
debug: all
|
debug: all
|
||||||
full: all
|
full: all
|
||||||
lite: all
|
lite: all
|
||||||
release: all
|
|
||||||
cycles: all
|
cycles: all
|
||||||
headless: all
|
headless: all
|
||||||
bpy: all
|
bpy: all
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
# build_deps 2015 x64 / build_deps 2015 x86
|
# build_deps 2015 x64 / build_deps 2015 x86
|
||||||
#
|
#
|
||||||
# MAC OS X USAGE:
|
# MAC OS X USAGE:
|
||||||
# Install with homebrew: brew install cmake autoconf automake libtool yasm nasm bison
|
# Install with homebrew: brew install cmake autoconf automake libtool yasm nasm
|
||||||
# Run "make deps" from main Blender directory
|
# Run "make deps" from main Blender directory
|
||||||
#
|
#
|
||||||
# LINUX USAGE:
|
# LINUX USAGE:
|
||||||
@@ -48,7 +48,11 @@ include(cmake/options.cmake)
|
|||||||
include(cmake/versions.cmake)
|
include(cmake/versions.cmake)
|
||||||
|
|
||||||
if(ENABLE_MINGW64)
|
if(ENABLE_MINGW64)
|
||||||
include(cmake/setup_mingw64.cmake)
|
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||||
|
include(cmake/setup_mingw64.cmake)
|
||||||
|
else()
|
||||||
|
include(cmake/setup_mingw32.cmake)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(mingw_LIBDIR ${LIBDIR})
|
set(mingw_LIBDIR ${LIBDIR})
|
||||||
endif()
|
endif()
|
||||||
@@ -76,7 +80,6 @@ include(cmake/llvm.cmake)
|
|||||||
include(cmake/clang.cmake)
|
include(cmake/clang.cmake)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
include(cmake/openmp.cmake)
|
include(cmake/openmp.cmake)
|
||||||
include(cmake/nasm.cmake)
|
|
||||||
endif()
|
endif()
|
||||||
include(cmake/openimageio.cmake)
|
include(cmake/openimageio.cmake)
|
||||||
include(cmake/tiff.cmake)
|
include(cmake/tiff.cmake)
|
||||||
@@ -94,18 +97,17 @@ if(UNIX)
|
|||||||
else()
|
else()
|
||||||
include(cmake/pugixml.cmake)
|
include(cmake/pugixml.cmake)
|
||||||
endif()
|
endif()
|
||||||
include(cmake/ispc.cmake)
|
|
||||||
include(cmake/openimagedenoise.cmake)
|
include(cmake/openimagedenoise.cmake)
|
||||||
include(cmake/embree.cmake)
|
include(cmake/embree.cmake)
|
||||||
if(NOT APPLE)
|
include(cmake/xr_openxr.cmake)
|
||||||
include(cmake/xr_openxr.cmake)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WITH_WEBP)
|
if(WITH_WEBP)
|
||||||
include(cmake/webp.cmake)
|
include(cmake/webp.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
# HMD branch deps
|
||||||
|
include(cmake/hidapi.cmake)
|
||||||
# OCIO deps
|
# OCIO deps
|
||||||
include(cmake/tinyxml.cmake)
|
include(cmake/tinyxml.cmake)
|
||||||
include(cmake/yamlcpp.cmake)
|
include(cmake/yamlcpp.cmake)
|
||||||
|
@@ -16,6 +16,16 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
|
if(ALEMBIC_HDF5)
|
||||||
|
set(ALEMBIC_HDF5_HL)
|
||||||
|
# in debug mode we do not build HDF5_hdf5_hl_LIBRARY which makes cmake really
|
||||||
|
# unhappy, stub it with the debug mode lib. it's not linking it in at this
|
||||||
|
# point in time anyhow
|
||||||
|
if(BUILD_MODE STREQUAL Debug)
|
||||||
|
set(ALEMBIC_HDF5_HL -DHDF5_hdf5_hl_LIBRARY=${LIBDIR}/hdf5/lib/libhdf5_hl_D.${LIBEXT})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(ALEMBIC_EXTRA_ARGS
|
set(ALEMBIC_EXTRA_ARGS
|
||||||
-DBUILDSTATIC=ON
|
-DBUILDSTATIC=ON
|
||||||
-DLINKSTATIC=ON
|
-DLINKSTATIC=ON
|
||||||
@@ -43,6 +53,7 @@ set(ALEMBIC_EXTRA_ARGS
|
|||||||
-DUSE_PRMAN=0
|
-DUSE_PRMAN=0
|
||||||
-DUSE_HDF5=Off
|
-DUSE_HDF5=Off
|
||||||
-DUSE_STATIC_HDF5=Off
|
-DUSE_STATIC_HDF5=Off
|
||||||
|
-DHDF5_ROOT=${LIBDIR}/hdf5
|
||||||
-DUSE_TESTS=Off
|
-DUSE_TESTS=Off
|
||||||
-DALEMBIC_NO_OPENGL=1
|
-DALEMBIC_NO_OPENGL=1
|
||||||
-DUSE_BINARIES=ON
|
-DUSE_BINARIES=ON
|
||||||
@@ -51,6 +62,7 @@ set(ALEMBIC_EXTRA_ARGS
|
|||||||
-DGLUT_INCLUDE_DIR=""
|
-DGLUT_INCLUDE_DIR=""
|
||||||
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
|
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
|
||||||
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
|
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/
|
||||||
|
${ALEMBIC_HDF5_HL}
|
||||||
)
|
)
|
||||||
|
|
||||||
ExternalProject_Add(external_alembic
|
ExternalProject_Add(external_alembic
|
||||||
|
@@ -44,7 +44,7 @@ if(WIN32)
|
|||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
|
set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh)
|
||||||
set(BOOST_BUILD_COMMAND ./b2)
|
set(BOOST_BUILD_COMMAND ./b2)
|
||||||
set(BOOST_BUILD_OPTIONS toolset=clang-darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} visibility=global --disable-icu boost.locale.icu=off)
|
set(BOOST_BUILD_OPTIONS toolset=darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} visibility=global --disable-icu boost.locale.icu=off)
|
||||||
set(BOOST_HARVEST_CMD echo .)
|
set(BOOST_HARVEST_CMD echo .)
|
||||||
set(BOOST_PATCH_COMMAND echo .)
|
set(BOOST_PATCH_COMMAND echo .)
|
||||||
else()
|
else()
|
||||||
|
@@ -30,7 +30,6 @@ if(UNIX)
|
|||||||
nasm
|
nasm
|
||||||
yasm
|
yasm
|
||||||
tclsh
|
tclsh
|
||||||
bison
|
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(_software ${_required_software})
|
foreach(_software ${_required_software})
|
||||||
@@ -41,12 +40,6 @@ if(UNIX)
|
|||||||
unset(_software_find CACHE)
|
unset(_software_find CACHE)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
if(NOT EXISTS "/usr/local/opt/bison/bin/bison")
|
|
||||||
set(_software_missing "${_software_missing} bison")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(_software_missing)
|
if(_software_missing)
|
||||||
message(
|
message(
|
||||||
"\n"
|
"\n"
|
||||||
@@ -57,7 +50,7 @@ if(UNIX)
|
|||||||
" apt install autoconf automake libtool yasm nasm tcl\n"
|
" apt install autoconf automake libtool yasm nasm tcl\n"
|
||||||
"\n"
|
"\n"
|
||||||
"On macOS (with homebrew):\n"
|
"On macOS (with homebrew):\n"
|
||||||
" brew install cmake autoconf automake libtool yasm nasm bison\n"
|
" brew install cmake autoconf automake libtool yasm nasm\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Other platforms:\n"
|
"Other platforms:\n"
|
||||||
" Install equivalent packages.\n")
|
" Install equivalent packages.\n")
|
||||||
|
@@ -51,7 +51,6 @@ ExternalProject_Add(external_embree
|
|||||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||||
URL_HASH MD5=${EMBREE_HASH}
|
URL_HASH MD5=${EMBREE_HASH}
|
||||||
PREFIX ${BUILD_DIR}/embree
|
PREFIX ${BUILD_DIR}/embree
|
||||||
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/embree/src/external_embree < ${PATCH_DIR}/embree.diff
|
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/embree ${DEFAULT_CMAKE_FLAGS} ${EMBREE_EXTRA_ARGS}
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/embree ${DEFAULT_CMAKE_FLAGS} ${EMBREE_EXTRA_ARGS}
|
||||||
INSTALL_DIR ${LIBDIR}/embree
|
INSTALL_DIR ${LIBDIR}/embree
|
||||||
)
|
)
|
||||||
|
@@ -50,8 +50,7 @@ if(APPLE)
|
|||||||
set(FFMPEG_EXTRA_FLAGS
|
set(FFMPEG_EXTRA_FLAGS
|
||||||
${FFMPEG_EXTRA_FLAGS}
|
${FFMPEG_EXTRA_FLAGS}
|
||||||
--target-os=darwin
|
--target-os=darwin
|
||||||
--x86asmexe=${LIBDIR}/nasm/bin/nasm
|
)
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
ExternalProject_Add(external_ffmpeg
|
ExternalProject_Add(external_ffmpeg
|
||||||
@@ -144,12 +143,6 @@ if(WIN32)
|
|||||||
external_zlib_mingw
|
external_zlib_mingw
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(APPLE)
|
|
||||||
add_dependencies(
|
|
||||||
external_ffmpeg
|
|
||||||
external_nasm
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_MODE STREQUAL Release AND WIN32)
|
if(BUILD_MODE STREQUAL Release AND WIN32)
|
||||||
ExternalProject_Add_Step(external_ffmpeg after_install
|
ExternalProject_Add_Step(external_ffmpeg after_install
|
||||||
|
@@ -24,8 +24,7 @@ set(FREETYPE_EXTRA_ARGS
|
|||||||
-DFT_WITH_HARFBUZZ=OFF
|
-DFT_WITH_HARFBUZZ=OFF
|
||||||
-DFT_WITH_BZIP2=OFF
|
-DFT_WITH_BZIP2=OFF
|
||||||
-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE
|
-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE
|
||||||
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE
|
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE)
|
||||||
-DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE)
|
|
||||||
|
|
||||||
ExternalProject_Add(external_freetype
|
ExternalProject_Add(external_freetype
|
||||||
URL ${FREETYPE_URI}
|
URL ${FREETYPE_URI}
|
||||||
|
@@ -43,10 +43,21 @@ if(BUILD_MODE STREQUAL Release)
|
|||||||
# tiff
|
# tiff
|
||||||
${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
|
${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
|
||||||
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ &&
|
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ &&
|
||||||
|
# hidapi
|
||||||
|
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hidapi/ ${HARVEST_TARGET}/hidapi/
|
||||||
DEPENDS
|
DEPENDS
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_MODE STREQUAL Debug)
|
||||||
|
add_custom_target(Harvest_Debug_Results
|
||||||
|
COMMAND
|
||||||
|
# hdf5
|
||||||
|
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5/lib ${HARVEST_TARGET}/hdf5/lib &&
|
||||||
|
DEPENDS Package_Python
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
else(WIN32)
|
else(WIN32)
|
||||||
|
|
||||||
function(harvest from to)
|
function(harvest from to)
|
||||||
|
@@ -16,14 +16,27 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
ExternalProject_Add(external_nasm
|
set(HDF5_EXTRA_ARGS
|
||||||
URL ${NASM_URI}
|
-DHDF5_ENABLE_THREADSAFE=Off
|
||||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
-DHDF5_BUILD_CPP_LIB=Off
|
||||||
URL_HASH SHA256=${NASM_HASH}
|
-DBUILD_TESTING=Off
|
||||||
PREFIX ${BUILD_DIR}/nasm
|
-DHDF5_BUILD_TOOLS=Off
|
||||||
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/nasm/src/external_nasm < ${PATCH_DIR}/nasm.diff
|
-DHDF5_BUILD_EXAMPLES=Off
|
||||||
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm
|
-DHDF5_BUILD_HL_LIB=On
|
||||||
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make -j${MAKE_THREADS}
|
-DBUILD_STATIC_CRT_LIBS=On
|
||||||
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make install
|
-DBUILD_SHARED_LIBS=On
|
||||||
INSTALL_DIR ${LIBDIR}/nasm
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(HDF5_PATCH ${PATCH_CMD} --verbose -p 0 -d ${BUILD_DIR}/hdf5/src/external_hdf5 < ${PATCH_DIR}/hdf5.diff)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ExternalProject_Add(external_hdf5
|
||||||
|
URL ${HDF5_URI}
|
||||||
|
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||||
|
URL_HASH MD5=${HDF5_HASH}
|
||||||
|
PREFIX ${BUILD_DIR}/hdf5
|
||||||
|
PATCH_COMMAND ${HDF5_PATCH}
|
||||||
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/hdf5 ${HDF5_EXTRA_ARGS}
|
||||||
|
INSTALL_DIR ${LIBDIR}/hdf5
|
||||||
)
|
)
|
@@ -16,20 +16,14 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
set(INC
|
set(HIDAPI_EXTRA_ARGS)
|
||||||
include
|
|
||||||
|
ExternalProject_Add(external_hidapi
|
||||||
|
URL ${HIDAPI_URI}
|
||||||
|
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||||
|
URL_HASH MD5=${HIDAPI_HASH}
|
||||||
|
PREFIX ${BUILD_DIR}/hidapi
|
||||||
|
PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_hidapi.txt ${BUILD_DIR}/hidapi/src/external_hidapi/cmakelists.txt && ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/hidapi/src/external_hidapi < ${PATCH_DIR}/hidapi.diff
|
||||||
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/hidapi -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${HIDAPI_EXTRA_ARGS}
|
||||||
|
INSTALL_DIR ${LIBDIR}/hidapi
|
||||||
)
|
)
|
||||||
|
|
||||||
set(INC_SYS
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SRC
|
|
||||||
source/sky_model.cpp
|
|
||||||
source/sky_nishita.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set(LIB
|
|
||||||
)
|
|
||||||
|
|
||||||
blender_add_lib(bf_intern_sky "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
|
@@ -1,76 +0,0 @@
|
|||||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU General Public License
|
|
||||||
# as published by the Free Software Foundation; either version 2
|
|
||||||
# of the License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software Foundation,
|
|
||||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
#
|
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
set(ISPC_EXTRA_ARGS_WIN
|
|
||||||
-DFLEX_EXECUTABLE=${LIBDIR}/flexbison/win_flex.exe
|
|
||||||
-DBISON_EXECUTABLE=${LIBDIR}/flexbison/win_bison.exe
|
|
||||||
-DM4_EXECUTABLE=${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/m4.exe
|
|
||||||
)
|
|
||||||
elseif(APPLE)
|
|
||||||
# Use bison installed via Homebrew.
|
|
||||||
# The one which comes which Xcode toolset is too old.
|
|
||||||
set(ISPC_EXTRA_ARGS_APPLE
|
|
||||||
-DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
|
|
||||||
)
|
|
||||||
elseif(UNIX)
|
|
||||||
set(ISPC_EXTRA_ARGS_UNIX
|
|
||||||
-DCMAKE_C_COMPILER=${LIBDIR}/clang/bin/clang
|
|
||||||
-DCMAKE_CXX_COMPILER=${LIBDIR}/clang/bin/clang++
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(ISPC_EXTRA_ARGS
|
|
||||||
-DARM_ENABLED=Off
|
|
||||||
-DISPC_NO_DUMPS=On
|
|
||||||
-DISPC_INCLUDE_EXAMPLES=Off
|
|
||||||
-DISPC_INCLUDE_TESTS=Off
|
|
||||||
-DLLVM_ROOT=${LIBDIR}/llvm/lib/cmake/llvm
|
|
||||||
-DLLVM_LIBRARY_DIR=${LIBDIR}/llvm/lib
|
|
||||||
-DCLANG_EXECUTABLE=${LIBDIR}/clang/bin/clang
|
|
||||||
-DISPC_INCLUDE_TESTS=Off
|
|
||||||
-DCLANG_LIBRARY_DIR=${LIBDIR}/clang/lib
|
|
||||||
-DCLANG_INCLUDE_DIRS=${LIBDIR}/clang/include
|
|
||||||
${ISPC_EXTRA_ARGS_WIN}
|
|
||||||
${ISPC_EXTRA_ARGS_APPLE}
|
|
||||||
${ISPC_EXTRA_ARGS_UNIX}
|
|
||||||
)
|
|
||||||
|
|
||||||
ExternalProject_Add(external_ispc
|
|
||||||
URL ${ISPC_URI}
|
|
||||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
|
||||||
URL_HASH MD5=${ISPC_HASH}
|
|
||||||
PREFIX ${BUILD_DIR}/ispc
|
|
||||||
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/ispc/src/external_ispc < ${PATCH_DIR}/ispc.diff
|
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ispc -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${ISPC_EXTRA_ARGS} ${BUILD_DIR}/ispc/src/external_ispc
|
|
||||||
INSTALL_DIR ${LIBDIR}/ispc
|
|
||||||
)
|
|
||||||
|
|
||||||
add_dependencies(
|
|
||||||
external_ispc
|
|
||||||
ll
|
|
||||||
external_clang
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
add_dependencies(
|
|
||||||
external_ispc
|
|
||||||
external_flexbison
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
@@ -21,7 +21,6 @@ ExternalProject_Add(external_ogg
|
|||||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||||
URL_HASH SHA256=${OGG_HASH}
|
URL_HASH SHA256=${OGG_HASH}
|
||||||
PREFIX ${BUILD_DIR}/ogg
|
PREFIX ${BUILD_DIR}/ogg
|
||||||
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/ogg/src/external_ogg < ${PATCH_DIR}/ogg.diff
|
|
||||||
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ogg --disable-shared --enable-static
|
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ogg --disable-shared --enable-static
|
||||||
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make -j${MAKE_THREADS}
|
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make -j${MAKE_THREADS}
|
||||||
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make install
|
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ogg/src/external_ogg/ && make install
|
||||||
|
@@ -18,41 +18,26 @@
|
|||||||
|
|
||||||
|
|
||||||
set(OIDN_EXTRA_ARGS
|
set(OIDN_EXTRA_ARGS
|
||||||
-DOIDN_APPS=OFF
|
-DWITH_EXAMPLE=OFF
|
||||||
|
-DWITH_TEST=OFF
|
||||||
-DTBB_ROOT=${LIBDIR}/tbb
|
-DTBB_ROOT=${LIBDIR}/tbb
|
||||||
-DTBB_STATIC_LIB=${TBB_STATIC_LIBRARY}
|
-DTBB_STATIC_LIB=${TBB_STATIC_LIBRARY}
|
||||||
-DOIDN_STATIC_LIB=ON
|
-DOIDN_STATIC_LIB=ON
|
||||||
-DOIDN_STATIC_RUNTIME=OFF
|
|
||||||
-DISPC_EXECUTABLE=${LIBDIR}/ispc/bin/ispc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
set(OIDN_EXTRA_ARGS
|
|
||||||
${OIDN_EXTRA_ARGS}
|
|
||||||
-DTBB_DEBUG_LIBRARY=${LIBDIR}/tbb/lib/tbb.lib
|
|
||||||
-DTBB_DEBUG_LIBRARY_MALLOC=${LIBDIR}/tbb/lib/tbbmalloc.lib
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
set(OIDN_EXTRA_ARGS
|
|
||||||
${OIDN_EXTRA_ARGS}
|
|
||||||
-Dtbb_LIBRARY_RELEASE=${LIBDIR}/tbb/lib/tbb_static.a
|
|
||||||
-Dtbbmalloc_LIBRARY_RELEASE=${LIBDIR}/tbb/lib/tbbmalloc_static.a
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ExternalProject_Add(external_openimagedenoise
|
ExternalProject_Add(external_openimagedenoise
|
||||||
URL ${OIDN_URI}
|
URL ${OIDN_URI}
|
||||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||||
URL_HASH MD5=${OIDN_HASH}
|
URL_HASH MD5=${OIDN_HASH}
|
||||||
PREFIX ${BUILD_DIR}/openimagedenoise
|
PREFIX ${BUILD_DIR}/openimagedenoise
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimagedenoise ${DEFAULT_CMAKE_FLAGS} ${OIDN_EXTRA_ARGS}
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimagedenoise ${DEFAULT_CMAKE_FLAGS} ${OIDN_EXTRA_ARGS}
|
||||||
|
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/openimagedenoise/src/external_openimagedenoise < ${PATCH_DIR}/openimagedenoise.diff
|
||||||
INSTALL_DIR ${LIBDIR}/openimagedenoise
|
INSTALL_DIR ${LIBDIR}/openimagedenoise
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(
|
add_dependencies(
|
||||||
external_openimagedenoise
|
external_openimagedenoise
|
||||||
external_tbb
|
external_tbb
|
||||||
external_ispc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@@ -61,7 +46,7 @@ if(WIN32)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/include ${HARVEST_TARGET}/openimagedenoise/include
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/include ${HARVEST_TARGET}/openimagedenoise/include
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/openimagedenoise.lib ${HARVEST_TARGET}/openimagedenoise/lib/openimagedenoise.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/openimagedenoise.lib ${HARVEST_TARGET}/openimagedenoise/lib/openimagedenoise.lib
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/common.lib ${HARVEST_TARGET}/openimagedenoise/lib/common.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/common.lib ${HARVEST_TARGET}/openimagedenoise/lib/common.lib
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/dnnl.lib ${HARVEST_TARGET}/openimagedenoise/lib/dnnl.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/mkldnn.lib ${HARVEST_TARGET}/openimagedenoise/lib/mkldnn.lib
|
||||||
DEPENDEES install
|
DEPENDEES install
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@@ -69,7 +54,7 @@ if(WIN32)
|
|||||||
ExternalProject_Add_Step(external_openimagedenoise after_install
|
ExternalProject_Add_Step(external_openimagedenoise after_install
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/openimagedenoise.lib ${HARVEST_TARGET}/openimagedenoise/lib/openimagedenoise_d.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/openimagedenoise.lib ${HARVEST_TARGET}/openimagedenoise/lib/openimagedenoise_d.lib
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/common.lib ${HARVEST_TARGET}/openimagedenoise/lib/common_d.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/common.lib ${HARVEST_TARGET}/openimagedenoise/lib/common_d.lib
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/dnnl.lib ${HARVEST_TARGET}/openimagedenoise/lib/dnnl_d.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/mkldnn.lib ${HARVEST_TARGET}/openimagedenoise/lib/mkldnn_d.lib
|
||||||
DEPENDEES install
|
DEPENDEES install
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/fftw3 by installing mingw64" ON)
|
option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/lapack/fftw3 by installing mingw64" ON)
|
||||||
endif()
|
endif()
|
||||||
option(WITH_WEBP "Enable building of oiio with webp support" OFF)
|
option(WITH_WEBP "Enable building of oiio with webp support" OFF)
|
||||||
set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with")
|
set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with")
|
||||||
@@ -45,7 +45,11 @@ message("PATCH_DIR = ${PATCH_DIR}")
|
|||||||
message("BUILD_DIR = ${BUILD_DIR}")
|
message("BUILD_DIR = ${BUILD_DIR}")
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/patch.exe)
|
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||||
|
set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/patch.exe)
|
||||||
|
else()
|
||||||
|
set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/patch.exe)
|
||||||
|
endif()
|
||||||
set(LIBEXT ".lib")
|
set(LIBEXT ".lib")
|
||||||
set(LIBPREFIX "")
|
set(LIBPREFIX "")
|
||||||
|
|
||||||
@@ -78,10 +82,17 @@ if(WIN32)
|
|||||||
set(PLATFORM_CXX_FLAGS)
|
set(PLATFORM_CXX_FLAGS)
|
||||||
set(PLATFORM_CMAKE_FLAGS)
|
set(PLATFORM_CMAKE_FLAGS)
|
||||||
|
|
||||||
set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw64)
|
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||||
set(MINGW_SHELL ming64sh.cmd)
|
set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw64)
|
||||||
set(PERL_SHELL ${DOWNLOAD_DIR}/perl/portableshell.bat)
|
set(MINGW_SHELL ming64sh.cmd)
|
||||||
set(MINGW_HOST x86_64-w64-mingw32)
|
set(PERL_SHELL ${DOWNLOAD_DIR}/perl/portableshell.bat)
|
||||||
|
set(MINGW_HOST x86_64-w64-mingw32)
|
||||||
|
else()
|
||||||
|
set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw32)
|
||||||
|
set(MINGW_SHELL ming32sh.cmd)
|
||||||
|
set(PERL_SHELL ${DOWNLOAD_DIR}/perl32/portableshell.bat)
|
||||||
|
set(MINGW_HOST i686-w64-mingw32)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CONFIGURE_ENV
|
set(CONFIGURE_ENV
|
||||||
cd ${MINGW_PATH} &&
|
cd ${MINGW_PATH} &&
|
||||||
@@ -113,18 +124,14 @@ else()
|
|||||||
COMMAND xcode-select --print-path
|
COMMAND xcode-select --print-path
|
||||||
OUTPUT_VARIABLE XCODE_DEV_PATH OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_VARIABLE XCODE_DEV_PATH OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
execute_process(
|
|
||||||
COMMAND xcodebuild -version -sdk macosx SDKVersion
|
|
||||||
OUTPUT_VARIABLE MACOSX_SDK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
set(OSX_ARCHITECTURES x86_64)
|
set(OSX_ARCHITECTURES x86_64)
|
||||||
set(OSX_DEPLOYMENT_TARGET 10.13)
|
set(OSX_DEPLOYMENT_TARGET 10.11)
|
||||||
set(OSX_SYSROOT ${XCODE_DEV_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)
|
set(OSX_SYSROOT ${XCODE_DEV_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)
|
||||||
|
|
||||||
set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
|
set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
|
||||||
set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++")
|
set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++")
|
||||||
set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
|
set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}")
|
||||||
set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin17.0.0) # OS X 10.13
|
set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin15.0.0) # OS X 10.11
|
||||||
set(PLATFORM_CMAKE_FLAGS
|
set(PLATFORM_CMAKE_FLAGS
|
||||||
-DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES}
|
-DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES}
|
||||||
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET}
|
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET}
|
||||||
@@ -159,7 +166,6 @@ else()
|
|||||||
|
|
||||||
set(CONFIGURE_ENV
|
set(CONFIGURE_ENV
|
||||||
export MACOSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} &&
|
export MACOSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} &&
|
||||||
export MACOSX_SDK_VERSION=${OSX_DEPLOYMENT_TARGET} &&
|
|
||||||
export CFLAGS=${PLATFORM_CFLAGS} &&
|
export CFLAGS=${PLATFORM_CFLAGS} &&
|
||||||
export CXXFLAGS=${PLATFORM_CXXFLAGS} &&
|
export CXXFLAGS=${PLATFORM_CXXFLAGS} &&
|
||||||
export LDFLAGS=${PLATFORM_LDFLAGS}
|
export LDFLAGS=${PLATFORM_LDFLAGS}
|
||||||
|
@@ -75,7 +75,6 @@ set(OSL_EXTRA_ARGS
|
|||||||
-DUSE_LLVM_BITCODE=OFF
|
-DUSE_LLVM_BITCODE=OFF
|
||||||
-DUSE_PARTIO=OFF
|
-DUSE_PARTIO=OFF
|
||||||
-DUSE_QT=OFF
|
-DUSE_QT=OFF
|
||||||
-DINSTALL_DOCS=OFF
|
|
||||||
${OSL_SIMD_FLAGS}
|
${OSL_SIMD_FLAGS}
|
||||||
-DPARTIO_LIBRARIES=
|
-DPARTIO_LIBRARIES=
|
||||||
)
|
)
|
||||||
|
@@ -48,12 +48,7 @@ if(WIN32)
|
|||||||
|
|
||||||
else()
|
else()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# Disable functions that can be in 10.13 sdk but aren't available on 10.9 target.
|
# disable functions that can be in 10.13 sdk but aren't available on 10.9 target
|
||||||
#
|
|
||||||
# Disable libintl (gettext library) as it might come from Homebrew, which makes
|
|
||||||
# it so test program compiles, but the Python does not. This is because for Python
|
|
||||||
# we use isysroot, which seems to forbid using libintl.h.
|
|
||||||
# The gettext functionality seems to come from CoreFoundation, so should be all fine.
|
|
||||||
set(PYTHON_FUNC_CONFIGS
|
set(PYTHON_FUNC_CONFIGS
|
||||||
export ac_cv_func_futimens=no &&
|
export ac_cv_func_futimens=no &&
|
||||||
export ac_cv_func_utimensat=no &&
|
export ac_cv_func_utimensat=no &&
|
||||||
@@ -65,10 +60,7 @@ else()
|
|||||||
export ac_cv_func_getentropy=no &&
|
export ac_cv_func_getentropy=no &&
|
||||||
export ac_cv_func_mkostemp=no &&
|
export ac_cv_func_mkostemp=no &&
|
||||||
export ac_cv_func_mkostemps=no &&
|
export ac_cv_func_mkostemps=no &&
|
||||||
export ac_cv_func_timingsafe_bcmp=no &&
|
export ac_cv_func_timingsafe_bcmp=no)
|
||||||
export ac_cv_header_libintl_h=no &&
|
|
||||||
export ac_cv_lib_intl_textdomain=no
|
|
||||||
)
|
|
||||||
set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && ${PYTHON_FUNC_CONFIGS})
|
set(PYTHON_CONFIGURE_ENV ${CONFIGURE_ENV} && ${PYTHON_FUNC_CONFIGS})
|
||||||
set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe)
|
set(PYTHON_BINARY ${BUILD_DIR}/python/src/external_python/python.exe)
|
||||||
else()
|
else()
|
||||||
|
227
build_files/build_environment/cmake/setup_mingw32.cmake
Normal file
227
build_files/build_environment/cmake/setup_mingw32.cmake
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
|
####################################################################################################################
|
||||||
|
# Mingw32 Builds
|
||||||
|
####################################################################################################################
|
||||||
|
# This installs mingw32+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3
|
||||||
|
####################################################################################################################
|
||||||
|
|
||||||
|
message("LIBDIR = ${LIBDIR}")
|
||||||
|
macro(cmake_to_msys_path MsysPath ResultingPath)
|
||||||
|
string(REPLACE ":" "" TmpPath "${MsysPath}")
|
||||||
|
string(SUBSTRING ${TmpPath} 0 1 Drive)
|
||||||
|
string(SUBSTRING ${TmpPath} 1 255 PathPart)
|
||||||
|
string(TOLOWER ${Drive} LowerDrive)
|
||||||
|
string(CONCAT ${ResultingPath} "/" ${LowerDrive} ${PathPart})
|
||||||
|
endmacro()
|
||||||
|
cmake_to_msys_path(${LIBDIR} mingw_LIBDIR)
|
||||||
|
message("mingw_LIBDIR = ${mingw_LIBDIR}")
|
||||||
|
|
||||||
|
message("Checking for mingw32")
|
||||||
|
# download mingw32
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z")
|
||||||
|
message("Downloading mingw32")
|
||||||
|
file(DOWNLOAD "https://astuteinternet.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.4/threads-win32/sjlj/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z" "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# make mingw root directory
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/mingw
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# extract mingw32
|
||||||
|
if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd") AND (EXISTS "${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z"))
|
||||||
|
message("Extracting mingw32")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/i686-4.9.4-release-win32-sjlj-rt_v5-rev0.7z
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("Checking for pkg-config")
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
|
||||||
|
message("Downloading pkg-config")
|
||||||
|
file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip" "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# extract pkgconfig
|
||||||
|
if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe") AND (EXISTS "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"))
|
||||||
|
message("Extracting pkg-config")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1_bin-win32.zip"
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/pkg-config-lite-0.28-1/bin/pkg-config.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/pkg-config.exe"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("Checking for nasm")
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip")
|
||||||
|
message("Downloading nasm")
|
||||||
|
file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/win32/nasm-2.13.02-win32.zip" "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# extract nasm
|
||||||
|
if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe") AND (EXISTS "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip"))
|
||||||
|
message("Extracting nasm")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/nasm-2.13.02-win32.zip"
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.13.02/nasm.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe"
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
SET(NASM_PATH ${DOWNLOAD_DIR}/mingw/mingw32/bin/nasm.exe)
|
||||||
|
message("Checking for mingwGet")
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
|
||||||
|
message("Downloading mingw-get")
|
||||||
|
file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# extract mingw_get
|
||||||
|
if((NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (EXISTS "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"))
|
||||||
|
message("Extracting mingw-get")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E tar jxf "${DOWNLOAD_DIR}/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip"
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/make.exe"))
|
||||||
|
message("Installing MSYS")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get install msys msys-patch
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/bin/
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/mktemp.exe"))
|
||||||
|
message("Installing mktemp")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${DOWNLOAD_DIR}/mingw/mingw32/bin/mingw-get install msys msys-mktemp
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw32/bin/
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
message("Checking for CoreUtils")
|
||||||
|
# download old core_utils for pr.exe (ffmpeg needs it to build)
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
|
||||||
|
message("Downloading CoreUtils 5.97")
|
||||||
|
file(DOWNLOAD "https://nchc.dl.sourceforge.net/project/mingw/MSYS/Base/msys-core/_obsolete/coreutils-5.97-MSYS-1.0.11-2/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2" "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if((EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe"))
|
||||||
|
message("Installing pr from CoreUtils 5.97")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/tmp_coreutils
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${DOWNLOAD_DIR}/tmp_coreutils/coreutils-5.97/bin/pr.exe "${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/pr.exe"
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/tmp_coreutils/
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd")
|
||||||
|
message("Installing ming32sh.cmd")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming32sh.cmd ${DOWNLOAD_DIR}/mingw/mingw32/ming32sh.cmd
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("Checking for perl")
|
||||||
|
# download perl for libvpx
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")
|
||||||
|
message("Downloading perl")
|
||||||
|
file(DOWNLOAD "http://strawberryperl.com/download/5.22.1.3/strawberry-perl-5.22.1.3-32bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# make perl root directory
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/perl32")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOWNLOAD_DIR}/perl32
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# extract perl
|
||||||
|
if((NOT EXISTS "${DOWNLOAD_DIR}/perl32/portable.perl") AND (EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip"))
|
||||||
|
message("Extracting perl")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/strawberry-perl-5.22.1.3-32bit-portable.zip
|
||||||
|
WORKING_DIRECTORY ${DOWNLOAD_DIR}/perl32
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# get yasm for vpx
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe")
|
||||||
|
message("Downloading yasm")
|
||||||
|
file(DOWNLOAD "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/yasm.exe")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("checking i686-w64-mingw32-strings")
|
||||||
|
# copy strings.exe to i686-w64-mingw32-strings for x264
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe")
|
||||||
|
message("fixing i686-w64-mingw32-strings.exe")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strings.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strings.exe"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("checking i686-w64-mingw32-ar.exe")
|
||||||
|
# copy ar.exe to i686-w64-mingw32-ar.exe for x264
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe")
|
||||||
|
message("fixing i686-w64-mingw32-ar.exe")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ar.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ar.exe"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("checking i686-w64-mingw32-strip.exe")
|
||||||
|
# copy strip.exe to i686-w64-mingw32-strip.exe for x264
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe")
|
||||||
|
message("fixing i686-w64-mingw32-strip.exe")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/strip.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-strip.exe"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("checking i686-w64-mingw32-ranlib.exe")
|
||||||
|
# copy ranlib.exe to i686-w64-mingw32-ranlib.exe for x264
|
||||||
|
if(NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe")
|
||||||
|
message("fixing i686-w64-mingw32-ranlib.exe")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/mingw/mingw32/bin/ranlib.exe" "${DOWNLOAD_DIR}/mingw/mingw32/bin/i686-w64-mingw32-ranlib.exe"
|
||||||
|
)
|
||||||
|
endif()
|
@@ -19,7 +19,7 @@
|
|||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# Mingw64 Builds
|
# Mingw64 Builds
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# This installs mingw64+msys to compile ffmpeg/iconv/libsndfile/fftw3
|
# This installs mingw64+msys to compile ffmpeg/iconv/libsndfile/lapack/fftw3
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
message("LIBDIR = ${LIBDIR}")
|
message("LIBDIR = ${LIBDIR}")
|
||||||
@@ -128,14 +128,6 @@ if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get.exe") AND (NOT EXISTS "$
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if((EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get.exe") AND (NOT EXISTS "${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/m4.exe"))
|
|
||||||
message("Installing m4")
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${DOWNLOAD_DIR}/mingw/mingw64/bin/mingw-get install msys msys-m4
|
|
||||||
WORKING_DIRECTORY ${DOWNLOAD_DIR}/mingw/mingw64/bin/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message("Checking for CoreUtils")
|
message("Checking for CoreUtils")
|
||||||
# download old core_utils for pr.exe (ffmpeg needs it to build)
|
# download old core_utils for pr.exe (ffmpeg needs it to build)
|
||||||
if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
|
if(NOT EXISTS "${DOWNLOAD_DIR}/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2")
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
my %targets = (
|
%targets = (
|
||||||
|
|
||||||
"blender-linux-x86" => {
|
"blender-linux-x86" => {
|
||||||
inherit_from => [ "linux-x86" ],
|
inherit_from => [ "linux-x86" ],
|
||||||
|
@@ -50,13 +50,6 @@ ExternalProject_Add(external_tbb
|
|||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(BUILD_MODE STREQUAL Release)
|
if(BUILD_MODE STREQUAL Release)
|
||||||
ExternalProject_Add_Step(external_tbb after_install
|
ExternalProject_Add_Step(external_tbb after_install
|
||||||
# findtbb.cmake in some deps *NEEDS* to find tbb_debug.lib even if they are not going to use it
|
|
||||||
# to make that test pass, we place a copy with the right name in the lib folder.
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.lib
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.dll ${HARVEST_TARGET}/tbb/lib/tbb_debug.dll
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.dll ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.dll
|
|
||||||
# Normal collection of build artifacts
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.dll ${HARVEST_TARGET}/tbb/lib/tbb.dll
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.dll ${HARVEST_TARGET}/tbb/lib/tbb.dll
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib
|
||||||
|
@@ -16,12 +16,6 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
if(WITH_WEBP)
|
|
||||||
set(WITH_TIFF_WEBP ON)
|
|
||||||
else()
|
|
||||||
set(WITH_TIFF_WEBP OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(TIFF_EXTRA_ARGS
|
set(TIFF_EXTRA_ARGS
|
||||||
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
|
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
|
||||||
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
|
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
|
||||||
@@ -29,8 +23,6 @@ set(TIFF_EXTRA_ARGS
|
|||||||
-DBUILD_SHARED_LIBS=OFF
|
-DBUILD_SHARED_LIBS=OFF
|
||||||
-Dlzma=OFF
|
-Dlzma=OFF
|
||||||
-Djbig=OFF
|
-Djbig=OFF
|
||||||
-Dzstd=OFF
|
|
||||||
-Dwebp=${WITH_TIFF_WEBP}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ExternalProject_Add(external_tiff
|
ExternalProject_Add(external_tiff
|
||||||
|
@@ -27,9 +27,6 @@ set(USD_EXTRA_ARGS
|
|||||||
-DTBB_INCLUDE_DIRS=${LIBDIR}/tbb/include
|
-DTBB_INCLUDE_DIRS=${LIBDIR}/tbb/include
|
||||||
-DTBB_LIBRARIES=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${LIBEXT}
|
-DTBB_LIBRARIES=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${LIBEXT}
|
||||||
-DTbb_TBB_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${LIBEXT}
|
-DTbb_TBB_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${LIBEXT}
|
||||||
# USD wants the tbb debug lib set even when you are doing a release build
|
|
||||||
# Otherwise it will error out during the cmake configure phase.
|
|
||||||
-DTBB_LIBRARIES_DEBUG=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${LIBEXT}
|
|
||||||
|
|
||||||
# This is a preventative measure that avoids possible conflicts when add-ons
|
# This is a preventative measure that avoids possible conflicts when add-ons
|
||||||
# try to load another USD library into the same process space.
|
# try to load another USD library into the same process space.
|
||||||
@@ -81,14 +78,14 @@ if(WIN32)
|
|||||||
if(BUILD_MODE STREQUAL Release)
|
if(BUILD_MODE STREQUAL Release)
|
||||||
ExternalProject_Add_Step(external_usd after_install
|
ExternalProject_Add_Step(external_usd after_install
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/ ${HARVEST_TARGET}/usd
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/ ${HARVEST_TARGET}/usd
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Release/usd_m.lib ${HARVEST_TARGET}/usd/lib/libusd_m.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Release/libusd_m.lib ${HARVEST_TARGET}/usd/lib/libusd_m.lib
|
||||||
DEPENDEES install
|
DEPENDEES install
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_MODE STREQUAL Debug)
|
if(BUILD_MODE STREQUAL Debug)
|
||||||
ExternalProject_Add_Step(external_usd after_install
|
ExternalProject_Add_Step(external_usd after_install
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/lib ${HARVEST_TARGET}/usd/lib
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/lib ${HARVEST_TARGET}/usd/lib
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Debug/usd_m_d.lib ${HARVEST_TARGET}/usd/lib/libusd_m_d.lib
|
COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/usd/src/external_usd-build/pxr/Debug/libusd_m_d.lib ${HARVEST_TARGET}/usd/lib/libusd_m_d.lib
|
||||||
DEPENDEES install
|
DEPENDEES install
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -78,6 +78,10 @@ set(FREEGLUT_VERSION 3.0.0)
|
|||||||
set(FREEGLUT_URI http://pilotfiber.dl.sourceforge.net/project/freeglut/freeglut/${FREEGLUT_VERSION}/freeglut-${FREEGLUT_VERSION}.tar.gz)
|
set(FREEGLUT_URI http://pilotfiber.dl.sourceforge.net/project/freeglut/freeglut/${FREEGLUT_VERSION}/freeglut-${FREEGLUT_VERSION}.tar.gz)
|
||||||
set(FREEGLUT_HASH 90c3ca4dd9d51cf32276bc5344ec9754)
|
set(FREEGLUT_HASH 90c3ca4dd9d51cf32276bc5344ec9754)
|
||||||
|
|
||||||
|
set(HDF5_VERSION 1.8.17)
|
||||||
|
set(HDF5_URI https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-${HDF5_VERSION}/src/hdf5-${HDF5_VERSION}.tar.gz)
|
||||||
|
set(HDF5_HASH 7d572f8f3b798a628b8245af0391a0ca)
|
||||||
|
|
||||||
set(ALEMBIC_VERSION 1.7.12)
|
set(ALEMBIC_VERSION 1.7.12)
|
||||||
set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.tar.gz)
|
set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.tar.gz)
|
||||||
set(ALEMBIC_MD5 e2b3777f23c5c09481a008cc6f0f8a40)
|
set(ALEMBIC_MD5 e2b3777f23c5c09481a008cc6f0f8a40)
|
||||||
@@ -135,11 +139,11 @@ set(OSL_VERSION 1.10.10)
|
|||||||
set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.tar.gz)
|
set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.tar.gz)
|
||||||
set(OSL_HASH 00dec08a93c8084e53848b9ad047889f)
|
set(OSL_HASH 00dec08a93c8084e53848b9ad047889f)
|
||||||
|
|
||||||
set(PYTHON_VERSION 3.7.7)
|
set(PYTHON_VERSION 3.7.4)
|
||||||
set(PYTHON_SHORT_VERSION 3.7)
|
set(PYTHON_SHORT_VERSION 3.7)
|
||||||
set(PYTHON_SHORT_VERSION_NO_DOTS 37)
|
set(PYTHON_SHORT_VERSION_NO_DOTS 37)
|
||||||
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
|
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
|
||||||
set(PYTHON_HASH 172c650156f7bea68ce31b2fd01fa766)
|
set(PYTHON_HASH d33e4aae66097051c2eca45ee3604803)
|
||||||
|
|
||||||
set(TBB_VERSION 2019_U9)
|
set(TBB_VERSION 2019_U9)
|
||||||
set(TBB_URI https://github.com/oneapi-src/oneTBB/archive/${TBB_VERSION}.tar.gz)
|
set(TBB_URI https://github.com/oneapi-src/oneTBB/archive/${TBB_VERSION}.tar.gz)
|
||||||
@@ -149,16 +153,16 @@ set(OPENVDB_VERSION 7.0.0)
|
|||||||
set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
|
set(OPENVDB_URI https://github.com/dreamworksanimation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
|
||||||
set(OPENVDB_HASH fd6c4f168282f7e0e494d290cd531fa8)
|
set(OPENVDB_HASH fd6c4f168282f7e0e494d290cd531fa8)
|
||||||
|
|
||||||
set(IDNA_VERSION 2.9)
|
set(IDNA_VERSION 2.8)
|
||||||
set(CHARDET_VERSION 3.0.4)
|
set(CHARDET_VERSION 3.0.4)
|
||||||
set(URLLIB3_VERSION 1.25.9)
|
set(URLLIB3_VERSION 1.25.3)
|
||||||
set(CERTIFI_VERSION 2020.4.5.2)
|
set(CERTIFI_VERSION 2019.6.16)
|
||||||
set(REQUESTS_VERSION 2.23.0)
|
set(REQUESTS_VERSION 2.22.0)
|
||||||
|
|
||||||
set(NUMPY_VERSION 1.17.5)
|
set(NUMPY_VERSION v1.17.0)
|
||||||
set(NUMPY_SHORT_VERSION 1.17)
|
set(NUMPY_SHORT_VERSION 1.17)
|
||||||
set(NUMPY_URI https://github.com/numpy/numpy/releases/download/v${NUMPY_VERSION}/numpy-${NUMPY_VERSION}.zip)
|
set(NUMPY_URI https://files.pythonhosted.org/packages/da/32/1b8f2bb5fb50e4db68543eb85ce37b9fa6660cd05b58bddfafafa7ed62da/numpy-1.17.0.zip)
|
||||||
set(NUMPY_HASH 763a5646fa6eef7a22f4895bca0524f2)
|
set(NUMPY_HASH aed49b31bcb44ec73b8155be78566135)
|
||||||
|
|
||||||
set(LAME_VERSION 3.100)
|
set(LAME_VERSION 3.100)
|
||||||
set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.100/lame-${LAME_VERSION}.tar.gz)
|
set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.100/lame-${LAME_VERSION}.tar.gz)
|
||||||
@@ -188,8 +192,8 @@ set(OPUS_VERSION 1.3.1)
|
|||||||
set(OPUS_URI https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz)
|
set(OPUS_URI https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz)
|
||||||
set(OPUS_HASH 65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d)
|
set(OPUS_HASH 65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d)
|
||||||
|
|
||||||
set(X264_URI https://code.videolan.org/videolan/x264/-/archive/33f9e1474613f59392be5ab6a7e7abf60fa63622/x264-33f9e1474613f59392be5ab6a7e7abf60fa63622.tar.gz)
|
set(X264_URI https://code.videolan.org/videolan/x264/-/archive/master/x264-33f9e1474613f59392be5ab6a7e7abf60fa63622.tar.gz)
|
||||||
set(X264_HASH 5456450ee1ae02cd2328be3157367a232a0ab73315e8c8f80dab80469524f525)
|
set(X264_HASH 300dfb5b6c35722516f168868ce9419252a9e9eb77a05d82c9cede925b691bd6)
|
||||||
|
|
||||||
set(XVIDCORE_VERSION 1.3.7)
|
set(XVIDCORE_VERSION 1.3.7)
|
||||||
set(XVIDCORE_URI https://downloads.xvid.com/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz)
|
set(XVIDCORE_URI https://downloads.xvid.com/downloads/xvidcore-${XVIDCORE_VERSION}.tar.gz)
|
||||||
@@ -212,6 +216,10 @@ set(ICONV_VERSION 1.16)
|
|||||||
set(ICONV_URI http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ICONV_VERSION}.tar.gz)
|
set(ICONV_URI http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ICONV_VERSION}.tar.gz)
|
||||||
set(ICONV_HASH 7d2a800b952942bb2880efb00cfd524c)
|
set(ICONV_HASH 7d2a800b952942bb2880efb00cfd524c)
|
||||||
|
|
||||||
|
set(LAPACK_VERSION 3.6.0)
|
||||||
|
set(LAPACK_URI http://www.netlib.org/lapack/lapack-${LAPACK_VERSION}.tgz)
|
||||||
|
set(LAPACK_HASH f2f6c67134e851fe189bb3ca1fbb5101)
|
||||||
|
|
||||||
set(SNDFILE_VERSION 1.0.28)
|
set(SNDFILE_VERSION 1.0.28)
|
||||||
set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz)
|
set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_VERSION}.tar.gz)
|
||||||
set(SNDFILE_HASH 646b5f98ce89ac60cdb060fcd398247c)
|
set(SNDFILE_HASH 646b5f98ce89ac60cdb060fcd398247c)
|
||||||
@@ -232,13 +240,13 @@ set(SPNAV_VERSION 0.2.3)
|
|||||||
set(SPNAV_URI http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%20${SPNAV_VERSION}/libspnav-${SPNAV_VERSION}.tar.gz)
|
set(SPNAV_URI http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%20${SPNAV_VERSION}/libspnav-${SPNAV_VERSION}.tar.gz)
|
||||||
set(SPNAV_HASH 44d840540d53326d4a119c0f1aa7bf0a)
|
set(SPNAV_HASH 44d840540d53326d4a119c0f1aa7bf0a)
|
||||||
|
|
||||||
set(JEMALLOC_VERSION 5.2.1)
|
set(JEMALLOC_VERSION 5.0.1)
|
||||||
set(JEMALLOC_URI https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2)
|
set(JEMALLOC_URI https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2)
|
||||||
set(JEMALLOC_HASH 3d41fbf006e6ebffd489bdb304d009ae)
|
set(JEMALLOC_HASH 507f7b6b882d868730d644510491d18f)
|
||||||
|
|
||||||
set(XML2_VERSION 2.9.10)
|
set(XML2_VERSION 2.9.4)
|
||||||
set(XML2_URI http://xmlsoft.org/sources/libxml2-${XML2_VERSION}.tar.gz)
|
set(XML2_URI http://xmlsoft.org/sources/libxml2-${XML2_VERSION}.tar.gz)
|
||||||
set(XML2_HASH 10942a1dc23137a8aa07f0639cbfece5)
|
set(XML2_HASH ae249165c173b1ff386ee8ad676815f5)
|
||||||
|
|
||||||
set(TINYXML_VERSION 2_6_2)
|
set(TINYXML_VERSION 2_6_2)
|
||||||
set(TINYXML_VERSION_DOTS 2.6.2)
|
set(TINYXML_VERSION_DOTS 2.6.2)
|
||||||
@@ -265,23 +273,23 @@ set(FLEXBISON_HASH d87a3938194520d904013abef3df10ce)
|
|||||||
|
|
||||||
# NOTE: bzip.org domain does no longer belong to BZip 2 project, so we download
|
# NOTE: bzip.org domain does no longer belong to BZip 2 project, so we download
|
||||||
# sources from Debian packaging.
|
# sources from Debian packaging.
|
||||||
set(BZIP2_VERSION 1.0.8)
|
set(BZIP2_VERSION 1.0.6)
|
||||||
set(BZIP2_URI http://http.debian.net/debian/pool/main/b/bzip2/bzip2_${BZIP2_VERSION}.orig.tar.gz)
|
set(BZIP2_URI http://http.debian.net/debian/pool/main/b/bzip2/bzip2_${BZIP2_VERSION}.orig.tar.bz2)
|
||||||
set(BZIP2_HASH ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269)
|
set(BZIP2_HASH d70a9ccd8bdf47e302d96c69fecd54925f45d9c7b966bb4ef5f56b770960afa7)
|
||||||
|
|
||||||
set(FFI_VERSION 3.3)
|
set(FFI_VERSION 3.2.1)
|
||||||
set(FFI_URI https://sourceware.org/pub/libffi/libffi-${FFI_VERSION}.tar.gz)
|
set(FFI_URI https://sourceware.org/pub/libffi/libffi-${FFI_VERSION}.tar.gz)
|
||||||
set(FFI_HASH 72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056)
|
set(FFI_HASH d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37)
|
||||||
|
|
||||||
set(LZMA_VERSION 5.2.5)
|
set(LZMA_VERSION 5.2.4)
|
||||||
set(LZMA_URI https://tukaani.org/xz/xz-${LZMA_VERSION}.tar.bz2)
|
set(LZMA_URI https://tukaani.org/xz/xz-${LZMA_VERSION}.tar.bz2)
|
||||||
set(LZMA_HASH 5117f930900b341493827d63aa910ff5e011e0b994197c3b71c08a20228a42df)
|
set(LZMA_HASH 3313fd2a95f43d88e44264e6b015e7d03053e681860b0d5d3f9baca79c57b7bf)
|
||||||
|
|
||||||
set(SSL_VERSION 1.1.1g)
|
set(SSL_VERSION 1.1.0i)
|
||||||
set(SSL_URI https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz)
|
set(SSL_URI https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz)
|
||||||
set(SSL_HASH ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46)
|
set(SSL_HASH ebbfc844a8c8cc0ea5dc10b86c9ce97f401837f3fa08c17b2cdadc118253cf99)
|
||||||
|
|
||||||
set(SQLITE_VERSION 3.31.1)
|
set(SQLITE_VERSION 3.24.0)
|
||||||
set(SQLITE_URI https://www.sqlite.org/2018/sqlite-src-3240000.zip)
|
set(SQLITE_URI https://www.sqlite.org/2018/sqlite-src-3240000.zip)
|
||||||
set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7)
|
set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7)
|
||||||
|
|
||||||
@@ -289,13 +297,13 @@ set(EMBREE_VERSION 3.10.0)
|
|||||||
set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
|
set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
|
||||||
set(EMBREE_HASH 4bbe29e7eaa46417efc75fc5f1e8eb87)
|
set(EMBREE_HASH 4bbe29e7eaa46417efc75fc5f1e8eb87)
|
||||||
|
|
||||||
set(USD_VERSION 20.05)
|
set(USD_VERSION 19.11)
|
||||||
set(USD_URI https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
|
set(USD_URI https://github.com/PixarAnimationStudios/USD/archive/v${USD_VERSION}.tar.gz)
|
||||||
set(USD_HASH 6d679e739e7f65725d9c029e37dda9fc)
|
set(USD_HASH 79ff176167b3fe85f4953abd6cc5e0cc)
|
||||||
|
|
||||||
set(OIDN_VERSION 1.2.1)
|
set(OIDN_VERSION 1.0.0)
|
||||||
set(OIDN_URI https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.tar.gz)
|
set(OIDN_URI https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.zip)
|
||||||
set(OIDN_HASH cbebc1a25eb6de62af3a59e943063608)
|
set(OIDN_HASH 19fe67b0164e8f020ac8a4f520defe60)
|
||||||
|
|
||||||
set(LIBGLU_VERSION 9.0.1)
|
set(LIBGLU_VERSION 9.0.1)
|
||||||
set(LIBGLU_URI ftp://ftp.freedesktop.org/pub/mesa/glu/glu-${LIBGLU_VERSION}.tar.xz)
|
set(LIBGLU_URI ftp://ftp.freedesktop.org/pub/mesa/glu/glu-${LIBGLU_VERSION}.tar.xz)
|
||||||
@@ -305,13 +313,6 @@ set(MESA_VERSION 18.3.1)
|
|||||||
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
|
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
|
||||||
set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
|
set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
|
||||||
|
|
||||||
set(NASM_VERSION 2.15.02)
|
|
||||||
set(NASM_URI https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.xz)
|
|
||||||
set(NASM_HASH f4fd1329b1713e1ccd34b2fc121c4bcd278c9f91cc4cb205ae8fcd2e4728dd14)
|
|
||||||
|
|
||||||
set(XR_OPENXR_SDK_VERSION 1.0.8)
|
set(XR_OPENXR_SDK_VERSION 1.0.8)
|
||||||
set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
|
set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
|
||||||
set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07)
|
set(XR_OPENXR_SDK_HASH c6de63d2e0f9029aa58dfa97cad8ce07)
|
||||||
set(ISPC_VERSION v1.13.0)
|
|
||||||
set(ISPC_URI https://github.com/ispc/ispc/archive/${ISPC_VERSION}.tar.gz)
|
|
||||||
set(ISPC_HASH 4bf5e8d0020c4b9980faa702c1a6f25f)
|
|
||||||
|
@@ -21,21 +21,12 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
set(X264_CONFIGURE_ENV
|
|
||||||
export AS=${LIBDIR}/nasm/bin/nasm
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
set(X264_CONFIGURE_ENV echo .)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ExternalProject_Add(external_x264
|
ExternalProject_Add(external_x264
|
||||||
URL ${X264_URI}
|
URL ${X264_URI}
|
||||||
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${DOWNLOAD_DIR}
|
||||||
URL_HASH SHA256=${X264_HASH}
|
URL_HASH SHA256=${X264_HASH}
|
||||||
PREFIX ${BUILD_DIR}/x264
|
PREFIX ${BUILD_DIR}/x264
|
||||||
CONFIGURE_COMMAND ${CONFIGURE_ENV} && ${X264_CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ &&
|
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
|
||||||
${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264
|
|
||||||
--enable-static
|
--enable-static
|
||||||
--enable-pic
|
--enable-pic
|
||||||
--disable-lavf
|
--disable-lavf
|
||||||
@@ -48,10 +39,3 @@ ExternalProject_Add(external_x264
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_target_properties(external_x264 PROPERTIES FOLDER Mingw)
|
set_target_properties(external_x264 PROPERTIES FOLDER Mingw)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
add_dependencies(
|
|
||||||
external_x264
|
|
||||||
external_nasm
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
@@ -376,7 +376,7 @@ USE_CXX11=true
|
|||||||
|
|
||||||
CLANG_FORMAT_VERSION_MIN="6.0"
|
CLANG_FORMAT_VERSION_MIN="6.0"
|
||||||
|
|
||||||
PYTHON_VERSION="3.7.7"
|
PYTHON_VERSION="3.7.4"
|
||||||
PYTHON_VERSION_MIN="3.7"
|
PYTHON_VERSION_MIN="3.7"
|
||||||
PYTHON_VERSION_INSTALLED=$PYTHON_VERSION_MIN
|
PYTHON_VERSION_INSTALLED=$PYTHON_VERSION_MIN
|
||||||
PYTHON_FORCE_BUILD=false
|
PYTHON_FORCE_BUILD=false
|
||||||
@@ -459,7 +459,7 @@ ALEMBIC_FORCE_BUILD=false
|
|||||||
ALEMBIC_FORCE_REBUILD=false
|
ALEMBIC_FORCE_REBUILD=false
|
||||||
ALEMBIC_SKIP=false
|
ALEMBIC_SKIP=false
|
||||||
|
|
||||||
USD_VERSION="20.05"
|
USD_VERSION="19.11"
|
||||||
USD_FORCE_BUILD=false
|
USD_FORCE_BUILD=false
|
||||||
USD_FORCE_REBUILD=false
|
USD_FORCE_REBUILD=false
|
||||||
USD_SKIP=false
|
USD_SKIP=false
|
||||||
@@ -1574,7 +1574,7 @@ compile_TBB() {
|
|||||||
if [ ! -d $_inst ]; then
|
if [ ! -d $_inst ]; then
|
||||||
INFO "Building TBB-$TBB_VERSION$TBB_VERSION_UPDATE"
|
INFO "Building TBB-$TBB_VERSION$TBB_VERSION_UPDATE"
|
||||||
_is_building=true
|
_is_building=true
|
||||||
|
|
||||||
# Rebuild dependencies as well!
|
# Rebuild dependencies as well!
|
||||||
_update_deps_tbb
|
_update_deps_tbb
|
||||||
|
|
||||||
@@ -1691,7 +1691,7 @@ compile_OCIO() {
|
|||||||
if [ ! -d $_inst ]; then
|
if [ ! -d $_inst ]; then
|
||||||
INFO "Building OpenColorIO-$OCIO_VERSION"
|
INFO "Building OpenColorIO-$OCIO_VERSION"
|
||||||
_is_building=true
|
_is_building=true
|
||||||
|
|
||||||
# Rebuild dependencies as well!
|
# Rebuild dependencies as well!
|
||||||
_update_deps_ocio
|
_update_deps_ocio
|
||||||
|
|
||||||
@@ -3428,7 +3428,7 @@ compile_XR_OpenXR_SDK() {
|
|||||||
# Install on DEB-like
|
# Install on DEB-like
|
||||||
|
|
||||||
get_package_version_DEB() {
|
get_package_version_DEB() {
|
||||||
dpkg-query -W -f '${Version}' $1 | sed -r 's/([0-9]+:)?(([0-9]+\.?)+([0-9]+)).*/\2/'
|
dpkg-query -W -f '${Version}' $1 | sed -r 's/([0-9]+:)?(([0-9]+\.?){$2}([0-9]+)).*/\2/'
|
||||||
}
|
}
|
||||||
|
|
||||||
check_package_DEB() {
|
check_package_DEB() {
|
||||||
@@ -3631,7 +3631,7 @@ install_DEB() {
|
|||||||
# Check cmake/glew versions and disable features for older distros.
|
# Check cmake/glew versions and disable features for older distros.
|
||||||
# This is so Blender can at least compile.
|
# This is so Blender can at least compile.
|
||||||
PRINT ""
|
PRINT ""
|
||||||
_cmake=`get_package_version_DEB cmake`
|
_cmake=`get_package_version_DEB cmake 3`
|
||||||
version_ge $_cmake "2.8.10"
|
version_ge $_cmake "2.8.10"
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
version_ge $_cmake "2.8.8"
|
version_ge $_cmake "2.8.8"
|
||||||
@@ -3646,7 +3646,7 @@ install_DEB() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
PRINT ""
|
PRINT ""
|
||||||
_glew=`get_package_version_DEB libglew-dev`
|
_glew=`get_package_version_DEB libglew-dev 3`
|
||||||
if [ -z $_glew ]; then
|
if [ -z $_glew ]; then
|
||||||
# Stupid virtual package in Ubuntu 12.04 doesn't show version number...
|
# Stupid virtual package in Ubuntu 12.04 doesn't show version number...
|
||||||
_glew=`apt-cache showpkg libglew-dev|tail -n1|awk '{print $2}'|sed 's/-.*//'`
|
_glew=`apt-cache showpkg libglew-dev|tail -n1|awk '{print $2}'|sed 's/-.*//'`
|
||||||
@@ -3678,7 +3678,8 @@ install_DEB() {
|
|||||||
check_package_version_ge_DEB python3-dev $PYTHON_VERSION_MIN
|
check_package_version_ge_DEB python3-dev $PYTHON_VERSION_MIN
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_DEB python3-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_DEB python3-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||||
|
PRINT $(echo `get_package_version_DEB python3-dev` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||||
|
|
||||||
install_packages_DEB python3-dev
|
install_packages_DEB python3-dev
|
||||||
clean_Python
|
clean_Python
|
||||||
PRINT ""
|
PRINT ""
|
||||||
@@ -3892,6 +3893,7 @@ install_DEB() {
|
|||||||
INFO "Forced Alembic building, as requested..."
|
INFO "Forced Alembic building, as requested..."
|
||||||
compile_ALEMBIC
|
compile_ALEMBIC
|
||||||
else
|
else
|
||||||
|
# No package currently, only HDF5!
|
||||||
compile_ALEMBIC
|
compile_ALEMBIC
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -4300,7 +4302,8 @@ install_RPM() {
|
|||||||
else
|
else
|
||||||
check_package_version_ge_RPM python3-devel $PYTHON_VERSION_MIN
|
check_package_version_ge_RPM python3-devel $PYTHON_VERSION_MIN
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_RPM python3-devel` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
get_package_version_RPM python3-devel
|
||||||
|
PYTHON_VERSION_INSTALLED=`echo $? | sed -r 's/([0-9]+:)?(([0-9]+\.?)?([0-9]+)).*/\2/'`
|
||||||
|
|
||||||
install_packages_RPM python3-devel
|
install_packages_RPM python3-devel
|
||||||
clean_Python
|
clean_Python
|
||||||
@@ -4825,7 +4828,8 @@ install_ARCH() {
|
|||||||
else
|
else
|
||||||
check_package_version_ge_ARCH python $PYTHON_VERSION_MIN
|
check_package_version_ge_ARCH python $PYTHON_VERSION_MIN
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
PYTHON_VERSION_INSTALLED=$(echo `get_package_version_ARCH python` | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')
|
get_package_version_ARCH python
|
||||||
|
PYTHON_VERSION_INSTALLED=`echo $? | sed -r 's/([0-9]+:)?(([0-9]+\.?)?([0-9]+)).*/\2/'`
|
||||||
|
|
||||||
install_packages_ARCH python
|
install_packages_ARCH python
|
||||||
clean_Python
|
clean_Python
|
||||||
|
20
build_files/build_environment/patches/cmakelists_hidapi.txt
Normal file
20
build_files/build_environment/patches/cmakelists_hidapi.txt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
project(hidapi)
|
||||||
|
|
||||||
|
set(SRC_FILES
|
||||||
|
windows/hid.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HEADER_FILES
|
||||||
|
hidapi/hidapi.h
|
||||||
|
)
|
||||||
|
include_directories(hidapi)
|
||||||
|
add_definitions(-DHID_API_STATIC)
|
||||||
|
add_library(hidapi STATIC ${SRC_FILES} ${HEADER_FILES})
|
||||||
|
|
||||||
|
install(TARGETS hidapi DESTINATION lib)
|
||||||
|
|
||||||
|
INSTALL(FILES hidapi/hidapi.h
|
||||||
|
DESTINATION "include"
|
||||||
|
)
|
||||||
|
|
@@ -1,14 +0,0 @@
|
|||||||
diff -Naur orig/common/sys/platform.h external_embree/common/sys/platform.h
|
|
||||||
--- orig/common/sys/platform.h 2020-05-13 23:08:53 -0600
|
|
||||||
+++ external_embree/common/sys/platform.h 2020-06-13 17:40:26 -0600
|
|
||||||
@@ -84,8 +84,8 @@
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
-#define dll_export __declspec(dllexport)
|
|
||||||
-#define dll_import __declspec(dllimport)
|
|
||||||
+#define dll_export
|
|
||||||
+#define dll_import
|
|
||||||
#else
|
|
||||||
#define dll_export __attribute__ ((visibility ("default")))
|
|
||||||
#define dll_import
|
|
@@ -9,62 +9,3 @@
|
|||||||
enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++"
|
enabled libopenmpt && require_pkg_config libopenmpt "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create -lstdc++ && append libopenmpt_extralibs "-lstdc++"
|
||||||
enabled libopus && {
|
enabled libopus && {
|
||||||
enabled libopus_decoder && {
|
enabled libopus_decoder && {
|
||||||
--- a/libavcodec/cfhddata.c
|
|
||||||
+++ b/libavcodec/cfhddata.c
|
|
||||||
@@ -276,10 +276,10 @@
|
|
||||||
av_cold int ff_cfhd_init_vlcs(CFHDContext *s)
|
|
||||||
{
|
|
||||||
int i, j, ret = 0;
|
|
||||||
- uint32_t new_cfhd_vlc_bits[NB_VLC_TABLE_18 * 2];
|
|
||||||
- uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2];
|
|
||||||
- uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2];
|
|
||||||
- int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2];
|
|
||||||
+ uint32_t *new_cfhd_vlc_bits = av_calloc(sizeof(uint32_t), NB_VLC_TABLE_18 * 2);
|
|
||||||
+ uint8_t *new_cfhd_vlc_len = av_calloc(sizeof(uint8_t), NB_VLC_TABLE_18 * 2);
|
|
||||||
+ uint16_t *new_cfhd_vlc_run = av_calloc(sizeof(uint16_t), NB_VLC_TABLE_18 * 2);
|
|
||||||
+ int16_t *new_cfhd_vlc_level = av_calloc(sizeof(int16_t), NB_VLC_TABLE_18 * 2);
|
|
||||||
|
|
||||||
/** Similar to dv.c, generate signed VLC tables **/
|
|
||||||
|
|
||||||
@@ -305,8 +305,13 @@
|
|
||||||
|
|
||||||
ret = init_vlc(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len,
|
|
||||||
1, 1, new_cfhd_vlc_bits, 4, 4, 0);
|
|
||||||
- if (ret < 0)
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ av_free(new_cfhd_vlc_bits);
|
|
||||||
+ av_free(new_cfhd_vlc_len);
|
|
||||||
+ av_free(new_cfhd_vlc_run);
|
|
||||||
+ av_free(new_cfhd_vlc_level);
|
|
||||||
return ret;
|
|
||||||
+ }
|
|
||||||
for (i = 0; i < s->vlc_9.table_size; i++) {
|
|
||||||
int code = s->vlc_9.table[i][0];
|
|
||||||
int len = s->vlc_9.table[i][1];
|
|
||||||
@@ -346,8 +351,14 @@
|
|
||||||
|
|
||||||
ret = init_vlc(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len,
|
|
||||||
1, 1, new_cfhd_vlc_bits, 4, 4, 0);
|
|
||||||
- if (ret < 0)
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ av_free(new_cfhd_vlc_bits);
|
|
||||||
+ av_free(new_cfhd_vlc_len);
|
|
||||||
+ av_free(new_cfhd_vlc_run);
|
|
||||||
+ av_free(new_cfhd_vlc_level);
|
|
||||||
return ret;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
av_assert0(s->vlc_18.table_size == 4572);
|
|
||||||
|
|
||||||
for (i = 0; i < s->vlc_18.table_size; i++) {
|
|
||||||
@@ -367,5 +378,10 @@
|
|
||||||
s->table_18_rl_vlc[i].run = run;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ av_free(new_cfhd_vlc_bits);
|
|
||||||
+ av_free(new_cfhd_vlc_len);
|
|
||||||
+ av_free(new_cfhd_vlc_run);
|
|
||||||
+ av_free(new_cfhd_vlc_level);
|
|
||||||
+
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
15
build_files/build_environment/patches/hidapi.diff
Normal file
15
build_files/build_environment/patches/hidapi.diff
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
--- hidapi/hidapi.h 2011-10-25 20:58:16 -0600
|
||||||
|
+++ hidapi/hidapi.h 2016-11-01 12:05:58 -0600
|
||||||
|
@@ -30,7 +30,11 @@
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
- #define HID_API_EXPORT __declspec(dllexport)
|
||||||
|
+ #ifdef HID_API_STATIC
|
||||||
|
+ #define HID_API_EXPORT
|
||||||
|
+ #else
|
||||||
|
+ #define HID_API_EXPORT __declspec(dllexport)
|
||||||
|
+ #endif
|
||||||
|
#define HID_API_CALL
|
||||||
|
#else
|
||||||
|
#define HID_API_EXPORT /**< API export macro */
|
@@ -1,85 +0,0 @@
|
|||||||
diff -Naur external_ispc/CMakeLists.txt external_ispc_fixed/CMakeLists.txt
|
|
||||||
--- external_ispc/CMakeLists.txt 2020-04-23 17:29:06 -0600
|
|
||||||
+++ external_ispc_fixed/CMakeLists.txt 2020-05-05 09:01:09 -0600
|
|
||||||
@@ -389,7 +389,7 @@
|
|
||||||
|
|
||||||
# Link against Clang libraries
|
|
||||||
foreach(clangLib ${CLANG_LIBRARY_LIST})
|
|
||||||
- find_library(${clangLib}Path NAMES ${clangLib} HINTS ${LLVM_LIBRARY_DIRS})
|
|
||||||
+ find_library(${clangLib}Path NAMES ${clangLib} HINTS ${LLVM_LIBRARY_DIRS} ${CLANG_LIBRARY_DIR})
|
|
||||||
list(APPEND CLANG_LIBRARY_FULL_PATH_LIST ${${clangLib}Path})
|
|
||||||
endforeach()
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${CLANG_LIBRARY_FULL_PATH_LIST})
|
|
||||||
diff -Naur orig/CMakeLists.txt external_ispc/CMakeLists.txt
|
|
||||||
--- orig/CMakeLists.txt 2020-05-05 09:19:11 -0600
|
|
||||||
+++ external_ispc/CMakeLists.txt 2020-05-05 09:26:44 -0600
|
|
||||||
@@ -333,7 +333,7 @@
|
|
||||||
|
|
||||||
# Include directories
|
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
||||||
- ${LLVM_INCLUDE_DIRS}
|
|
||||||
+ ${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS}
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
|
|
||||||
# Compile options
|
|
||||||
diff -Naur orig/cmake/GenerateBuiltins.cmake.txt external_ispc/cmake/GenerateBuiltins.cmake.txt
|
|
||||||
+++ orig/cmake/GenerateBuiltins.cmake 2020-05-25 13:32:40.830803821 +0200
|
|
||||||
+++ external_ispc/cmake/GenerateBuiltins.cmake 2020-05-25 13:32:40.830803821 +0200
|
|
||||||
@@ -97,6 +97,8 @@
|
|
||||||
|
|
||||||
if ("${bit}" STREQUAL "32" AND ${arch} STREQUAL "x86")
|
|
||||||
set(target_arch "i386")
|
|
||||||
+ # Blender: disable 32bit due to build issues on Linux and being unnecessary.
|
|
||||||
+ set(SKIP ON)
|
|
||||||
elseif ("${bit}" STREQUAL "64" AND ${arch} STREQUAL "x86")
|
|
||||||
set(target_arch "x86_64")
|
|
||||||
elseif ("${bit}" STREQUAL "32" AND ${arch} STREQUAL "arm")
|
|
||||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
||||||
index 46a8db8..f53beef 100644
|
|
||||||
--- a/CMakeLists.txt
|
|
||||||
+++ b/CMakeLists.txt
|
|
||||||
@@ -36,8 +36,12 @@
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
|
||||||
|
|
||||||
if (UNIX)
|
|
||||||
- set(CMAKE_C_COMPILER "clang")
|
|
||||||
- set(CMAKE_CXX_COMPILER "clang++")
|
|
||||||
+ if (NOT CMAKE_C_COMPILER)
|
|
||||||
+ set(CMAKE_C_COMPILER "clang")
|
|
||||||
+ endif()
|
|
||||||
+ if (NOT CMAKE_CXX_COMPILER)
|
|
||||||
+ set(CMAKE_CXX_COMPILER "clang++")
|
|
||||||
+ endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(PROJECT_NAME ispc)
|
|
||||||
@@ -412,6 +416,29 @@ else()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
+# Link against libstdc++.a which must be provided to the linker after
|
|
||||||
+# LLVM and CLang libraries.
|
|
||||||
+# This is needed because some of LLVM/CLang dependencies are using
|
|
||||||
+# std::make_shared, which is defined in one of those:
|
|
||||||
+# - libclang-cpp.so
|
|
||||||
+# - libstdc++.a
|
|
||||||
+# Using the former one is tricky because then generated binary depends
|
|
||||||
+# on a library which is outside of the LD_LIBRARY_PATH.
|
|
||||||
+#
|
|
||||||
+# Hence, using C++ implementation from G++ which seems to work just fine.
|
|
||||||
+# In fact, from investigation seems that libclang-cpp.so itself is pulling
|
|
||||||
+# std::_Sp_make_shared_tag from G++'s libstdc++.a.
|
|
||||||
+if(UNIX AND NOT APPLE)
|
|
||||||
+ execute_process(
|
|
||||||
+ COMMAND g++ --print-file-name libstdc++.a
|
|
||||||
+ OUTPUT_VARIABLE GCC_LIBSTDCXX_A
|
|
||||||
+ OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
+ )
|
|
||||||
+ if(GCC_LIBSTDCXX_A AND EXISTS ${GCC_LIBSTDCXX_A})
|
|
||||||
+ target_link_libraries(${PROJECT_NAME} ${GCC_LIBSTDCXX_A})
|
|
||||||
+ endif()
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
# Build target for utility checking host ISA
|
|
||||||
if (ISPC_INCLUDE_UTILS)
|
|
||||||
add_executable(check_isa "")
|
|
@@ -1,129 +0,0 @@
|
|||||||
diff --git a/output/macho.h b/output/macho.h
|
|
||||||
index 538c531e..fd5e8849 100644
|
|
||||||
--- a/output/macho.h
|
|
||||||
+++ b/output/macho.h
|
|
||||||
@@ -60,6 +60,8 @@
|
|
||||||
#define LC_SEGMENT 0x1
|
|
||||||
#define LC_SEGMENT_64 0x19
|
|
||||||
#define LC_SYMTAB 0x2
|
|
||||||
+#define LC_VERSION_MIN_MACOSX 0x24
|
|
||||||
+#define LC_BUILD_VERSION 0x32
|
|
||||||
|
|
||||||
/* Symbol type bits */
|
|
||||||
#define N_STAB 0xe0
|
|
||||||
diff --git a/output/outmacho.c b/output/outmacho.c
|
|
||||||
index 08147883..de6ec902 100644
|
|
||||||
--- a/output/outmacho.c
|
|
||||||
+++ b/output/outmacho.c
|
|
||||||
@@ -38,6 +38,8 @@
|
|
||||||
|
|
||||||
#include "compiler.h"
|
|
||||||
|
|
||||||
+#include <stdlib.h>
|
|
||||||
+
|
|
||||||
#include "nctype.h"
|
|
||||||
|
|
||||||
#include "nasm.h"
|
|
||||||
@@ -64,6 +66,8 @@
|
|
||||||
#define MACHO_SYMCMD_SIZE 24
|
|
||||||
#define MACHO_NLIST_SIZE 12
|
|
||||||
#define MACHO_RELINFO_SIZE 8
|
|
||||||
+#define MACHO_BUILD_VERSION_SIZE 24
|
|
||||||
+#define MACHO_VERSION_MIN_MACOSX_SIZE 16
|
|
||||||
|
|
||||||
#define MACHO_HEADER64_SIZE 32
|
|
||||||
#define MACHO_SEGCMD64_SIZE 72
|
|
||||||
@@ -1224,6 +1228,46 @@ static void macho_layout_symbols (uint32_t *numsyms,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+static bool get_full_version_from_env (const char *variable_name,
|
|
||||||
+ int *r_major,
|
|
||||||
+ int *r_minor,
|
|
||||||
+ int *r_patch) {
|
|
||||||
+ *r_major = 0;
|
|
||||||
+ *r_minor = 0;
|
|
||||||
+ *r_patch = 0;
|
|
||||||
+
|
|
||||||
+ const char *value = getenv(variable_name);
|
|
||||||
+ if (value == NULL || value[0] == '\0') {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ const char *current_value = value;
|
|
||||||
+ const char *end_value = value + strlen(value);
|
|
||||||
+
|
|
||||||
+ char *endptr;
|
|
||||||
+
|
|
||||||
+ *r_major = strtol(current_value, &endptr, 10);
|
|
||||||
+ if (endptr >= end_value) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ current_value = endptr + 1;
|
|
||||||
+
|
|
||||||
+ *r_minor = strtol(current_value, &endptr, 10);
|
|
||||||
+ if (endptr >= end_value) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ current_value = endptr + 1;
|
|
||||||
+
|
|
||||||
+ *r_patch = strtol(current_value, &endptr, 10);
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static bool need_version_min_macosx_command (void) {
|
|
||||||
+ return getenv("MACOSX_DEPLOYMENT_TARGET") &&
|
|
||||||
+ getenv("MACOSX_SDK_VERSION");
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/* Calculate some values we'll need for writing later. */
|
|
||||||
|
|
||||||
static void macho_calculate_sizes (void)
|
|
||||||
@@ -1270,6 +1314,12 @@ static void macho_calculate_sizes (void)
|
|
||||||
head_sizeofcmds += fmt.segcmd_size + seg_nsects * fmt.sectcmd_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* LC_VERSION_MIN_MACOSX */
|
|
||||||
+ if (need_version_min_macosx_command()) {
|
|
||||||
+ ++head_ncmds;
|
|
||||||
+ head_sizeofcmds += MACHO_VERSION_MIN_MACOSX_SIZE;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (nsyms > 0) {
|
|
||||||
++head_ncmds;
|
|
||||||
head_sizeofcmds += MACHO_SYMCMD_SIZE;
|
|
||||||
@@ -1653,6 +1703,33 @@ static void macho_write (void)
|
|
||||||
else
|
|
||||||
nasm_warn(WARN_OTHER, "no sections?");
|
|
||||||
|
|
||||||
+#define ENCODE_BUILD_VERSION(major, minor, patch) \
|
|
||||||
+ (((major) << 16) | ((minor) << 8) | (patch))
|
|
||||||
+
|
|
||||||
+ if (0) {
|
|
||||||
+ fwriteint32_t(LC_BUILD_VERSION, ofile); /* cmd == LC_BUILD_VERSION */
|
|
||||||
+ fwriteint32_t(MACHO_BUILD_VERSION_SIZE, ofile); /* size of load command */
|
|
||||||
+ fwriteint32_t(1, ofile); /* platform */
|
|
||||||
+ fwriteint32_t(ENCODE_BUILD_VERSION(10, 13, 0), ofile); /* minos, X.Y.Z is encoded in nibbles xxxx.yy.zz */
|
|
||||||
+ fwriteint32_t(ENCODE_BUILD_VERSION(10, 15, 4), ofile); /* sdk, X.Y.Z is encoded in nibbles xxxx.yy.zz */
|
|
||||||
+ fwriteint32_t(0, ofile); /* number of tool entries following this */
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (need_version_min_macosx_command()) {
|
|
||||||
+ int sdk_major, sdk_minor, sdk_patch;
|
|
||||||
+ get_full_version_from_env("MACOSX_SDK_VERSION", &sdk_major, &sdk_minor, &sdk_patch);
|
|
||||||
+
|
|
||||||
+ int version_major, version_minor, version_patch;
|
|
||||||
+ get_full_version_from_env("MACOSX_DEPLOYMENT_TARGET", &version_major, &version_minor, &version_patch);
|
|
||||||
+
|
|
||||||
+ fwriteint32_t(LC_VERSION_MIN_MACOSX, ofile); /* cmd == LC_VERSION_MIN_MACOSX */
|
|
||||||
+ fwriteint32_t(MACHO_VERSION_MIN_MACOSX_SIZE, ofile); /* size of load command */
|
|
||||||
+ fwriteint32_t(ENCODE_BUILD_VERSION(version_major, version_minor, version_patch), ofile); /* minos, X.Y.Z is encoded in nibbles xxxx.yy.zz */
|
|
||||||
+ fwriteint32_t(ENCODE_BUILD_VERSION(sdk_major, sdk_minor, sdk_patch), ofile); /* sdk, X.Y.Z is encoded in nibbles xxxx.yy.zz */
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+#undef ENCODE_BUILD_VERSION
|
|
||||||
+
|
|
||||||
if (nsyms > 0) {
|
|
||||||
/* write out symbol command */
|
|
||||||
fwriteint32_t(LC_SYMTAB, ofile); /* cmd == LC_SYMTAB */
|
|
@@ -1,12 +0,0 @@
|
|||||||
diff --git a/include/ogg/os_types.h b/include/ogg/os_types.h
|
|
||||||
index eb8a322..6f73b72 100644
|
|
||||||
--- a/include/ogg/os_types.h
|
|
||||||
+++ b/include/ogg/os_types.h
|
|
||||||
@@ -71,6 +71,7 @@
|
|
||||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
|
|
||||||
|
|
||||||
# include <sys/types.h>
|
|
||||||
+# include <stdint.h>
|
|
||||||
typedef int16_t ogg_int16_t;
|
|
||||||
typedef uint16_t ogg_uint16_t;
|
|
||||||
typedef int32_t ogg_int32_t;
|
|
120
build_files/build_environment/patches/openimagedenoise.diff
Normal file
120
build_files/build_environment/patches/openimagedenoise.diff
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 70ec895..e616b63 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -178,7 +178,9 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY SOVERSION "0")
|
||||||
|
## Open Image Denoise examples
|
||||||
|
## ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-add_subdirectory(examples)
|
||||||
|
+if(WITH_EXAMPLE)
|
||||||
|
+ add_subdirectory(examples)
|
||||||
|
+endif()
|
||||||
|
|
||||||
|
## ----------------------------------------------------------------------------
|
||||||
|
## Open Image Denoise install and packaging
|
||||||
|
Submodule mkl-dnn contains modified content
|
||||||
|
diff --git a/mkl-dnn/cmake/TBB.cmake b/mkl-dnn/cmake/TBB.cmake
|
||||||
|
index 0711e699..c14210b6 100644
|
||||||
|
--- a/mkl-dnn/cmake/TBB.cmake
|
||||||
|
+++ b/mkl-dnn/cmake/TBB.cmake
|
||||||
|
@@ -138,13 +138,13 @@ else()
|
||||||
|
set(TBB_LIBRARY_MALLOC TBB_LIBRARY_MALLOC-NOTFOUND)
|
||||||
|
if(APPLE)
|
||||||
|
find_path(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include NO_DEFAULT_PATH)
|
||||||
|
- find_library(TBB_LIBRARY tbb PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
|
||||||
|
- find_library(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
|
||||||
|
+ find_library(TBB_LIBRARY tbb_static PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
|
||||||
|
+ find_library(TBB_LIBRARY_MALLOC tbbmalloc_static PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
|
||||||
|
else()
|
||||||
|
find_path(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include NO_DEFAULT_PATH)
|
||||||
|
set(TBB_HINTS HINTS ${TBB_ROOT}/lib/intel64/gcc4.4 ${TBB_ROOT}/lib ${TBB_ROOT}/lib64 PATHS /usr/libx86_64-linux-gnu/)
|
||||||
|
- find_library(TBB_LIBRARY tbb ${TBB_HINTS})
|
||||||
|
- find_library(TBB_LIBRARY_MALLOC tbbmalloc ${TBB_HINTS})
|
||||||
|
+ find_library(TBB_LIBRARY tbb_static ${TBB_HINTS})
|
||||||
|
+ find_library(TBB_LIBRARY_MALLOC tbbmalloc_static ${TBB_HINTS})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
diff '--ignore-matching-lines=:' -ur '--exclude=*.svn*' -u -r
|
||||||
|
--- a/cmake/install.cmake 2019-08-12 18:02:20.794402575 +0200
|
||||||
|
+++ b/cmake/install.cmake 2019-08-12 18:06:07.470045703 +0200
|
||||||
|
@@ -18,6 +18,13 @@
|
||||||
|
## Install library
|
||||||
|
## ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
+if(UNIX)
|
||||||
|
+install(FILES
|
||||||
|
+ ${CMAKE_BINARY_DIR}/libOpenImageDenoise.a
|
||||||
|
+ ${CMAKE_BINARY_DIR}/libmkldnn.a
|
||||||
|
+ ${CMAKE_BINARY_DIR}/libcommon.a
|
||||||
|
+ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
+else()
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT
|
||||||
|
${PROJECT_NAME}_Export
|
||||||
|
@@ -38,6 +45,7 @@
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
+endif()
|
||||||
|
|
||||||
|
## ----------------------------------------------------------------------------
|
||||||
|
## Install headers
|
||||||
|
@@ -78,6 +86,7 @@
|
||||||
|
## Install CMake configuration files
|
||||||
|
## ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
+if(NOT UNIX)
|
||||||
|
install(EXPORT ${PROJECT_NAME}_Export
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||||
|
#NAMESPACE ${PROJECT_NAME}::
|
||||||
|
@@ -92,3 +101,4 @@
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
)
|
||||||
|
+endif()
|
||||||
|
diff '--ignore-matching-lines=:' -ur '--exclude=*.svn*' -u -r
|
||||||
|
--- a/CMakeLists.txt 2019-08-12 14:22:00.974078598 +0200
|
||||||
|
+++ b/CMakeLists.txt 2019-08-12 18:05:05.949057375 +0200
|
||||||
|
@@ -14,7 +14,11 @@
|
||||||
|
## limitations under the License. ##
|
||||||
|
## ======================================================================== ##
|
||||||
|
|
||||||
|
-cmake_minimum_required(VERSION 3.1)
|
||||||
|
+if(UNIX)
|
||||||
|
+ cmake_minimum_required(VERSION 3.1)
|
||||||
|
+else()
|
||||||
|
+ cmake_minimum_required(VERSION 3.13)
|
||||||
|
+endif()
|
||||||
|
|
||||||
|
set(OIDN_VERSION_MAJOR 1)
|
||||||
|
set(OIDN_VERSION_MINOR 0)
|
||||||
|
@@ -32,13 +36,8 @@
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
# Build as shared or static library
|
||||||
|
-if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
|
||||||
|
- option(OIDN_STATIC_LIB "Build Open Image Denoise as a static library.")
|
||||||
|
- mark_as_advanced(CLEAR OIDN_STATIC_LIB)
|
||||||
|
-else()
|
||||||
|
- set(OIDN_STATIC_LIB OFF CACHE BOOL "Build Open Image Denoise as a static library." FORCE)
|
||||||
|
- mark_as_advanced(OIDN_STATIC_LIB)
|
||||||
|
-endif()
|
||||||
|
+option(OIDN_STATIC_LIB "Build Open Image Denoise as a static library.")
|
||||||
|
+mark_as_advanced(CLEAR OIDN_STATIC_LIB)
|
||||||
|
if(OIDN_STATIC_LIB)
|
||||||
|
set(OIDN_LIB_TYPE STATIC)
|
||||||
|
else()
|
||||||
|
diff -Naur orig/core/api.cpp external_openimagedenoise/core/api.cpp
|
||||||
|
--- orig/core/api.cpp 2019-07-19 08:37:04 -0600
|
||||||
|
+++ external_openimagedenoise/core/api.cpp 2020-01-21 15:10:56 -0700
|
||||||
|
@@ -15,7 +15,7 @@
|
||||||
|
// ======================================================================== //
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
-# define OIDN_API extern "C" __declspec(dllexport)
|
||||||
|
+# define OIDN_API extern "C"
|
||||||
|
#else
|
||||||
|
# define OIDN_API extern "C" __attribute__ ((visibility ("default")))
|
||||||
|
#endif
|
@@ -1,3 +1,14 @@
|
|||||||
|
diff -x .git -ur usd.orig/cmake/defaults/Options.cmake external_usd/cmake/defaults/Options.cmake
|
||||||
|
--- usd.orig/cmake/defaults/Options.cmake 2019-10-24 22:39:53.000000000 +0200
|
||||||
|
+++ external_usd/cmake/defaults/Options.cmake 2019-11-28 13:00:33.197957712 +0100
|
||||||
|
@@ -25,6 +25,7 @@
|
||||||
|
option(PXR_VALIDATE_GENERATED_CODE "Validate script generated code" OFF)
|
||||||
|
option(PXR_HEADLESS_TEST_MODE "Disallow GUI based tests, useful for running under headless CI systems." OFF)
|
||||||
|
option(PXR_BUILD_TESTS "Build tests" ON)
|
||||||
|
+option(PXR_BUILD_USD_TOOLS "Build commandline tools" ON)
|
||||||
|
option(PXR_BUILD_IMAGING "Build imaging components" ON)
|
||||||
|
option(PXR_BUILD_EMBREE_PLUGIN "Build embree imaging plugin" OFF)
|
||||||
|
option(PXR_BUILD_OPENIMAGEIO_PLUGIN "Build OpenImageIO plugin" OFF)
|
||||||
diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defaults/Packages.cmake
|
diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defaults/Packages.cmake
|
||||||
--- usd.orig/cmake/defaults/Packages.cmake 2019-10-24 22:39:53.000000000 +0200
|
--- usd.orig/cmake/defaults/Packages.cmake 2019-10-24 22:39:53.000000000 +0200
|
||||||
+++ external_usd/cmake/defaults/Packages.cmake 2019-11-28 13:00:33.185957483 +0100
|
+++ external_usd/cmake/defaults/Packages.cmake 2019-11-28 13:00:33.185957483 +0100
|
||||||
@@ -10,11 +21,11 @@ diff -x .git -ur usd.orig/cmake/defaults/Packages.cmake external_usd/cmake/defau
|
|||||||
add_definitions(${TBB_DEFINITIONS})
|
add_definitions(${TBB_DEFINITIONS})
|
||||||
|
|
||||||
# --math
|
# --math
|
||||||
diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plug/initConfig.cpp
|
diff -x .git -ur usd.orig/pxr/base/lib/plug/initConfig.cpp external_usd/pxr/base/lib/plug/initConfig.cpp
|
||||||
--- usd.orig/pxr/base/plug/initConfig.cpp.orig 2020-06-12 17:20:07.478199779 +0200
|
--- usd.orig/pxr/base/lib/plug/initConfig.cpp 2019-10-24 22:39:53.000000000 +0200
|
||||||
+++ external_usd/pxr/base/plug/initConfig.cpp 2020-06-12 17:25:28.648588552 +0200
|
+++ external_usd/pxr/base/lib/plug/initConfig.cpp 2019-12-11 11:00:37.643323127 +0100
|
||||||
@@ -69,10 +69,40 @@
|
@@ -69,8 +69,38 @@
|
||||||
|
|
||||||
ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void)
|
ARCH_CONSTRUCTOR(Plug_InitConfig, 2, void)
|
||||||
{
|
{
|
||||||
+ /* The contents of this constructor have been moved to usd_initialise_plugin_path(...) */
|
+ /* The contents of this constructor have been moved to usd_initialise_plugin_path(...) */
|
||||||
@@ -39,9 +50,7 @@ diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plu
|
|||||||
+usd_initialise_plugin_path(const char *datafiles_usd_path)
|
+usd_initialise_plugin_path(const char *datafiles_usd_path)
|
||||||
+{
|
+{
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|
||||||
std::vector<std::string> debugMessages;
|
|
||||||
|
|
||||||
+ // Add Blender-specific paths. They MUST end in a slash, or symlinks will not be treated as directory.
|
+ // Add Blender-specific paths. They MUST end in a slash, or symlinks will not be treated as directory.
|
||||||
+ if (datafiles_usd_path != NULL && datafiles_usd_path[0] != '\0') {
|
+ if (datafiles_usd_path != NULL && datafiles_usd_path[0] != '\0') {
|
||||||
+ std::string datafiles_usd_path_str(datafiles_usd_path);
|
+ std::string datafiles_usd_path_str(datafiles_usd_path);
|
||||||
@@ -51,14 +60,14 @@ diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plu
|
|||||||
+ result.push_back(datafiles_usd_path_str);
|
+ result.push_back(datafiles_usd_path_str);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
// Determine the absolute path to the Plug shared library. Any relative
|
// Determine the absolute path to the Plug shared library.
|
||||||
// paths specified in the plugin search path will be anchored to this
|
// Any relative paths specified in the plugin search path will be
|
||||||
// directory, to allow for relocatability. Note that this can fail when pxr
|
// anchored to this directory, to allow for relocatability.
|
||||||
@@ -114,9 +144,24 @@
|
@@ -94,9 +124,24 @@
|
||||||
_AppendPathList(&result, installLocation, binaryPath);
|
_AppendPathList(&result, installLocation, sharedLibPath);
|
||||||
#endif // PXR_INSTALL_LOCATION
|
#endif // PXR_INSTALL_LOCATION
|
||||||
|
|
||||||
- Plug_SetPaths(result, debugMessages);
|
- Plug_SetPaths(result);
|
||||||
-}
|
-}
|
||||||
+ if (!TfGetenv("PXR_PATH_DEBUG").empty()) {
|
+ if (!TfGetenv("PXR_PATH_DEBUG").empty()) {
|
||||||
+ printf("USD Plugin paths: (%zu in total):\n", result.size());
|
+ printf("USD Plugin paths: (%zu in total):\n", result.size());
|
||||||
@@ -66,10 +75,10 @@ diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plu
|
|||||||
+ printf(" %s\n", path.c_str());
|
+ printf(" %s\n", path.c_str());
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
+ Plug_SetPaths(result, debugMessages);
|
+ Plug_SetPaths(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
PXR_NAMESPACE_CLOSE_SCOPE
|
PXR_NAMESPACE_CLOSE_SCOPE
|
||||||
+
|
+
|
||||||
+/* Workaround to make it possible to pass a path at runtime to USD. */
|
+/* Workaround to make it possible to pass a path at runtime to USD. */
|
||||||
@@ -81,6 +90,37 @@ diff -x .git -ur usd.orig/pxr/base/plug/initConfig.cpp external_usd/pxr/base/plu
|
|||||||
+ PXR_NS::usd_initialise_plugin_path(datafiles_usd_path);
|
+ PXR_NS::usd_initialise_plugin_path(datafiles_usd_path);
|
||||||
+}
|
+}
|
||||||
+}
|
+}
|
||||||
|
diff -x .git -ur usd.orig/pxr/usd/CMakeLists.txt external_usd/pxr/usd/CMakeLists.txt
|
||||||
|
--- usd.orig/pxr/usd/CMakeLists.txt 2019-10-24 22:39:53.000000000 +0200
|
||||||
|
+++ external_usd/pxr/usd/CMakeLists.txt 2019-11-28 13:00:33.197957712 +0100
|
||||||
|
@@ -1,6 +1,5 @@
|
||||||
|
set(DIRS
|
||||||
|
lib
|
||||||
|
- bin
|
||||||
|
plugin
|
||||||
|
)
|
||||||
|
|
||||||
|
@@ -8,3 +7,8 @@
|
||||||
|
add_subdirectory(${d})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
+if (PXR_BUILD_USD_TOOLS)
|
||||||
|
+ add_subdirectory(bin)
|
||||||
|
+else()
|
||||||
|
+ message(STATUS "Skipping commandline tools because PXR_BUILD_USD_TOOLS=OFF")
|
||||||
|
+endif()
|
||||||
|
diff -Naur external_usd_orig/pxr/base/lib/tf/preprocessorUtils.h external_usd/pxr/base/lib/tf/preprocessorUtils.h
|
||||||
|
--- external_usd_orig/pxr/base/lib/tf/preprocessorUtils.h 2019-10-24 14:39:53 -0600
|
||||||
|
+++ external_usd/pxr/base/lib/tf/preprocessorUtils.h 2020-01-14 09:30:18 -0700
|
||||||
|
@@ -189,7 +189,7 @@
|
||||||
|
/// Exapnds to 1 if the argument is a tuple, and 0 otherwise.
|
||||||
|
/// \ingroup group_tf_Preprocessor
|
||||||
|
/// \hideinitializer
|
||||||
|
-#if defined(ARCH_OS_WINDOWS)
|
||||||
|
+#if defined(ARCH_COMPILER_MSVC)
|
||||||
|
#define TF_PP_IS_TUPLE(sequence) \
|
||||||
|
BOOST_VMD_IS_TUPLE(sequence)
|
||||||
|
#else
|
||||||
diff -Naur external_usd_base/cmake/macros/Public.cmake external_usd/cmake/macros/Public.cmake
|
diff -Naur external_usd_base/cmake/macros/Public.cmake external_usd/cmake/macros/Public.cmake
|
||||||
--- external_usd_base/cmake/macros/Public.cmake 2019-10-24 14:39:53 -0600
|
--- external_usd_base/cmake/macros/Public.cmake 2019-10-24 14:39:53 -0600
|
||||||
+++ external_usd/cmake/macros/Public.cmake 2020-01-11 13:33:29 -0700
|
+++ external_usd/cmake/macros/Public.cmake 2020-01-11 13:33:29 -0700
|
||||||
|
@@ -8,7 +8,7 @@ Code signing is done as part of INSTALL target, which makes it possible to sign
|
|||||||
files which are aimed into a bundle and coming from a non-signed source (such as
|
files which are aimed into a bundle and coming from a non-signed source (such as
|
||||||
libraries SVN).
|
libraries SVN).
|
||||||
|
|
||||||
This is achieved by specifying `worker_codesign.cmake` as a post-install script
|
This is achieved by specifying `slave_codesign.cmake` as a post-install script
|
||||||
run by CMake. This CMake script simply involves an utility script written in
|
run by CMake. This CMake script simply involves an utility script written in
|
||||||
Python which takes care of an actual signing.
|
Python which takes care of an actual signing.
|
||||||
|
|
||||||
|
@@ -40,8 +40,8 @@ class Builder:
|
|||||||
|
|
||||||
# Buildbot runs from build/ directory
|
# Buildbot runs from build/ directory
|
||||||
self.blender_dir = os.path.abspath(os.path.join('..', 'blender.git'))
|
self.blender_dir = os.path.abspath(os.path.join('..', 'blender.git'))
|
||||||
self.build_dir = os.path.abspath(os.path.join('..', 'build'))
|
self.build_dir = os.path.abspath(os.path.join('..', 'build', name))
|
||||||
self.install_dir = os.path.abspath(os.path.join('..', 'install'))
|
self.install_dir = os.path.abspath(os.path.join('..', 'install', name))
|
||||||
self.upload_dir = os.path.abspath(os.path.join('..', 'install'))
|
self.upload_dir = os.path.abspath(os.path.join('..', 'install'))
|
||||||
|
|
||||||
# Detect platform
|
# Detect platform
|
||||||
@@ -51,7 +51,7 @@ class Builder:
|
|||||||
elif name.startswith('linux'):
|
elif name.startswith('linux'):
|
||||||
self.platform = 'linux'
|
self.platform = 'linux'
|
||||||
if is_tool('scl'):
|
if is_tool('scl'):
|
||||||
self.command_prefix = ['scl', 'enable', 'devtoolset-9', '--']
|
self.command_prefix = ['scl', 'enable', 'devtoolset-6', '--']
|
||||||
else:
|
else:
|
||||||
self.command_prefix = []
|
self.command_prefix = []
|
||||||
elif name.startswith('win'):
|
elif name.startswith('win'):
|
||||||
|
@@ -48,7 +48,6 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import tarfile
|
import tarfile
|
||||||
import uuid
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
@@ -122,10 +121,21 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
# Consider this an input of the code signing server.
|
# Consider this an input of the code signing server.
|
||||||
unsigned_storage_dir: Path
|
unsigned_storage_dir: Path
|
||||||
|
|
||||||
|
# Information about archive which contains files which are to be signed.
|
||||||
|
#
|
||||||
|
# This archive is created by the buildbot worked and acts as an input for
|
||||||
|
# the code signing server.
|
||||||
|
unsigned_archive_info: ArchiveWithIndicator
|
||||||
|
|
||||||
# Storage where signed files are stored.
|
# Storage where signed files are stored.
|
||||||
# Consider this an output of the code signer server.
|
# Consider this an output of the code signer server.
|
||||||
signed_storage_dir: Path
|
signed_storage_dir: Path
|
||||||
|
|
||||||
|
# Information about archive which contains signed files.
|
||||||
|
#
|
||||||
|
# This archive is created by the code signing server.
|
||||||
|
signed_archive_info: ArchiveWithIndicator
|
||||||
|
|
||||||
# Platform the code is currently executing on.
|
# Platform the code is currently executing on.
|
||||||
platform: util.Platform
|
platform: util.Platform
|
||||||
|
|
||||||
@@ -136,44 +146,50 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
# Unsigned (signing server input) configuration.
|
# Unsigned (signing server input) configuration.
|
||||||
self.unsigned_storage_dir = absolute_shared_storage_dir / 'unsigned'
|
self.unsigned_storage_dir = absolute_shared_storage_dir / 'unsigned'
|
||||||
|
self.unsigned_archive_info = ArchiveWithIndicator(
|
||||||
|
self.unsigned_storage_dir, 'unsigned_files.tar', 'ready.stamp')
|
||||||
|
|
||||||
# Signed (signing server output) configuration.
|
# Signed (signing server output) configuration.
|
||||||
self.signed_storage_dir = absolute_shared_storage_dir / 'signed'
|
self.signed_storage_dir = absolute_shared_storage_dir / 'signed'
|
||||||
|
self.signed_archive_info = ArchiveWithIndicator(
|
||||||
|
self.signed_storage_dir, 'signed_files.tar', 'ready.stamp')
|
||||||
|
|
||||||
self.platform = util.get_current_platform()
|
self.platform = util.get_current_platform()
|
||||||
|
|
||||||
|
"""
|
||||||
|
General note on cleanup environment functions.
|
||||||
|
|
||||||
|
It is expected that there is only one instance of the code signer server
|
||||||
|
running for a given input/output directory, and that it serves a single
|
||||||
|
buildbot worker.
|
||||||
|
By its nature, a buildbot worker only produces one build at a time and
|
||||||
|
never performs concurrent builds.
|
||||||
|
This leads to a conclusion that when starting in a clean environment
|
||||||
|
there shouldn't be any archives remaining from a previous build.
|
||||||
|
|
||||||
|
However, it is possible to have various failure scenarios which might
|
||||||
|
leave the environment in a non-clean state:
|
||||||
|
|
||||||
|
- Network hiccup which makes buildbot worker to stop current build
|
||||||
|
and re-start it after connection to server is re-established.
|
||||||
|
|
||||||
|
Note, this could also happen during buildbot server maintenance.
|
||||||
|
|
||||||
|
- Signing server might get restarted due to updates or other reasons.
|
||||||
|
|
||||||
|
Requiring manual interaction in such cases is not something good to
|
||||||
|
require, so here we simply assume that the system is used the way it is
|
||||||
|
intended to and restore environment to a prestine clean state.
|
||||||
|
"""
|
||||||
|
|
||||||
def cleanup_environment_for_builder(self) -> None:
|
def cleanup_environment_for_builder(self) -> None:
|
||||||
# TODO(sergey): Revisit need of cleaning up the existing files.
|
self.unsigned_archive_info.clean()
|
||||||
# In practice it wasn't so helpful, and with multiple clients
|
self.signed_archive_info.clean()
|
||||||
# talking to the same server it becomes even mor etricky.
|
|
||||||
pass
|
|
||||||
|
|
||||||
def cleanup_environment_for_signing_server(self) -> None:
|
def cleanup_environment_for_signing_server(self) -> None:
|
||||||
# TODO(sergey): Revisit need of cleaning up the existing files.
|
# Don't clear the requested to-be-signed archive since we might be
|
||||||
# In practice it wasn't so helpful, and with multiple clients
|
# restarting signing machine while the buildbot is busy.
|
||||||
# talking to the same server it becomes even mor etricky.
|
self.signed_archive_info.clean()
|
||||||
pass
|
|
||||||
|
|
||||||
def generate_request_id(self) -> str:
|
|
||||||
"""
|
|
||||||
Generate an unique identifier for code signing request.
|
|
||||||
"""
|
|
||||||
return str(uuid.uuid4())
|
|
||||||
|
|
||||||
def archive_info_for_request_id(
|
|
||||||
self, path: Path, request_id: str) -> ArchiveWithIndicator:
|
|
||||||
return ArchiveWithIndicator(
|
|
||||||
path, f'{request_id}.tar', f'{request_id}.ready')
|
|
||||||
|
|
||||||
def signed_archive_info_for_request_id(
|
|
||||||
self, request_id: str) -> ArchiveWithIndicator:
|
|
||||||
return self.archive_info_for_request_id(
|
|
||||||
self.signed_storage_dir, request_id)
|
|
||||||
|
|
||||||
def unsigned_archive_info_for_request_id(
|
|
||||||
self, request_id: str) -> ArchiveWithIndicator:
|
|
||||||
return self.archive_info_for_request_id(
|
|
||||||
self.unsigned_storage_dir, request_id)
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Buildbot worker side helpers.
|
# Buildbot worker side helpers.
|
||||||
@@ -216,7 +232,7 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
if self.check_file_is_to_be_signed(file)]
|
if self.check_file_is_to_be_signed(file)]
|
||||||
return files_to_be_signed
|
return files_to_be_signed
|
||||||
|
|
||||||
def wait_for_signed_archive_or_die(self, request_id) -> None:
|
def wait_for_signed_archive_or_die(self) -> None:
|
||||||
"""
|
"""
|
||||||
Wait until archive with signed files is available.
|
Wait until archive with signed files is available.
|
||||||
|
|
||||||
@@ -224,19 +240,13 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
is still no responce from the signing server the application will exit
|
is still no responce from the signing server the application will exit
|
||||||
with a non-zero exit code.
|
with a non-zero exit code.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
signed_archive_info = self.signed_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
unsigned_archive_info = self.unsigned_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
|
|
||||||
timeout_in_seconds = self.config.TIMEOUT_IN_SECONDS
|
timeout_in_seconds = self.config.TIMEOUT_IN_SECONDS
|
||||||
time_start = time.monotonic()
|
time_start = time.monotonic()
|
||||||
while not signed_archive_info.is_ready():
|
while not self.signed_archive_info.is_ready():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
time_slept_in_seconds = time.monotonic() - time_start
|
time_slept_in_seconds = time.monotonic() - time_start
|
||||||
if time_slept_in_seconds > timeout_in_seconds:
|
if time_slept_in_seconds > timeout_in_seconds:
|
||||||
unsigned_archive_info.clean()
|
self.unsigned_archive_info.clean()
|
||||||
raise SystemExit("Signing server didn't finish signing in "
|
raise SystemExit("Signing server didn't finish signing in "
|
||||||
f"{timeout_in_seconds} seconds, dying :(")
|
f"{timeout_in_seconds} seconds, dying :(")
|
||||||
|
|
||||||
@@ -293,19 +303,13 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
return
|
return
|
||||||
logger_builder.info('Found %d files to sign.', len(files))
|
logger_builder.info('Found %d files to sign.', len(files))
|
||||||
|
|
||||||
request_id = self.generate_request_id()
|
|
||||||
signed_archive_info = self.signed_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
unsigned_archive_info = self.unsigned_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
|
|
||||||
pack_files(files=files,
|
pack_files(files=files,
|
||||||
archive_filepath=unsigned_archive_info.archive_filepath)
|
archive_filepath=self.unsigned_archive_info.archive_filepath)
|
||||||
unsigned_archive_info.tag_ready()
|
self.unsigned_archive_info.tag_ready()
|
||||||
|
|
||||||
# Wait for the signing server to finish signing.
|
# Wait for the signing server to finish signing.
|
||||||
logger_builder.info('Waiting signing server to sign the files...')
|
logger_builder.info('Waiting signing server to sign the files...')
|
||||||
self.wait_for_signed_archive_or_die(request_id)
|
self.wait_for_signed_archive_or_die()
|
||||||
|
|
||||||
# Extract signed files from archive and move files to final location.
|
# Extract signed files from archive and move files to final location.
|
||||||
with TemporaryDirectory(prefix='blender-buildbot-') as temp_dir_str:
|
with TemporaryDirectory(prefix='blender-buildbot-') as temp_dir_str:
|
||||||
@@ -313,7 +317,7 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
logger_builder.info('Extracting signed files from archive...')
|
logger_builder.info('Extracting signed files from archive...')
|
||||||
extract_files(
|
extract_files(
|
||||||
archive_filepath=signed_archive_info.archive_filepath,
|
archive_filepath=self.signed_archive_info.archive_filepath,
|
||||||
extraction_dir=unpacked_signed_files_dir)
|
extraction_dir=unpacked_signed_files_dir)
|
||||||
|
|
||||||
destination_dir = path
|
destination_dir = path
|
||||||
@@ -323,44 +327,19 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
unpacked_signed_files_dir, destination_dir)
|
unpacked_signed_files_dir, destination_dir)
|
||||||
|
|
||||||
logger_builder.info('Removing archive with signed files...')
|
logger_builder.info('Removing archive with signed files...')
|
||||||
signed_archive_info.clean()
|
self.signed_archive_info.clean()
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Signing server side helpers.
|
# Signing server side helpers.
|
||||||
|
|
||||||
def wait_for_sign_request(self) -> str:
|
def wait_for_sign_request(self) -> None:
|
||||||
"""
|
"""
|
||||||
Wait for the buildbot to request signing of an archive.
|
Wait for the buildbot to request signing of an archive.
|
||||||
|
|
||||||
Returns an identifier of signing request.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TOOD(sergey): Support graceful shutdown on Ctrl-C.
|
# TOOD(sergey): Support graceful shutdown on Ctrl-C.
|
||||||
|
while not self.unsigned_archive_info.is_ready():
|
||||||
logger_server.info(
|
|
||||||
f'Waiting for a request directory {self.unsigned_storage_dir} to appear.')
|
|
||||||
while not self.unsigned_storage_dir.exists():
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
logger_server.info(
|
|
||||||
'Waiting for a READY indicator of any signing request.')
|
|
||||||
request_id = None
|
|
||||||
while request_id is None:
|
|
||||||
for file in self.unsigned_storage_dir.iterdir():
|
|
||||||
if file.suffix != '.ready':
|
|
||||||
continue
|
|
||||||
request_id = file.stem
|
|
||||||
logger_server.info(f'Found READY for request ID {request_id}.')
|
|
||||||
if request_id is None:
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
unsigned_archive_info = self.unsigned_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
while not unsigned_archive_info.is_ready():
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
return request_id
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def sign_all_files(self, files: List[AbsoluteAndRelativeFileName]) -> None:
|
def sign_all_files(self, files: List[AbsoluteAndRelativeFileName]) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -369,7 +348,7 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
NOTE: Signing should happen in-place.
|
NOTE: Signing should happen in-place.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def run_signing_pipeline(self, request_id: str):
|
def run_signing_pipeline(self):
|
||||||
"""
|
"""
|
||||||
Run the full signing pipeline starting from the point when buildbot
|
Run the full signing pipeline starting from the point when buildbot
|
||||||
worker have requested signing.
|
worker have requested signing.
|
||||||
@@ -381,14 +360,9 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
with TemporaryDirectory(prefix='blender-codesign-') as temp_dir_str:
|
with TemporaryDirectory(prefix='blender-codesign-') as temp_dir_str:
|
||||||
temp_dir = Path(temp_dir_str)
|
temp_dir = Path(temp_dir_str)
|
||||||
|
|
||||||
signed_archive_info = self.signed_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
unsigned_archive_info = self.unsigned_archive_info_for_request_id(
|
|
||||||
request_id)
|
|
||||||
|
|
||||||
logger_server.info('Extracting unsigned files from archive...')
|
logger_server.info('Extracting unsigned files from archive...')
|
||||||
extract_files(
|
extract_files(
|
||||||
archive_filepath=unsigned_archive_info.archive_filepath,
|
archive_filepath=self.unsigned_archive_info.archive_filepath,
|
||||||
extraction_dir=temp_dir)
|
extraction_dir=temp_dir)
|
||||||
|
|
||||||
logger_server.info('Collecting all files which needs signing...')
|
logger_server.info('Collecting all files which needs signing...')
|
||||||
@@ -400,11 +374,11 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
logger_server.info('Packing signed files...')
|
logger_server.info('Packing signed files...')
|
||||||
pack_files(files=files,
|
pack_files(files=files,
|
||||||
archive_filepath=signed_archive_info.archive_filepath)
|
archive_filepath=self.signed_archive_info.archive_filepath)
|
||||||
signed_archive_info.tag_ready()
|
self.signed_archive_info.tag_ready()
|
||||||
|
|
||||||
logger_server.info('Removing signing request...')
|
logger_server.info('Removing signing request...')
|
||||||
unsigned_archive_info.clean()
|
self.unsigned_archive_info.clean()
|
||||||
|
|
||||||
logger_server.info('Signing is complete.')
|
logger_server.info('Signing is complete.')
|
||||||
|
|
||||||
@@ -415,11 +389,11 @@ class BaseCodeSigner(metaclass=abc.ABCMeta):
|
|||||||
while True:
|
while True:
|
||||||
logger_server.info('Waiting for the signing request in %s...',
|
logger_server.info('Waiting for the signing request in %s...',
|
||||||
self.unsigned_storage_dir)
|
self.unsigned_storage_dir)
|
||||||
request_id = self.wait_for_sign_request()
|
self.wait_for_sign_request()
|
||||||
|
|
||||||
logger_server.info(
|
logger_server.info(
|
||||||
f'Beging signign procedure for request ID {request_id}.')
|
'Got signing request, beging signign procedure.')
|
||||||
self.run_signing_pipeline(request_id)
|
self.run_signing_pipeline()
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Command executing.
|
# Command executing.
|
||||||
|
@@ -30,7 +30,7 @@ from tempfile import TemporaryDirectory, NamedTemporaryFile
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
BUILDBOT_DIRECTORY = Path(__file__).absolute().parent
|
BUILDBOT_DIRECTORY = Path(__file__).absolute().parent
|
||||||
CODESIGN_SCRIPT = BUILDBOT_DIRECTORY / 'worker_codesign.py'
|
CODESIGN_SCRIPT = BUILDBOT_DIRECTORY / 'slave_codesign.py'
|
||||||
BLENDER_GIT_ROOT_DIRECTORY = BUILDBOT_DIRECTORY.parent.parent
|
BLENDER_GIT_ROOT_DIRECTORY = BUILDBOT_DIRECTORY.parent.parent
|
||||||
DARWIN_DIRECTORY = BLENDER_GIT_ROOT_DIRECTORY / 'release' / 'darwin'
|
DARWIN_DIRECTORY = BLENDER_GIT_ROOT_DIRECTORY / 'release' / 'darwin'
|
||||||
|
|
@@ -33,7 +33,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/worker_codesign.py"
|
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/slave_codesign.py"
|
||||||
"${CMAKE_INSTALL_PREFIX}"
|
"${CMAKE_INSTALL_PREFIX}"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||||
RESULT_VARIABLE exit_code
|
RESULT_VARIABLE exit_code
|
@@ -25,7 +25,7 @@ import buildbot_utils
|
|||||||
|
|
||||||
def get_cmake_options(builder):
|
def get_cmake_options(builder):
|
||||||
post_install_script = os.path.join(
|
post_install_script = os.path.join(
|
||||||
builder.blender_dir, 'build_files', 'buildbot', 'worker_codesign.cmake')
|
builder.blender_dir, 'build_files', 'buildbot', 'slave_codesign.cmake')
|
||||||
|
|
||||||
config_file = "build_files/cmake/config/blender_release.cmake"
|
config_file = "build_files/cmake/config/blender_release.cmake"
|
||||||
options = ['-DCMAKE_BUILD_TYPE:STRING=Release',
|
options = ['-DCMAKE_BUILD_TYPE:STRING=Release',
|
||||||
@@ -35,7 +35,7 @@ def get_cmake_options(builder):
|
|||||||
options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
|
options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64')
|
||||||
options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
|
options.append('-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
|
||||||
elif builder.platform == 'win':
|
elif builder.platform == 'win':
|
||||||
options.extend(['-G', 'Visual Studio 16 2019', '-A', 'x64'])
|
options.extend(['-G', 'Visual Studio 15 2017 Win64'])
|
||||||
options.extend(['-DPOSTINSTALL_SCRIPT:PATH=' + post_install_script])
|
options.extend(['-DPOSTINSTALL_SCRIPT:PATH=' + post_install_script])
|
||||||
elif builder.platform == 'linux':
|
elif builder.platform == 'linux':
|
||||||
config_file = "build_files/buildbot/config/blender_linux.cmake"
|
config_file = "build_files/buildbot/config/blender_linux.cmake"
|
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
# <pep8 compliant>
|
# <pep8 compliant>
|
||||||
|
|
||||||
# Runs on buildbot worker, creating a release package using the build
|
# Runs on buildbot slave, creating a release package using the build
|
||||||
# system and zipping it into buildbot_upload.zip. This is then uploaded
|
# system and zipping it into buildbot_upload.zip. This is then uploaded
|
||||||
# to the master in the next buildbot step.
|
# to the master in the next buildbot step.
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ def pack_mac(builder):
|
|||||||
|
|
||||||
release_dir = os.path.join(builder.blender_dir, 'release', 'darwin')
|
release_dir = os.path.join(builder.blender_dir, 'release', 'darwin')
|
||||||
buildbot_dir = os.path.join(builder.blender_dir, 'build_files', 'buildbot')
|
buildbot_dir = os.path.join(builder.blender_dir, 'build_files', 'buildbot')
|
||||||
bundle_script = os.path.join(buildbot_dir, 'worker_bundle_dmg.py')
|
bundle_script = os.path.join(buildbot_dir, 'slave_bundle_dmg.py')
|
||||||
|
|
||||||
command = [bundle_script]
|
command = [bundle_script]
|
||||||
command += ['--dmg', package_filepath]
|
command += ['--dmg', package_filepath]
|
37
build_files/buildbot/slave_rsync.py
Normal file
37
build_files/buildbot/slave_rsync.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
# <pep8 compliant>
|
||||||
|
|
||||||
|
# Runs on buildbot slave, rsync zip directly to buildbot server rather
|
||||||
|
# than using upload which is much slower
|
||||||
|
|
||||||
|
import buildbot_utils
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
builder = buildbot_utils.create_builder_from_arguments()
|
||||||
|
|
||||||
|
# rsync, this assumes ssh keys are setup so no password is needed
|
||||||
|
local_zip = "buildbot_upload.zip"
|
||||||
|
remote_folder = "builder.blender.org:/data/buildbot-master/uploaded/"
|
||||||
|
remote_zip = remote_folder + "buildbot_upload_" + builder.name + ".zip"
|
||||||
|
|
||||||
|
command = ["rsync", "-avz", local_zip, remote_zip]
|
||||||
|
buildbot_utils.call(command)
|
@@ -1,104 +0,0 @@
|
|||||||
# - Find clang-tidy executable
|
|
||||||
#
|
|
||||||
# Find the native clang-tidy executable
|
|
||||||
#
|
|
||||||
# This module defines
|
|
||||||
# CLANG_TIDY_EXECUTABLE, the ful lpath to clang-tidy executable
|
|
||||||
#
|
|
||||||
# CLANG_TIDY_VERSION, the full version of the clang-tidy in the
|
|
||||||
# major,minor.patch format
|
|
||||||
#
|
|
||||||
# CLANG_TIDY_VERSION_MAJOR,
|
|
||||||
# CLANG_TIDY_VERSION_MINOR,
|
|
||||||
# CLANG_TIDY_VERSION_PATCH, individual components of the clang-tidy version.
|
|
||||||
#
|
|
||||||
# CLANG_TIDY_FOUND, If false, do not try to use Eigen3.
|
|
||||||
|
|
||||||
#=============================================================================
|
|
||||||
# Copyright 2020 Blender Foundation.
|
|
||||||
#
|
|
||||||
# Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
# see accompanying file Copyright.txt for details.
|
|
||||||
#
|
|
||||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
# See the License for more information.
|
|
||||||
#=============================================================================
|
|
||||||
|
|
||||||
# If CLANG_TIDY_ROOT_DIR was defined in the environment, use it.
|
|
||||||
if(NOT CLANG_TIDY_ROOT_DIR AND NOT $ENV{CLANG_TIDY_ROOT_DIR} STREQUAL "")
|
|
||||||
set(CLANG_TIDY_ROOT_DIR $ENV{CLANG_TIDY_ROOT_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(_clang_tidy_SEARCH_DIRS
|
|
||||||
${CLANG_TIDY_ROOT_DIR}
|
|
||||||
/usr/local/bin
|
|
||||||
)
|
|
||||||
|
|
||||||
# TODO(sergey): Find more reliable way of finding the latest clang-tidy.
|
|
||||||
find_program(CLANG_TIDY_EXECUTABLE
|
|
||||||
NAMES
|
|
||||||
clang-tidy-10
|
|
||||||
clang-tidy-9
|
|
||||||
clang-tidy-8
|
|
||||||
clang-tidy-7
|
|
||||||
clang-tidy
|
|
||||||
HINTS
|
|
||||||
${_clang_tidy_SEARCH_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(CLANG_TIDY_EXECUTABLE)
|
|
||||||
# Mark clang-tidy as found.
|
|
||||||
set(CLANG_TIDY_FOUND TRUE)
|
|
||||||
|
|
||||||
# Setup fallback values.
|
|
||||||
set(CLANG_TIDY_VERSION_MAJOR 0)
|
|
||||||
set(CLANG_TIDY_VERSION_MINOR 0)
|
|
||||||
set(CLANG_TIDY_VERSION_PATCH 0)
|
|
||||||
|
|
||||||
# Get version from the output.
|
|
||||||
#
|
|
||||||
# NOTE: Don't use name of the executable file since that only includes a
|
|
||||||
# major version. Also, even the major version might be missing in the
|
|
||||||
# executable name.
|
|
||||||
execute_process(COMMAND ${CLANG_TIDY_EXECUTABLE} -version
|
|
||||||
OUTPUT_VARIABLE CLANG_TIDY_VERSION_RAW
|
|
||||||
ERROR_QUIET
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
|
|
||||||
# Parse parts.
|
|
||||||
if(CLANG_TIDY_VERSION_RAW MATCHES "LLVM version .*")
|
|
||||||
# Strip the LLVM prefix and get list of individual version components.
|
|
||||||
string(REGEX REPLACE
|
|
||||||
".*LLVM version ([.0-9]+).*" "\\1"
|
|
||||||
CLANG_SEMANTIC_VERSION "${CLANG_TIDY_VERSION_RAW}")
|
|
||||||
string(REPLACE "." ";" CLANG_VERSION_PARTS "${CLANG_SEMANTIC_VERSION}")
|
|
||||||
list(LENGTH CLANG_VERSION_PARTS NUM_CLANG_TIDY_VERSION_PARTS)
|
|
||||||
|
|
||||||
# Extract components into corresponding variables.
|
|
||||||
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 0)
|
|
||||||
list(GET CLANG_VERSION_PARTS 0 CLANG_TIDY_VERSION_MAJOR)
|
|
||||||
endif()
|
|
||||||
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 1)
|
|
||||||
list(GET CLANG_VERSION_PARTS 1 CLANG_TIDY_VERSION_MINOR)
|
|
||||||
endif()
|
|
||||||
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 2)
|
|
||||||
list(GET CLANG_VERSION_PARTS 2 CLANG_TIDY_VERSION_PATCH)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Unset temp variables.
|
|
||||||
unset(NUM_CLANG_TIDY_VERSION_PARTS)
|
|
||||||
unset(CLANG_SEMANTIC_VERSION)
|
|
||||||
unset(CLANG_VERSION_PARTS)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Construct full semantic version.
|
|
||||||
set(CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION_MAJOR}.\
|
|
||||||
${CLANG_TIDY_VERSION_MINOR}.\
|
|
||||||
${CLANG_TIDY_VERSION_PATCH}")
|
|
||||||
unset(CLANG_TIDY_VERSION_RAW)
|
|
||||||
|
|
||||||
message(STATUS "Found clang-tidy ${CLANG_TIDY_EXECUTABLE} (${CLANG_TIDY_VERSION})")
|
|
||||||
else()
|
|
||||||
set(CLANG_TIDY_FOUND FALSE)
|
|
||||||
endif()
|
|
@@ -82,7 +82,7 @@ FIND_LIBRARY(EMBREE_LIBRARY
|
|||||||
# handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Embree DEFAULT_MSG
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EMBREE DEFAULT_MSG
|
||||||
_embree_LIBRARIES EMBREE_INCLUDE_DIR)
|
_embree_LIBRARIES EMBREE_INCLUDE_DIR)
|
||||||
|
|
||||||
IF(EMBREE_FOUND)
|
IF(EMBREE_FOUND)
|
||||||
|
65
build_files/cmake/Modules/FindHDF5.cmake
Normal file
65
build_files/cmake/Modules/FindHDF5.cmake
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# - Find HDF5 library
|
||||||
|
# Find the native HDF5 includes and libraries
|
||||||
|
# This module defines
|
||||||
|
# HDF5_INCLUDE_DIRS, where to find hdf5.h, Set when HDF5_INCLUDE_DIR is found.
|
||||||
|
# HDF5_LIBRARIES, libraries to link against to use HDF5.
|
||||||
|
# HDF5_ROOT_DIR, The base directory to search for HDF5.
|
||||||
|
# This can also be an environment variable.
|
||||||
|
# HDF5_FOUND, If false, do not try to use HDF5.
|
||||||
|
#
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2016 Blender Foundation.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
# If HDF5_ROOT_DIR was defined in the environment, use it.
|
||||||
|
IF(NOT HDF5_ROOT_DIR AND NOT $ENV{HDF5_ROOT_DIR} STREQUAL "")
|
||||||
|
SET(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
SET(_hdf5_SEARCH_DIRS
|
||||||
|
${HDF5_ROOT_DIR}
|
||||||
|
/opt/lib/hdf5
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(HDF5_LIBRARY
|
||||||
|
NAMES
|
||||||
|
hdf5
|
||||||
|
HINTS
|
||||||
|
${_hdf5_SEARCH_DIRS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
lib64 lib
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_PATH(HDF5_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
hdf5.h
|
||||||
|
HINTS
|
||||||
|
${_hdf5_SEARCH_DIRS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set HDF5_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HDF5 DEFAULT_MSG HDF5_LIBRARY HDF5_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(HDF5_FOUND)
|
||||||
|
SET(HDF5_LIBRARIES ${HDF5_LIBRARY})
|
||||||
|
SET(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR})
|
||||||
|
ENDIF(HDF5_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(
|
||||||
|
HDF5_INCLUDE_DIR
|
||||||
|
HDF5_LIBRARY
|
||||||
|
)
|
||||||
|
|
||||||
|
UNSET(_hdf5_SEARCH_DIRS)
|
@@ -48,14 +48,7 @@ SET(_openimagedenoise_FIND_COMPONENTS
|
|||||||
# These are needed when building statically
|
# These are needed when building statically
|
||||||
SET(_openimagedenoise_FIND_STATIC_COMPONENTS
|
SET(_openimagedenoise_FIND_STATIC_COMPONENTS
|
||||||
common
|
common
|
||||||
|
|
||||||
# These additional library names change between versions, we list all of them
|
|
||||||
# so builds work with multiple versions. Missing libraries are skipped.
|
|
||||||
dnnl_cpu
|
|
||||||
dnnl_common
|
|
||||||
dnnl_cpu # Second time because of circular dependency
|
|
||||||
mkldnn
|
mkldnn
|
||||||
dnnl
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(_openimagedenoise_LIBRARIES)
|
SET(_openimagedenoise_LIBRARIES)
|
||||||
|
@@ -11,7 +11,6 @@ set(WITH_CODEC_AVI ON CACHE BOOL "" FORCE)
|
|||||||
set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
|
set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
|
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
|
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
|
|
||||||
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
|
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_DRACO ON CACHE BOOL "" FORCE)
|
set(WITH_DRACO ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
|
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
|
||||||
|
@@ -15,7 +15,6 @@ set(WITH_CODEC_AVI OFF CACHE BOOL "" FORCE)
|
|||||||
set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
|
set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
|
||||||
set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
|
set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
|
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES_EMBREE OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WITH_CYCLES_OSL OFF CACHE BOOL "" FORCE)
|
set(WITH_CYCLES_OSL OFF CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES_DEVICE_OPTIX OFF CACHE BOOL "" FORCE)
|
set(WITH_CYCLES_DEVICE_OPTIX OFF CACHE BOOL "" FORCE)
|
||||||
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
|
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
|
||||||
|
@@ -12,7 +12,6 @@ set(WITH_CODEC_AVI ON CACHE BOOL "" FORCE)
|
|||||||
set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
|
set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
|
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
|
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
|
|
||||||
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
|
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_DRACO ON CACHE BOOL "" FORCE)
|
set(WITH_DRACO ON CACHE BOOL "" FORCE)
|
||||||
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
|
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
|
||||||
|
@@ -437,6 +437,7 @@ function(SETUP_LIBDIRS)
|
|||||||
|
|
||||||
if(WITH_ALEMBIC)
|
if(WITH_ALEMBIC)
|
||||||
link_directories(${ALEMBIC_LIBPATH})
|
link_directories(${ALEMBIC_LIBPATH})
|
||||||
|
link_directories(${HDF5_LIBPATH})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_GHOST_WAYLAND)
|
if(WITH_GHOST_WAYLAND)
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
# Libraries configuration for Apple.
|
# Libraries configuration for Apple.
|
||||||
|
|
||||||
set(MACOSX_DEPLOYMENT_TARGET "10.13")
|
set(MACOSX_DEPLOYMENT_TARGET "10.11")
|
||||||
|
|
||||||
macro(find_package_wrapper)
|
macro(find_package_wrapper)
|
||||||
# do nothing, just satisfy the macro
|
# do nothing, just satisfy the macro
|
||||||
|
@@ -65,9 +65,13 @@ endif()
|
|||||||
|
|
||||||
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")
|
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")
|
||||||
|
|
||||||
# Require a relatively recent Xcode version.
|
# Older Xcode versions had different approach to the directory hiearchy.
|
||||||
if(${XCODE_VERSION} VERSION_LESS 10.0)
|
# Require newer Xcode which is also have better chances of being able to compile with the
|
||||||
message(FATAL_ERROR "Only Xcode version 10.0 and newer is supported")
|
# required deployment target.
|
||||||
|
#
|
||||||
|
# NOTE: Xcode version 8.2 is the latest one which runs on macOS 10.11.
|
||||||
|
if(${XCODE_VERSION} VERSION_LESS 8.2)
|
||||||
|
message(FATAL_ERROR "Only Xcode version 8.2 and newer is supported")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# note: xcode-select path could be ambiguous,
|
# note: xcode-select path could be ambiguous,
|
||||||
@@ -129,14 +133,14 @@ if(${CMAKE_GENERATOR} MATCHES "Xcode")
|
|||||||
endif()
|
endif()
|
||||||
unset(OSX_SDKROOT)
|
unset(OSX_SDKROOT)
|
||||||
|
|
||||||
# 10.13 is our min. target, if you use higher sdk, weak linking happens
|
# 10.11 is our min. target, if you use higher sdk, weak linking happens
|
||||||
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||||
if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.13)
|
if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.11)
|
||||||
message(STATUS "Setting deployment target to 10.13, lower versions are not supported")
|
message(STATUS "Setting deployment target to 10.11, lower versions are not supported")
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
|
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
|
||||||
|
@@ -265,8 +265,14 @@ endif()
|
|||||||
if(WITH_ALEMBIC)
|
if(WITH_ALEMBIC)
|
||||||
find_package_wrapper(Alembic)
|
find_package_wrapper(Alembic)
|
||||||
|
|
||||||
if(NOT ALEMBIC_FOUND)
|
if(WITH_ALEMBIC_HDF5)
|
||||||
|
set(HDF5_ROOT_DIR ${LIBDIR}/hdf5)
|
||||||
|
find_package_wrapper(HDF5)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ALEMBIC_FOUND OR (WITH_ALEMBIC_HDF5 AND NOT HDF5_FOUND))
|
||||||
set(WITH_ALEMBIC OFF)
|
set(WITH_ALEMBIC OFF)
|
||||||
|
set(WITH_ALEMBIC_HDF5 OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -539,10 +539,10 @@ if(WITH_OPENIMAGEDENOISE)
|
|||||||
set(OPENIMAGEDENOISE_LIBRARIES
|
set(OPENIMAGEDENOISE_LIBRARIES
|
||||||
optimized ${OPENIMAGEDENOISE_LIBPATH}/OpenImageDenoise.lib
|
optimized ${OPENIMAGEDENOISE_LIBPATH}/OpenImageDenoise.lib
|
||||||
optimized ${OPENIMAGEDENOISE_LIBPATH}/common.lib
|
optimized ${OPENIMAGEDENOISE_LIBPATH}/common.lib
|
||||||
optimized ${OPENIMAGEDENOISE_LIBPATH}/dnnl.lib
|
optimized ${OPENIMAGEDENOISE_LIBPATH}/mkldnn.lib
|
||||||
debug ${OPENIMAGEDENOISE_LIBPATH}/OpenImageDenoise_d.lib
|
debug ${OPENIMAGEDENOISE_LIBPATH}/OpenImageDenoise_d.lib
|
||||||
debug ${OPENIMAGEDENOISE_LIBPATH}/common_d.lib
|
debug ${OPENIMAGEDENOISE_LIBPATH}/common_d.lib
|
||||||
debug ${OPENIMAGEDENOISE_LIBPATH}/dnnl_d.lib)
|
debug ${OPENIMAGEDENOISE_LIBPATH}/mkldnn_d.lib)
|
||||||
set(OPENIMAGEDENOISE_DEFINITIONS)
|
set(OPENIMAGEDENOISE_DEFINITIONS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -40,8 +40,7 @@ if make_utils.command_missing(git_command):
|
|||||||
|
|
||||||
# Test if we are building a specific release version.
|
# Test if we are building a specific release version.
|
||||||
branch = make_utils.git_branch(git_command)
|
branch = make_utils.git_branch(git_command)
|
||||||
tag = make_utils.git_tag(git_command)
|
release_version = make_utils.git_branch_release_version(branch)
|
||||||
release_version = make_utils.git_branch_release_version(branch, tag)
|
|
||||||
lib_tests_dirpath = os.path.join('..', 'lib', "tests")
|
lib_tests_dirpath = os.path.join('..', 'lib', "tests")
|
||||||
|
|
||||||
if not os.path.exists(lib_tests_dirpath):
|
if not os.path.exists(lib_tests_dirpath):
|
||||||
|
@@ -197,8 +197,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Test if we are building a specific release version.
|
# Test if we are building a specific release version.
|
||||||
branch = make_utils.git_branch(args.git_command)
|
branch = make_utils.git_branch(args.git_command)
|
||||||
tag = make_utils.git_tag(args.git_command)
|
release_version = make_utils.git_branch_release_version(branch)
|
||||||
release_version = make_utils.git_branch_release_version(branch, tag)
|
|
||||||
|
|
||||||
if not args.no_libraries:
|
if not args.no_libraries:
|
||||||
svn_update(args, release_version)
|
svn_update(args, release_version)
|
||||||
|
@@ -36,7 +36,7 @@ def check_output(cmd, exit_on_error=True):
|
|||||||
return output.strip()
|
return output.strip()
|
||||||
|
|
||||||
def git_branch(git_command):
|
def git_branch(git_command):
|
||||||
# Get current branch name.
|
# Test if we are building a specific release version.
|
||||||
try:
|
try:
|
||||||
branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"])
|
branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@@ -45,23 +45,10 @@ def git_branch(git_command):
|
|||||||
|
|
||||||
return branch.strip().decode('utf8')
|
return branch.strip().decode('utf8')
|
||||||
|
|
||||||
def git_tag(git_command):
|
def git_branch_release_version(branch):
|
||||||
# Get current tag name.
|
|
||||||
try:
|
|
||||||
tag = subprocess.check_output([git_command, "describe", "--exact-match"])
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return tag.strip().decode('utf8')
|
|
||||||
|
|
||||||
def git_branch_release_version(branch, tag):
|
|
||||||
release_version = re.search("^blender-v(.*)-release$", branch)
|
release_version = re.search("^blender-v(.*)-release$", branch)
|
||||||
if release_version:
|
if release_version:
|
||||||
release_version = release_version.group(1)
|
release_version = release_version.group(1)
|
||||||
elif tag:
|
|
||||||
release_version = re.search("^v([0-9]*\.[0-9]*).*", tag)
|
|
||||||
if release_version:
|
|
||||||
release_version = release_version.group(1)
|
|
||||||
return release_version
|
return release_version
|
||||||
|
|
||||||
def svn_libraries_base_url(release_version):
|
def svn_libraries_base_url(release_version):
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
Sphinx==3.1.1
|
Sphinx==3.0.3
|
||||||
sphinx_rtd_theme==0.5.0
|
sphinx_rtd_theme==0.5.0rc1
|
||||||
|
@@ -427,7 +427,7 @@ offers a set of extensive examples, including advanced features.
|
|||||||
|
|
||||||
Return evaluator parameters
|
Return evaluator parameters
|
||||||
|
|
||||||
.. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetMap.xml>`__
|
.. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetMap.xml>`_
|
||||||
|
|
||||||
:type target: Enumerated constant
|
:type target: Enumerated constant
|
||||||
:arg target: Specifies the symbolic name of a map.
|
:arg target: Specifies the symbolic name of a map.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
..
|
..
|
||||||
This document is appended to the auto generated BMesh API doc to avoid clogging up the C files with details.
|
This document is appended to the auto generated bmesh api doc to avoid clogging up the C files with details.
|
||||||
to test this run:
|
to test this run:
|
||||||
./blender.bin -b -noaudio -P doc/python_api/sphinx_doc_gen.py -- \
|
./blender.bin -b -noaudio -P doc/python_api/sphinx_doc_gen.py -- \
|
||||||
--partial bmesh* ; cd doc/python_api ; sphinx-build sphinx-in sphinx-out ; cd ../../
|
--partial bmesh* ; cd doc/python_api ; sphinx-build sphinx-in sphinx-out ; cd ../../
|
||||||
@@ -19,24 +19,25 @@ Submodules:
|
|||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
This API gives access the Blender's internal mesh editing API, featuring geometry connectivity data and
|
This API gives access the blenders internal mesh editing api, featuring geometry connectivity data and
|
||||||
access to editing operations such as split, separate, collapse and dissolve.
|
access to editing operations such as split, separate, collapse and dissolve.
|
||||||
|
|
||||||
The features exposed closely follow the C API,
|
The features exposed closely follow the C API,
|
||||||
giving Python access to the functions used by Blender's own mesh editing tools.
|
giving python access to the functions used by blenders own mesh editing tools.
|
||||||
|
|
||||||
For an overview of BMesh data types and how they reference each other see:
|
For an overview of BMesh data types and how they reference each other see:
|
||||||
`BMesh Design Document <https://wiki.blender.org/index.php/Dev:Source/Modeling/BMesh/Design>`__.
|
`BMesh Design Document <https://wiki.blender.org/index.php/Dev:Source/Modeling/BMesh/Design>`_ .
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
**Disk** and **Radial** data is not exposed by the Python API since this is for internal use only.
|
**Disk** and **Radial** data is not exposed by the python api since this is for internal use only.
|
||||||
|
|
||||||
|
|
||||||
.. warning:: TODO items are...
|
.. warning:: TODO items are...
|
||||||
|
|
||||||
- add access to BMesh **walkers**.
|
* add access to BMesh **walkers**
|
||||||
- add custom-data manipulation functions add, remove or rename.
|
* add custom-data manipulation functions add/remove/rename.
|
||||||
|
|
||||||
|
|
||||||
Example Script
|
Example Script
|
||||||
@@ -45,52 +46,55 @@ Example Script
|
|||||||
.. literalinclude:: __/__/__/release/scripts/templates_py/bmesh_simple.py
|
.. literalinclude:: __/__/__/release/scripts/templates_py/bmesh_simple.py
|
||||||
|
|
||||||
|
|
||||||
Standalone Module
|
Stand-Alone Module
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The BMesh module is written to be standalone except for :mod:`mathutils`
|
The bmesh module is written to be standalone except for :mod:`mathutils`
|
||||||
which is used for vertex locations and normals.
|
which is used for vertex locations and normals.
|
||||||
|
|
||||||
The only other exception to this are when converting mesh data to and from :class:`bpy.types.Mesh`.
|
The only other exception to this are when converting mesh data to and from :class:`bpy.types.Mesh`.
|
||||||
|
|
||||||
|
|
||||||
Mesh Access
|
Mesh Access
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
There are two ways to access BMesh data, you can create a new BMesh by converting a mesh from
|
There are 2 ways to access BMesh data, you can create a new BMesh by converting a mesh from
|
||||||
:class:`bpy.types.BlendData.meshes` or by accessing the current Edit-Mode mesh.
|
:class:`bpy.types.BlendData.meshes` or by accessing the current edit mode mesh.
|
||||||
See: :class:`bmesh.types.BMesh.from_mesh` and :mod:`bmesh.from_edit_mesh` respectively.
|
see: :class:`bmesh.types.BMesh.from_mesh` and :mod:`bmesh.from_edit_mesh` respectively.
|
||||||
|
|
||||||
When explicitly converting from mesh data Python **owns** the data, that means that
|
When explicitly converting from mesh data python **owns** the data, that is to say -
|
||||||
the mesh only exists while Python holds a reference to it.
|
that the mesh only exists while python holds a reference to it,
|
||||||
The script is responsible for putting it back into a mesh data-block when the edits are done.
|
and the script is responsible for putting it back into a mesh data-block when the edits are done.
|
||||||
|
|
||||||
Note that unlike :mod:`bpy`, a BMesh does not necessarily correspond to data in the currently open blend-file,
|
Note that unlike :mod:`bpy`, a BMesh does not necessarily correspond to data in the currently open blend file,
|
||||||
a BMesh can be created, edited and freed without the user ever seeing or having access to it.
|
a BMesh can be created, edited and freed without the user ever seeing or having access to it.
|
||||||
Unlike Edit-Mode, the BMesh module can use multiple BMesh instances at once.
|
Unlike edit mode, the bmesh module can use multiple BMesh instances at once.
|
||||||
|
|
||||||
Take care when dealing with multiple BMesh instances since the mesh data can use a lot of memory.
|
Take care when dealing with multiple BMesh instances since the mesh data can use a lot of memory, while a mesh that
|
||||||
While a mesh that the Python script owns will be freed when the script holds no references to it,
|
python owns will be freed in when the script holds no references to it,
|
||||||
it's good practice to call :class:`bmesh.types.BMesh.free` which will remove all the mesh data immediately
|
its good practice to call :class:`bmesh.types.BMesh.free` which will remove all the mesh data immediately and disable
|
||||||
and disable further access.
|
further access.
|
||||||
|
|
||||||
|
|
||||||
Edit-Mode Tessellation
|
EditMode Tessellation
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
When writing scripts that operate on Edit-Mode data you will normally want to re-calculate the tessellation after
|
When writing scripts that operate on editmode data you will normally want to re-calculate the tessellation after
|
||||||
running the script, this needs to be called explicitly.
|
running the script, this needs to be called explicitly.
|
||||||
The BMesh itself does not store the triangulated faces, instead they are stored in the :class:`bpy.types.Mesh`,
|
|
||||||
|
The BMesh its self does not store the triangulated faces, they are stored in the :class:`bpy.types.Mesh`,
|
||||||
to refresh tessellation triangles call :class:`bpy.types.Mesh.calc_loop_triangles`.
|
to refresh tessellation triangles call :class:`bpy.types.Mesh.calc_loop_triangles`.
|
||||||
|
|
||||||
|
|
||||||
CustomData Access
|
CustomData Access
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
BMesh has a unified way to access mesh attributes such as UVs, vertex colors, shape keys, edge crease, etc.
|
BMesh has a unified way to access mesh attributes such as UV's vertex colors, shape keys, edge crease etc.
|
||||||
This works by having a **layers** property on BMesh data sequences to access the custom data layers
|
|
||||||
which can then be used to access the actual data on each vert, edge, face or loop.
|
|
||||||
|
|
||||||
Here are some examples:
|
This works by having a **layers** property on bmesh data sequences to access the custom data layers which can then be
|
||||||
|
used to access the actual data on each vert/edge/face/loop.
|
||||||
|
|
||||||
|
Here are some examples ...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -135,27 +139,27 @@ Here are some examples:
|
|||||||
Keeping a Correct State
|
Keeping a Correct State
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
When modeling in Blender there are certain assumptions made about the state of the mesh:
|
When modeling in blender there are certain assumptions made about the state of the mesh.
|
||||||
|
|
||||||
- Hidden geometry isn't selected.
|
* hidden geometry isn't selected.
|
||||||
- When an edge is selected, its vertices are selected too.
|
* when an edge is selected, its vertices are selected too.
|
||||||
- When a face is selected, its edges and vertices are selected.
|
* when a face is selected, its edges and vertices are selected.
|
||||||
- Duplicate edges / faces don't exist.
|
* duplicate edges / faces don't exist.
|
||||||
- Faces have at least three vertices.
|
* faces have at least 3 vertices.
|
||||||
|
|
||||||
To give developers flexibility these conventions are not enforced,
|
To give developers flexibility these conventions are not enforced,
|
||||||
yet tools must leave the mesh in a valid state or else other tools may behave incorrectly.
|
however tools must leave the mesh in a valid state else other tools may behave incorrectly.
|
||||||
|
|
||||||
Any errors that arise from not following these conventions is considered a bug in the script,
|
Any errors that arise from not following these conventions is considered a bug in the script,
|
||||||
not a bug in Blender.
|
not a bug in blender.
|
||||||
|
|
||||||
|
|
||||||
Selection / Flushing
|
Selection / Flushing
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
As mentioned above, it is possible to create an invalid selection state
|
As mentioned above, it is possible to create an invalid selection state
|
||||||
(by selecting a state and then deselecting one of its vertices for example),
|
(by selecting a state and then de-selecting one of its vertices's for example), mostly the best way to solve this is to
|
||||||
mostly the best way to solve this is to flush the selection
|
flush the selection after performing a series of edits. this validates the selection state.
|
||||||
after performing a series of edits. This validates the selection state.
|
|
||||||
|
|
||||||
|
|
||||||
Module Functions
|
Module Functions
|
||||||
|
@@ -3,84 +3,94 @@
|
|||||||
Reference API Usage
|
Reference API Usage
|
||||||
*******************
|
*******************
|
||||||
|
|
||||||
Blender has many interlinking data types which have an auto-generated reference API which often has the information
|
Blender has many interlinking data types which have an auto-generated reference api which often has the information
|
||||||
you need to write a script, but can be difficult to use.
|
you need to write a script, but can be difficult to use.
|
||||||
This document is designed to help you understand how to use the reference API.
|
|
||||||
|
This document is designed to help you understand how to use the reference api.
|
||||||
|
|
||||||
|
|
||||||
Reference API Scope
|
Reference API Scope
|
||||||
===================
|
===================
|
||||||
|
|
||||||
The reference API covers :mod:`bpy.types`, which stores types accessed via :mod:`bpy.context` -- *the user context*
|
The reference API covers :mod:`bpy.types`, which stores types accessed via :mod:`bpy.context` - *The user context*
|
||||||
or :mod:`bpy.data` -- *blend-file data*.
|
or :mod:`bpy.data` - *Blend file data*.
|
||||||
|
|
||||||
Other modules such as :mod:`bmesh` and :mod:`aud` are not using Blender's data API
|
Other modules such as :mod:`bmesh` and :mod:`aud` are not using Blenders data API
|
||||||
so this document doesn't apply to those modules.
|
so this document doesn't apply to those modules.
|
||||||
|
|
||||||
|
|
||||||
Data Access
|
Data Access
|
||||||
===========
|
===========
|
||||||
|
|
||||||
The most common case for using the reference API is to find out how to access data in the blend-file.
|
The most common case for using the reference API is to find out how to access data in the blend file.
|
||||||
Before going any further its best to be aware of ID data-blocks in Blender since you will often find properties
|
|
||||||
|
Before going any further its best to be aware of ID Data-Blocks in Blender since you will often find properties
|
||||||
relative to them.
|
relative to them.
|
||||||
|
|
||||||
|
|
||||||
ID Data
|
ID Data
|
||||||
-------
|
-------
|
||||||
|
|
||||||
ID data-blocks are used in Blender as top-level data containers.
|
ID Data-Blocks are used in Blender as top-level data containers.
|
||||||
From the user interface this isn't so obvious, but when developing you need to know about ID data-blocks.
|
|
||||||
ID data types include Scene, Group, Object, Mesh, Workspace, World, Armature, Image and Texture.
|
|
||||||
For a full list see the subclasses of :class:`bpy.types.ID`.
|
|
||||||
|
|
||||||
Here are some characteristics ID data-blocks share:
|
From the user interface this isn't so obvious, but when developing you need to know about ID Data-Blocks.
|
||||||
|
|
||||||
- IDs are blend-file data, so loading a new blend-file reloads an entire new set of data-blocks.
|
ID data types include Scene, Group, Object, Mesh, Screen, World, Armature, Image and Texture.
|
||||||
- IDs can be accessed in Python from ``bpy.data.*``.
|
for a full list see the sub-classes of :class:`bpy.types.ID`
|
||||||
|
|
||||||
|
Here are some characteristics ID Data-Blocks share.
|
||||||
|
|
||||||
|
- ID's are blend file data, so loading a new blend file reloads an entire new set of Data-Blocks.
|
||||||
|
- ID's can be accessed in Python from ``bpy.data.*``
|
||||||
- Each data-block has a unique ``.name`` attribute, displayed in the interface.
|
- Each data-block has a unique ``.name`` attribute, displayed in the interface.
|
||||||
- Animation data is stored in IDs ``.animation_data``.
|
- Animation data is stored in ID's ``.animation_data``.
|
||||||
- IDs are the only data types that can be linked between blend-files.
|
- ID's are the only data types that can be linked between blend files.
|
||||||
- IDs can be added/copied and removed via Python.
|
- ID's can be added/copied and removed via Python.
|
||||||
- IDs have their own garbage-collection system which frees unused IDs when saving.
|
- ID's have their own garbage-collection system which frees unused ID's when saving.
|
||||||
- When a data-block has a reference to some external data, this is typically an ID data-block.
|
- When a data-block has a reference to some external data, this is typically an ID Data-Block.
|
||||||
|
|
||||||
|
|
||||||
Simple Data Access
|
Simple Data Access
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
In this simple case a Python script is used to adjust the object's location.
|
Lets start with a simple case, say you want a python script to adjust the object's location.
|
||||||
Start by collecting the information where the data is located.
|
|
||||||
|
|
||||||
First find this setting in the interface ``Properties editor -> Object -> Transform -> Location``.
|
Start by finding this setting in the interface ``Properties Window -> Object -> Transform -> Location``
|
||||||
From the button context menu select *Online Python Reference*, this will link you to:
|
|
||||||
:class:`bpy.types.Object.location`.
|
From the button you can right click and select **Online Python Reference**, this will link you to:
|
||||||
Being an API reference, this link often gives little more information then the tooltip, though some of the pages
|
:class:`bpy.types.Object.location`
|
||||||
|
|
||||||
|
Being an API reference, this link often gives little more information then the tool-tip, though some of the pages
|
||||||
include examples (normally at the top of the page).
|
include examples (normally at the top of the page).
|
||||||
But you now know that you have to use ``.location`` and that its an array of three floats.
|
|
||||||
|
|
||||||
So the next step is to find out where to access objects, go down to the bottom of the page to the references section,
|
At this point you may say *Now what?* - you know that you have to use ``.location`` and that its an array of 3 floats
|
||||||
for objects there are many references, but one of the most common places to access objects is via the context.
|
but you're still left wondering how to access this in a script.
|
||||||
It's easy to be overwhelmed at this point since there ``Object`` get referenced in so many places:
|
|
||||||
modifiers, functions, textures and constraints.
|
So the next step is to find out where to access objects, go down to the bottom of the page to the **References**
|
||||||
|
section, for objects there are many references, but one of the most common places to access objects is via the context.
|
||||||
|
|
||||||
|
It's easy to be overwhelmed at this point since there ``Object`` get referenced in so many places - modifiers,
|
||||||
|
functions, textures and constraints.
|
||||||
|
|
||||||
But if you want to access any data the user has selected
|
But if you want to access any data the user has selected
|
||||||
you typically only need to check the :mod:`bpy.context` references.
|
you typically only need to check the :mod:`bpy.context` references.
|
||||||
|
|
||||||
Even then, in this case there are quite a few though
|
Even then, in this case there are quite a few though if you read over these - most are mode specific.
|
||||||
if you read over these you'll notice that most are mode specific.
|
If you happen to be writing a tool that only runs in weight paint mode, then using ``weight_paint_object``
|
||||||
If you happen to be writing a tool that only runs in Weight Paint Mode,
|
would be appropriate.
|
||||||
then using ``weight_paint_object`` would be appropriate.
|
However to access an item the user last selected, look for the ``active`` members,
|
||||||
However, to access an item the user last selected, look for the ``active`` members,
|
Having access to a single active member the user selects is a convention in Blender: eg. ``active_bone``,
|
||||||
Having access to a single active member the user selects is a convention in Blender:
|
``active_pose_bone``, ``active_node`` ... and in this case we can use - ``active_object``.
|
||||||
e.g. ``active_bone``, ``active_pose_bone``, ``active_node``, etc. and in this case you can use ``active_object``.
|
|
||||||
|
|
||||||
So now you have enough information to find the location of the active object.
|
|
||||||
|
So now we have enough information to find the location of the active object.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
bpy.context.active_object.location
|
bpy.context.active_object.location
|
||||||
|
|
||||||
You can type this into the Python console to see the result.
|
You can type this into the python console to see the result.
|
||||||
|
|
||||||
The other common place to access objects in the reference is :class:`bpy.types.BlendData.objects`.
|
The other common place to access objects in the reference is :class:`bpy.types.BlendData.objects`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -90,7 +100,7 @@ The other common place to access objects in the reference is :class:`bpy.types.B
|
|||||||
so the documentation points there.
|
so the documentation points there.
|
||||||
|
|
||||||
|
|
||||||
With :mod:`bpy.data.objects`, this is a collection of objects so you need to access one of its members:
|
With :mod:`bpy.data.objects`, this is a collection of objects so you need to access one of its members.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -107,34 +117,37 @@ Here are some more complex examples:
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Access the number of samples for the Cycles render engine.
|
# access a render layers samples
|
||||||
bpy.context.scene.cycles.samples
|
bpy.context.scene.render.layers["RenderLayer"].samples
|
||||||
|
|
||||||
# Access to the current weight paint brush size.
|
# access to the current weight paint brush size
|
||||||
bpy.context.tool_settings.weight_paint.brush.size
|
bpy.context.tool_settings.weight_paint.brush.size
|
||||||
|
|
||||||
# Check if the window is full-screen.
|
# check if the window is fullscreen
|
||||||
bpy.context.window.screen.show_fullscreen
|
bpy.context.window.screen.show_fullscreen
|
||||||
|
|
||||||
|
|
||||||
As you can see there are times when you want to access data which is nested
|
As you can see there are times when you want to access data which is nested
|
||||||
in a way that causes you to go through a few indirections.
|
in a way that causes you to go through a few indirections.
|
||||||
The properties are arranged to match how data is stored internally (in Blender's C code) which is often logical
|
|
||||||
but not always quite what you would expect from using Blender.
|
|
||||||
So this takes some time to learn, it helps you understand how data fits together in Blender
|
|
||||||
which is important to know when writing scripts.
|
|
||||||
|
|
||||||
When starting out scripting you will often run into the problem
|
The properties are arranged to match how data is stored internally (in blenders C code) which is often logical but
|
||||||
where you're not sure how to access the data you want.
|
not always quite what you would expect from using Blender.
|
||||||
There are a few ways to do this:
|
|
||||||
|
So this takes some time to learn, it helps you understand how data fits together in Blender which is important
|
||||||
|
to know when writing scripts.
|
||||||
|
|
||||||
|
|
||||||
|
When starting out scripting you will often run into the problem where you're not sure how to access the data you want.
|
||||||
|
|
||||||
|
There are a few ways to do this.
|
||||||
|
|
||||||
- Use the Python console's auto-complete to inspect properties.
|
- Use the Python console's auto-complete to inspect properties.
|
||||||
*This can be hit-and-miss but has the advantage
|
*This can be hit-and-miss but has the advantage
|
||||||
that you can easily see the values of properties and assign them to interactively see the results.*
|
that you can easily see the values of properties and assign them to interactively see the results.*
|
||||||
- Copy the data path from the user interface.
|
- Copy the Data-Path from the user interface.
|
||||||
*Explained further in* :ref:`Copy Data Path <info_data_path_copy>`.
|
*Explained further in :ref:`Copy Data Path <info_data_path_copy>`*
|
||||||
- Using the documentation to follow references.
|
- Using the documentation to follow references.
|
||||||
*Explained further in* :ref:`Indirect Data Access <info_data_path_indirect>`.
|
*Explained further in :ref:`Indirect Data Access <info_data_path_indirect>`*
|
||||||
|
|
||||||
|
|
||||||
.. _info_data_path_copy:
|
.. _info_data_path_copy:
|
||||||
@@ -142,36 +155,42 @@ There are a few ways to do this:
|
|||||||
Copy Data Path
|
Copy Data Path
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Blender can compute the Python string to a property which is shown in the tooltip,
|
Blender can compute the Python string to a property which is shown in the tool-tip, on the line below ``Python: ...``,
|
||||||
on the line below ``Python: ...``. This saves having to open the API references to find where data is accessed from.
|
This saves having to use the API reference to click back up the references to find where data is accessed from.
|
||||||
In the context menu is a copy data-path tool which gives the path from an :class:`bpy.types.ID` data-block,
|
|
||||||
|
There is a user-interface feature to copy the data-path which gives the path from an :class:`bpy.types.ID` data-block,
|
||||||
to its property.
|
to its property.
|
||||||
|
|
||||||
To see how this works you'll get the path to the Subdivision Surface modifiers *Levels* setting.
|
To see how this works we'll get the path to the Subdivision-Surface modifiers subdivision setting.
|
||||||
Start with the default scene and select the Modifiers tab, then add a Subdivision Surface modifier to the cube.
|
|
||||||
Now hover your mouse over the button labeled *Levels Viewport*,
|
Start with the default scene and select the **Modifiers** tab, then add a **Subdivision-Surface** modifier to the cube.
|
||||||
The tooltip includes :class:`bpy.types.SubsurfModifier.levels` but you want the path from the object to this property.
|
|
||||||
|
Now hover your mouse over the button labeled **View**, The tool-tip includes :class:`bpy.types.SubsurfModifier.levels`
|
||||||
|
but we want the path from the object to this property.
|
||||||
|
|
||||||
Note that the text copied won't include the ``bpy.data.collection["name"].`` component since its assumed that
|
Note that the text copied won't include the ``bpy.data.collection["name"].`` component since its assumed that
|
||||||
you won't be doing collection look-ups on every access and typically you'll want to use the context rather
|
you won't be doing collection look-ups on every access and typically you'll want to use the context rather
|
||||||
then access each :class:`bpy.types.ID` instance by name.
|
then access each :class:`bpy.types.ID` instance by name.
|
||||||
|
|
||||||
Type in the ID path into a Python console :mod:`bpy.context.active_object`.
|
|
||||||
Include the trailing dot and don't execute the code, yet.
|
|
||||||
|
|
||||||
Now in the button's context menu select *Copy Data Path*, then paste the result into the console:
|
Type in the ID path into a Python console :mod:`bpy.context.active_object`.
|
||||||
|
Include the trailing dot and don't hit "enter", yet.
|
||||||
|
|
||||||
|
Now right-click on the button and select **Copy Data Path**, then paste the result into the console.
|
||||||
|
|
||||||
|
So now you should have the answer:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
bpy.context.active_object.modifiers["Subsurf"].levels
|
bpy.context.active_object.modifiers["Subsurf"].levels
|
||||||
|
|
||||||
Press :kbd:`Return` and you'll get the current value of 1. Now try changing the value to 2:
|
Hit "enter" and you'll get the current value of 1. Now try changing the value to 2:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
bpy.context.active_object.modifiers["Subsurf"].levels = 2
|
bpy.context.active_object.modifiers["Subsurf"].levels = 2
|
||||||
|
|
||||||
You can see the value update in the Subdivision Surface modifier's UI as well as the cube.
|
You can see the value update in the Subdivision-Surface modifier's UI as well as the cube.
|
||||||
|
|
||||||
|
|
||||||
.. _info_data_path_indirect:
|
.. _info_data_path_indirect:
|
||||||
@@ -179,45 +198,51 @@ You can see the value update in the Subdivision Surface modifier's UI as well as
|
|||||||
Indirect Data Access
|
Indirect Data Access
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
This more advanced example shows the steps to access the active sculpt brushes texture.
|
For this example we'll go over something more involved, showing the steps to access the active sculpt brushes texture.
|
||||||
For example, if you want to access the texture of a brush via Python to adjust its ``contrast``.
|
|
||||||
|
|
||||||
#. Start in the default scene and enable Sculpt Mode from the 3D Viewport header.
|
Lets say we want to access the texture of a brush via Python, to adjust its ``contrast`` for example.
|
||||||
#. From the Sidebar expand the Brush Settings panel's *Texture* subpanel and add a new texture.
|
|
||||||
*Notice the texture data-block menu itself doesn't have very useful links (you can check the tooltips).*
|
|
||||||
#. The contrast setting isn't exposed in the Sidebar, so view the texture in the properties editor:
|
|
||||||
|
|
||||||
- In the properties editor select the Texture tab.
|
- Start in the default scene and enable 'Sculpt' mode from the 3D-View header.
|
||||||
- Select brush texture.
|
- From the toolbar expand the **Texture** panel and add a new texture.
|
||||||
- Expand the *Colors* panel to locate the *Contrast* number field.
|
*Notice the texture button its self doesn't have very useful links (you can check the tooltips).*
|
||||||
#. Open the context menu of the contrast field and select *Online Python Reference*.
|
- The contrast setting isn't exposed in the sculpt toolbar, so view the texture in the properties panel...
|
||||||
This takes you to ``bpy.types.Texture.contrast``. Now you can see that ``contrast`` is a property of texture.
|
|
||||||
#. To find out how to access the texture from the brush check on the references at the bottom of the page.
|
|
||||||
Sometimes there are many references, and it may take some guesswork to find the right one,
|
|
||||||
but in this case it's ``Brush.texture``.
|
|
||||||
|
|
||||||
#. Now you know that the texture can be accessed from ``bpy.data.brushes["BrushName"].texture``
|
- In the properties button select the Texture context.
|
||||||
but normally you *won't* want to access the brush by name, instead you want to access the active brush.
|
- Select the Brush icon to show the brush texture.
|
||||||
So the next step is to check on where brushes are accessed from via the references.
|
- Expand the *Colors* panel to locate the *Contrast* button.
|
||||||
In this case there it is simply ``bpy.context.brush``.
|
- Right click on the contrast button and select **Online Python Reference**
|
||||||
|
This takes you to ``bpy.types.Texture.contrast``
|
||||||
|
- Now we can see that ``contrast`` is a property of texture,
|
||||||
|
so next we'll check on how to access the texture from the brush.
|
||||||
|
- Check on the **References** at the bottom of the page, sometimes there are many references, and it may take
|
||||||
|
some guess work to find the right one, but in this case its obviously ``Brush.texture``.
|
||||||
|
|
||||||
Now you can use the Python console to form the nested properties needed to access brush textures contrast:
|
*Now we know that the texture can be accessed from* ``bpy.data.brushes["BrushName"].texture``
|
||||||
*Context -> Brush -> Texture -> Contrast*.
|
*but normally you won't want to access the brush by name, so we'll see now to access the active brush instead.*
|
||||||
|
- So the next step is to check on where brushes are accessed from via the **References**.
|
||||||
|
In this case there is simply ``bpy.context.brush`` which is all we need.
|
||||||
|
|
||||||
Since the attribute for each is given along the way you can compose the data path in the Python console:
|
Now you can use the Python console to form the nested properties needed to access brush textures contrast,
|
||||||
|
logically we now know.
|
||||||
|
|
||||||
|
*Context -> Brush -> Texture -> Contrast*
|
||||||
|
|
||||||
|
Since the attribute for each is given along the way we can compose the data path in the python console:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
bpy.context.brush.texture.contrast
|
bpy.context.brush.texture.contrast
|
||||||
|
|
||||||
|
|
||||||
There can be multiple ways to access the same data, which you choose often depends on the task.
|
There can be multiple ways to access the same data, which you choose often depends on the task.
|
||||||
An alternate path to access the same setting is:
|
|
||||||
|
An alternate path to access the same setting is...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
bpy.context.sculpt.brush.texture.contrast
|
bpy.context.sculpt.brush.texture.contrast
|
||||||
|
|
||||||
Or access the brush directly:
|
Or access the brush directly...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -226,24 +251,27 @@ Or access the brush directly:
|
|||||||
|
|
||||||
If you are writing a user tool normally you want to use the :mod:`bpy.context` since the user normally expects
|
If you are writing a user tool normally you want to use the :mod:`bpy.context` since the user normally expects
|
||||||
the tool to operate on what they have selected.
|
the tool to operate on what they have selected.
|
||||||
For automation you are more likely to use :mod:`bpy.data` since you want to be able to access specific data and
|
|
||||||
manipulate it, no matter what the user currently has the view set at.
|
For automation you are more likely to use :mod:`bpy.data` since you want to be able to access specific data and manipulate
|
||||||
|
it, no matter what the user currently has the view set at.
|
||||||
|
|
||||||
|
|
||||||
Operators
|
Operators
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Most hotkeys and buttons in Blender call an operator which is also exposed to Python via :mod:`bpy.ops`.
|
Most key-strokes and buttons in Blender call an operator which is also exposed to python via :mod:`bpy.ops`,
|
||||||
|
|
||||||
To see the Python equivalent hover your mouse over the button and see the tooltip,
|
To see the Python equivalent hover your mouse over the button and see the tool-tip,
|
||||||
e.g ``Python: bpy.ops.render.render()``,
|
eg ``Python: bpy.ops.render.render()``,
|
||||||
If there is no tooltip or the ``Python:`` line is missing then this button is not using an operator
|
If there is no tool-tip or the ``Python:`` line is missing then this button is not using an operator and
|
||||||
and can't be accessed from Python.
|
can't be accessed from Python.
|
||||||
|
|
||||||
If you want to use this in a script you can press :kbd:`Ctrl-C` while your mouse is over the button
|
|
||||||
to copy it to the clipboard.
|
If you want to use this in a script you can press :kbd:`Control-C` while your mouse is over the button to copy it to the
|
||||||
You can also use button's context menu and view the *Online Python Reference*, this mainly shows arguments and
|
clipboard.
|
||||||
their defaults, however, operators written in Python show their file and line number which may be useful if you
|
|
||||||
|
You can also right click on the button and view the **Online Python Reference**, this mainly shows arguments and
|
||||||
|
their defaults however operators written in Python show their file and line number which may be useful if you
|
||||||
are interested to check on the source code.
|
are interested to check on the source code.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -252,18 +280,21 @@ are interested to check on the source code.
|
|||||||
for more on this see :ref:`using operators <using_operators>`.
|
for more on this see :ref:`using operators <using_operators>`.
|
||||||
|
|
||||||
|
|
||||||
Info Editor
|
Info View
|
||||||
-----------
|
---------
|
||||||
|
|
||||||
Blender records operators you run and displays them in the Info editor.
|
Blender records operators you run and displays them in the **Info** space.
|
||||||
Select the Scripting workspace that comes default with Blender to see its output.
|
This is located above the file-menu which can be dragged down to display its contents.
|
||||||
You can perform some actions and see them show up -- delete a vertex for example.
|
|
||||||
|
|
||||||
Each entry can be selected, then copied :kbd:`Ctrl-C`, usually to paste in the text editor or Python console.
|
Select the **Script** screen that comes default with Blender to see its output.
|
||||||
|
You can perform some actions and see them show up - delete a vertex for example.
|
||||||
|
|
||||||
|
Each entry can be selected (Right-Mouse-Button),
|
||||||
|
then copied :kbd:`Control-C`, usually to paste in the text editor or python console.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Not all operators get registered for display,
|
Not all operators get registered for display,
|
||||||
zooming the view for example isn't so useful to repeat so its excluded from the output.
|
zooming the view for example isn't so useful to repeat so its excluded from the output.
|
||||||
|
|
||||||
To display *every* operator that runs see :ref:`Show All Operators <info_show_all_operators>`.
|
To display *every* operator that runs see :ref:`Show All Operators <info_show_all_operators>`
|
||||||
|
@@ -3,34 +3,38 @@
|
|||||||
Best Practice
|
Best Practice
|
||||||
*************
|
*************
|
||||||
|
|
||||||
When writing your own scripts Python is great for new developers to pick up and become productive,
|
When writing your own scripts python is great for new developers to pick up and become productive,
|
||||||
but you can also pick up bad practices or at least write scripts that are not easy for others to understand.
|
but you can also pick up odd habits or at least write scripts that are not easy for others to understand.
|
||||||
|
|
||||||
For your own work this is of course fine,
|
For your own work this is of course fine,
|
||||||
but if you want to collaborate with others or have your work included with Blender there are practices we encourage.
|
but if you want to collaborate with others or have your work included with blender there are practices we encourage.
|
||||||
|
|
||||||
|
|
||||||
Style Conventions
|
Style Conventions
|
||||||
=================
|
=================
|
||||||
|
|
||||||
For Blender Python development we have chosen to follow Python suggested style guide to avoid mixing styles
|
For Blender/Python development we have chosen to follow python suggested style guide to avoid mixing styles
|
||||||
among our own scripts and make it easier to use Python scripts from other projects.
|
amongst our own scripts and make it easier to use python scripts from other projects.
|
||||||
Using our style guide for your own scripts makes it easier if you eventually want to contribute them to Blender.
|
|
||||||
|
|
||||||
This style guide is known as `pep8 <https://www.python.org/dev/peps/pep-0008/>`__
|
Using our style guide for your own scripts makes it easier if you eventually want to contribute them to blender.
|
||||||
and here is a brief listing of pep8 criteria:
|
|
||||||
|
|
||||||
- Camel caps for class names: MyClass
|
This style guide is known as pep8 and can be found `here <https://www.python.org/dev/peps/pep-0008/>`_
|
||||||
- All lower case underscore separated module names: my_module
|
|
||||||
- Indentation of 4 spaces (no tabs)
|
|
||||||
- Spaces around operators: ``1 + 1``, not ``1+1``
|
|
||||||
- Only use explicit imports (no wildcard importing ``*``)
|
|
||||||
- Don't use multiple statements on a single line: ``if val: body``, separate onto two lines instead.
|
|
||||||
|
|
||||||
As well as pep8 we have additional conventions used for Blender Python scripts:
|
A brief listing of pep8 criteria.
|
||||||
|
|
||||||
|
- camel caps for class names: MyClass
|
||||||
|
- all lower case underscore separated module names: my_module
|
||||||
|
- indentation of 4 spaces (no tabs)
|
||||||
|
- spaces around operators. ``1 + 1``, not ``1+1``
|
||||||
|
- only use explicit imports, (no importing ``*``)
|
||||||
|
- don't use single line: ``if val: body``, separate onto 2 lines instead.
|
||||||
|
|
||||||
|
|
||||||
|
As well as pep8 we have other conventions used for blender python scripts.
|
||||||
|
|
||||||
- Use single quotes for enums, and double quotes for strings.
|
- Use single quotes for enums, and double quotes for strings.
|
||||||
|
|
||||||
Both are of course strings, but in our internal API enums are unique items from a limited set, e.g:
|
Both are of course strings, but in our internal API enums are unique items from a limited set. eg.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -38,14 +42,14 @@ As well as pep8 we have additional conventions used for Blender Python scripts:
|
|||||||
bpy.context.scene.render.filepath = "//render_out"
|
bpy.context.scene.render.filepath = "//render_out"
|
||||||
|
|
||||||
- pep8 also defines that lines should not exceed 79 characters,
|
- pep8 also defines that lines should not exceed 79 characters,
|
||||||
we have decided that this is too restrictive so it is optional per script.
|
we felt this is too restrictive so this is optional per script.
|
||||||
|
|
||||||
Periodically we run checks for pep8 compliance on Blender scripts,
|
Periodically we run checks for pep8 compliance on blender scripts,
|
||||||
for scripts to be included in this check add this line as a comment at the top of the script:
|
for scripts to be included in this check add this line as a comment at the top of the script.
|
||||||
|
|
||||||
``# <pep8 compliant>``
|
``# <pep8 compliant>``
|
||||||
|
|
||||||
To enable line length checks use this instead:
|
To enable line length checks use this instead.
|
||||||
|
|
||||||
``# <pep8-80 compliant>``
|
``# <pep8-80 compliant>``
|
||||||
|
|
||||||
@@ -55,79 +59,85 @@ User Interface Layout
|
|||||||
|
|
||||||
Some notes to keep in mind when writing UI layouts:
|
Some notes to keep in mind when writing UI layouts:
|
||||||
|
|
||||||
UI code is quite simple. Layout declarations are there to easily create a decent layout.
|
- UI code is quite simple. Layout declarations are there to easily create a decent layout.
|
||||||
The general rule here is: If you need more code for the layout declaration,
|
|
||||||
than for the actual properties, then you are doing it wrong.
|
|
||||||
|
|
||||||
|
General rule here: If you need more code for the layout declaration,
|
||||||
|
then for the actual properties, you do it wrong.
|
||||||
|
|
||||||
.. rubric:: Example layouts:
|
Example layouts:
|
||||||
|
|
||||||
``layout()``
|
- layout()
|
||||||
The basic layout is a simple top-to-bottom layout.
|
|
||||||
|
|
||||||
.. code-block:: python
|
The basic layout is a simple Top -> Bottom layout.
|
||||||
|
|
||||||
layout.prop()
|
.. code-block:: python
|
||||||
layout.prop()
|
|
||||||
|
|
||||||
``layout.row()``
|
layout.prop()
|
||||||
Use ``row()``, when you want more than one property in a single line.
|
layout.prop()
|
||||||
|
|
||||||
.. code-block:: python
|
- layout.row()
|
||||||
|
|
||||||
row = layout.row()
|
Use row(), when you want more than 1 property in one line.
|
||||||
row.prop()
|
|
||||||
row.prop()
|
|
||||||
|
|
||||||
``layout.column()``
|
.. code-block:: python
|
||||||
Use ``column()``, when you want your properties in a column.
|
|
||||||
|
|
||||||
.. code-block:: python
|
row = layout.row()
|
||||||
|
row.prop()
|
||||||
|
row.prop()
|
||||||
|
|
||||||
col = layout.column()
|
- layout.column()
|
||||||
col.prop()
|
|
||||||
col.prop()
|
|
||||||
|
|
||||||
``layout.split()``
|
Use column(), when you want your properties in a column.
|
||||||
This can be used to create more complex layouts.
|
|
||||||
For example, you can split the layout and create two ``column()`` layouts next to each other.
|
|
||||||
Do not use split, when you simply want two properties in a row. Use ``row()`` instead.
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
split = layout.split()
|
col = layout.column()
|
||||||
|
col.prop()
|
||||||
|
col.prop()
|
||||||
|
|
||||||
col = split.column()
|
- layout.split()
|
||||||
col.prop()
|
|
||||||
col.prop()
|
|
||||||
|
|
||||||
col = split.column()
|
This can be used to create more complex layouts.
|
||||||
col.prop()
|
For example you can split the layout and create two column() layouts next to each other.
|
||||||
col.prop()
|
Don't use split, when you simply want two properties in a row. Use row() for that.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
.. rubric:: Declaration names:
|
split = layout.split()
|
||||||
|
|
||||||
|
col = split.column()
|
||||||
|
col.prop()
|
||||||
|
col.prop()
|
||||||
|
|
||||||
|
col = split.column()
|
||||||
|
col.prop()
|
||||||
|
col.prop()
|
||||||
|
|
||||||
|
Declaration names:
|
||||||
|
|
||||||
Try to only use these variable names for layout declarations:
|
Try to only use these variable names for layout declarations:
|
||||||
|
|
||||||
:row: for a ``row()`` layout
|
- row for a row() layout
|
||||||
:col: for a ``column()`` layout
|
- col for a column() layout
|
||||||
:split: for a ``split()`` layout
|
- split for a split() layout
|
||||||
:flow: for a ``column_flow()`` layout
|
- flow for a column_flow() layout
|
||||||
:sub: for a sub layout (a column inside a column for example)
|
- sub for a sub layout (a column inside a column for example)
|
||||||
|
|
||||||
|
|
||||||
Script Efficiency
|
Script Efficiency
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
||||||
List Manipulation (General Python Tips)
|
List Manipulation (General Python Tips)
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Searching for List Items
|
|
||||||
|
Searching for list items
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
In Python there are some handy list functions that save you having to search through the list.
|
In Python there are some handy list functions that save you having to search through the list.
|
||||||
Even though you are not looping on the list data **Python is**,
|
|
||||||
|
Even though you are not looping on the list data **python is**,
|
||||||
so you need to be aware of functions that will slow down your script by searching the whole list.
|
so you need to be aware of functions that will slow down your script by searching the whole list.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -140,21 +150,23 @@ so you need to be aware of functions that will slow down your script by searchin
|
|||||||
|
|
||||||
Modifying Lists
|
Modifying Lists
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
In python we can add and remove from a list, this is slower when the list length is modified,
|
||||||
In Python you can add and remove from a list, this is slower when the list length is modified,
|
|
||||||
especially at the start of the list, since all the data after the index of
|
especially at the start of the list, since all the data after the index of
|
||||||
modification needs to be moved up or down one place.
|
modification needs to be moved up or down 1 place.
|
||||||
|
|
||||||
The fastest way to add onto the end of the list is to use
|
The most simple way to add onto the end of the list is to use
|
||||||
``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and
|
``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to
|
||||||
to remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
|
remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
|
||||||
|
|
||||||
To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(index)``
|
To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(index)``
|
||||||
for list removal, but these are slower.
|
for list removal, but these are slower.
|
||||||
|
|
||||||
Sometimes it's faster (but less memory efficient) to just rebuild the list.
|
Sometimes its faster (but more memory hungry) to just rebuild the list.
|
||||||
For example if you want to remove all triangular polygons in a list.
|
|
||||||
Rather than:
|
|
||||||
|
Say you want to remove all triangular polygons in a list.
|
||||||
|
|
||||||
|
Rather than...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -167,7 +179,7 @@ Rather than:
|
|||||||
polygons.pop(p_idx) # remove the triangle
|
polygons.pop(p_idx) # remove the triangle
|
||||||
|
|
||||||
|
|
||||||
It's faster to build a new list with list comprehension:
|
It's faster to build a new list with list comprehension.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -177,14 +189,14 @@ It's faster to build a new list with list comprehension:
|
|||||||
Adding List Items
|
Adding List Items
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
If you have a list that you want to add onto another list, rather than:
|
If you have a list that you want to add onto another list, rather than...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
for l in some_list:
|
for l in some_list:
|
||||||
my_list.append(l)
|
my_list.append(l)
|
||||||
|
|
||||||
Use:
|
Use...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -193,7 +205,9 @@ Use:
|
|||||||
|
|
||||||
Note that insert can be used when needed,
|
Note that insert can be used when needed,
|
||||||
but it is slower than append especially when inserting at the start of a long list.
|
but it is slower than append especially when inserting at the start of a long list.
|
||||||
This example shows a very suboptimal way of making a reversed list:
|
|
||||||
|
This example shows a very sub-optimal way of making a reversed list.
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -205,6 +219,7 @@ This example shows a very suboptimal way of making a reversed list:
|
|||||||
Python provides more convenient ways to reverse a list using the slice method,
|
Python provides more convenient ways to reverse a list using the slice method,
|
||||||
but you may want to time this before relying on it too much:
|
but you may want to time this before relying on it too much:
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
some_reversed_list = some_list[::-1]
|
some_reversed_list = some_list[::-1]
|
||||||
@@ -213,10 +228,12 @@ but you may want to time this before relying on it too much:
|
|||||||
Removing List Items
|
Removing List Items
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Use ``my_list.pop(index)`` rather than ``my_list.remove(list_item)``.
|
Use ``my_list.pop(index)`` rather than ``my_list.remove(list_item)``
|
||||||
|
|
||||||
This requires you to have the index of the list item but is faster since ``remove()`` will search the list.
|
This requires you to have the index of the list item but is faster since ``remove()`` will search the list.
|
||||||
Here is an example of how to remove items in one loop,
|
|
||||||
removing the last items first, which is faster (as explained above):
|
Here is an example of how to remove items in 1 loop,
|
||||||
|
removing the last items first, which is faster (as explained above).
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -230,7 +247,7 @@ removing the last items first, which is faster (as explained above):
|
|||||||
|
|
||||||
This example shows a fast way of removing items,
|
This example shows a fast way of removing items,
|
||||||
for use in cases where you can alter the list order without breaking the scripts functionality.
|
for use in cases where you can alter the list order without breaking the scripts functionality.
|
||||||
This works by swapping two list items, so the item you remove is always last:
|
This works by swapping 2 list items, so the item you remove is always last.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -243,59 +260,64 @@ This works by swapping two list items, so the item you remove is always last:
|
|||||||
my_list.pop()
|
my_list.pop()
|
||||||
|
|
||||||
|
|
||||||
When removing many items in a large list this can provide a good speed-up.
|
When removing many items in a large list this can provide a good speedup.
|
||||||
|
|
||||||
|
|
||||||
Avoid Copying Lists
|
Avoid Copying Lists
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
When passing a list or dictionary to a function,
|
When passing a list/dictionary to a function,
|
||||||
it is faster to have the function modify the list rather than returning
|
it is faster to have the function modify the list rather than returning
|
||||||
a new list so Python doesn't have to duplicate the list in memory.
|
a new list so python doesn't have to duplicate the list in memory.
|
||||||
|
|
||||||
Functions that modify a list in-place are more efficient than functions that create new lists.
|
Functions that modify a list in-place are more efficient than functions that create new lists.
|
||||||
This is generally slower so only use for functions when it makes sense not to modify the list in place:
|
|
||||||
|
|
||||||
|
This is generally slower so only use for functions when it makes sense not to modify the list in place.
|
||||||
|
|
||||||
>>> my_list = some_list_func(my_list)
|
>>> my_list = some_list_func(my_list)
|
||||||
|
|
||||||
|
|
||||||
This is generally faster since there is no re-assignment and no list duplication:
|
This is generally faster since there is no re-assignment and no list duplication.
|
||||||
|
|
||||||
>>> some_list_func(vec)
|
>>> some_list_func(vec)
|
||||||
|
|
||||||
|
|
||||||
Also note that, passing a sliced list makes a copy of the list in Python memory:
|
Also note that passing a sliced list makes a copy of the list in python memory.
|
||||||
|
|
||||||
>>> foobar(my_list[:])
|
>>> foobar(my_list[:])
|
||||||
|
|
||||||
If my_list was a large array containing 10,000's of items, a copy could use a lot of extra memory.
|
If my_list was a large array containing 10000's of items, a copy could use a lot of extra memory.
|
||||||
|
|
||||||
|
|
||||||
Writing Strings to a File (Python General)
|
Writing Strings to a File (Python General)
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
Here are three ways of joining multiple strings into one string for writing.
|
Here are 3 ways of joining multiple strings into one string for writing.
|
||||||
This also applies to any area of your code that involves a lot of string joining:
|
This also applies to any area of your code that involves a lot of string joining.
|
||||||
|
|
||||||
String concatenation
|
|
||||||
This is the slowest option, do **not** use if you can avoid it, especially when writing data in a loop.
|
|
||||||
|
|
||||||
>>> file.write(str1 + " " + str2 + " " + str3 + "\n")
|
|
||||||
|
|
||||||
String formatting
|
|
||||||
Use this when you are writing string data from floats and ints.
|
|
||||||
|
|
||||||
>>> file.write("%s %s %s\n" % (str1, str2, str3))
|
|
||||||
|
|
||||||
String joining
|
|
||||||
Use to join a list of strings (the list may be temporary). In the following example, the strings are joined with
|
|
||||||
a space " " in between, other examples are "" or ", ".
|
|
||||||
|
|
||||||
>>> file.write(" ".join((str1, str2, str3, "\n")))
|
|
||||||
|
|
||||||
|
|
||||||
Join is fastest on many strings, string formatting is quite fast too (better for converting data types).
|
``String addition`` -
|
||||||
String concatenation is the slowest.
|
this is the slowest option, *don't use if you can help it, especially when writing data in a loop*.
|
||||||
|
|
||||||
|
>>> file.write(str1 + " " + str2 + " " + str3 + "\n")
|
||||||
|
|
||||||
|
|
||||||
|
``String formatting`` -
|
||||||
|
use this when you are writing string data from floats and ints.
|
||||||
|
|
||||||
|
>>> file.write("%s %s %s\n" % (str1, str2, str3))
|
||||||
|
|
||||||
|
|
||||||
|
``String join() function``
|
||||||
|
use to join a list of strings (the list may be temporary). In the following example, the strings are joined with a space " " in between, other examples are "" or ", ".
|
||||||
|
|
||||||
|
>>> file.write(" ".join([str1, str2, str3, "\n"]))
|
||||||
|
|
||||||
|
|
||||||
|
Join is fastest on many strings,
|
||||||
|
`string formatting <https://wiki.blender.org/index.php/Dev:Source/Modeling/BMesh/Design>`__
|
||||||
|
is quite fast too (better for converting data types). String arithmetic is slowest.
|
||||||
|
|
||||||
|
|
||||||
Parsing Strings (Import/Exporting)
|
Parsing Strings (Import/Exporting)
|
||||||
@@ -311,35 +333,36 @@ Parsing Numbers
|
|||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``,
|
Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``,
|
||||||
``float()`` will work for an int too but it is faster to read ints with ``int()``.
|
float() will work for an int too but it is faster to read ints with int().
|
||||||
|
|
||||||
|
|
||||||
Checking String Start/End
|
Checking String Start/End
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
If you are checking the start of a string for a keyword, rather than:
|
If you are checking the start of a string for a keyword, rather than...
|
||||||
|
|
||||||
>>> if line[0:5] == "vert ": ...
|
>>> if line[0:5] == "vert ": ...
|
||||||
|
|
||||||
Use:
|
use...
|
||||||
|
|
||||||
>>> if line.startswith("vert "):
|
>>> if line.startswith("vert "):
|
||||||
|
|
||||||
Using ``startswith()`` is slightly faster (around 5%) and also avoids a possible error
|
Using ``startswith()`` is slightly faster (approx 5%) and also avoids a possible
|
||||||
with the slice length not matching the string length.
|
error with the slice length not matching the string length.
|
||||||
|
|
||||||
``my_string.endswith("foo_bar")`` can be used for line endings too.
|
my_string.endswith("foo_bar") can be used for line endings too.
|
||||||
|
|
||||||
If you are unsure whether the text is upper or lower case, use the ``lower()`` or ``upper()`` string function:
|
If you are unsure whether the text is upper or lower case, use the ``lower()`` or ``upper()`` string function.
|
||||||
|
|
||||||
>>> if line.lower().startswith("vert ")
|
>>> if line.lower().startswith("vert ")
|
||||||
|
|
||||||
|
|
||||||
Error Handling
|
Use try/except Sparingly
|
||||||
--------------
|
------------------------
|
||||||
|
|
||||||
The **try** statement is useful to save time writing error checking code.
|
The **try** statement is useful to save time writing error checking code.
|
||||||
However, **try** is significantly slower than an **if** since an exception has to be set each time,
|
|
||||||
|
However **try** is significantly slower than an **if** since an exception has to be set each time,
|
||||||
so avoid using **try** in areas of your code that execute in a loop and runs many times.
|
so avoid using **try** in areas of your code that execute in a loop and runs many times.
|
||||||
|
|
||||||
There are cases where using **try** is faster than checking whether the condition will raise an error,
|
There are cases where using **try** is faster than checking whether the condition will raise an error,
|
||||||
@@ -359,7 +382,7 @@ In cases where you know you are checking for the same value which is referenced
|
|||||||
Time Your Code
|
Time Your Code
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
While developing a script it is good to time it to be aware of any changes in performance, this can be done simply:
|
While developing a script it is good to time it to be aware of any changes in performance, this can be done simply.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ Gotchas
|
|||||||
*******
|
*******
|
||||||
|
|
||||||
This document attempts to help you work with the Blender API in areas
|
This document attempts to help you work with the Blender API in areas
|
||||||
that can be troublesome and avoid practices that are known to cause instability.
|
that can be troublesome and avoid practices that are known to give instability.
|
||||||
|
|
||||||
|
|
||||||
.. _using_operators:
|
.. _using_operators:
|
||||||
@@ -12,13 +12,13 @@ that can be troublesome and avoid practices that are known to cause instability.
|
|||||||
Using Operators
|
Using Operators
|
||||||
===============
|
===============
|
||||||
|
|
||||||
Blender's operators are tools for users to access, that can access with Python too which is very useful.
|
Blender's operators are tools for users to access, that Python can access them too is very useful
|
||||||
Still operators have limitations that can make them cumbersome to script.
|
nevertheless operators have limitations that can make them cumbersome to script.
|
||||||
|
|
||||||
The main limits are:
|
Main limits are...
|
||||||
|
|
||||||
- Can't pass data such as objects, meshes or materials to operate on (operators use the context instead).
|
- Can't pass data such as objects, meshes or materials to operate on (operators use the context instead)
|
||||||
- The return value from calling an operator is the success (if it finished or was canceled),
|
- The return value from calling an operator gives the success (if it finished or was canceled),
|
||||||
in some cases it would be more logical from an API perspective to return the result of the operation.
|
in some cases it would be more logical from an API perspective to return the result of the operation.
|
||||||
- Operators poll function can fail where an API function would raise an exception giving details on exactly why.
|
- Operators poll function can fail where an API function would raise an exception giving details on exactly why.
|
||||||
|
|
||||||
@@ -34,23 +34,26 @@ When calling an operator gives an error like this:
|
|||||||
Which raises the question as to what the correct context might be?
|
Which raises the question as to what the correct context might be?
|
||||||
|
|
||||||
Typically operators check for the active area type, a selection or active object they can operate on,
|
Typically operators check for the active area type, a selection or active object they can operate on,
|
||||||
but some operators are more strict when they run.
|
but some operators are more picky about when they run.
|
||||||
In most cases you can figure out what context an operator needs
|
|
||||||
by examining how it's used in Blender and thinking about what it does.
|
In most cases you can figure out what context an operator needs
|
||||||
|
simply be seeing how it's used in Blender and thinking about what it does.
|
||||||
|
|
||||||
|
Unfortunately if you're still stuck - the only way to **really** know
|
||||||
|
what's going on is to read the source code for the poll function and see what its checking.
|
||||||
|
|
||||||
If you're still stuck, unfortunately, the only way to eventually know what is causing the error is
|
|
||||||
to read the source code for the poll function and see what it is checking.
|
|
||||||
For Python operators it's not so hard to find the source
|
For Python operators it's not so hard to find the source
|
||||||
since it's included with Blender and the source file and line is included in the operator reference docs.
|
since it's included with Blender and the source file/line is included in the operator reference docs.
|
||||||
|
|
||||||
Downloading and searching the C code isn't so simple,
|
Downloading and searching the C code isn't so simple,
|
||||||
especially if you're not familiar with the C language but by searching the operator name or description
|
especially if you're not familiar with the C language but by searching the
|
||||||
you should be able to find the poll function with no knowledge of C.
|
operator name or description you should be able to find the poll function with no knowledge of C.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Blender does have the functionality for poll functions to describe why they fail,
|
Blender does have the functionality for poll functions to describe why they fail,
|
||||||
but its currently not used much, if you're interested to help improve the API
|
but its currently not used much, if you're interested to help improve our API
|
||||||
feel free to add calls to ``CTX_wm_operator_poll_msg_set`` where its not obvious why poll fails, e.g:
|
feel free to add calls to ``CTX_wm_operator_poll_msg_set`` where its not obvious why poll fails.
|
||||||
|
|
||||||
>>> bpy.ops.gpencil.draw()
|
>>> bpy.ops.gpencil.draw()
|
||||||
RuntimeError: Operator bpy.ops.gpencil.draw.poll() Failed to find Grease Pencil data to draw into
|
RuntimeError: Operator bpy.ops.gpencil.draw.poll() Failed to find Grease Pencil data to draw into
|
||||||
@@ -60,7 +63,7 @@ The operator still doesn't work!
|
|||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Certain operators in Blender are only intended for use in a specific context,
|
Certain operators in Blender are only intended for use in a specific context,
|
||||||
some operators for example are only called from the properties editor where they check the current material,
|
some operators for example are only called from the properties window where they check the current material,
|
||||||
modifier or constraint.
|
modifier or constraint.
|
||||||
|
|
||||||
Examples of this are:
|
Examples of this are:
|
||||||
@@ -71,8 +74,8 @@ Examples of this are:
|
|||||||
- :mod:`bpy.ops.buttons.file_browse`
|
- :mod:`bpy.ops.buttons.file_browse`
|
||||||
|
|
||||||
Another possibility is that you are the first person to attempt to use this operator
|
Another possibility is that you are the first person to attempt to use this operator
|
||||||
in a script and some modifications need to be made to the operator to run in a different context.
|
in a script and some modifications need to be made to the operator to run in a different context,
|
||||||
If the operator should logically be able to run but fails when accessed from a script
|
if the operator should logically be able to run but fails when accessed from a script
|
||||||
it should be reported to the bug tracker.
|
it should be reported to the bug tracker.
|
||||||
|
|
||||||
|
|
||||||
@@ -82,20 +85,22 @@ Stale Data
|
|||||||
No updates after setting values
|
No updates after setting values
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
Sometimes you want to modify values from Python and immediately access the updated values, e.g:
|
Sometimes you want to modify values from Python and immediately access the updated values, eg:
|
||||||
|
|
||||||
Once changing the objects :class:`bpy.types.Object.location`
|
Once changing the objects :class:`bpy.types.Object.location`
|
||||||
you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`,
|
you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`,
|
||||||
but this doesn't work as you might expect.
|
but this doesn't work as you might expect.
|
||||||
|
|
||||||
Consider the calculations that might contribute to the object's final transformation, this includes:
|
Consider the calculations that might go into working out the object's final transformation, this includes:
|
||||||
|
|
||||||
- Animation function curves.
|
- animation function curves.
|
||||||
- Drivers and their Python expressions.
|
- drivers and their Python expressions.
|
||||||
- Constraints
|
- constraints
|
||||||
- Parent objects and all of their F-curves, constraints, etc.
|
- parent objects and all of their f-curves, constraints etc.
|
||||||
|
|
||||||
To avoid expensive recalculations every time a property is modified,
|
To avoid expensive recalculations every time a property is modified,
|
||||||
Blender defers the evaluation until the results are needed.
|
Blender defers making the actual calculations until they are needed.
|
||||||
|
|
||||||
However, while the script runs you may want to access the updated values.
|
However, while the script runs you may want to access the updated values.
|
||||||
In this case you need to call :class:`bpy.types.ViewLayer.update` after modifying values, for example:
|
In this case you need to call :class:`bpy.types.ViewLayer.update` after modifying values, for example:
|
||||||
|
|
||||||
@@ -105,41 +110,44 @@ In this case you need to call :class:`bpy.types.ViewLayer.update` after modifyin
|
|||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
|
|
||||||
|
|
||||||
Now all dependent data (child objects, modifiers, drivers, etc.)
|
Now all dependent data (child objects, modifiers, drivers... etc)
|
||||||
has been recalculated and is available to the script within active view layer.
|
has been recalculated and is available to the script within active view layer.
|
||||||
|
|
||||||
|
|
||||||
Can I redraw during script execution?
|
Can I redraw during the script?
|
||||||
-------------------------------------
|
-------------------------------
|
||||||
|
|
||||||
The official answer to this is no, or... *"You don't want to do that"*.
|
The official answer to this is no, or... *"You don't want to do that"*.
|
||||||
To give some background on the topic:
|
|
||||||
|
To give some background on the topic...
|
||||||
|
|
||||||
While a script executes Blender waits for it to finish and is effectively locked until its done,
|
While a script executes Blender waits for it to finish and is effectively locked until its done,
|
||||||
while in this state Blender won't redraw or respond to user input.
|
while in this state Blender won't redraw or respond to user input.
|
||||||
Normally this is not such a problem because scripts distributed with Blender
|
Normally this is not such a problem because scripts distributed with Blender
|
||||||
tend not to run for an extended period of time,
|
tend not to run for an extended period of time,
|
||||||
nevertheless scripts *can* take a long time to complete and it would be nice to see progress in the viewport.
|
nevertheless scripts *can* take ages to execute and its nice to see what's going on in the view port.
|
||||||
|
|
||||||
When tools lock Blender in a loop redraw are highly discouraged
|
Tools that lock Blender in a loop and redraw are highly discouraged
|
||||||
since they conflict with Blender's ability to run multiple operators
|
since they conflict with Blenders ability to run multiple operators
|
||||||
at once and update different parts of the interface as the tool runs.
|
at once and update different parts of the interface as the tool runs.
|
||||||
|
|
||||||
So the solution here is to write a **modal** operator, which is an operator that defines a ``modal()`` function,
|
So the solution here is to write a **modal** operator, that is - an operator which defines a modal() function,
|
||||||
See the modal operator template in the text editor.
|
See the modal operator template in the text editor.
|
||||||
|
|
||||||
Modal operators execute on user input or setup their own timers to run frequently,
|
Modal operators execute on user input or setup their own timers to run frequently,
|
||||||
they can handle the events or pass through to be handled by the keymap or other modal operators.
|
they can handle the events or pass through to be handled by the keymap or other modal operators.
|
||||||
Examples of a modal operators are Transform, Painting, Fly Navigation and File Select.
|
|
||||||
|
Transform, Painting, Fly-Mode and File-Select are example of a modal operators.
|
||||||
|
|
||||||
Writing modal operators takes more effort than a simple ``for`` loop
|
Writing modal operators takes more effort than a simple ``for`` loop
|
||||||
that contains draw calls but is more flexible and integrates better with Blender's design.
|
that happens to redraw but is more flexible and integrates better with Blenders design.
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Ok, Ok! I still want to draw from Python
|
**Ok, Ok! I still want to draw from Python**
|
||||||
|
|
||||||
If you insist -- yes it's possible, but scripts that use this hack will not be considered
|
If you insist - yes its possible, but scripts that use this hack won't be considered
|
||||||
for inclusion in Blender and any issue with using it will not be considered a bug,
|
for inclusion in Blender and any issues with using it won't be considered bugs,
|
||||||
there is also no guaranteed compatibility in future releases.
|
this is also not guaranteed to work in future releases.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -149,18 +157,18 @@ there is also no guaranteed compatibility in future releases.
|
|||||||
Modes and Mesh Access
|
Modes and Mesh Access
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
When working with mesh data you may run into the problem where a script fails to run as expected in Edit-Mode.
|
When working with mesh data you may run into the problem where a script fails to run as expected in edit-mode.
|
||||||
This is caused by Edit-Mode having its own data which is only written back to the mesh when exiting Edit-Mode.
|
This is caused by edit-mode having its own data which is only written back to the mesh when exiting edit-mode.
|
||||||
|
|
||||||
A common example is that exporters may access a mesh through ``obj.data`` (a :class:`bpy.types.Mesh`)
|
A common example is that exporters may access a mesh through ``obj.data`` (a :class:`bpy.types.Mesh`)
|
||||||
when the user is in Edit-Mode, where the mesh data is available but out of sync with the edit mesh.
|
but the user is in edit-mode, where the mesh data is available but out of sync with the edit mesh.
|
||||||
|
|
||||||
In this situation you can...
|
In this situation you can...
|
||||||
|
|
||||||
- Exit Edit-Mode before running the tool.
|
- Exit edit-mode before running the tool.
|
||||||
- Explicitly update the mesh by calling :class:`bmesh.types.BMesh.to_mesh`.
|
- Explicitly update the mesh by calling :class:`bmesh.types.BMesh.to_mesh`.
|
||||||
- Modify the script to support working on the edit-mode data directly, see: :mod:`bmesh.from_edit_mesh`.
|
- Modify the script to support working on the edit-mode data directly, see: :mod:`bmesh.from_edit_mesh`.
|
||||||
- Report the context as incorrect and only allow the script to run outside Edit-Mode.
|
- Report the context as incorrect and only allow the script to run outside edit-mode.
|
||||||
|
|
||||||
|
|
||||||
.. _info_gotcha_mesh_faces:
|
.. _info_gotcha_mesh_faces:
|
||||||
@@ -168,24 +176,24 @@ In this situation you can...
|
|||||||
N-Gons and Tessellation
|
N-Gons and Tessellation
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Since 2.63 n-gons are supported, this adds some complexity
|
Since 2.63 NGons are supported, this adds some complexity
|
||||||
since in some cases you need to access triangles still (some exporters for example).
|
since in some cases you need to access triangles still (some exporters for example).
|
||||||
|
|
||||||
There are now three ways to access faces:
|
There are now 3 ways to access faces:
|
||||||
|
|
||||||
- :class:`bpy.types.MeshPolygon` --
|
- :class:`bpy.types.MeshPolygon` -
|
||||||
this is the data structure which now stores faces in Object-Mode
|
this is the data structure which now stores faces in object mode
|
||||||
(access as ``mesh.polygons`` rather than ``mesh.faces``).
|
(access as ``mesh.polygons`` rather than ``mesh.faces``).
|
||||||
- :class:`bpy.types.MeshLoopTriangle` --
|
- :class:`bpy.types.MeshLoopTriangle` -
|
||||||
the result of tessellating polygons into triangles
|
the result of tessellating polygons into triangles
|
||||||
(access as ``mesh.loop_triangles``).
|
(access as ``mesh.loop_triangles``).
|
||||||
- :class:`bmesh.types.BMFace` --
|
- :class:`bmesh.types.BMFace` -
|
||||||
the polygons as used in Edit-Mode.
|
the polygons as used in editmode.
|
||||||
|
|
||||||
For the purpose of the following documentation,
|
For the purpose of the following documentation,
|
||||||
these will be referred to as polygons, loop triangles and BMesh-faces respectively.
|
these will be referred to as polygons, loop triangles and bmesh-faces respectively.
|
||||||
|
|
||||||
Faces with five or more sides will be referred to as ``ngons``.
|
5+ sided faces will be referred to as ``ngons``.
|
||||||
|
|
||||||
|
|
||||||
Support Overview
|
Support Overview
|
||||||
@@ -208,58 +216,58 @@ Support Overview
|
|||||||
- Unusable *(read-only)*.
|
- Unusable *(read-only)*.
|
||||||
- Best
|
- Best
|
||||||
* - Export/Output
|
* - Export/Output
|
||||||
- Good *(n-gon support)*
|
- Good *(ngon support)*
|
||||||
- Good *(When n-gons cannot be used)*
|
- Good *(When ngons can't be used)*
|
||||||
- Good *(n-gons, extra memory overhead)*
|
- Good *(ngons, extra memory overhead)*
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Using the :mod:`bmesh` API is completely separate API from :mod:`bpy`,
|
Using the :mod:`bmesh` API is completely separate API from :mod:`bpy`,
|
||||||
typically you would use one or the other based on the level of editing needed,
|
typically you would would use one or the other based on the level of editing needed,
|
||||||
not simply for a different way to access faces.
|
not simply for a different way to access faces.
|
||||||
|
|
||||||
|
|
||||||
Creating
|
Creating
|
||||||
--------
|
--------
|
||||||
|
|
||||||
All three data types can be used for face creation:
|
All 3 datatypes can be used for face creation.
|
||||||
|
|
||||||
- Polygons are the most efficient way to create faces but the data structure is *very* rigid and inflexible,
|
- polygons are the most efficient way to create faces but the data structure is _very_ rigid and inflexible,
|
||||||
you must have all your vertices and faces ready and create them all at once.
|
you must have all your vertices and faces ready and create them all at once.
|
||||||
This is further complicated by the fact that each polygon does not store its own vertices,
|
This is further complicated by the fact that each polygon does not store its own verts,
|
||||||
rather they reference an index and size in :class:`bpy.types.Mesh.loops` which are a fixed array too.
|
rather they reference an index and size in :class:`bpy.types.Mesh.loops` which are a fixed array too.
|
||||||
- BMesh-faces are most likely the easiest way to create faces in new scripts,
|
- bmesh-faces are most likely the easiest way for new scripts to create faces,
|
||||||
since faces can be added one by one and the API has features intended for mesh manipulation.
|
since faces can be added one by one and the api has features intended for mesh manipulation.
|
||||||
While :class:`bmesh.types.BMesh` uses more memory it can be managed by only operating on one mesh at a time.
|
While :class:`bmesh.types.BMesh` uses more memory it can be managed by only operating on one mesh at a time.
|
||||||
|
|
||||||
|
|
||||||
Editing
|
Editing
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Editing is where the three data types vary most.
|
Editing is where the 3 data types vary most.
|
||||||
|
|
||||||
- Polygons are very limited for editing,
|
- Polygons are very limited for editing,
|
||||||
changing materials and options like smooth works but for anything else
|
changing materials and options like smooth works but for anything else
|
||||||
they are too inflexible and are only intended for storage.
|
they are too inflexible and are only intended for storage.
|
||||||
- Tessfaces should not be used for editing geometry because doing so will cause existing n-gons to be tessellated.
|
- Tessfaces should not be used for editing geometry because doing so will cause existing ngons to be tessellated.
|
||||||
- BMesh-faces are by far the best way to manipulate geometry.
|
- BMesh-Faces are by far the best way to manipulate geometry.
|
||||||
|
|
||||||
|
|
||||||
Exporting
|
Exporting
|
||||||
---------
|
---------
|
||||||
|
|
||||||
All three data types can be used for exporting,
|
All 3 data types can be used for exporting,
|
||||||
the choice mostly depends on whether the target format supports n-gons or not.
|
the choice mostly depends on whether the target format supports ngons or not.
|
||||||
|
|
||||||
- Polygons are the most direct and efficient way to export providing they convert into the output format easily enough.
|
- Polygons are the most direct & efficient way to export providing they convert into the output format easily enough.
|
||||||
- Tessfaces work well for exporting to formats which don't support n-gons,
|
- Tessfaces work well for exporting to formats which don't support ngons,
|
||||||
in fact this is the only place where their use is encouraged.
|
in fact this is the only place where their use is encouraged.
|
||||||
- BMesh-Faces can work for exporting too but may not be necessary if polygons can be used
|
- BMesh-Faces can work for exporting too but may not be necessary if polygons can be used
|
||||||
since using BMesh gives some overhead because its not the native storage format in Object-Mode.
|
since using bmesh gives some overhead because its not the native storage format in object mode.
|
||||||
|
|
||||||
|
|
||||||
Edit Bones, Pose Bones, Bone... Bones
|
EditBones, PoseBones, Bone... Bones
|
||||||
=====================================
|
===================================
|
||||||
|
|
||||||
Armature Bones in Blender have three distinct data structures that contain them.
|
Armature Bones in Blender have three distinct data structures that contain them.
|
||||||
If you are accessing the bones through one of them, you may not have access to the properties you really need.
|
If you are accessing the bones through one of them, you may not have access to the properties you really need.
|
||||||
@@ -272,41 +280,43 @@ If you are accessing the bones through one of them, you may not have access to t
|
|||||||
Edit Bones
|
Edit Bones
|
||||||
----------
|
----------
|
||||||
|
|
||||||
``bpy.context.object.data.edit_bones`` contains an edit bones;
|
``bpy.context.object.data.edit_bones`` contains a editbones;
|
||||||
to access them you must set the armature mode to Edit-Mode first (edit bones do not exist in Object or Pose-Mode).
|
to access them you must set the armature mode to edit mode first (editbones do not exist in object or pose mode).
|
||||||
Use these to create new bones, set their head/tail or roll, change their parenting relationships to other bones, etc.
|
Use these to create new bones, set their head/tail or roll, change their parenting relationships to other bones, etc.
|
||||||
|
|
||||||
Example using :class:`bpy.types.EditBone` in armature Edit-Mode
|
Example using :class:`bpy.types.EditBone` in armature editmode:
|
||||||
which is only possible in Edit-Mode:
|
|
||||||
|
This is only possible in edit mode.
|
||||||
|
|
||||||
>>> bpy.context.object.data.edit_bones["Bone"].head = Vector((1.0, 2.0, 3.0))
|
>>> bpy.context.object.data.edit_bones["Bone"].head = Vector((1.0, 2.0, 3.0))
|
||||||
|
|
||||||
This will be empty outside of Edit-Mode:
|
This will be empty outside of editmode.
|
||||||
|
|
||||||
>>> mybones = bpy.context.selected_editable_bones
|
>>> mybones = bpy.context.selected_editable_bones
|
||||||
|
|
||||||
Returns an edit bone only in Edit-Mode:
|
Returns an editbone only in edit mode.
|
||||||
|
|
||||||
>>> bpy.context.active_bone
|
>>> bpy.context.active_bone
|
||||||
|
|
||||||
|
|
||||||
Bones (Object-Mode)
|
Bones (Object Mode)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
``bpy.context.object.data.bones`` contains bones.
|
``bpy.context.object.data.bones`` contains bones.
|
||||||
These *live* in Object-Mode, and have various properties you can change,
|
These *live* in object mode, and have various properties you can change,
|
||||||
note that the head and tail properties are read-only.
|
note that the head and tail properties are read-only.
|
||||||
|
|
||||||
Example using :class:`bpy.types.Bone` in Object or Pose-Mode
|
Example using :class:`bpy.types.Bone` in object or pose mode:
|
||||||
returning a bone (not an edit bone) outside of Edit-Mode:
|
|
||||||
|
Returns a bone (not an editbone) outside of edit mode
|
||||||
|
|
||||||
>>> bpy.context.active_bone
|
>>> bpy.context.active_bone
|
||||||
|
|
||||||
This works, as with Blender the setting can be edited in any mode:
|
This works, as with blender the setting can be edited in any mode
|
||||||
|
|
||||||
>>> bpy.context.object.data.bones["Bone"].use_deform = True
|
>>> bpy.context.object.data.bones["Bone"].use_deform = True
|
||||||
|
|
||||||
Accessible but read-only:
|
Accessible but read-only
|
||||||
|
|
||||||
>>> tail = myobj.data.bones["Bone"].tail
|
>>> tail = myobj.data.bones["Bone"].tail
|
||||||
|
|
||||||
@@ -316,42 +326,42 @@ Pose Bones
|
|||||||
|
|
||||||
``bpy.context.object.pose.bones`` contains pose bones.
|
``bpy.context.object.pose.bones`` contains pose bones.
|
||||||
This is where animation data resides, i.e. animatable transformations
|
This is where animation data resides, i.e. animatable transformations
|
||||||
are applied to pose bones, as are constraints and IK-settings.
|
are applied to pose bones, as are constraints and ik-settings.
|
||||||
|
|
||||||
Examples using :class:`bpy.types.PoseBone` in Object or Pose-Mode:
|
Examples using :class:`bpy.types.PoseBone` in object or pose mode:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Gets the name of the first constraint (if it exists)
|
# Gets the name of the first constraint (if it exists)
|
||||||
bpy.context.object.pose.bones["Bone"].constraints[0].name
|
bpy.context.object.pose.bones["Bone"].constraints[0].name
|
||||||
|
|
||||||
# Gets the last selected pose bone (Pose-Mode only)
|
# Gets the last selected pose bone (pose mode only)
|
||||||
bpy.context.active_pose_bone
|
bpy.context.active_pose_bone
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Notice the pose is accessed from the object rather than the object data,
|
Notice the pose is accessed from the object rather than the object data,
|
||||||
this is why Blender can have two or more objects sharing the same armature in different poses.
|
this is why blender can have 2 or more objects sharing the same armature in different poses.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Strictly speaking pose bones are not bones, they are just the state of the armature,
|
Strictly speaking PoseBone's are not bones, they are just the state of the armature,
|
||||||
stored in the :class:`bpy.types.Object` rather than the :class:`bpy.types.Armature`,
|
stored in the :class:`bpy.types.Object` rather than the :class:`bpy.types.Armature`,
|
||||||
yet the real bones are accessible from the pose bones via :class:`bpy.types.PoseBone.bone`.
|
the real bones are however accessible from the pose bones - :class:`bpy.types.PoseBone.bone`
|
||||||
|
|
||||||
|
|
||||||
Armature Mode Switching
|
Armature Mode Switching
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
While writing scripts that deal with armatures you may find you have to switch between modes,
|
While writing scripts that deal with armatures you may find you have to switch between modes,
|
||||||
when doing so take care when switching out of Edit-Mode not to keep references
|
when doing so take care when switching out of edit-mode not to keep references
|
||||||
to the edit bones or their head/tail vectors.
|
to the edit-bones or their head/tail vectors.
|
||||||
Further access to these will crash Blender so its important the script
|
Further access to these will crash blender so its important the script
|
||||||
clearly separates sections of the code which operate in different modes.
|
clearly separates sections of the code which operate in different modes.
|
||||||
|
|
||||||
This is mainly an issue with Edit-Mode since pose data can be manipulated without having to be in Pose-Mode,
|
This is mainly an issue with editmode since pose data can be manipulated without having to be in pose mode,
|
||||||
yet for operator access you may still need to enter Pose-Mode.
|
however for operator access you may still need to enter pose mode.
|
||||||
|
|
||||||
|
|
||||||
Data Names
|
Data Names
|
||||||
@@ -362,7 +372,8 @@ Naming Limitations
|
|||||||
------------------
|
------------------
|
||||||
|
|
||||||
A common mistake is to assume newly created data is given the requested name.
|
A common mistake is to assume newly created data is given the requested name.
|
||||||
This can cause bugs when you add data (normally imported) then reference it later by name:
|
|
||||||
|
This can cause bugs when you add some data (normally imported) then reference it later by name.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -372,7 +383,7 @@ This can cause bugs when you add data (normally imported) then reference it late
|
|||||||
bpy.data.meshes[meshid]
|
bpy.data.meshes[meshid]
|
||||||
|
|
||||||
|
|
||||||
Or with name assignment:
|
Or with name assignment...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -386,12 +397,12 @@ Data names may not match the assigned values if they exceed the maximum length,
|
|||||||
|
|
||||||
|
|
||||||
Its better practice not to reference objects by names at all,
|
Its better practice not to reference objects by names at all,
|
||||||
once created you can store the data in a list, dictionary, on a class, etc;
|
once created you can store the data in a list, dictionary, on a class etc,
|
||||||
there is rarely a reason to have to keep searching for the same data by name.
|
there is rarely a reason to have to keep searching for the same data by name.
|
||||||
|
|
||||||
If you do need to use name references, its best to use a dictionary to maintain
|
If you do need to use name references, its best to use a dictionary to maintain
|
||||||
a mapping between the names of the imported assets and the newly created data,
|
a mapping between the names of the imported assets and the newly created data,
|
||||||
this way you don't run this risk of referencing existing data from the blend-file, or worse modifying it.
|
this way you don't run this risk of referencing existing data from the blend file, or worse modifying it.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -410,14 +421,17 @@ this way you don't run this risk of referencing existing data from the blend-fil
|
|||||||
Library Collisions
|
Library Collisions
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Blender keeps data names unique (:class:`bpy.types.ID.name`) so you can't name two objects,
|
Blender keeps data names unique - :class:`bpy.types.ID.name` so you can't name two objects,
|
||||||
meshes, scenes, etc., the same by accident.
|
meshes, scenes etc the same thing by accident.
|
||||||
However, when linking in library data from another blend-file naming collisions can occur,
|
|
||||||
|
However when linking in library data from another blend file naming collisions can occur,
|
||||||
so its best to avoid referencing data by name at all.
|
so its best to avoid referencing data by name at all.
|
||||||
|
|
||||||
This can be tricky at times and not even Blender handles this correctly in some case
|
This can be tricky at times and not even blender handles this correctly in some case
|
||||||
(when selecting the modifier object for e.g. you can't select between multiple objects with the same name),
|
(when selecting the modifier object for eg you can't select between multiple objects with the same name),
|
||||||
but its still good to try avoiding these problems in this area.
|
but its still good to try avoid problems in this area.
|
||||||
|
|
||||||
|
|
||||||
If you need to select between local and library data, there is a feature in ``bpy.data`` members to allow for this.
|
If you need to select between local and library data, there is a feature in ``bpy.data`` members to allow for this.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -440,17 +454,18 @@ If you need to select between local and library data, there is a feature in ``bp
|
|||||||
Relative File Paths
|
Relative File Paths
|
||||||
===================
|
===================
|
||||||
|
|
||||||
Blender's relative file paths are not compatible with standard Python modules such as ``sys`` and ``os``.
|
Blenders relative file paths are not compatible with standard Python modules such as ``sys`` and ``os``.
|
||||||
Built-in Python functions don't understand Blender's ``//`` prefix which denotes the blend-file path.
|
|
||||||
|
|
||||||
A common case where you would run into this problem is when exporting a material with associated image paths:
|
Built in Python functions don't understand blenders ``//`` prefix which denotes the blend file path.
|
||||||
|
|
||||||
|
A common case where you would run into this problem is when exporting a material with associated image paths.
|
||||||
|
|
||||||
>>> bpy.path.abspath(image.filepath)
|
>>> bpy.path.abspath(image.filepath)
|
||||||
|
|
||||||
|
|
||||||
When using Blender data from linked libraries there is an unfortunate complication
|
When using blender data from linked libraries there is an unfortunate complication
|
||||||
since the path will be relative to the library rather than the open blend-file.
|
since the path will be relative to the library rather than the open blend file.
|
||||||
When the data block may be from an external blend-file pass the library argument from the :class:`bpy.types.ID`.
|
When the data block may be from an external blend file pass the library argument from the :class:`bpy.types.ID`.
|
||||||
|
|
||||||
>>> bpy.path.abspath(image.filepath, library=image.library)
|
>>> bpy.path.abspath(image.filepath, library=image.library)
|
||||||
|
|
||||||
@@ -463,15 +478,19 @@ Unicode Problems
|
|||||||
|
|
||||||
Python supports many different encodings so there is nothing stopping you from
|
Python supports many different encodings so there is nothing stopping you from
|
||||||
writing a script in ``latin1`` or ``iso-8859-15``.
|
writing a script in ``latin1`` or ``iso-8859-15``.
|
||||||
See `PEP 263 <https://www.python.org/dev/peps/pep-0263/>`__.
|
|
||||||
|
|
||||||
However, this complicates matters for Blender's Python API because ``.blend`` files don't have an explicit encoding.
|
See `pep-0263 <https://www.python.org/dev/peps/pep-0263/>`_
|
||||||
To avoid the problem for Python integration and script authors we have decided all strings in blend-files
|
|
||||||
|
However this complicates matters for Blender's Python API because ``.blend`` files don't have an explicit encoding.
|
||||||
|
|
||||||
|
To avoid the problem for Python integration and script authors we have decided all strings in blend files
|
||||||
**must** be ``UTF-8``, ``ASCII`` compatible.
|
**must** be ``UTF-8``, ``ASCII`` compatible.
|
||||||
|
|
||||||
This means assigning strings with different encodings to an object names for instance will raise an error.
|
This means assigning strings with different encodings to an object names for instance will raise an error.
|
||||||
|
|
||||||
Paths are an exception to this rule since the existence of non-UTF-8 paths on user's file system cannot be ignored.
|
Paths are an exception to this rule since we cannot ignore the existence of non ``UTF-8`` paths on users file-system.
|
||||||
This means seemingly harmless expressions can raise errors, e.g:
|
|
||||||
|
This means seemingly harmless expressions can raise errors, eg.
|
||||||
|
|
||||||
>>> print(bpy.data.filepath)
|
>>> print(bpy.data.filepath)
|
||||||
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-21: ordinal not in range(128)
|
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-21: ordinal not in range(128)
|
||||||
@@ -482,7 +501,7 @@ This means seemingly harmless expressions can raise errors, e.g:
|
|||||||
TypeError: bpy_struct: item.attr= val: Object.name expected a string type, not str
|
TypeError: bpy_struct: item.attr= val: Object.name expected a string type, not str
|
||||||
|
|
||||||
|
|
||||||
Here are two ways around file-system encoding issues:
|
Here are 2 ways around filesystem encoding issues:
|
||||||
|
|
||||||
>>> print(repr(bpy.data.filepath))
|
>>> print(repr(bpy.data.filepath))
|
||||||
|
|
||||||
@@ -493,11 +512,11 @@ Here are two ways around file-system encoding issues:
|
|||||||
|
|
||||||
|
|
||||||
Unicode encoding/decoding is a big topic with comprehensive Python documentation,
|
Unicode encoding/decoding is a big topic with comprehensive Python documentation,
|
||||||
to keep it short about encoding problems -- here are some suggestions:
|
to avoid getting stuck too deep in encoding problems - here are some suggestions:
|
||||||
|
|
||||||
- Always use UTF-8 encoding or convert to UTF-8 where the input is unknown.
|
- Always use utf-8 encoding or convert to utf-8 where the input is unknown.
|
||||||
- Avoid manipulating file paths as strings directly, use ``os.path`` functions instead.
|
- Avoid manipulating filepaths as strings directly, use ``os.path`` functions instead.
|
||||||
- Use ``os.fsencode()`` or ``os.fsdecode()`` instead of built-in string decoding functions when operating on paths.
|
- Use ``os.fsencode()`` / ``os.fsdecode()`` instead of built in string decoding functions when operating on paths.
|
||||||
- To print paths or to include them in the user interface use ``repr(path)`` first
|
- To print paths or to include them in the user interface use ``repr(path)`` first
|
||||||
or ``"%r" % path`` with string formatting.
|
or ``"%r" % path`` with string formatting.
|
||||||
|
|
||||||
@@ -509,11 +528,11 @@ to keep it short about encoding problems -- here are some suggestions:
|
|||||||
some importers do this.
|
some importers do this.
|
||||||
|
|
||||||
|
|
||||||
Strange Errors when Using the 'Threading' Module
|
Strange errors using 'threading' module
|
||||||
================================================
|
=======================================
|
||||||
|
|
||||||
Python threading with Blender only works properly when the threads finish up before the script does,
|
Python threading with Blender only works properly when the threads finish up before the script does.
|
||||||
for example by using ``threading.join()``.
|
By using ``threading.join()`` for example.
|
||||||
|
|
||||||
Here is an example of threading supported by Blender:
|
Here is an example of threading supported by Blender:
|
||||||
|
|
||||||
@@ -552,8 +571,8 @@ Here is an example of threading supported by Blender:
|
|||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
|
|
||||||
This an example of a timer which runs many times a second
|
This an example of a timer which runs many times a second and moves
|
||||||
and moves the default cube continuously while Blender runs **(Unsupported)**.
|
the default cube continuously while Blender runs **(Unsupported)**.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -573,33 +592,33 @@ and moves the default cube continuously while Blender runs **(Unsupported)**.
|
|||||||
Use cases like the one above which leave the thread running once the script finishes
|
Use cases like the one above which leave the thread running once the script finishes
|
||||||
may seem to work for a while but end up causing random crashes or errors in Blender's own drawing code.
|
may seem to work for a while but end up causing random crashes or errors in Blender's own drawing code.
|
||||||
|
|
||||||
So far, no work has been done to make Blender's Python integration thread safe,
|
So far, no work has gone into making Blender's Python integration thread safe,
|
||||||
so until it's properly supported, it's best not make use of this.
|
so until its properly supported, best not make use of this.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Python threads only allow concurrency and won't speed up your scripts on multiprocessor systems,
|
Pythons threads only allow co-currency and won't speed up your scripts on multi-processor systems,
|
||||||
the ``subprocess`` and ``multiprocess`` modules can be used with Blender to make use of multiple CPUs too.
|
the ``subprocess`` and ``multiprocess`` modules can be used with Blender and make use of multiple CPU's too.
|
||||||
|
|
||||||
|
|
||||||
Help! My script crashes Blender
|
Help! My script crashes Blender
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
:abbr:`TL;DR (Too long; didn't read.)` Do not keep direct references to Blender data (of any kind)
|
**TL;DR:** Do not keep direct references to Blender data (of any kind) when modifying the container
|
||||||
when modifying the container of that data, and/or when some undo/redo may happen
|
of that data, and/or when some undo/redo may happen (e.g. during modal operators execution...).
|
||||||
(e.g. during modal operators execution...).
|
|
||||||
Instead, use indices (or other data always stored by value in Python, like string keys...),
|
Instead, use indices (or other data always stored by value in Python, like string keys...),
|
||||||
that allow you to get access to the desired data.
|
that allow you to get access to the desired data.
|
||||||
|
|
||||||
Ideally it would be impossible to crash Blender from Python,
|
Ideally it would be impossible to crash Blender from Python
|
||||||
however, there are some problems with the API where it can be made to crash.
|
however there are some problems with the API where it can be made to crash.
|
||||||
|
|
||||||
Strictly speaking this is a bug in the API but fixing it would mean adding memory verification
|
Strictly speaking this is a bug in the API but fixing it would mean adding memory verification
|
||||||
on every access since most crashes are caused by the Python objects referencing Blender's memory directly,
|
on every access since most crashes are caused by the Python objects referencing Blenders memory directly,
|
||||||
whenever the memory is freed or re-allocated, further Python access to it can crash the script.
|
whenever the memory is freed or re-allocated, further Python access to it can crash the script.
|
||||||
But fixing this would make the scripts run very slow,
|
But fixing this would make the scripts run very slow,
|
||||||
or writing a very different kind of API which doesn't reference the memory directly.
|
or writing a very different kind of API which doesn't reference the memory directly.
|
||||||
|
|
||||||
Here are some general hints to avoid running into these problems:
|
Here are some general hints to avoid running into these problems.
|
||||||
|
|
||||||
- Be aware of memory limits,
|
- Be aware of memory limits,
|
||||||
especially when working with large lists since Blender can crash simply by running out of memory.
|
especially when working with large lists since Blender can crash simply by running out of memory.
|
||||||
@@ -612,16 +631,16 @@ Here are some general hints to avoid running into these problems:
|
|||||||
- Modules or classes that remain active while Blender is used,
|
- Modules or classes that remain active while Blender is used,
|
||||||
should not hold references to data the user may remove, instead,
|
should not hold references to data the user may remove, instead,
|
||||||
fetch data from the context each time the script is activated.
|
fetch data from the context each time the script is activated.
|
||||||
- Crashes may not happen every time, they may happen more on some configurations or operating systems.
|
- Crashes may not happen every time, they may happen more on some configurations/operating-systems.
|
||||||
- Be careful with recursive patterns, those are very efficient at hiding the issues described here.
|
- Be wary of recursive patterns, those are very efficient at hiding the issues described here.
|
||||||
- See last subsection about `Unfortunate Corner Cases`_ for some known breaking exceptions.
|
- See last sub-section about `Unfortunate Corner Cases`_ for some known breaking exceptions.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
To find the line of your script that crashes you can use the ``faulthandler`` module.
|
To find the line of your script that crashes you can use the ``faulthandler`` module.
|
||||||
See the `Faulthandler docs <https://docs.python.org/dev/library/faulthandler.html>`__.
|
See the `faulthandler docs <https://docs.python.org/dev/library/faulthandler.html>`_.
|
||||||
|
|
||||||
While the crash may be in Blender's C/C++ code,
|
While the crash may be in Blenders C/C++ code,
|
||||||
this can help a lot to track down the area of the script that causes the crash.
|
this can help a lot to track down the area of the script that causes the crash.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -635,7 +654,7 @@ Here are some general hints to avoid running into these problems:
|
|||||||
in any possible way.
|
in any possible way.
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Do not:
|
**Don’t:**
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -654,7 +673,7 @@ Here are some general hints to avoid running into these problems:
|
|||||||
first_item.name = "foobar"
|
first_item.name = "foobar"
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Do:
|
**Do:**
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -677,31 +696,33 @@ Here are some general hints to avoid running into these problems:
|
|||||||
Undo/Redo
|
Undo/Redo
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Undo invalidates all :class:`bpy.types.ID` instances (Object, Scene, Mesh, Light, etc.).
|
Undo invalidates all :class:`bpy.types.ID` instances (Object, Scene, Mesh, Lamp... etc).
|
||||||
|
|
||||||
This example shows how you can tell undo changes the memory locations:
|
This example shows how you can tell undo changes the memory locations.
|
||||||
|
|
||||||
>>> hash(bpy.context.object)
|
>>> hash(bpy.context.object)
|
||||||
-9223372036849950810
|
-9223372036849950810
|
||||||
>>> hash(bpy.context.object)
|
>>> hash(bpy.context.object)
|
||||||
-9223372036849950810
|
-9223372036849950810
|
||||||
|
|
||||||
Move the active object, then undo:
|
# ... move the active object, then undo
|
||||||
|
|
||||||
>>> hash(bpy.context.object)
|
>>> hash(bpy.context.object)
|
||||||
-9223372036849951740
|
-9223372036849951740
|
||||||
|
|
||||||
As suggested above, simply not holding references to data when Blender is used
|
As suggested above, simply not holding references to data when Blender is used
|
||||||
interactively by the user is the only way to make sure that the script doesn't become unstable.
|
interactively by the user is the only way to ensure the script doesn't become unstable.
|
||||||
|
|
||||||
|
|
||||||
Undo & Library Data
|
Undo & Library Data
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
One of the advantages with Blender's library linking system that undo
|
One of the advantages with Blenders library linking system that undo
|
||||||
can skip checking changes in library data since it is assumed to be static.
|
can skip checking changes in library data since it is assumed to be static.
|
||||||
|
|
||||||
Tools in Blender are not allowed to modify library data.
|
Tools in Blender are not allowed to modify library data.
|
||||||
But Python does not enforce this restriction.
|
|
||||||
|
Python however does not enforce this restriction.
|
||||||
|
|
||||||
This can be useful in some cases, using a script to adjust material values for example.
|
This can be useful in some cases, using a script to adjust material values for example.
|
||||||
But its also possible to use a script to make library data point to newly created local data,
|
But its also possible to use a script to make library data point to newly created local data,
|
||||||
@@ -712,13 +733,13 @@ So it's best to consider modifying library data an advanced usage of the API
|
|||||||
and only to use it when you know what you're doing.
|
and only to use it when you know what you're doing.
|
||||||
|
|
||||||
|
|
||||||
Edit-Mode / Memory Access
|
Edit Mode / Memory Access
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
Switching mode ``bpy.ops.object.mode_set(mode='EDIT')`` or ``bpy.ops.object.mode_set(mode='OBJECT')``
|
Switching edit-mode ``bpy.ops.object.mode_set(mode='EDIT')`` / ``bpy.ops.object.mode_set(mode='OBJECT')``
|
||||||
will re-allocate objects data,
|
will re-allocate objects data,
|
||||||
any references to a meshes vertices/polygons/UVs, armatures bones,
|
any references to a meshes vertices/polygons/uvs, armatures bones,
|
||||||
curves points, etc. cannot be accessed after switching mode.
|
curves points etc cannot be accessed after switching edit-mode.
|
||||||
|
|
||||||
Only the reference to the data its self can be re-accessed, the following example will crash.
|
Only the reference to the data its self can be re-accessed, the following example will crash.
|
||||||
|
|
||||||
@@ -733,7 +754,7 @@ Only the reference to the data its self can be re-accessed, the following exampl
|
|||||||
print(polygons)
|
print(polygons)
|
||||||
|
|
||||||
|
|
||||||
So after switching mode you need to re-access any object data variables,
|
So after switching edit-mode you need to re-access any object data variables,
|
||||||
the following example shows how to avoid the crash above.
|
the following example shows how to avoid the crash above.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -749,7 +770,7 @@ the following example shows how to avoid the crash above.
|
|||||||
|
|
||||||
|
|
||||||
These kinds of problems can happen for any functions which re-allocate
|
These kinds of problems can happen for any functions which re-allocate
|
||||||
the object data but are most common when switching mode.
|
the object data but are most common when switching edit-mode.
|
||||||
|
|
||||||
|
|
||||||
Array Re-Allocation
|
Array Re-Allocation
|
||||||
@@ -770,20 +791,21 @@ internally the array which stores this data is re-allocated.
|
|||||||
This can be avoided by re-assigning the point variables after adding the new one or by storing
|
This can be avoided by re-assigning the point variables after adding the new one or by storing
|
||||||
indices to the points rather than the points themselves.
|
indices to the points rather than the points themselves.
|
||||||
|
|
||||||
The best way is to sidestep the problem altogether by adding all the points to the curve at once.
|
The best way is to sidestep the problem altogether add all the points to the curve at once.
|
||||||
This means you don't have to worry about array re-allocation and it's faster too
|
This means you don't have to worry about array re-allocation and its faster too
|
||||||
since re-allocating the entire array for every added point is inefficient.
|
since reallocating the entire array for every point added is inefficient.
|
||||||
|
|
||||||
|
|
||||||
Removing Data
|
Removing Data
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
**Any** data that you remove shouldn't be modified or accessed afterwards,
|
**Any** data that you remove shouldn't be modified or accessed afterwards,
|
||||||
this includes: F-curves, drivers, render layers, timeline markers, modifiers, constraints
|
this includes f-curves, drivers, render layers, timeline markers, modifiers, constraints
|
||||||
along with objects, scenes, collections, bones, etc.
|
along with objects, scenes, collections, bones.. etc.
|
||||||
|
|
||||||
The ``remove()`` API calls will invalidate the data they free to prevent common mistakes.
|
The ``remove()`` api calls will invalidate the data they free to prevent common mistakes.
|
||||||
The following example shows how this precaution works:
|
|
||||||
|
The following example shows how this precaution works.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -796,7 +818,7 @@ The following example shows how this precaution works:
|
|||||||
|
|
||||||
|
|
||||||
But take care because this is limited to scripts accessing the variable which is removed,
|
But take care because this is limited to scripts accessing the variable which is removed,
|
||||||
the next example will still crash:
|
the next example will still crash.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -813,8 +835,8 @@ Besides all expected cases listed above, there are a few others that should not
|
|||||||
an issue but, due to internal implementation details, currently are:
|
an issue but, due to internal implementation details, currently are:
|
||||||
|
|
||||||
- ``Object.hide_viewport``, ``Object.hide_select`` and ``Object.hide_render``:
|
- ``Object.hide_viewport``, ``Object.hide_select`` and ``Object.hide_render``:
|
||||||
Setting any of those Booleans will trigger a rebuild of Collection caches,
|
Setting any of those booleans will trigger a rebuild of Collection caches, hence breaking
|
||||||
thus breaking any current iteration over ``Collection.all_objects``.
|
any current iteration over ``Collection.all_objects``.
|
||||||
|
|
||||||
|
|
||||||
sys.exit
|
sys.exit
|
||||||
@@ -826,5 +848,5 @@ as if Blender is crashing since ``sys.exit()`` will close Blender immediately.
|
|||||||
|
|
||||||
For example, the ``argparse`` module will print an error and exit if the arguments are invalid.
|
For example, the ``argparse`` module will print an error and exit if the arguments are invalid.
|
||||||
|
|
||||||
An dirty way of troubleshooting this is to set ``sys.exit = None`` and see what line of Python code is quitting,
|
An ugly way of troubleshooting this is to set ``sys.exit = None`` and see what line of Python code is quitting,
|
||||||
you could of course replace ``sys.exit`` with your own function but manipulating Python in this way is bad practice.
|
you could of course replace ``sys.exit`` with your own function but manipulating Python in this way is bad practice.
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
.. _info_overview:
|
.. _info_overview:
|
||||||
|
|
||||||
*******************
|
*******************
|
||||||
@@ -5,24 +6,24 @@ Python API Overview
|
|||||||
*******************
|
*******************
|
||||||
|
|
||||||
The purpose of this document is to explain how Python and Blender fit together,
|
The purpose of this document is to explain how Python and Blender fit together,
|
||||||
covering some of the functionality that may not be obvious from reading the API references
|
covering some of the functionality that may not be obvious from reading the API
|
||||||
and example scripts.
|
references and example scripts.
|
||||||
|
|
||||||
|
|
||||||
Python in Blender
|
Python in Blender
|
||||||
=================
|
=================
|
||||||
|
|
||||||
Blender has an embedded Python interpreter which is loaded when Blender is started
|
Blender has an embedded Python interpreter which is loaded when Blender is started and stays
|
||||||
and stays active while Blender is running. This interpreter runs scripts to draw the user interface
|
active while Blender is running. This interpreter runs scripts to draw the user interface
|
||||||
and is used for some of Blender's internal tools as well.
|
and is used for some of Blender’s internal tools as well.
|
||||||
|
|
||||||
Blender's embedded interpreter provides a typical Python environment, so code from tutorials
|
Blender's embedded interpreter provides a typical Python environment, so code from tutorials
|
||||||
on how to write Python scripts can also be run with Blender's interpreter. Blender provides its
|
on how to write Python scripts can also be run with Blender’s interpreter. Blender provides its
|
||||||
Python modules, such as :mod:`bpy` and :mod:`mathutils`, to the embedded interpreter so they can
|
Python modules, such as :mod:`bpy` and :mod:`mathutils`, to the embedded interpreter so they can
|
||||||
be imported into a script and give access to Blender's data, classes, and functions.
|
be imported into a script and give access to Blender's data, classes, and functions. Scripts that
|
||||||
Scripts that deal with Blender data will need to import the modules to work.
|
deal with Blender data will need to import the modules to work.
|
||||||
|
|
||||||
Here is a simple example which moves a vertex attached to an object named "Cube":
|
Here is a simple example which moves a vertex attached to an object named **Cube**:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ Here is a simple example which moves a vertex attached to an object named "Cube"
|
|||||||
bpy.data.objects["Cube"].data.vertices[0].co.x += 1.0
|
bpy.data.objects["Cube"].data.vertices[0].co.x += 1.0
|
||||||
|
|
||||||
This modifies Blender's internal data directly.
|
This modifies Blender's internal data directly.
|
||||||
When you run this in the interactive console you will see the 3D Viewport update.
|
When you run this in the interactive console you will see the 3D viewport update.
|
||||||
|
|
||||||
|
|
||||||
The Default Environment
|
The Default Environment
|
||||||
@@ -40,7 +41,7 @@ When developing your own scripts it may help to understand how Blender sets up i
|
|||||||
Many Python scripts come bundled with Blender and can be used as a reference
|
Many Python scripts come bundled with Blender and can be used as a reference
|
||||||
because they use the same API that script authors write tools in.
|
because they use the same API that script authors write tools in.
|
||||||
Typical usage for scripts include: user interface, import/export,
|
Typical usage for scripts include: user interface, import/export,
|
||||||
scene manipulation, automation, defining your own tool set and customization.
|
scene manipulation, automation, defining your own toolset and customization.
|
||||||
|
|
||||||
On startup Blender scans the ``scripts/startup/`` directory for Python modules and imports them.
|
On startup Blender scans the ``scripts/startup/`` directory for Python modules and imports them.
|
||||||
The exact location of this directory depends on your installation.
|
The exact location of this directory depends on your installation.
|
||||||
@@ -53,8 +54,8 @@ Script Loading
|
|||||||
This may seem obvious, but it is important to note the difference between
|
This may seem obvious, but it is important to note the difference between
|
||||||
executing a script directly and importing a script as a module.
|
executing a script directly and importing a script as a module.
|
||||||
|
|
||||||
Extending Blender by executing a script directly means the classes that the script defines
|
Extending Blender by executing a script directly means the classes that the script
|
||||||
remain available inside Blender after the script finishes execution.
|
defines remain available inside Blender after the script finishes execution.
|
||||||
Using scripts this way makes future access to their classes
|
Using scripts this way makes future access to their classes
|
||||||
(to unregister them for example) more difficult compared to importing the scripts as modules.
|
(to unregister them for example) more difficult compared to importing the scripts as modules.
|
||||||
When a script is imported as a module, its class instances will remain
|
When a script is imported as a module, its class instances will remain
|
||||||
@@ -62,11 +63,12 @@ inside the module and can be accessed later on by importing that module again.
|
|||||||
|
|
||||||
For this reason it is preferable to avoid directly executing scripts that extend Blender by registering classes.
|
For this reason it is preferable to avoid directly executing scripts that extend Blender by registering classes.
|
||||||
|
|
||||||
Here are some ways to run scripts directly in Blender:
|
|
||||||
|
|
||||||
- Loaded in the text editor and press *Run Script*.
|
Here are some ways to run scripts directly in Blender.
|
||||||
|
|
||||||
|
- Loaded in the text editor and press **Run Script**.
|
||||||
- Typed or pasted into the interactive console.
|
- Typed or pasted into the interactive console.
|
||||||
- Execute a Python file from the command line with Blender, e.g:
|
- Execute a Python file from the command line with Blender, eg:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
@@ -75,22 +77,24 @@ Here are some ways to run scripts directly in Blender:
|
|||||||
|
|
||||||
To run as modules:
|
To run as modules:
|
||||||
|
|
||||||
- The obvious way, ``import some_module`` command from the text editor or interactive console.
|
- The obvious way, ``import some_module`` command from the text window or interactive console.
|
||||||
- Open as a text data-block and check the *Register* option, this will load with the blend-file.
|
- Open as a text block and tick "Register" option, this will load with the blend file.
|
||||||
- Copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
|
- copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
|
||||||
- Define as an add-on, enabling the add-on will load it as a Python module.
|
- define as an add-on, enabling the add-on will load it as a Python module.
|
||||||
|
|
||||||
|
|
||||||
Add-ons
|
Add-ons
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Some of Blender's functionality is best kept optional,
|
Some of Blenders functionality is best kept optional,
|
||||||
alongside scripts loaded at startup there are add-ons which are kept in their own directory ``scripts/addons``,
|
alongside scripts loaded at startup we have add-ons which are kept in their own directory ``scripts/addons``,
|
||||||
They are only loaded on startup if selected from the user preferences.
|
and only load on startup if selected from the user preferences.
|
||||||
|
|
||||||
|
The only difference between add-ons and built-in Python modules is that add-ons must contain a ``bl_info``
|
||||||
|
variable which Blender uses to read metadata such as name, author, category and URL.
|
||||||
|
|
||||||
|
The User Preferences add-on listing uses **bl_info** to display information about each add-on.
|
||||||
|
|
||||||
The only difference between add-ons and built-in Python modules is that add-ons must contain a ``bl_info`` variable
|
|
||||||
which Blender uses to read metadata such as name, author, category and project link.
|
|
||||||
The User Preferences add-on listing uses ``bl_info`` to display information about each add-on.
|
|
||||||
`See Add-ons <https://wiki.blender.org/index.php/Dev:Py/Scripts/Guidelines/Addons>`__
|
`See Add-ons <https://wiki.blender.org/index.php/Dev:Py/Scripts/Guidelines/Addons>`__
|
||||||
for details on the ``bl_info`` dictionary.
|
for details on the ``bl_info`` dictionary.
|
||||||
|
|
||||||
@@ -101,7 +105,7 @@ Integration through Classes
|
|||||||
Running Python scripts in the text editor is useful for testing but you'll
|
Running Python scripts in the text editor is useful for testing but you'll
|
||||||
want to extend Blender to make tools accessible like other built-in functionality.
|
want to extend Blender to make tools accessible like other built-in functionality.
|
||||||
|
|
||||||
The Blender Python API allows integration for:
|
The Blender Python api allows integration for:
|
||||||
|
|
||||||
- :class:`bpy.types.Panel`
|
- :class:`bpy.types.Panel`
|
||||||
- :class:`bpy.types.Menu`
|
- :class:`bpy.types.Menu`
|
||||||
@@ -110,12 +114,13 @@ The Blender Python API allows integration for:
|
|||||||
- :class:`bpy.types.KeyingSet`
|
- :class:`bpy.types.KeyingSet`
|
||||||
- :class:`bpy.types.RenderEngine`
|
- :class:`bpy.types.RenderEngine`
|
||||||
|
|
||||||
|
|
||||||
This is intentionally limited. Currently, for more advanced features such as mesh modifiers,
|
This is intentionally limited. Currently, for more advanced features such as mesh modifiers,
|
||||||
object types, or shader nodes, C/C++ must be used.
|
object types, or shader nodes, C/C++ must be used.
|
||||||
|
|
||||||
For Python integration Blender defines methods which are common to all types.
|
For Python integration Blender defines methods which are common to all types.
|
||||||
This works by creating a Python subclass of a Blender class which contains variables and functions
|
This works by creating a Python subclass of a Blender class which contains variables and functions
|
||||||
specified by the parent class which are predefined to interface with Blender.
|
specified by the parent class which are pre-defined to interface with Blender.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
@@ -132,20 +137,22 @@ For example:
|
|||||||
|
|
||||||
bpy.utils.register_class(SimpleOperator)
|
bpy.utils.register_class(SimpleOperator)
|
||||||
|
|
||||||
First note that it defines a subclass as a member of :mod:`bpy.types`,
|
First note that we subclass a member of :mod:`bpy.types`,
|
||||||
this is common for all classes which can be integrated with Blender and
|
this is common for all classes which can be integrated with Blender and
|
||||||
is used to distinguish an Operator from a Panel when registering.
|
used so we know if this is an Operator and not a Panel when registering.
|
||||||
|
|
||||||
Both class properties start with a ``bl_`` prefix.
|
Both class properties start with a ``bl_`` prefix.
|
||||||
This is a convention used to distinguish Blender properties from those you add yourself.
|
This is a convention used to distinguish Blender properties from those you add yourself.
|
||||||
|
|
||||||
Next see the execute function, which takes an instance of the operator and the current context.
|
Next see the execute function, which takes an instance of the operator and the current context.
|
||||||
A common prefix is not used for functions.
|
A common prefix is not used for functions.
|
||||||
|
|
||||||
Lastly the register function is called, this takes the class and loads it into Blender. See `Class Registration`_.
|
Lastly the register function is called, this takes the class and loads it into Blender. See `Class Registration`_.
|
||||||
|
|
||||||
Regarding inheritance, Blender doesn't impose restrictions on the kinds of class inheritance used,
|
Regarding inheritance, Blender doesn't impose restrictions on the kinds of class inheritance used,
|
||||||
the registration checks will use attributes and functions defined in parent classes.
|
the registration checks will use attributes and functions defined in parent classes.
|
||||||
|
|
||||||
Class mix-in example:
|
class mix-in example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -166,8 +173,8 @@ While ``__init__()`` and ``__del__()`` will be called if defined,
|
|||||||
the class instances lifetime only spans the execution.
|
the class instances lifetime only spans the execution.
|
||||||
So a panel for example will have a new instance for every redraw,
|
So a panel for example will have a new instance for every redraw,
|
||||||
for this reason there is rarely a cause to store variables in the panel instance.
|
for this reason there is rarely a cause to store variables in the panel instance.
|
||||||
Instead, persistent variables should be stored in Blender's data
|
Instead, persistent variables should be stored in Blenders
|
||||||
so that the state can be restored when Blender is restarted.
|
ata so that the state can be restored when Blender is restarted.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@@ -175,14 +182,15 @@ so that the state can be restored when Blender is restarted.
|
|||||||
|
|
||||||
So once the class is registered with Blender, instancing the class and calling the functions is left up to Blender.
|
So once the class is registered with Blender, instancing the class and calling the functions is left up to Blender.
|
||||||
In fact you cannot instance these classes from the script as you would expect with most Python API's.
|
In fact you cannot instance these classes from the script as you would expect with most Python API's.
|
||||||
To run operators you can call them through the operator API, e.g:
|
|
||||||
|
To run operators you can call them through the operator api, eg:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
bpy.ops.object.simple_operator()
|
bpy.ops.object.simple_operator()
|
||||||
|
|
||||||
User interface classes are given a context in which to draw, buttons, window, file header, toolbar, etc.,
|
User interface classes are given a context in which to draw, buttons window, file header, toolbar etc,
|
||||||
then they are drawn when that area is displayed so they are never called by Python scripts directly.
|
then they are drawn when that area is displayed so they are never called by Python scripts directly.
|
||||||
|
|
||||||
|
|
||||||
@@ -197,7 +205,7 @@ Module Registration
|
|||||||
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions.
|
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions.
|
||||||
These are the *only* functions that Blender calls from your code, which is otherwise a regular Python module.
|
These are the *only* functions that Blender calls from your code, which is otherwise a regular Python module.
|
||||||
|
|
||||||
A simple Blender Python module can look like this:
|
A simple Blender/Python module can look like this:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -217,15 +225,16 @@ A simple Blender Python module can look like this:
|
|||||||
|
|
||||||
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items.
|
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items.
|
||||||
You can also use them for internal purposes setting up data for your own tools but take care
|
You can also use them for internal purposes setting up data for your own tools but take care
|
||||||
since register won't re-run when a new blend-file is loaded.
|
since register won't re-run when a new blend file is loaded.
|
||||||
|
|
||||||
The register/unregister calls are used so it's possible to toggle add-ons and reload scripts while Blender runs.
|
The register/unregister calls are used so it's possible to toggle add-ons and reload scripts while Blender runs.
|
||||||
If the register calls were placed in the body of the script, registration would be called on import,
|
If the register calls were placed in the body of the script, registration would be called on import,
|
||||||
meaning there would be no distinction between importing a module or loading its classes into Blender.
|
meaning there would be no distinction between importing a module or loading its classes into Blender.
|
||||||
|
|
||||||
This becomes problematic when a script imports classes from another module
|
This becomes problematic when a script imports classes from another module
|
||||||
making it difficult to manage which classes are being loaded and when.
|
making it difficult to manage which classes are being loaded and when.
|
||||||
|
|
||||||
The last two lines are only for testing:
|
The last 2 lines are only for testing:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -242,13 +251,14 @@ Class Registration
|
|||||||
|
|
||||||
Registering a class with Blender results in the class definition being loaded into Blender,
|
Registering a class with Blender results in the class definition being loaded into Blender,
|
||||||
where it becomes available alongside existing functionality.
|
where it becomes available alongside existing functionality.
|
||||||
|
|
||||||
Once this class is loaded you can access it from :mod:`bpy.types`,
|
Once this class is loaded you can access it from :mod:`bpy.types`,
|
||||||
using the ``bl_idname`` rather than the classes original name.
|
using the ``bl_idname`` rather than the classes original name.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
There are some exceptions to this for class names which aren't guarantee to be unique.
|
There are some exceptions to this for class names which aren't guarantee to be unique.
|
||||||
In this case use: :func:`bpy.types.Struct.bl_rna_get_subclass_py`.
|
In this case use: :func:`bpy.types.Struct.bl_rna_get_subclass`.
|
||||||
|
|
||||||
|
|
||||||
When loading a class, Blender performs sanity checks making sure all required properties and functions are found,
|
When loading a class, Blender performs sanity checks making sure all required properties and functions are found,
|
||||||
@@ -261,23 +271,23 @@ Using the function arguments ``def execute(self, context, spam)``, will raise an
|
|||||||
|
|
||||||
``ValueError: expected Operator, SimpleOperator class "execute" function to have 2 args, found 3``
|
``ValueError: expected Operator, SimpleOperator class "execute" function to have 2 args, found 3``
|
||||||
|
|
||||||
Using ``bl_idname = 1`` will raise:
|
Using ``bl_idname = 1`` will raise.
|
||||||
|
|
||||||
``TypeError: validating class error: Operator.bl_idname expected a string type, not int``
|
``TypeError: validating class error: Operator.bl_idname expected a string type, not int``
|
||||||
|
|
||||||
|
|
||||||
Inter-Class Dependencies
|
Inter Classes Dependencies
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
When customizing Blender you may want to group your own settings together,
|
When customizing Blender you may want to group your own settings together,
|
||||||
after all, they will likely have to co-exist with other scripts.
|
after all, they will likely have to co-exist with other scripts.
|
||||||
To group these properties classes need to be defined,
|
To group these properties classes need to be defined,
|
||||||
for groups within groups or collections within groups
|
for groups within groups or collections within groups
|
||||||
you can't avoid having to deal with the order of registration/unregistration.
|
you can find yourself having to deal with order of registration/unregistration.
|
||||||
|
|
||||||
Custom properties groups are themselves classes which need to be registered.
|
Custom properties groups are themselves classes which need to be registered.
|
||||||
|
|
||||||
For example, if you want to store material settings for a custom engine:
|
Say you want to store material settings for a custom engine.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -301,7 +311,7 @@ For example, if you want to store material settings for a custom engine:
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
The class **must be** registered before being used in a property, failing to do so will raise an error:
|
*The class must be registered before being used in a property, failing to do so will raise an error:*
|
||||||
|
|
||||||
``ValueError: bpy_struct "Material" registration error: my_custom_props could not register``
|
``ValueError: bpy_struct "Material" registration error: my_custom_props could not register``
|
||||||
|
|
||||||
@@ -331,17 +341,17 @@ For example, if you want to store material settings for a custom engine:
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|
||||||
.. important::
|
.. note::
|
||||||
|
|
||||||
The lower most class needs to be registered first and that ``unregister()`` is a mirror of ``register()``.
|
*The lower most class needs to be registered first and that unregister() is a mirror of register()*
|
||||||
|
|
||||||
|
|
||||||
Manipulating Classes
|
Manipulating Classes
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Properties can be added and removed as Blender runs,
|
Properties can be added and removed as Blender runs,
|
||||||
normally done on register or unregister but for some special cases
|
normally happens on register or unregister but for some
|
||||||
it may be useful to modify types as the script runs.
|
special cases it may be useful to modify types as the script runs.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
@@ -352,7 +362,7 @@ For example:
|
|||||||
# remove
|
# remove
|
||||||
del bpy.types.Object.my_float
|
del bpy.types.Object.my_float
|
||||||
|
|
||||||
This works just as well for ``PropertyGroup`` subclasses you define yourself.
|
This works just as well for PropertyGroup subclasses you define yourself.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -360,7 +370,7 @@ This works just as well for ``PropertyGroup`` subclasses you define yourself.
|
|||||||
pass
|
pass
|
||||||
MyPropGroup.my_float: bpy.props.FloatProperty()
|
MyPropGroup.my_float: bpy.props.FloatProperty()
|
||||||
|
|
||||||
This is equivalent to:
|
...this is equivalent to:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -368,11 +378,11 @@ This is equivalent to:
|
|||||||
my_float: bpy.props.FloatProperty()
|
my_float: bpy.props.FloatProperty()
|
||||||
|
|
||||||
|
|
||||||
Dynamic Class Definition (Advanced)
|
Dynamic Defined-Classes (Advanced)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
In some cases the specifier for data may not be in Blender, for example a external render engines shader definitions,
|
In some cases the specifier for data may not be in Blender, renderman shader definitions
|
||||||
and it may be useful to define them as types and remove them on the fly.
|
for example, and it may be useful to define them as types and remove them on the fly.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@@ -1,16 +1,19 @@
|
|||||||
|
|
||||||
.. _info_quickstart:
|
.. _info_quickstart:
|
||||||
|
|
||||||
**********
|
***********************
|
||||||
Quickstart
|
Quickstart Introduction
|
||||||
**********
|
***********************
|
||||||
|
|
||||||
This :abbr:`API (Application Programming Interface)` is generally stable
|
Preface
|
||||||
but some areas are still being extended and improved.
|
=======
|
||||||
|
|
||||||
.. rubric:: Blender Python API features:
|
This API is generally stable but some areas are still being added and improved.
|
||||||
|
|
||||||
|
The Blender/Python API can do the following:
|
||||||
|
|
||||||
- Edit any data the user interface can (Scenes, Meshes, Particles etc.).
|
- Edit any data the user interface can (Scenes, Meshes, Particles etc.).
|
||||||
- Modify user preferences, keymaps and themes.
|
- Modify user preferences, key-maps and themes.
|
||||||
- Run tools with own settings.
|
- Run tools with own settings.
|
||||||
- Create user interface elements such as menus, headers and panels.
|
- Create user interface elements such as menus, headers and panels.
|
||||||
- Create new tools.
|
- Create new tools.
|
||||||
@@ -18,10 +21,10 @@ but some areas are still being extended and improved.
|
|||||||
- Create new rendering engines that integrate with Blender.
|
- Create new rendering engines that integrate with Blender.
|
||||||
- Subscribe to changes to data and it's properties.
|
- Subscribe to changes to data and it's properties.
|
||||||
- Define new settings in existing Blender data.
|
- Define new settings in existing Blender data.
|
||||||
- Draw in the 3D Viewport using Python.
|
- Draw in the 3D view using Python.
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: (Still) missing features:
|
The Blender/Python API **can't** (yet)...
|
||||||
|
|
||||||
- Create new space types.
|
- Create new space types.
|
||||||
- Assign custom properties to every type.
|
- Assign custom properties to every type.
|
||||||
@@ -30,21 +33,22 @@ but some areas are still being extended and improved.
|
|||||||
Before Starting
|
Before Starting
|
||||||
===============
|
===============
|
||||||
|
|
||||||
This document its intended to familiarize you with Blender Python API
|
This document isn't intended to fully cover each topic.
|
||||||
but not to fully cover each topic.
|
Rather, its purpose is to familiarize you with Blender Python API.
|
||||||
|
|
||||||
|
|
||||||
A quick list of helpful things to know before starting:
|
A quick list of helpful things to know before starting:
|
||||||
|
|
||||||
- Blender uses Python 3.x; some online documentation still assumes version 2.x.
|
- Blender uses Python 3.x; some online documentation still assumes 2.x.
|
||||||
- The interactive console is great for testing one-liners.
|
- The interactive console is great for testing one-liners.
|
||||||
It also has autocompletion so you can inspect the API quickly.
|
It also has autocompletion so you can inspect the API quickly.
|
||||||
- Button tooltips show Python attributes and operator names.
|
- Button tool tips show Python attributes and operator names.
|
||||||
- The context menu of buttons directly links to this API documentation.
|
- Right clicking on buttons and menu items directly links to API documentation.
|
||||||
- More operator examples can be found in the text editor's template menu.
|
- For more examples, the text menu has a templates section where some example operators can be found.
|
||||||
- To examine further scripts distributed with Blender, see:
|
- To examine further scripts distributed with Blender, see:
|
||||||
|
|
||||||
- ``scripts/startup/bl_ui`` for the user interface.
|
| ``scripts/startup/bl_ui`` for the user interface,
|
||||||
- ``scripts/startup/bl_operators`` for operators.
|
| ``scripts/startup/bl_operators`` for operators.
|
||||||
|
|
||||||
Exact location depends on platform, see:
|
Exact location depends on platform, see:
|
||||||
:ref:`directory layout docs <blender_manual:blender-directory-layout>`.
|
:ref:`directory layout docs <blender_manual:blender-directory-layout>`.
|
||||||
@@ -55,14 +59,19 @@ Running Scripts
|
|||||||
|
|
||||||
The two most common ways to execute Python scripts are using the built-in
|
The two most common ways to execute Python scripts are using the built-in
|
||||||
text editor or entering commands in the Python console.
|
text editor or entering commands in the Python console.
|
||||||
Both the *Text Editor* and *Python Console* are space types you can select from the header.
|
|
||||||
|
Both the *Text Editor* and *Python Console* are space types you can select from the view header.
|
||||||
|
|
||||||
Rather than manually configuring your spaces for Python development,
|
Rather than manually configuring your spaces for Python development,
|
||||||
you can use the *Scripting* workspace accessible from the Topbar tabs.
|
you may prefer to use the *Scripting* screen, included default with Blender,
|
||||||
|
accessible from the top headers screen selector.
|
||||||
|
|
||||||
From the text editor you can open ``.py`` files or paste then from the clipboard, then test using *Run Script*.
|
From the text editor you can open ``.py`` files or paste then from the clipboard, then test using *Run Script*.
|
||||||
|
|
||||||
The Python Console is typically used for typing in snippets and for testing to get immediate feedback,
|
The Python Console is typically used for typing in snippets and for testing to get immediate feedback,
|
||||||
but can also have entire scripts pasted into it.
|
but can also have entire scripts pasted into it.
|
||||||
Scripts can also run from the command line with Blender but to learn scripting in Blender this isn't essential.
|
|
||||||
|
Scripts can also run from the command line with Blender but to learn Blender/Python this isn't essential.
|
||||||
|
|
||||||
|
|
||||||
Key Concepts
|
Key Concepts
|
||||||
@@ -71,13 +80,14 @@ Key Concepts
|
|||||||
Data Access
|
Data Access
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Accessing Data-Blocks
|
Accessing DataBlocks
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
You can access Blender's data with the Python API in the same way as the animation system or user interface;
|
Python accesses Blender's data in the same way as the animation system and user interface;
|
||||||
this implies that any setting that can be changed via a button can also be changed with Python.
|
this implies that any setting that can be changed via a button can also be changed from Python.
|
||||||
Accessing data from the currently loaded blend-file is done with the module :mod:`bpy.data`.
|
|
||||||
It gives access to library data, for example:
|
Accessing data from the currently loaded blend file is done with the module :mod:`bpy.data`.
|
||||||
|
This gives access to library data. For example:
|
||||||
|
|
||||||
>>> bpy.data.objects
|
>>> bpy.data.objects
|
||||||
<bpy_collection[3], BlendDataObjects>
|
<bpy_collection[3], BlendDataObjects>
|
||||||
@@ -89,11 +99,12 @@ It gives access to library data, for example:
|
|||||||
<bpy_collection[1], BlendDataMaterials>
|
<bpy_collection[1], BlendDataMaterials>
|
||||||
|
|
||||||
|
|
||||||
Accessing Collections
|
About Collections
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
You will notice that an index as well as a string can be used to access members of the collection.
|
You'll notice that an index as well as a string can be used to access members of the collection.
|
||||||
Unlike Python dictionaries, both methods are available;
|
|
||||||
|
Unlike Python's dictionaries, both methods are acceptable;
|
||||||
however, the index of a member may change while running Blender.
|
however, the index of a member may change while running Blender.
|
||||||
|
|
||||||
>>> list(bpy.data.objects)
|
>>> list(bpy.data.objects)
|
||||||
@@ -109,7 +120,7 @@ however, the index of a member may change while running Blender.
|
|||||||
Accessing Attributes
|
Accessing Attributes
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Once you have a data-block, such as a material, object, collection, etc.,
|
Once you have a data block, such as a material, object, collections etc.,
|
||||||
its attributes can be accessed much like you would change a setting using the graphical interface.
|
its attributes can be accessed much like you would change a setting using the graphical interface.
|
||||||
In fact, the tooltip for each button also displays the Python attribute
|
In fact, the tooltip for each button also displays the Python attribute
|
||||||
which can help in finding what settings to change in a script.
|
which can help in finding what settings to change in a script.
|
||||||
@@ -124,8 +135,8 @@ which can help in finding what settings to change in a script.
|
|||||||
bpy.data.materials['MyMaterial']
|
bpy.data.materials['MyMaterial']
|
||||||
|
|
||||||
|
|
||||||
For testing what data to access it's useful to use the Python Console, which is its own space type.
|
For testing what data to access it's useful to use the "Console", which is its own space type.
|
||||||
This supports auto-complete, giving you a fast way to explore the data in your file.
|
This supports auto-complete, giving you a fast way to dig into different data in your file.
|
||||||
|
|
||||||
Example of a data path that can be quickly found via the console:
|
Example of a data path that can be quickly found via the console:
|
||||||
|
|
||||||
@@ -138,8 +149,8 @@ Example of a data path that can be quickly found via the console:
|
|||||||
Data Creation/Removal
|
Data Creation/Removal
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
When you are familiar with other Python APIs you may be surprised that
|
Those of you familiar with other Python API's may be surprised that
|
||||||
new data-blocks in the bpy API cannot be created by calling the class:
|
new data-blocks in the bpy API can't be created by calling the class:
|
||||||
|
|
||||||
>>> bpy.types.Mesh()
|
>>> bpy.types.Mesh()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
@@ -148,10 +159,10 @@ new data-blocks in the bpy API cannot be created by calling the class:
|
|||||||
|
|
||||||
|
|
||||||
This is an intentional part of the API design.
|
This is an intentional part of the API design.
|
||||||
The Blender Python API can't create Blender data that exists outside the main Blender database
|
The Blender/Python API can't create Blender data that exists outside the main Blender database
|
||||||
(accessed through :mod:`bpy.data`), because this data is managed by Blender (save, load, undo, append, etc).
|
(accessed through :mod:`bpy.data`), because this data is managed by Blender (save/load/undo/append... etc).
|
||||||
|
|
||||||
Data is added and removed via methods on the collections in :mod:`bpy.data`, e.g:
|
Data is added and removed via methods on the collections in :mod:`bpy.data`, eg:
|
||||||
|
|
||||||
>>> mesh = bpy.data.meshes.new(name="MyMesh")
|
>>> mesh = bpy.data.meshes.new(name="MyMesh")
|
||||||
>>> print(mesh)
|
>>> print(mesh)
|
||||||
@@ -163,12 +174,14 @@ Data is added and removed via methods on the collections in :mod:`bpy.data`, e.g
|
|||||||
Custom Properties
|
Custom Properties
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Python can access properties on any data-block that has an ID
|
Python can access properties on any datablock that has an ID
|
||||||
(data that can be linked in and accessed from :mod:`bpy.data`).
|
(data that can be linked in and accessed from :mod:`bpy.data`.
|
||||||
When assigning a property, you can pick your own names,
|
When assigning a property, you can make up your own names,
|
||||||
these will be created when needed or overwritten if they already exist.
|
these will be created when needed or overwritten if they exist.
|
||||||
|
|
||||||
This data is saved with the blend-file and copied with objects, for example:
|
This data is saved with the blend file and copied with objects.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -188,10 +201,10 @@ This data is saved with the blend-file and copied with objects, for example:
|
|||||||
del collection["MySettings"]
|
del collection["MySettings"]
|
||||||
|
|
||||||
|
|
||||||
Note that these properties can only be assigned basic Python types:
|
Note that these properties can only be assigned basic Python types.
|
||||||
|
|
||||||
- int, float, string
|
- int, float, string
|
||||||
- array of ints or floats
|
- array of ints/floats
|
||||||
- dictionary (only string keys are supported, values must be basic types too)
|
- dictionary (only string keys are supported, values must be basic types too)
|
||||||
|
|
||||||
These properties are valid outside of Python. They can be animated by curves or used in driver paths.
|
These properties are valid outside of Python. They can be animated by curves or used in driver paths.
|
||||||
@@ -205,16 +218,18 @@ it's more common to operate on the user's selection.
|
|||||||
The context is always available from ``bpy.context`` and can be used to get the active object, scene,
|
The context is always available from ``bpy.context`` and can be used to get the active object, scene,
|
||||||
tool settings along with many other attributes.
|
tool settings along with many other attributes.
|
||||||
|
|
||||||
Some common use cases are:
|
Common-use cases:
|
||||||
|
|
||||||
>>> bpy.context.object
|
>>> bpy.context.object
|
||||||
>>> bpy.context.selected_objects
|
>>> bpy.context.selected_objects
|
||||||
>>> bpy.context.visible_bones
|
>>> bpy.context.visible_bones
|
||||||
|
|
||||||
Note that the context is read-only, which means that these values cannot be modified directly.
|
Note that the context is read-only.
|
||||||
But they can be changed by running API functions or by using the data API.
|
These values cannot be modified directly,
|
||||||
|
though they may be changed by running API functions or by using the data API.
|
||||||
|
|
||||||
So ``bpy.context.active_object = obj`` will raise an error.
|
So ``bpy.context.active_object = obj`` will raise an error.
|
||||||
|
|
||||||
But ``bpy.context.view_layer.objects.active = obj`` works as expected.
|
But ``bpy.context.view_layer.objects.active = obj`` works as expected.
|
||||||
|
|
||||||
The context attributes change depending on where they are accessed.
|
The context attributes change depending on where they are accessed.
|
||||||
@@ -242,7 +257,7 @@ Examples:
|
|||||||
|
|
||||||
.. tip::
|
.. tip::
|
||||||
|
|
||||||
The :ref:`Operator Cheat Sheet <blender_manual:bpy.ops.wm.operator_cheat_sheet>`
|
The :ref:`Operator Cheat Sheet <blender_manual:bpy.ops.wm.operator_cheat_sheet>`.
|
||||||
gives a list of all operators and their default values in Python syntax, along with the generated docs.
|
gives a list of all operators and their default values in Python syntax, along with the generated docs.
|
||||||
This is a good way to get an overview of all Blender's operators.
|
This is a good way to get an overview of all Blender's operators.
|
||||||
|
|
||||||
@@ -250,8 +265,8 @@ Examples:
|
|||||||
Operator Poll()
|
Operator Poll()
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Many operators have a "poll" function which checks if the cursor
|
Many operators have a "poll" function which may check that the cursor
|
||||||
is in a valid area or if the object is in the correct mode (Edit Mode, Weight Paint Mode, etc).
|
is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
|
||||||
When an operator's poll function fails within Python, an exception is raised.
|
When an operator's poll function fails within Python, an exception is raised.
|
||||||
|
|
||||||
For example, calling ``bpy.ops.view3d.render_border()`` from the console raises the following error:
|
For example, calling ``bpy.ops.view3d.render_border()`` from the console raises the following error:
|
||||||
@@ -260,10 +275,10 @@ For example, calling ``bpy.ops.view3d.render_border()`` from the console raises
|
|||||||
|
|
||||||
RuntimeError: Operator bpy.ops.view3d.render_border.poll() failed, context is incorrect
|
RuntimeError: Operator bpy.ops.view3d.render_border.poll() failed, context is incorrect
|
||||||
|
|
||||||
In this case the context must be the 3D Viewport with an active camera.
|
In this case the context must be the 3d view with an active camera.
|
||||||
|
|
||||||
To avoid using try-except clauses wherever operators are called, you can call the operators
|
To avoid using try/except clauses wherever operators are called you can call the operators
|
||||||
own ``poll()`` function to check if it can run the operator in the current context.
|
own ``poll()`` function to check if it can run in the current context.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -276,10 +291,11 @@ Integration
|
|||||||
|
|
||||||
Python scripts can integrate with Blender in the following ways:
|
Python scripts can integrate with Blender in the following ways:
|
||||||
|
|
||||||
- By defining a render engine.
|
- By defining a rendering engine.
|
||||||
- By defining operators.
|
- By defining operators.
|
||||||
- By defining menus, headers and panels.
|
- By defining menus, headers and panels.
|
||||||
- By inserting new buttons into existing menus, headers and panels.
|
- By inserting new buttons into existing menus, headers and panels
|
||||||
|
|
||||||
|
|
||||||
In Python, this is done by defining a class, which is a subclass of an existing type.
|
In Python, this is done by defining a class, which is a subclass of an existing type.
|
||||||
|
|
||||||
@@ -290,52 +306,56 @@ Example Operator
|
|||||||
.. literalinclude:: __/__/__/release/scripts/templates_py/operator_simple.py
|
.. literalinclude:: __/__/__/release/scripts/templates_py/operator_simple.py
|
||||||
|
|
||||||
Once this script runs, ``SimpleOperator`` is registered with Blender
|
Once this script runs, ``SimpleOperator`` is registered with Blender
|
||||||
and can be called from Operator Search or added to the toolbar.
|
and can be called from the operator search popup or added to the toolbar.
|
||||||
|
|
||||||
To run the script:
|
To run the script:
|
||||||
|
|
||||||
#. Start Blender and switch to the Scripting workspace.
|
#. Highlight the above code then press :kbd:`Ctrl-C` to copy it.
|
||||||
#. Click the *New* button in the text editor to create a new text data-block.
|
#. Start Blender
|
||||||
#. Copy the code from above and paste it into the text editor.
|
#. Press :kbd:`Ctrl-Right` twice to change to the Scripting layout.
|
||||||
#. Click on the *Run Script* button.
|
#. Click the button labeled ``New`` and the confirmation pop up in order to create a new text block.
|
||||||
|
#. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame).
|
||||||
|
#. Click on the button **Run Script**.
|
||||||
#. Move your cursor into the 3D Viewport,
|
#. Move your cursor into the 3D Viewport,
|
||||||
open the :ref:`Operator Search menu <blender_manual:bpy.ops.wm.search_menu>`,
|
open the :ref:`operator search menu <blender_manual:bpy.ops.wm.search_menu>`,
|
||||||
and type "Simple".
|
and type "Simple".
|
||||||
#. Click on the "Simple Operator" item found in search.
|
#. Click on the "Simple Operator" item found in search.
|
||||||
|
|
||||||
.. seealso::
|
|
||||||
|
|
||||||
The class members with the ``bl_`` prefix are documented in the API reference :class:`bpy.types.Operator`.
|
.. seealso:: The class members with the ``bl_`` prefix are documented in the API
|
||||||
|
reference :class:`bpy.types.Operator`
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
The output from the ``main`` function is sent to the terminal;
|
The output from the ``main`` function is sent to the terminal;
|
||||||
in order to see this, be sure to :ref:`use the terminal <use_the_terminal>`.
|
in order to see this, be sure to :ref:`use the terminal <use_the_terminal>`.
|
||||||
|
|
||||||
|
|
||||||
Example Panel
|
Example Panel
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Panels are registered as a class, like an operator.
|
Panels register themselves as a class, like an operator.
|
||||||
Notice the extra ``bl_`` variables used to set the context they display in.
|
Notice the extra ``bl_`` variables used to set the context they display in.
|
||||||
|
|
||||||
.. literalinclude:: __/__/__/release/scripts/templates_py/ui_panel_simple.py
|
.. literalinclude:: __/__/__/release/scripts/templates_py/ui_panel_simple.py
|
||||||
|
|
||||||
To run the script:
|
To run the script:
|
||||||
|
|
||||||
#. Start Blender and switch to the Scripting workspace.
|
#. Highlight the above code then press :kbd:`Ctrl-C` to copy it.
|
||||||
#. Click the *New* button in the text editor to create a new text data-block.
|
#. Start Blender.
|
||||||
#. Copy the code from above and paste it into the text editor.
|
#. Click on the tab for the *Scripting* workspace.
|
||||||
#. Click on the *Run Script* button.
|
#. Click the button labeled ``New`` to create a new text block.
|
||||||
|
#. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame).
|
||||||
|
#. Click on the button **Run Script**.
|
||||||
|
|
||||||
|
|
||||||
To view the results:
|
To view the results:
|
||||||
|
|
||||||
#. Select the default cube.
|
#. Select the the default cube.
|
||||||
#. Click on the Object properties icon in the buttons panel (far right; appears as a tiny cube).
|
#. Click on the Object properties icon in the buttons panel (far right; appears as a tiny cube).
|
||||||
#. Scroll down to see a panel named "Hello World Panel".
|
#. Scroll down to see a panel named **Hello World Panel**.
|
||||||
#. Changing the object name also updates *Hello World Panel's* name: field.
|
#. Changing the object name also updates **Hello World Panel's** Name: field.
|
||||||
|
|
||||||
Note the row distribution and the label and properties that are defined through the code.
|
Note the row distribution and the label and properties that are available through the code.
|
||||||
|
|
||||||
.. seealso:: :class:`bpy.types.Panel`
|
.. seealso:: :class:`bpy.types.Panel`
|
||||||
|
|
||||||
@@ -344,7 +364,8 @@ Types
|
|||||||
=====
|
=====
|
||||||
|
|
||||||
Blender defines a number of Python types but also uses Python native types.
|
Blender defines a number of Python types but also uses Python native types.
|
||||||
Blender's Python API can be split up into three categories.
|
|
||||||
|
Blender's Python API can be split up into 3 categories.
|
||||||
|
|
||||||
|
|
||||||
Native Types
|
Native Types
|
||||||
@@ -353,7 +374,7 @@ Native Types
|
|||||||
In simple cases returning a number or a string as a custom type would be cumbersome,
|
In simple cases returning a number or a string as a custom type would be cumbersome,
|
||||||
so these are accessed as normal Python types.
|
so these are accessed as normal Python types.
|
||||||
|
|
||||||
- Blender float, int, boolean -> float, int, boolean
|
- Blender float/int/boolean -> float/int/boolean
|
||||||
- Blender enumerator -> string
|
- Blender enumerator -> string
|
||||||
|
|
||||||
>>> C.object.rotation_mode = 'AXIS_ANGLE'
|
>>> C.object.rotation_mode = 'AXIS_ANGLE'
|
||||||
@@ -372,10 +393,11 @@ so these are accessed as normal Python types.
|
|||||||
Internal Types
|
Internal Types
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
:class:`bpy.types.bpy_struct` is used for Blender data-blocks and collections.
|
Used for Blender data-blocks and collections: :class:`bpy.types.bpy_struct`
|
||||||
Also for data that contains its own attributes: collections, meshes, bones, scenes, etc.
|
|
||||||
|
|
||||||
There are two main types that wrap Blender's data, one for data-blocks
|
For data that contains its own attributes collections/meshes/bones/scenes... etc.
|
||||||
|
|
||||||
|
There are 2 main types that wrap Blenders data, one for data-blocks
|
||||||
(known internally as ``bpy_struct``), another for properties.
|
(known internally as ``bpy_struct``), another for properties.
|
||||||
|
|
||||||
>>> bpy.context.object
|
>>> bpy.context.object
|
||||||
@@ -384,13 +406,14 @@ There are two main types that wrap Blender's data, one for data-blocks
|
|||||||
>>> C.scene.objects
|
>>> C.scene.objects
|
||||||
bpy.data.scenes['Scene'].objects
|
bpy.data.scenes['Scene'].objects
|
||||||
|
|
||||||
Note that these types reference Blender's data so modifying them is visible immediately.
|
Note that these types reference Blender's data so modifying them is immediately visible.
|
||||||
|
|
||||||
|
|
||||||
Mathutils Types
|
Mathutils Types
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Accessible from :mod:`mathutils` are vectors, quaternions, Euler angles, matrix and color types.
|
Used for vectors, quaternion, eulers, matrix and color types, accessible from :mod:`mathutils`
|
||||||
|
|
||||||
Some attributes such as :class:`bpy.types.Object.location`,
|
Some attributes such as :class:`bpy.types.Object.location`,
|
||||||
:class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location`
|
:class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location`
|
||||||
can be accessed as special math types which can be used together and manipulated in various useful ways.
|
can be accessed as special math types which can be used together and manipulated in various useful ways.
|
||||||
@@ -399,13 +422,14 @@ Example of a matrix, vector multiplication:
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
bpy.context.object.matrix_world @ bpy.context.object.data.verts[0].co
|
bpy.context.object.matrix_world * bpy.context.object.data.verts[0].co
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
mathutils types keep a reference to Blender's internal data so changes can
|
mathutils types keep a reference to Blender's internal data so changes can
|
||||||
be applied back.
|
be applied back.
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -425,11 +449,13 @@ Example of a matrix, vector multiplication:
|
|||||||
Animation
|
Animation
|
||||||
=========
|
=========
|
||||||
|
|
||||||
There are two ways to add keyframes through Python.
|
There are 2 ways to add keyframes through Python.
|
||||||
|
|
||||||
The first is through key properties directly, which is like inserting a keyframe from the button as a user.
|
The first is through key properties directly, which is similar to inserting a keyframe from the button as a user.
|
||||||
You can also manually create the curves and keyframe data, then set the path to the property.
|
You can also manually create the curves and keyframe data, then set the path to the property.
|
||||||
Here are examples of both methods. Both insert a keyframe on the active object's Z axis.
|
Here are examples of both methods.
|
||||||
|
|
||||||
|
Both examples insert a keyframe on the active object's Z axis.
|
||||||
|
|
||||||
Simple example:
|
Simple example:
|
||||||
|
|
||||||
@@ -441,7 +467,7 @@ Simple example:
|
|||||||
obj.location[2] = 1.0
|
obj.location[2] = 1.0
|
||||||
obj.keyframe_insert(data_path="location", frame=20.0, index=2)
|
obj.keyframe_insert(data_path="location", frame=20.0, index=2)
|
||||||
|
|
||||||
Using low-level functions:
|
Using Low-Level Functions:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@@ -4,22 +4,23 @@ Tips and Tricks
|
|||||||
***************
|
***************
|
||||||
|
|
||||||
Here are various suggestions that you might find useful when writing scripts.
|
Here are various suggestions that you might find useful when writing scripts.
|
||||||
Some of these are just Python features that you may not have thought to use with Blender,
|
|
||||||
others are Blender-specific.
|
Some of these are just Python features that scripters may not have thought to use with Blender,
|
||||||
|
others are Blender specific.
|
||||||
|
|
||||||
|
|
||||||
.. _use_the_terminal:
|
.. _use_the_terminal:
|
||||||
|
|
||||||
Use the Terminal
|
Use The Terminal
|
||||||
================
|
================
|
||||||
|
|
||||||
When writing Python scripts, it's useful to have a terminal open,
|
When writing Python scripts, it's useful to have a terminal open,
|
||||||
this is not the built-in Python console but a terminal application which is used to start Blender.
|
this is not the built-in Python console but a terminal application which is used to start Blender.
|
||||||
|
|
||||||
The three main use cases for the terminal are:
|
There are 3 main uses for the terminal, these are:
|
||||||
|
|
||||||
- You can see the output of ``print()`` as your script runs, which is useful to view debug info.
|
- You can see the output of ``print()`` as your script runs, which is useful to view debug info.
|
||||||
- The error traceback is printed in full to the terminal which won't always generate an report message in
|
- The error trace-back is printed in full to the terminal which won't always generate an error popup in
|
||||||
Blender's user interface (depending on how the script is executed).
|
Blender's user interface (depending on how the script is executed).
|
||||||
- If the script runs for too long or you accidentally enter an infinite loop,
|
- If the script runs for too long or you accidentally enter an infinite loop,
|
||||||
:kbd:`Ctrl-C` in the terminal (:kbd:`Ctrl-Break` on Windows) will quit the script early.
|
:kbd:`Ctrl-C` in the terminal (:kbd:`Ctrl-Break` on Windows) will quit the script early.
|
||||||
@@ -27,25 +28,26 @@ The three main use cases for the terminal are:
|
|||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
For Linux and macOS users this means starting the terminal first, then running Blender from within it.
|
For Linux and macOS users this means starting the terminal first, then running Blender from within it.
|
||||||
On Windows the terminal can be enabled from the Help menu.
|
On Windows the terminal can be enabled from the help menu.
|
||||||
|
|
||||||
|
|
||||||
Interface Tricks
|
Interface Tricks
|
||||||
================
|
================
|
||||||
|
|
||||||
|
|
||||||
Access Operator Commands
|
Access Operator Commands
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
You may have noticed that the tooltip for menu items and buttons includes the ``bpy.ops.[...]`` command
|
You may have noticed that the tooltip for menu items and buttons includes the ``bpy.ops.[...])`` command
|
||||||
to run that button, a handy (hidden) feature is that you can press :kbd:`Ctrl-C` over
|
to run that button, a handy (hidden) feature is that you can press :kbd:`Ctrl-C` over
|
||||||
any menu item or button to copy this command into the clipboard.
|
any menu item/button to copy this command into the clipboard.
|
||||||
|
|
||||||
|
|
||||||
Access Data Path
|
Access Data Path
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
To find the path from an :class:`ID` data-block to its setting isn't always so simple since it may be nested away.
|
To find the path from an :class:`ID` datablock to its setting isn't always so simple since it may be nested away.
|
||||||
To get this quickly open the context menu of the setting and select *Copy Data Path*,
|
To get this quickly you can right click on the setting and select select **Copy Data Path**,
|
||||||
if this can't be generated, only the property name is copied.
|
if this can't be generated, only the property name is copied.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -60,10 +62,11 @@ if this can't be generated, only the property name is copied.
|
|||||||
Show All Operators
|
Show All Operators
|
||||||
==================
|
==================
|
||||||
|
|
||||||
While Blender logs operators in the Info editor,
|
While Blender logs operators in the Info space,
|
||||||
this only reports operators with the ``REGISTER`` option enabled so as not to flood the *Info* view
|
this only reports operators with the ``REGISTER`` option enabeld so as not to flood the *Info* view
|
||||||
with calls to ``bpy.ops.view3d.smoothview`` and ``bpy.ops.view3d.zoom``.
|
with calls to ``bpy.ops.view3d.smoothview`` and ``bpy.ops.view3d.zoom``.
|
||||||
Yet for testing it can be useful to see **every** operator called in a terminal,
|
|
||||||
|
However, for testing it can be useful to see **every** operator called in a terminal,
|
||||||
do this by enabling the debug option either by passing the ``--debug-wm`` argument when starting Blender
|
do this by enabling the debug option either by passing the ``--debug-wm`` argument when starting Blender
|
||||||
or by setting :mod:`bpy.app.debug_wm` to ``True`` while Blender is running.
|
or by setting :mod:`bpy.app.debug_wm` to ``True`` while Blender is running.
|
||||||
|
|
||||||
@@ -71,18 +74,20 @@ or by setting :mod:`bpy.app.debug_wm` to ``True`` while Blender is running.
|
|||||||
Use an External Editor
|
Use an External Editor
|
||||||
======================
|
======================
|
||||||
|
|
||||||
Blender's text editor is fine for small changes and writing tests but its not full featured,
|
Blenders text editor is fine for small changes and writing tests but its not full featured,
|
||||||
for larger projects you'll probably want to use a standalone editor or Python IDE.
|
for larger projects you'll probably want to use a standalone editor or Python IDE.
|
||||||
Editing a text file externally and having the same text open in Blender does work
|
|
||||||
but isn't that optimal so here are two ways you can use an external file from Blender.
|
Editing a text file externally and having the same text open in Blender does work but isn't that optimal
|
||||||
Using the following examples you'll still need text data-block in Blender to execute,
|
so here are 2 ways you can easily use an external file from Blender.
|
||||||
|
|
||||||
|
Using the following examples you'll still need textblock in Blender to execute,
|
||||||
but reference an external file rather than including it directly.
|
but reference an external file rather than including it directly.
|
||||||
|
|
||||||
|
|
||||||
Executing External Scripts
|
Executing External Scripts
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
This is the equivalent to running the script directly, referencing a scripts path from a two line code block.
|
This is the equivalent to running the script directly, referencing a scripts path from a 2 line text-block.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -90,7 +95,7 @@ This is the equivalent to running the script directly, referencing a scripts pat
|
|||||||
exec(compile(open(filename).read(), filename, 'exec'))
|
exec(compile(open(filename).read(), filename, 'exec'))
|
||||||
|
|
||||||
|
|
||||||
You might want to reference a script relative to the blend-file.
|
You might want to reference a script relative to the blend file.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -123,10 +128,9 @@ has to call a function in the module, in this case ``main()`` but it can be any
|
|||||||
an advantage with this is you can pass arguments to the function from this
|
an advantage with this is you can pass arguments to the function from this
|
||||||
small script which is often useful for testing different settings quickly.
|
small script which is often useful for testing different settings quickly.
|
||||||
|
|
||||||
The other issue with this is the script has to be in Python's module search path.
|
The other issue with this is the script has to be in Pythons module search path.
|
||||||
While this is not best practice -- for testing purposes you can extend the search path,
|
While this is not best practice - for testing you can extend the search path,
|
||||||
this following example adds the current blend-files directory to the search path
|
this example adds the current blend files directory to the search path, then loads the script as a module.
|
||||||
and then loads the script as a module.
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -144,40 +148,42 @@ and then loads the script as a module.
|
|||||||
myscript.main()
|
myscript.main()
|
||||||
|
|
||||||
|
|
||||||
Use Blender without it's User Interface
|
Don't Use Blender!
|
||||||
=======================================
|
==================
|
||||||
|
|
||||||
|
While developing your own scripts Blenders interface can get in the way,
|
||||||
|
manually reloading, running the scripts, opening file import etc. adds overhead.
|
||||||
|
|
||||||
While developing your own scripts Blender's interface can get in the way,
|
|
||||||
manually reloading, running the scripts, opening file import, etc. adds overhead.
|
|
||||||
For scripts that are not interactive it can end up being more efficient not to use
|
For scripts that are not interactive it can end up being more efficient not to use
|
||||||
Blender's interface at all and instead execute the script on the command line.
|
Blenders interface at all and instead execute the script on the command line.
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
blender --background --python myscript.py
|
blender --background --python myscript.py
|
||||||
|
|
||||||
|
|
||||||
You might want to run this with a blend-file so the script has some data to operate on.
|
You might want to run this with a blend file so the script has some data to operate on.
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
blender myscene.blend --background --python myscript.py
|
blender myscene.blend --background --python myscript.py
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Depending on your setup you might have to enter the full path to the Blender executable.
|
Depending on your setup you might have to enter the full path to the Blender executable.
|
||||||
|
|
||||||
|
|
||||||
Once the script is running properly in background mode, you'll want to check the output of the script,
|
Once the script is running properly in background mode, you'll want to check the output of the script,
|
||||||
this depends completely on the task at hand, however, here are some suggestions:
|
this depends completely on the task at hand however here are some suggestions.
|
||||||
|
|
||||||
- Render the output to an image, use an image viewer and keep writing over the same image each time.
|
- render the output to an image, use an image viewer and keep writing over the same image each time.
|
||||||
- Save a new blend-file, or export the file using one of Blender's exporters.
|
- save a new blend file, or export the file using one of Blenders exporters.
|
||||||
- If the results can be displayed as text then print them or write them to a file.
|
- if the results can be displayed as text - print them or write them to a file.
|
||||||
|
|
||||||
|
|
||||||
While this can take a little time to setup, it can be well worth the effort
|
While this can take a little time to setup, it can be well worth the effort
|
||||||
to reduce the time it takes to test changes. You can even have
|
to reduce the time it takes to test changes - you can even have
|
||||||
Blender running the script every few seconds with a viewer updating the results,
|
Blender running the script every few seconds with a viewer updating the results,
|
||||||
so no need to leave your text editor to see changes.
|
so no need to leave your text editor to see changes.
|
||||||
|
|
||||||
@@ -194,7 +200,7 @@ but to quickly setup your own custom pipeline or writing one-off scripts this ca
|
|||||||
|
|
||||||
Examples include:
|
Examples include:
|
||||||
|
|
||||||
- Run Gimp in batch mode to execute custom scripts for advanced image processing.
|
- Run The Gimp in batch mode to execute custom scripts for advanced image processing.
|
||||||
- Write out 3D models to use external mesh manipulation tools and read back in the results.
|
- Write out 3D models to use external mesh manipulation tools and read back in the results.
|
||||||
- Convert files into recognizable formats before reading.
|
- Convert files into recognizable formats before reading.
|
||||||
|
|
||||||
@@ -203,16 +209,15 @@ Bundled Python & Extensions
|
|||||||
===========================
|
===========================
|
||||||
|
|
||||||
The Blender releases distributed from blender.org include a complete Python installation on all platforms,
|
The Blender releases distributed from blender.org include a complete Python installation on all platforms,
|
||||||
this has the disadvantage that any extensions you have installed on your system's Python environment
|
this has the disadvantage that any extensions you have installed in your systems Python won't be found by Blender.
|
||||||
will not be found by Blender.
|
|
||||||
|
|
||||||
There are two ways to work around this:
|
There are 2 ways around this:
|
||||||
|
|
||||||
- Remove Blender Python subdirectory, Blender will then fallback on the system's Python and use that instead.
|
- Remove Blender Python sub-directory, Blender will then fallback on the systems Python and use that instead.
|
||||||
|
|
||||||
Depending on your platform,
|
Depending on your platform,
|
||||||
you may need to explicitly reference the location of your Python installation using
|
you may need to explicitly reference the location of your Python installation using the
|
||||||
the ``PYTHONPATH`` environment variable, e.g:
|
``PYTHONPATH`` environment variable, eg:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
@@ -221,21 +226,21 @@ There are two ways to work around this:
|
|||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
The Python (major, minor) version must match the one that Blender comes with.
|
The Python (major, minor) version must match the one that Blender comes with.
|
||||||
Therefor you can't use Python 3.6 with Blender built to use Python 3.7.
|
Therefor can't use Python 3.6 with Blender built to use Python 3.7.
|
||||||
|
|
||||||
- Copy or link the extensions into Blender's Python subdirectory so Blender can access them,
|
- Copy or link the extensions into Blender's Python sub-directory so Blender can access them,
|
||||||
you can also copy the entire Python installation into Blender's subdirectory,
|
you could also copy the entire Python installation into Blenders sub-directory,
|
||||||
replacing the one Blender comes with.
|
replacing the one Blender comes with.
|
||||||
This works as long as the Python versions match and the paths are created in the same relative locations.
|
This works as long as the Python versions match and the paths are created in the same relative locations.
|
||||||
Doing this has the advantage that you can redistribute this bundle to others with Blender
|
Doing this has the advantage that you can redistribute this bundle to others with Blender
|
||||||
including any extensions you rely on.
|
including any extensions you rely on.
|
||||||
|
|
||||||
|
|
||||||
Insert a Python Interpreter into your Script
|
Drop Into a Python Interpreter in Your Script
|
||||||
============================================
|
=============================================
|
||||||
|
|
||||||
In the middle of a script you may want to inspect variables,
|
In the middle of a script you may want to inspect some variables,
|
||||||
run functions and inspect the flow.
|
run some function and generally dig about to see what's going on.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -243,7 +248,7 @@ run functions and inspect the flow.
|
|||||||
code.interact(local=locals())
|
code.interact(local=locals())
|
||||||
|
|
||||||
|
|
||||||
If you want to access both global and local variables run this:
|
If you want to access both global and local variables do this...
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@@ -261,7 +266,7 @@ The next example is an equivalent single line version of the script above which
|
|||||||
|
|
||||||
|
|
||||||
``code.interact`` can be added at any line in the script
|
``code.interact`` can be added at any line in the script
|
||||||
and will pause the script to launch an interactive interpreter in the terminal,
|
and will pause the script an launch an interactive interpreter in the terminal,
|
||||||
when you're done you can quit the interpreter and the script will continue execution.
|
when you're done you can quit the interpreter and the script will continue execution.
|
||||||
|
|
||||||
|
|
||||||
@@ -274,14 +279,13 @@ The IPython prompt has auto-complete and some useful features that the standard
|
|||||||
IPython.embed()
|
IPython.embed()
|
||||||
|
|
||||||
|
|
||||||
Admittedly this highlights the lack of any Python debugging support built into Blender,
|
Admittedly this highlights the lack of any Python debugging support built into Blender, but its still handy to know.
|
||||||
but its still a handy thing to know.
|
|
||||||
|
|
||||||
|
|
||||||
Advanced
|
Advanced
|
||||||
========
|
========
|
||||||
|
|
||||||
Blender as a Module
|
|
||||||
|
Blender as a module
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
From a Python perspective it's nicer to have everything as an extension
|
From a Python perspective it's nicer to have everything as an extension
|
||||||
@@ -289,22 +293,26 @@ which lets the Python script combine many components.
|
|||||||
|
|
||||||
Advantages include:
|
Advantages include:
|
||||||
|
|
||||||
- You can use external editors or IDEs with Blender's Python API and execute scripts within the IDE
|
- you can use external editors/IDE's with Blenders Python API and execute scripts within the IDE
|
||||||
(step over code, inspect variables as the script runs).
|
(step over code, inspect variables as the script runs).
|
||||||
- Editors or IDEs can auto-complete Blender modules and variables.
|
- editors/IDE's can auto complete Blender modules & variables.
|
||||||
- Existing scripts can import Blender APIs without having to be run inside of Blender.
|
- existing scripts can import Blender API's without having to run inside Blender.
|
||||||
|
|
||||||
|
|
||||||
This is marked advanced because to run Blender as a Python module requires a special build option.
|
This is marked advanced because to run Blender as a Python module requires a special build option.
|
||||||
|
|
||||||
For instructions on building see
|
For instructions on building see
|
||||||
`Building Blender as a Python module <https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule>`__.
|
`Building Blender as a Python module <https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule>`_
|
||||||
|
|
||||||
|
|
||||||
Python Safety (Build Option)
|
Python Safety (Build Option)
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
Since it's possible to access data which has been removed (see :doc:`Gotchas <info_gotcha>`),
|
Since it's possible to access data which has been removed (see Gotcha's),
|
||||||
can make it hard to track down the cause of crashes.
|
this can be hard to track down the cause of crashes.
|
||||||
|
|
||||||
To raise Python exceptions on accessing freed data (rather than crashing),
|
To raise Python exceptions on accessing freed data (rather than crashing),
|
||||||
enable the CMake build option ``WITH_PYTHON_SAFETY``.
|
enable the CMake build option ``WITH_PYTHON_SAFETY``.
|
||||||
This enables data tracking which makes data access about two times slower
|
|
||||||
|
This enables data tracking which makes data access about 2x slower
|
||||||
which is why the option isn't enabled in release builds.
|
which is why the option isn't enabled in release builds.
|
||||||
|
@@ -83,8 +83,6 @@ import inspect
|
|||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from textwrap import indent
|
|
||||||
|
|
||||||
from platform import platform
|
from platform import platform
|
||||||
PLATFORM = platform().split('-')[0].lower() # 'linux', 'darwin', 'windows'
|
PLATFORM = platform().split('-')[0].lower() # 'linux', 'darwin', 'windows'
|
||||||
|
|
||||||
@@ -359,7 +357,7 @@ INFO_DOCS = (
|
|||||||
("info_tips_and_tricks.rst",
|
("info_tips_and_tricks.rst",
|
||||||
"Tips and Tricks: Hints to help you while writing scripts for Blender"),
|
"Tips and Tricks: Hints to help you while writing scripts for Blender"),
|
||||||
("info_gotcha.rst",
|
("info_gotcha.rst",
|
||||||
"Gotcha's: some of the problems you may encounter when writing scripts"),
|
"Gotcha's: some of the problems you may come up against when writing scripts"),
|
||||||
("change_log.rst", "List of changes since last Blender release"),
|
("change_log.rst", "List of changes since last Blender release"),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -440,30 +438,25 @@ if ARGS.sphinx_build:
|
|||||||
|
|
||||||
if ARGS.log:
|
if ARGS.log:
|
||||||
SPHINX_BUILD_LOG = os.path.join(ARGS.output_dir, ".sphinx-build.log")
|
SPHINX_BUILD_LOG = os.path.join(ARGS.output_dir, ".sphinx-build.log")
|
||||||
SPHINX_BUILD = [
|
SPHINX_BUILD = ["sphinx-build",
|
||||||
"sphinx-build",
|
"-w", SPHINX_BUILD_LOG,
|
||||||
"-w", SPHINX_BUILD_LOG,
|
SPHINX_IN, SPHINX_OUT]
|
||||||
SPHINX_IN, SPHINX_OUT,
|
|
||||||
]
|
|
||||||
|
|
||||||
# pdf build
|
# pdf build
|
||||||
if ARGS.sphinx_build_pdf:
|
if ARGS.sphinx_build_pdf:
|
||||||
SPHINX_OUT_PDF = os.path.join(ARGS.output_dir, "sphinx-out_pdf")
|
SPHINX_OUT_PDF = os.path.join(ARGS.output_dir, "sphinx-out_pdf")
|
||||||
SPHINX_BUILD_PDF = [
|
SPHINX_BUILD_PDF = ["sphinx-build",
|
||||||
"sphinx-build",
|
"-b", "latex",
|
||||||
"-b", "latex",
|
SPHINX_IN, SPHINX_OUT_PDF]
|
||||||
SPHINX_IN, SPHINX_OUT_PDF,
|
|
||||||
]
|
|
||||||
SPHINX_MAKE_PDF = ["make", "-C", SPHINX_OUT_PDF]
|
SPHINX_MAKE_PDF = ["make", "-C", SPHINX_OUT_PDF]
|
||||||
SPHINX_MAKE_PDF_STDOUT = None
|
SPHINX_MAKE_PDF_STDOUT = None
|
||||||
|
|
||||||
if ARGS.log:
|
if ARGS.log:
|
||||||
SPHINX_BUILD_PDF_LOG = os.path.join(ARGS.output_dir, ".sphinx-build_pdf.log")
|
SPHINX_BUILD_PDF_LOG = os.path.join(ARGS.output_dir, ".sphinx-build_pdf.log")
|
||||||
SPHINX_BUILD_PDF = [
|
SPHINX_BUILD_PDF = ["sphinx-build", "-b", "latex",
|
||||||
"sphinx-build", "-b", "latex",
|
"-w", SPHINX_BUILD_PDF_LOG,
|
||||||
"-w", SPHINX_BUILD_PDF_LOG,
|
SPHINX_IN, SPHINX_OUT_PDF]
|
||||||
SPHINX_IN, SPHINX_OUT_PDF,
|
|
||||||
]
|
|
||||||
sphinx_make_pdf_log = os.path.join(ARGS.output_dir, ".latex_make.log")
|
sphinx_make_pdf_log = os.path.join(ARGS.output_dir, ".latex_make.log")
|
||||||
SPHINX_MAKE_PDF_STDOUT = open(sphinx_make_pdf_log, "w", encoding="utf-8")
|
SPHINX_MAKE_PDF_STDOUT = open(sphinx_make_pdf_log, "w", encoding="utf-8")
|
||||||
|
|
||||||
@@ -1033,7 +1026,6 @@ context_type_map = {
|
|||||||
"gpencil": ("GreasePencil", False),
|
"gpencil": ("GreasePencil", False),
|
||||||
"gpencil_data": ("GreasePencil", False),
|
"gpencil_data": ("GreasePencil", False),
|
||||||
"gpencil_data_owner": ("ID", False),
|
"gpencil_data_owner": ("ID", False),
|
||||||
"hair": ("Hair", False),
|
|
||||||
"image_paint_object": ("Object", False),
|
"image_paint_object": ("Object", False),
|
||||||
"lattice": ("Lattice", False),
|
"lattice": ("Lattice", False),
|
||||||
"light": ("Light", False),
|
"light": ("Light", False),
|
||||||
@@ -1050,7 +1042,6 @@ context_type_map = {
|
|||||||
"particle_settings": ("ParticleSettings", False),
|
"particle_settings": ("ParticleSettings", False),
|
||||||
"particle_system": ("ParticleSystem", False),
|
"particle_system": ("ParticleSystem", False),
|
||||||
"particle_system_editable": ("ParticleSystem", False),
|
"particle_system_editable": ("ParticleSystem", False),
|
||||||
"pointcloud": ("PointCloud", False),
|
|
||||||
"pose_bone": ("PoseBone", False),
|
"pose_bone": ("PoseBone", False),
|
||||||
"pose_object": ("Object", False),
|
"pose_object": ("Object", False),
|
||||||
"scene": ("Scene", False),
|
"scene": ("Scene", False),
|
||||||
@@ -1205,15 +1196,12 @@ def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
return "".join([
|
return "".join(["* ``%s`` %s.\n" %
|
||||||
"* ``%s``\n"
|
(identifier,
|
||||||
"%s.\n" % (
|
", ".join(escape_rst(val) for val in (name, description) if val),
|
||||||
identifier,
|
)
|
||||||
# Account for multi-line enum descriptions, allowing this to be a block of text.
|
for identifier, name, description in prop.enum_items
|
||||||
indent(", ".join(escape_rst(val) for val in (name, description) if val) or "Undocumented", " "),
|
])
|
||||||
)
|
|
||||||
for identifier, name, description in prop.enum_items
|
|
||||||
])
|
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@@ -1280,7 +1268,7 @@ def pyrna2sphinx(basepath):
|
|||||||
fw(ident + ":%s%s:\n\n" % (id_name, identifier))
|
fw(ident + ":%s%s:\n\n" % (id_name, identifier))
|
||||||
|
|
||||||
if prop.name or prop.description:
|
if prop.name or prop.description:
|
||||||
fw(indent(", ".join(val for val in (prop.name, prop.description) if val), ident + " ") + "\n\n")
|
fw(ident + " " + ", ".join(val for val in (prop.name, prop.description) if val) + "\n\n")
|
||||||
|
|
||||||
# special exception, can't use generic code here for enums
|
# special exception, can't use generic code here for enums
|
||||||
if enum_text:
|
if enum_text:
|
||||||
@@ -1726,7 +1714,7 @@ class PatchedPythonDomain(PythonDomain):
|
|||||||
# end workaround
|
# end workaround
|
||||||
|
|
||||||
fw("def setup(app):\n")
|
fw("def setup(app):\n")
|
||||||
fw(" app.add_css_file('css/theme_overrides.css')\n")
|
fw(" app.add_stylesheet('css/theme_overrides.css')\n")
|
||||||
fw(" app.add_domain(PatchedPythonDomain, override=True)\n\n")
|
fw(" app.add_domain(PatchedPythonDomain, override=True)\n\n")
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
@@ -118,19 +118,20 @@ def main():
|
|||||||
|
|
||||||
# III) Get Blender version info.
|
# III) Get Blender version info.
|
||||||
getver_file = os.path.join(tmp_dir, "blendver.txt")
|
getver_file = os.path.join(tmp_dir, "blendver.txt")
|
||||||
getver_script = (r"""import sys, bpy
|
getver_script = (
|
||||||
with open(sys.argv[-1], 'w') as f:
|
"import sys, bpy\n"
|
||||||
is_release = bpy.app.version_cycle in {'rc', 'release'}
|
"with open(sys.argv[-1], 'w') as f:\n"
|
||||||
is_beta = bpy.app.version_cycle in {'beta'}
|
" is_release = bpy.app.version_cycle in {'rc', 'release'}\n"
|
||||||
branch = bpy.app.build_branch.split()[0].decode()
|
" is_beta = bpy.app.version_cycle in {'beta'}\n"
|
||||||
f.write('%d\n' % is_release)
|
" branch = bpy.app.build_branch.split()[0].decode()\n"
|
||||||
f.write('%d\n' % is_beta)
|
" f.write('%d\\n' % is_release)\n"
|
||||||
f.write('%s\n' % branch)
|
" f.write('%d\\n' % is_beta)\n"
|
||||||
f.write('%d.%d\n' % (bpy.app.version[0], bpy.app.version[1]))
|
" f.write('%s\\n' % branch)\n"
|
||||||
f.write('%d.%d\n' % (bpy.app.version[0], bpy.app.version[1])
|
" f.write('%d.%d\\n' % (bpy.app.version[0], bpy.app.version[1]))\n"
|
||||||
if (is_release or is_beta) else '%s\n' % branch)
|
" f.write('%d.%d\\n' % (bpy.app.version[0], bpy.app.version[1])\n"
|
||||||
f.write('%d_%d' % (bpy.app.version[0], bpy.app.version[1]))
|
" if (is_release or is_beta) else '%s\\n' % branch)\n"
|
||||||
""")
|
" f.write('%d_%d' % (bpy.app.version[0], bpy.app.version[1]))\n"
|
||||||
|
)
|
||||||
get_ver_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
|
get_ver_cmd = (args.blender, "--background", "-noaudio", "--factory-startup", "--python-exit-code", "1",
|
||||||
"--python-expr", getver_script, "--", getver_file)
|
"--python-expr", getver_script, "--", getver_file)
|
||||||
subprocess.run(get_ver_cmd)
|
subprocess.run(get_ver_cmd)
|
||||||
|
40
extern/audaspace/plugins/sdl/SDLDevice.cpp
vendored
40
extern/audaspace/plugins/sdl/SDLDevice.cpp
vendored
@@ -52,7 +52,7 @@ SDLDevice::SDLDevice(DeviceSpecs specs, int buffersize) :
|
|||||||
if(specs.channels == CHANNELS_INVALID)
|
if(specs.channels == CHANNELS_INVALID)
|
||||||
specs.channels = CHANNELS_STEREO;
|
specs.channels = CHANNELS_STEREO;
|
||||||
if(specs.format == FORMAT_INVALID)
|
if(specs.format == FORMAT_INVALID)
|
||||||
specs.format = FORMAT_FLOAT32;
|
specs.format = FORMAT_S16;
|
||||||
if(specs.rate == RATE_INVALID)
|
if(specs.rate == RATE_INVALID)
|
||||||
specs.rate = RATE_48000;
|
specs.rate = RATE_48000;
|
||||||
|
|
||||||
@@ -61,25 +61,10 @@ SDLDevice::SDLDevice(DeviceSpecs specs, int buffersize) :
|
|||||||
SDL_AudioSpec format, obtained;
|
SDL_AudioSpec format, obtained;
|
||||||
|
|
||||||
format.freq = m_specs.rate;
|
format.freq = m_specs.rate;
|
||||||
switch(m_specs.format)
|
if(m_specs.format == FORMAT_U8)
|
||||||
{
|
|
||||||
case FORMAT_U8:
|
|
||||||
format.format = AUDIO_U8;
|
format.format = AUDIO_U8;
|
||||||
break;
|
else
|
||||||
case FORMAT_S16:
|
|
||||||
format.format = AUDIO_S16SYS;
|
format.format = AUDIO_S16SYS;
|
||||||
break;
|
|
||||||
case FORMAT_S32:
|
|
||||||
format.format = AUDIO_S32SYS;
|
|
||||||
break;
|
|
||||||
case FORMAT_FLOAT32:
|
|
||||||
format.format = AUDIO_F32SYS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
format.format = AUDIO_F32SYS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
format.channels = m_specs.channels;
|
format.channels = m_specs.channels;
|
||||||
format.samples = buffersize;
|
format.samples = buffersize;
|
||||||
format.callback = SDLDevice::SDL_mix;
|
format.callback = SDLDevice::SDL_mix;
|
||||||
@@ -90,25 +75,14 @@ SDLDevice::SDLDevice(DeviceSpecs specs, int buffersize) :
|
|||||||
|
|
||||||
m_specs.rate = (SampleRate)obtained.freq;
|
m_specs.rate = (SampleRate)obtained.freq;
|
||||||
m_specs.channels = (Channels)obtained.channels;
|
m_specs.channels = (Channels)obtained.channels;
|
||||||
|
if(obtained.format == AUDIO_U8)
|
||||||
switch(obtained.format)
|
|
||||||
{
|
|
||||||
case AUDIO_U8:
|
|
||||||
m_specs.format = FORMAT_U8;
|
m_specs.format = FORMAT_U8;
|
||||||
break;
|
else if(obtained.format == AUDIO_S16LSB || obtained.format == AUDIO_S16MSB)
|
||||||
case AUDIO_S16SYS:
|
|
||||||
m_specs.format = FORMAT_S16;
|
m_specs.format = FORMAT_S16;
|
||||||
break;
|
else
|
||||||
case AUDIO_S32SYS:
|
{
|
||||||
m_specs.format = FORMAT_S32;
|
|
||||||
break;
|
|
||||||
case AUDIO_F32SYS:
|
|
||||||
m_specs.format = FORMAT_FLOAT32;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
AUD_THROW(DeviceException, "The sample format obtained from SDL is not supported.");
|
AUD_THROW(DeviceException, "The sample format obtained from SDL is not supported.");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create();
|
create();
|
||||||
|
576
extern/ceres/CMakeLists.txt
vendored
576
extern/ceres/CMakeLists.txt
vendored
@@ -37,279 +37,223 @@ set(INC_SYS
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(SRC
|
set(SRC
|
||||||
internal/ceres/accelerate_sparse.cc
|
internal/ceres/array_utils.cc
|
||||||
internal/ceres/array_utils.cc
|
internal/ceres/blas.cc
|
||||||
internal/ceres/blas.cc
|
internal/ceres/block_evaluate_preparer.cc
|
||||||
internal/ceres/block_evaluate_preparer.cc
|
internal/ceres/block_jacobian_writer.cc
|
||||||
internal/ceres/block_jacobian_writer.cc
|
internal/ceres/block_jacobi_preconditioner.cc
|
||||||
internal/ceres/block_jacobi_preconditioner.cc
|
internal/ceres/block_random_access_dense_matrix.cc
|
||||||
internal/ceres/block_random_access_dense_matrix.cc
|
internal/ceres/block_random_access_diagonal_matrix.cc
|
||||||
internal/ceres/block_random_access_diagonal_matrix.cc
|
internal/ceres/block_random_access_matrix.cc
|
||||||
internal/ceres/block_random_access_matrix.cc
|
internal/ceres/block_random_access_sparse_matrix.cc
|
||||||
internal/ceres/block_random_access_sparse_matrix.cc
|
internal/ceres/block_sparse_matrix.cc
|
||||||
internal/ceres/block_sparse_matrix.cc
|
internal/ceres/block_structure.cc
|
||||||
internal/ceres/block_structure.cc
|
internal/ceres/callbacks.cc
|
||||||
internal/ceres/callbacks.cc
|
internal/ceres/c_api.cc
|
||||||
internal/ceres/canonical_views_clustering.cc
|
internal/ceres/cgnr_solver.cc
|
||||||
internal/ceres/c_api.cc
|
internal/ceres/compressed_col_sparse_matrix_utils.cc
|
||||||
internal/ceres/cgnr_solver.cc
|
internal/ceres/compressed_row_jacobian_writer.cc
|
||||||
internal/ceres/compressed_col_sparse_matrix_utils.cc
|
internal/ceres/compressed_row_sparse_matrix.cc
|
||||||
internal/ceres/compressed_row_jacobian_writer.cc
|
internal/ceres/conditioned_cost_function.cc
|
||||||
internal/ceres/compressed_row_sparse_matrix.cc
|
internal/ceres/conjugate_gradients_solver.cc
|
||||||
internal/ceres/conditioned_cost_function.cc
|
internal/ceres/coordinate_descent_minimizer.cc
|
||||||
internal/ceres/conjugate_gradients_solver.cc
|
internal/ceres/corrector.cc
|
||||||
internal/ceres/context.cc
|
internal/ceres/covariance.cc
|
||||||
internal/ceres/context_impl.cc
|
internal/ceres/covariance_impl.cc
|
||||||
internal/ceres/coordinate_descent_minimizer.cc
|
internal/ceres/dense_normal_cholesky_solver.cc
|
||||||
internal/ceres/corrector.cc
|
internal/ceres/dense_qr_solver.cc
|
||||||
internal/ceres/covariance.cc
|
internal/ceres/dense_sparse_matrix.cc
|
||||||
internal/ceres/covariance_impl.cc
|
internal/ceres/detect_structure.cc
|
||||||
internal/ceres/cxsparse.cc
|
internal/ceres/dogleg_strategy.cc
|
||||||
internal/ceres/dense_normal_cholesky_solver.cc
|
internal/ceres/dynamic_compressed_row_jacobian_writer.cc
|
||||||
internal/ceres/dense_qr_solver.cc
|
internal/ceres/dynamic_compressed_row_sparse_matrix.cc
|
||||||
internal/ceres/dense_sparse_matrix.cc
|
internal/ceres/evaluator.cc
|
||||||
internal/ceres/detect_structure.cc
|
internal/ceres/file.cc
|
||||||
internal/ceres/dogleg_strategy.cc
|
internal/ceres/generated/partitioned_matrix_view_d_d_d.cc
|
||||||
internal/ceres/dynamic_compressed_row_jacobian_writer.cc
|
internal/ceres/generated/schur_eliminator_d_d_d.cc
|
||||||
internal/ceres/dynamic_compressed_row_sparse_matrix.cc
|
internal/ceres/gradient_checker.cc
|
||||||
internal/ceres/dynamic_sparse_normal_cholesky_solver.cc
|
internal/ceres/gradient_checking_cost_function.cc
|
||||||
internal/ceres/eigensparse.cc
|
internal/ceres/gradient_problem.cc
|
||||||
internal/ceres/evaluator.cc
|
internal/ceres/gradient_problem_solver.cc
|
||||||
internal/ceres/file.cc
|
internal/ceres/implicit_schur_complement.cc
|
||||||
internal/ceres/float_cxsparse.cc
|
internal/ceres/is_close.cc
|
||||||
internal/ceres/float_suitesparse.cc
|
internal/ceres/iterative_schur_complement_solver.cc
|
||||||
internal/ceres/function_sample.cc
|
internal/ceres/lapack.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_d_d_d.cc
|
internal/ceres/levenberg_marquardt_strategy.cc
|
||||||
internal/ceres/generated/schur_eliminator_d_d_d.cc
|
internal/ceres/linear_least_squares_problems.cc
|
||||||
internal/ceres/gradient_checker.cc
|
internal/ceres/linear_operator.cc
|
||||||
internal/ceres/gradient_checking_cost_function.cc
|
internal/ceres/linear_solver.cc
|
||||||
internal/ceres/gradient_problem.cc
|
internal/ceres/line_search.cc
|
||||||
internal/ceres/gradient_problem_solver.cc
|
internal/ceres/line_search_direction.cc
|
||||||
internal/ceres/implicit_schur_complement.cc
|
internal/ceres/line_search_minimizer.cc
|
||||||
internal/ceres/inner_product_computer.cc
|
internal/ceres/line_search_preprocessor.cc
|
||||||
internal/ceres/is_close.cc
|
internal/ceres/local_parameterization.cc
|
||||||
internal/ceres/iterative_refiner.cc
|
internal/ceres/loss_function.cc
|
||||||
internal/ceres/iterative_schur_complement_solver.cc
|
internal/ceres/low_rank_inverse_hessian.cc
|
||||||
internal/ceres/lapack.cc
|
internal/ceres/minimizer.cc
|
||||||
internal/ceres/levenberg_marquardt_strategy.cc
|
internal/ceres/normal_prior.cc
|
||||||
internal/ceres/linear_least_squares_problems.cc
|
internal/ceres/parameter_block_ordering.cc
|
||||||
internal/ceres/linear_operator.cc
|
internal/ceres/partitioned_matrix_view.cc
|
||||||
internal/ceres/linear_solver.cc
|
internal/ceres/polynomial.cc
|
||||||
internal/ceres/line_search.cc
|
internal/ceres/preconditioner.cc
|
||||||
internal/ceres/line_search_direction.cc
|
internal/ceres/preprocessor.cc
|
||||||
internal/ceres/line_search_minimizer.cc
|
internal/ceres/problem.cc
|
||||||
internal/ceres/line_search_preprocessor.cc
|
internal/ceres/problem_impl.cc
|
||||||
internal/ceres/local_parameterization.cc
|
internal/ceres/program.cc
|
||||||
internal/ceres/loss_function.cc
|
internal/ceres/reorder_program.cc
|
||||||
internal/ceres/low_rank_inverse_hessian.cc
|
internal/ceres/residual_block.cc
|
||||||
internal/ceres/minimizer.cc
|
internal/ceres/residual_block_utils.cc
|
||||||
internal/ceres/normal_prior.cc
|
internal/ceres/schur_complement_solver.cc
|
||||||
internal/ceres/parallel_for_cxx.cc
|
internal/ceres/schur_eliminator.cc
|
||||||
internal/ceres/parallel_for_nothreads.cc
|
internal/ceres/schur_jacobi_preconditioner.cc
|
||||||
internal/ceres/parallel_for_openmp.cc
|
internal/ceres/scratch_evaluate_preparer.cc
|
||||||
internal/ceres/parallel_utils.cc
|
internal/ceres/solver.cc
|
||||||
internal/ceres/parameter_block_ordering.cc
|
internal/ceres/solver_utils.cc
|
||||||
internal/ceres/partitioned_matrix_view.cc
|
internal/ceres/sparse_matrix.cc
|
||||||
internal/ceres/polynomial.cc
|
internal/ceres/sparse_normal_cholesky_solver.cc
|
||||||
internal/ceres/preconditioner.cc
|
internal/ceres/split.cc
|
||||||
internal/ceres/preprocessor.cc
|
internal/ceres/stringprintf.cc
|
||||||
internal/ceres/problem.cc
|
internal/ceres/triplet_sparse_matrix.cc
|
||||||
internal/ceres/problem_impl.cc
|
internal/ceres/trust_region_minimizer.cc
|
||||||
internal/ceres/program.cc
|
internal/ceres/trust_region_preprocessor.cc
|
||||||
internal/ceres/reorder_program.cc
|
internal/ceres/trust_region_step_evaluator.cc
|
||||||
internal/ceres/residual_block.cc
|
internal/ceres/trust_region_strategy.cc
|
||||||
internal/ceres/residual_block_utils.cc
|
internal/ceres/types.cc
|
||||||
internal/ceres/schur_complement_solver.cc
|
internal/ceres/wall_time.cc
|
||||||
internal/ceres/schur_eliminator.cc
|
|
||||||
internal/ceres/schur_jacobi_preconditioner.cc
|
|
||||||
internal/ceres/schur_templates.cc
|
|
||||||
internal/ceres/scratch_evaluate_preparer.cc
|
|
||||||
internal/ceres/single_linkage_clustering.cc
|
|
||||||
internal/ceres/solver.cc
|
|
||||||
internal/ceres/solver_utils.cc
|
|
||||||
internal/ceres/sparse_cholesky.cc
|
|
||||||
internal/ceres/sparse_matrix.cc
|
|
||||||
internal/ceres/sparse_normal_cholesky_solver.cc
|
|
||||||
internal/ceres/split.cc
|
|
||||||
internal/ceres/stringprintf.cc
|
|
||||||
internal/ceres/subset_preconditioner.cc
|
|
||||||
internal/ceres/suitesparse.cc
|
|
||||||
internal/ceres/thread_pool.cc
|
|
||||||
internal/ceres/thread_token_provider.cc
|
|
||||||
internal/ceres/triplet_sparse_matrix.cc
|
|
||||||
internal/ceres/trust_region_minimizer.cc
|
|
||||||
internal/ceres/trust_region_preprocessor.cc
|
|
||||||
internal/ceres/trust_region_step_evaluator.cc
|
|
||||||
internal/ceres/trust_region_strategy.cc
|
|
||||||
internal/ceres/types.cc
|
|
||||||
internal/ceres/visibility_based_preconditioner.cc
|
|
||||||
internal/ceres/visibility.cc
|
|
||||||
internal/ceres/wall_time.cc
|
|
||||||
|
|
||||||
include/ceres/autodiff_cost_function.h
|
include/ceres/autodiff_cost_function.h
|
||||||
include/ceres/autodiff_first_order_function.h
|
include/ceres/autodiff_local_parameterization.h
|
||||||
include/ceres/autodiff_local_parameterization.h
|
include/ceres/c_api.h
|
||||||
include/ceres/c_api.h
|
include/ceres/ceres.h
|
||||||
include/ceres/ceres.h
|
include/ceres/conditioned_cost_function.h
|
||||||
include/ceres/conditioned_cost_function.h
|
include/ceres/cost_function.h
|
||||||
include/ceres/context.h
|
include/ceres/cost_function_to_functor.h
|
||||||
include/ceres/cost_function.h
|
include/ceres/covariance.h
|
||||||
include/ceres/cost_function_to_functor.h
|
include/ceres/crs_matrix.h
|
||||||
include/ceres/covariance.h
|
include/ceres/dynamic_autodiff_cost_function.h
|
||||||
include/ceres/crs_matrix.h
|
include/ceres/dynamic_cost_function_to_functor.h
|
||||||
include/ceres/cubic_interpolation.h
|
include/ceres/dynamic_numeric_diff_cost_function.h
|
||||||
include/ceres/dynamic_autodiff_cost_function.h
|
include/ceres/fpclassify.h
|
||||||
include/ceres/dynamic_cost_function.h
|
include/ceres/gradient_checker.h
|
||||||
include/ceres/dynamic_cost_function_to_functor.h
|
include/ceres/gradient_problem.h
|
||||||
include/ceres/dynamic_numeric_diff_cost_function.h
|
include/ceres/gradient_problem_solver.h
|
||||||
include/ceres/evaluation_callback.h
|
include/ceres/internal/autodiff.h
|
||||||
include/ceres/first_order_function.h
|
include/ceres/internal/disable_warnings.h
|
||||||
include/ceres/gradient_checker.h
|
include/ceres/internal/eigen.h
|
||||||
include/ceres/gradient_problem.h
|
include/ceres/internal/fixed_array.h
|
||||||
include/ceres/gradient_problem_solver.h
|
include/ceres/internal/macros.h
|
||||||
include/ceres/internal/array_selector.h
|
include/ceres/internal/manual_constructor.h
|
||||||
include/ceres/internal/autodiff.h
|
include/ceres/internal/numeric_diff.h
|
||||||
include/ceres/internal/disable_warnings.h
|
include/ceres/internal/port.h
|
||||||
include/ceres/internal/eigen.h
|
include/ceres/internal/reenable_warnings.h
|
||||||
include/ceres/internal/fixed_array.h
|
include/ceres/internal/scoped_ptr.h
|
||||||
include/ceres/internal/householder_vector.h
|
include/ceres/internal/variadic_evaluate.h
|
||||||
include/ceres/internal/integer_sequence_algorithm.h
|
include/ceres/iteration_callback.h
|
||||||
include/ceres/internal/line_parameterization.h
|
include/ceres/jet.h
|
||||||
include/ceres/internal/memory.h
|
include/ceres/local_parameterization.h
|
||||||
include/ceres/internal/numeric_diff.h
|
include/ceres/loss_function.h
|
||||||
include/ceres/internal/parameter_dims.h
|
include/ceres/normal_prior.h
|
||||||
include/ceres/internal/port.h
|
include/ceres/numeric_diff_cost_function.h
|
||||||
include/ceres/internal/reenable_warnings.h
|
include/ceres/numeric_diff_options.h
|
||||||
include/ceres/internal/variadic_evaluate.h
|
include/ceres/ordered_groups.h
|
||||||
include/ceres/iteration_callback.h
|
include/ceres/problem.h
|
||||||
include/ceres/jet.h
|
include/ceres/rotation.h
|
||||||
include/ceres/local_parameterization.h
|
include/ceres/sized_cost_function.h
|
||||||
include/ceres/loss_function.h
|
include/ceres/solver.h
|
||||||
include/ceres/normal_prior.h
|
include/ceres/types.h
|
||||||
include/ceres/numeric_diff_cost_function.h
|
include/ceres/version.h
|
||||||
include/ceres/numeric_diff_options.h
|
internal/ceres/array_utils.h
|
||||||
include/ceres/ordered_groups.h
|
internal/ceres/blas.h
|
||||||
include/ceres/problem.h
|
internal/ceres/block_evaluate_preparer.h
|
||||||
include/ceres/rotation.h
|
internal/ceres/block_jacobian_writer.h
|
||||||
include/ceres/sized_cost_function.h
|
internal/ceres/block_jacobi_preconditioner.h
|
||||||
include/ceres/solver.h
|
internal/ceres/block_random_access_dense_matrix.h
|
||||||
include/ceres/tiny_solver_autodiff_function.h
|
internal/ceres/block_random_access_diagonal_matrix.h
|
||||||
include/ceres/tiny_solver_cost_function_adapter.h
|
internal/ceres/block_random_access_matrix.h
|
||||||
include/ceres/tiny_solver.h
|
internal/ceres/block_random_access_sparse_matrix.h
|
||||||
include/ceres/types.h
|
internal/ceres/block_sparse_matrix.h
|
||||||
include/ceres/version.h
|
internal/ceres/block_structure.h
|
||||||
internal/ceres/accelerate_sparse.h
|
internal/ceres/callbacks.h
|
||||||
internal/ceres/array_utils.h
|
internal/ceres/casts.h
|
||||||
internal/ceres/blas.h
|
internal/ceres/cgnr_linear_operator.h
|
||||||
internal/ceres/block_evaluate_preparer.h
|
internal/ceres/cgnr_solver.h
|
||||||
internal/ceres/block_jacobian_writer.h
|
internal/ceres/collections_port.h
|
||||||
internal/ceres/block_jacobi_preconditioner.h
|
internal/ceres/compressed_col_sparse_matrix_utils.h
|
||||||
internal/ceres/block_random_access_dense_matrix.h
|
internal/ceres/compressed_row_jacobian_writer.h
|
||||||
internal/ceres/block_random_access_diagonal_matrix.h
|
internal/ceres/compressed_row_sparse_matrix.h
|
||||||
internal/ceres/block_random_access_matrix.h
|
internal/ceres/conjugate_gradients_solver.h
|
||||||
internal/ceres/block_random_access_sparse_matrix.h
|
internal/ceres/coordinate_descent_minimizer.h
|
||||||
internal/ceres/block_sparse_matrix.h
|
internal/ceres/corrector.h
|
||||||
internal/ceres/block_structure.h
|
internal/ceres/covariance_impl.h
|
||||||
internal/ceres/callbacks.h
|
internal/ceres/cxsparse.h
|
||||||
internal/ceres/canonical_views_clustering.h
|
internal/ceres/dense_jacobian_writer.h
|
||||||
internal/ceres/casts.h
|
internal/ceres/dense_normal_cholesky_solver.h
|
||||||
internal/ceres/cgnr_linear_operator.h
|
internal/ceres/dense_qr_solver.h
|
||||||
internal/ceres/cgnr_solver.h
|
internal/ceres/dense_sparse_matrix.h
|
||||||
internal/ceres/compressed_col_sparse_matrix_utils.h
|
internal/ceres/detect_structure.h
|
||||||
internal/ceres/compressed_row_jacobian_writer.h
|
internal/ceres/dogleg_strategy.h
|
||||||
internal/ceres/compressed_row_sparse_matrix.h
|
internal/ceres/dynamic_compressed_row_finalizer.h
|
||||||
internal/ceres/concurrent_queue.h
|
internal/ceres/dynamic_compressed_row_jacobian_writer.h
|
||||||
internal/ceres/conjugate_gradients_solver.h
|
internal/ceres/dynamic_compressed_row_sparse_matrix.h
|
||||||
internal/ceres/context_impl.h
|
internal/ceres/evaluator.h
|
||||||
internal/ceres/coordinate_descent_minimizer.h
|
internal/ceres/execution_summary.h
|
||||||
internal/ceres/corrector.h
|
internal/ceres/file.h
|
||||||
internal/ceres/covariance_impl.h
|
internal/ceres/gradient_checking_cost_function.h
|
||||||
internal/ceres/cxsparse.h
|
internal/ceres/gradient_problem_evaluator.h
|
||||||
internal/ceres/dense_jacobian_writer.h
|
internal/ceres/graph_algorithms.h
|
||||||
internal/ceres/dense_normal_cholesky_solver.h
|
internal/ceres/graph.h
|
||||||
internal/ceres/dense_qr_solver.h
|
internal/ceres/householder_vector.h
|
||||||
internal/ceres/dense_sparse_matrix.h
|
internal/ceres/implicit_schur_complement.h
|
||||||
internal/ceres/detect_structure.h
|
internal/ceres/integral_types.h
|
||||||
internal/ceres/dogleg_strategy.h
|
internal/ceres/is_close.h
|
||||||
internal/ceres/dynamic_compressed_row_finalizer.h
|
internal/ceres/iterative_schur_complement_solver.h
|
||||||
internal/ceres/dynamic_compressed_row_jacobian_writer.h
|
internal/ceres/lapack.h
|
||||||
internal/ceres/dynamic_compressed_row_sparse_matrix.h
|
internal/ceres/levenberg_marquardt_strategy.h
|
||||||
internal/ceres/dynamic_sparse_normal_cholesky_solver.h
|
internal/ceres/linear_least_squares_problems.h
|
||||||
internal/ceres/eigensparse.h
|
internal/ceres/linear_operator.h
|
||||||
internal/ceres/evaluator.h
|
internal/ceres/linear_solver.h
|
||||||
internal/ceres/execution_summary.h
|
internal/ceres/line_search_direction.h
|
||||||
internal/ceres/file.h
|
internal/ceres/line_search.h
|
||||||
internal/ceres/float_cxsparse.h
|
internal/ceres/line_search_minimizer.h
|
||||||
internal/ceres/float_suitesparse.h
|
internal/ceres/line_search_preprocessor.h
|
||||||
internal/ceres/function_sample.h
|
internal/ceres/low_rank_inverse_hessian.h
|
||||||
internal/ceres/gradient_checking_cost_function.h
|
internal/ceres/map_util.h
|
||||||
internal/ceres/gradient_problem_evaluator.h
|
internal/ceres/minimizer.h
|
||||||
internal/ceres/graph_algorithms.h
|
internal/ceres/mutex.h
|
||||||
internal/ceres/graph.h
|
internal/ceres/parameter_block.h
|
||||||
internal/ceres/implicit_schur_complement.h
|
internal/ceres/parameter_block_ordering.h
|
||||||
internal/ceres/inner_product_computer.h
|
internal/ceres/partitioned_matrix_view.h
|
||||||
internal/ceres/invert_psd_matrix.h
|
internal/ceres/partitioned_matrix_view_impl.h
|
||||||
internal/ceres/is_close.h
|
internal/ceres/polynomial.h
|
||||||
internal/ceres/iterative_refiner.h
|
internal/ceres/preconditioner.h
|
||||||
internal/ceres/iterative_schur_complement_solver.h
|
internal/ceres/preprocessor.h
|
||||||
internal/ceres/lapack.h
|
internal/ceres/problem_impl.h
|
||||||
internal/ceres/levenberg_marquardt_strategy.h
|
internal/ceres/program_evaluator.h
|
||||||
internal/ceres/linear_least_squares_problems.h
|
internal/ceres/program.h
|
||||||
internal/ceres/linear_operator.h
|
internal/ceres/random.h
|
||||||
internal/ceres/linear_solver.h
|
internal/ceres/reorder_program.h
|
||||||
internal/ceres/line_search_direction.h
|
internal/ceres/residual_block.h
|
||||||
internal/ceres/line_search.h
|
internal/ceres/residual_block_utils.h
|
||||||
internal/ceres/line_search_minimizer.h
|
internal/ceres/schur_complement_solver.h
|
||||||
internal/ceres/line_search_preprocessor.h
|
internal/ceres/schur_eliminator.h
|
||||||
internal/ceres/low_rank_inverse_hessian.h
|
internal/ceres/schur_eliminator_impl.h
|
||||||
internal/ceres/map_util.h
|
internal/ceres/schur_jacobi_preconditioner.h
|
||||||
internal/ceres/minimizer.h
|
internal/ceres/scratch_evaluate_preparer.h
|
||||||
internal/ceres/pair_hash.h
|
internal/ceres/small_blas.h
|
||||||
internal/ceres/parallel_for.h
|
internal/ceres/solver_utils.h
|
||||||
internal/ceres/parallel_utils.h
|
internal/ceres/sparse_matrix.h
|
||||||
internal/ceres/parameter_block.h
|
internal/ceres/sparse_normal_cholesky_solver.h
|
||||||
internal/ceres/parameter_block_ordering.h
|
internal/ceres/split.h
|
||||||
internal/ceres/partitioned_matrix_view.h
|
internal/ceres/stl_util.h
|
||||||
internal/ceres/partitioned_matrix_view_impl.h
|
internal/ceres/stringprintf.h
|
||||||
internal/ceres/polynomial.h
|
internal/ceres/suitesparse.h
|
||||||
internal/ceres/preconditioner.h
|
internal/ceres/triplet_sparse_matrix.h
|
||||||
internal/ceres/preprocessor.h
|
internal/ceres/trust_region_minimizer.h
|
||||||
internal/ceres/problem_impl.h
|
internal/ceres/trust_region_preprocessor.h
|
||||||
internal/ceres/program_evaluator.h
|
internal/ceres/trust_region_step_evaluator.h
|
||||||
internal/ceres/program.h
|
internal/ceres/trust_region_strategy.h
|
||||||
internal/ceres/random.h
|
internal/ceres/visibility_based_preconditioner.h
|
||||||
internal/ceres/reorder_program.h
|
internal/ceres/wall_time.h
|
||||||
internal/ceres/residual_block.h
|
|
||||||
internal/ceres/residual_block_utils.h
|
|
||||||
internal/ceres/schur_complement_solver.h
|
|
||||||
internal/ceres/schur_eliminator.h
|
|
||||||
internal/ceres/schur_eliminator_impl.h
|
|
||||||
internal/ceres/schur_jacobi_preconditioner.h
|
|
||||||
internal/ceres/schur_templates.h
|
|
||||||
internal/ceres/scoped_thread_token.h
|
|
||||||
internal/ceres/scratch_evaluate_preparer.h
|
|
||||||
internal/ceres/single_linkage_clustering.h
|
|
||||||
internal/ceres/small_blas_generic.h
|
|
||||||
internal/ceres/small_blas.h
|
|
||||||
internal/ceres/solver_utils.h
|
|
||||||
internal/ceres/sparse_cholesky.h
|
|
||||||
internal/ceres/sparse_matrix.h
|
|
||||||
internal/ceres/sparse_normal_cholesky_solver.h
|
|
||||||
internal/ceres/split.h
|
|
||||||
internal/ceres/stl_util.h
|
|
||||||
internal/ceres/stringprintf.h
|
|
||||||
internal/ceres/subset_preconditioner.h
|
|
||||||
internal/ceres/suitesparse.h
|
|
||||||
internal/ceres/thread_pool.h
|
|
||||||
internal/ceres/thread_token_provider.h
|
|
||||||
internal/ceres/triplet_sparse_matrix.h
|
|
||||||
internal/ceres/trust_region_minimizer.h
|
|
||||||
internal/ceres/trust_region_preprocessor.h
|
|
||||||
internal/ceres/trust_region_step_evaluator.h
|
|
||||||
internal/ceres/trust_region_strategy.h
|
|
||||||
internal/ceres/visibility_based_preconditioner.h
|
|
||||||
internal/ceres/visibility.h
|
|
||||||
internal/ceres/wall_time.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LIB
|
set(LIB
|
||||||
@@ -319,48 +263,44 @@ set(LIB
|
|||||||
|
|
||||||
if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
|
if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_2.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_2.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_3.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_4.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_4.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_d.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_3_3.cc
|
internal/ceres/generated/partitioned_matrix_view_2_3_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_3_4.cc
|
internal/ceres/generated/partitioned_matrix_view_2_3_4.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_3_6.cc
|
internal/ceres/generated/partitioned_matrix_view_2_3_6.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_3_9.cc
|
internal/ceres/generated/partitioned_matrix_view_2_3_9.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
|
internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_4.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_4.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_6.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_8.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_8.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_9.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_9.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_d.cc
|
internal/ceres/generated/partitioned_matrix_view_2_d_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_d_d.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_2.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_3_3_3.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_2.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_4.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_3.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_4.cc
|
internal/ceres/generated/schur_eliminator_2_2_2.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_d.cc
|
internal/ceres/generated/schur_eliminator_2_2_3.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_2_2.cc
|
internal/ceres/generated/schur_eliminator_2_2_4.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_2_3.cc
|
internal/ceres/generated/schur_eliminator_2_2_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_2_4.cc
|
internal/ceres/generated/schur_eliminator_2_3_3.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_2_d.cc
|
internal/ceres/generated/schur_eliminator_2_3_4.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_3_3.cc
|
internal/ceres/generated/schur_eliminator_2_3_6.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_3_4.cc
|
internal/ceres/generated/schur_eliminator_2_3_9.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_3_6.cc
|
internal/ceres/generated/schur_eliminator_2_3_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_3_9.cc
|
internal/ceres/generated/schur_eliminator_2_4_3.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_3_d.cc
|
internal/ceres/generated/schur_eliminator_2_4_4.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_3.cc
|
internal/ceres/generated/schur_eliminator_2_4_8.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_4.cc
|
internal/ceres/generated/schur_eliminator_2_4_9.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_6.cc
|
internal/ceres/generated/schur_eliminator_2_4_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_8.cc
|
internal/ceres/generated/schur_eliminator_2_d_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_9.cc
|
internal/ceres/generated/schur_eliminator_4_4_2.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_d.cc
|
internal/ceres/generated/schur_eliminator_4_4_3.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_d_d.cc
|
internal/ceres/generated/schur_eliminator_4_4_4.cc
|
||||||
internal/ceres/generated/schur_eliminator_3_3_3.cc
|
internal/ceres/generated/schur_eliminator_4_4_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_4_4_2.cc
|
|
||||||
internal/ceres/generated/schur_eliminator_4_4_3.cc
|
|
||||||
internal/ceres/generated/schur_eliminator_4_4_4.cc
|
|
||||||
internal/ceres/generated/schur_eliminator_4_4_d.cc
|
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DCERES_RESTRICT_SCHUR_SPECIALIZATION)
|
add_definitions(-DCERES_RESTRICT_SCHUR_SPECIALIZATION)
|
||||||
@@ -375,9 +315,13 @@ add_definitions(
|
|||||||
-DCERES_NO_SUITESPARSE
|
-DCERES_NO_SUITESPARSE
|
||||||
-DCERES_NO_CXSPARSE
|
-DCERES_NO_CXSPARSE
|
||||||
-DCERES_NO_LAPACK
|
-DCERES_NO_LAPACK
|
||||||
-DCERES_NO_ACCELERATE_SPARSE
|
|
||||||
-DCERES_HAVE_RWLOCK
|
-DCERES_HAVE_RWLOCK
|
||||||
-DCERES_USE_CXX_THREADS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WITH_OPENMP)
|
||||||
|
add_definitions(
|
||||||
|
-DCERES_USE_OPENMP
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||||
|
1095
extern/ceres/ChangeLog
vendored
1095
extern/ceres/ChangeLog
vendored
File diff suppressed because it is too large
Load Diff
9
extern/ceres/bundle.sh
vendored
9
extern/ceres/bundle.sh
vendored
@@ -9,6 +9,7 @@ fi
|
|||||||
|
|
||||||
repo="https://ceres-solver.googlesource.com/ceres-solver"
|
repo="https://ceres-solver.googlesource.com/ceres-solver"
|
||||||
branch="master"
|
branch="master"
|
||||||
|
#tag="1.4.0"
|
||||||
tag=""
|
tag=""
|
||||||
tmp=`mktemp -d`
|
tmp=`mktemp -d`
|
||||||
checkout="$tmp/ceres"
|
checkout="$tmp/ceres"
|
||||||
@@ -156,10 +157,14 @@ add_definitions(
|
|||||||
-DCERES_NO_SUITESPARSE
|
-DCERES_NO_SUITESPARSE
|
||||||
-DCERES_NO_CXSPARSE
|
-DCERES_NO_CXSPARSE
|
||||||
-DCERES_NO_LAPACK
|
-DCERES_NO_LAPACK
|
||||||
-DCERES_NO_ACCELERATE_SPARSE
|
|
||||||
-DCERES_HAVE_RWLOCK
|
-DCERES_HAVE_RWLOCK
|
||||||
-DCERES_USE_CXX_THREADS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WITH_OPENMP)
|
||||||
|
add_definitions(
|
||||||
|
-DCERES_USE_OPENMP
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
blender_add_lib(extern_ceres "\${SRC}" "\${INC}" "\${INC_SYS}" "\${LIB}")
|
blender_add_lib(extern_ceres "\${SRC}" "\${INC}" "\${INC_SYS}" "\${LIB}")
|
||||||
EOF
|
EOF
|
||||||
|
81
extern/ceres/files.txt
vendored
81
extern/ceres/files.txt
vendored
@@ -1,37 +1,29 @@
|
|||||||
include/ceres/autodiff_cost_function.h
|
include/ceres/autodiff_cost_function.h
|
||||||
include/ceres/autodiff_first_order_function.h
|
|
||||||
include/ceres/autodiff_local_parameterization.h
|
include/ceres/autodiff_local_parameterization.h
|
||||||
include/ceres/c_api.h
|
include/ceres/c_api.h
|
||||||
include/ceres/ceres.h
|
include/ceres/ceres.h
|
||||||
include/ceres/conditioned_cost_function.h
|
include/ceres/conditioned_cost_function.h
|
||||||
include/ceres/context.h
|
|
||||||
include/ceres/cost_function.h
|
include/ceres/cost_function.h
|
||||||
include/ceres/cost_function_to_functor.h
|
include/ceres/cost_function_to_functor.h
|
||||||
include/ceres/covariance.h
|
include/ceres/covariance.h
|
||||||
include/ceres/crs_matrix.h
|
include/ceres/crs_matrix.h
|
||||||
include/ceres/cubic_interpolation.h
|
|
||||||
include/ceres/dynamic_autodiff_cost_function.h
|
include/ceres/dynamic_autodiff_cost_function.h
|
||||||
include/ceres/dynamic_cost_function.h
|
|
||||||
include/ceres/dynamic_cost_function_to_functor.h
|
include/ceres/dynamic_cost_function_to_functor.h
|
||||||
include/ceres/dynamic_numeric_diff_cost_function.h
|
include/ceres/dynamic_numeric_diff_cost_function.h
|
||||||
include/ceres/evaluation_callback.h
|
include/ceres/fpclassify.h
|
||||||
include/ceres/first_order_function.h
|
|
||||||
include/ceres/gradient_checker.h
|
include/ceres/gradient_checker.h
|
||||||
include/ceres/gradient_problem.h
|
include/ceres/gradient_problem.h
|
||||||
include/ceres/gradient_problem_solver.h
|
include/ceres/gradient_problem_solver.h
|
||||||
include/ceres/internal/array_selector.h
|
|
||||||
include/ceres/internal/autodiff.h
|
include/ceres/internal/autodiff.h
|
||||||
include/ceres/internal/disable_warnings.h
|
include/ceres/internal/disable_warnings.h
|
||||||
include/ceres/internal/eigen.h
|
include/ceres/internal/eigen.h
|
||||||
include/ceres/internal/fixed_array.h
|
include/ceres/internal/fixed_array.h
|
||||||
include/ceres/internal/householder_vector.h
|
include/ceres/internal/macros.h
|
||||||
include/ceres/internal/integer_sequence_algorithm.h
|
include/ceres/internal/manual_constructor.h
|
||||||
include/ceres/internal/line_parameterization.h
|
|
||||||
include/ceres/internal/memory.h
|
|
||||||
include/ceres/internal/numeric_diff.h
|
include/ceres/internal/numeric_diff.h
|
||||||
include/ceres/internal/parameter_dims.h
|
|
||||||
include/ceres/internal/port.h
|
include/ceres/internal/port.h
|
||||||
include/ceres/internal/reenable_warnings.h
|
include/ceres/internal/reenable_warnings.h
|
||||||
|
include/ceres/internal/scoped_ptr.h
|
||||||
include/ceres/internal/variadic_evaluate.h
|
include/ceres/internal/variadic_evaluate.h
|
||||||
include/ceres/iteration_callback.h
|
include/ceres/iteration_callback.h
|
||||||
include/ceres/jet.h
|
include/ceres/jet.h
|
||||||
@@ -45,13 +37,8 @@ include/ceres/problem.h
|
|||||||
include/ceres/rotation.h
|
include/ceres/rotation.h
|
||||||
include/ceres/sized_cost_function.h
|
include/ceres/sized_cost_function.h
|
||||||
include/ceres/solver.h
|
include/ceres/solver.h
|
||||||
include/ceres/tiny_solver_autodiff_function.h
|
|
||||||
include/ceres/tiny_solver_cost_function_adapter.h
|
|
||||||
include/ceres/tiny_solver.h
|
|
||||||
include/ceres/types.h
|
include/ceres/types.h
|
||||||
include/ceres/version.h
|
include/ceres/version.h
|
||||||
internal/ceres/accelerate_sparse.cc
|
|
||||||
internal/ceres/accelerate_sparse.h
|
|
||||||
internal/ceres/array_utils.cc
|
internal/ceres/array_utils.cc
|
||||||
internal/ceres/array_utils.h
|
internal/ceres/array_utils.h
|
||||||
internal/ceres/blas.cc
|
internal/ceres/blas.cc
|
||||||
@@ -76,26 +63,21 @@ internal/ceres/block_structure.cc
|
|||||||
internal/ceres/block_structure.h
|
internal/ceres/block_structure.h
|
||||||
internal/ceres/callbacks.cc
|
internal/ceres/callbacks.cc
|
||||||
internal/ceres/callbacks.h
|
internal/ceres/callbacks.h
|
||||||
internal/ceres/canonical_views_clustering.cc
|
|
||||||
internal/ceres/canonical_views_clustering.h
|
|
||||||
internal/ceres/c_api.cc
|
internal/ceres/c_api.cc
|
||||||
internal/ceres/casts.h
|
internal/ceres/casts.h
|
||||||
internal/ceres/cgnr_linear_operator.h
|
internal/ceres/cgnr_linear_operator.h
|
||||||
internal/ceres/cgnr_solver.cc
|
internal/ceres/cgnr_solver.cc
|
||||||
internal/ceres/cgnr_solver.h
|
internal/ceres/cgnr_solver.h
|
||||||
|
internal/ceres/collections_port.h
|
||||||
internal/ceres/compressed_col_sparse_matrix_utils.cc
|
internal/ceres/compressed_col_sparse_matrix_utils.cc
|
||||||
internal/ceres/compressed_col_sparse_matrix_utils.h
|
internal/ceres/compressed_col_sparse_matrix_utils.h
|
||||||
internal/ceres/compressed_row_jacobian_writer.cc
|
internal/ceres/compressed_row_jacobian_writer.cc
|
||||||
internal/ceres/compressed_row_jacobian_writer.h
|
internal/ceres/compressed_row_jacobian_writer.h
|
||||||
internal/ceres/compressed_row_sparse_matrix.cc
|
internal/ceres/compressed_row_sparse_matrix.cc
|
||||||
internal/ceres/compressed_row_sparse_matrix.h
|
internal/ceres/compressed_row_sparse_matrix.h
|
||||||
internal/ceres/concurrent_queue.h
|
|
||||||
internal/ceres/conditioned_cost_function.cc
|
internal/ceres/conditioned_cost_function.cc
|
||||||
internal/ceres/conjugate_gradients_solver.cc
|
internal/ceres/conjugate_gradients_solver.cc
|
||||||
internal/ceres/conjugate_gradients_solver.h
|
internal/ceres/conjugate_gradients_solver.h
|
||||||
internal/ceres/context.cc
|
|
||||||
internal/ceres/context_impl.cc
|
|
||||||
internal/ceres/context_impl.h
|
|
||||||
internal/ceres/coordinate_descent_minimizer.cc
|
internal/ceres/coordinate_descent_minimizer.cc
|
||||||
internal/ceres/coordinate_descent_minimizer.h
|
internal/ceres/coordinate_descent_minimizer.h
|
||||||
internal/ceres/corrector.cc
|
internal/ceres/corrector.cc
|
||||||
@@ -103,7 +85,6 @@ internal/ceres/corrector.h
|
|||||||
internal/ceres/covariance.cc
|
internal/ceres/covariance.cc
|
||||||
internal/ceres/covariance_impl.cc
|
internal/ceres/covariance_impl.cc
|
||||||
internal/ceres/covariance_impl.h
|
internal/ceres/covariance_impl.h
|
||||||
internal/ceres/cxsparse.cc
|
|
||||||
internal/ceres/cxsparse.h
|
internal/ceres/cxsparse.h
|
||||||
internal/ceres/dense_jacobian_writer.h
|
internal/ceres/dense_jacobian_writer.h
|
||||||
internal/ceres/dense_normal_cholesky_solver.cc
|
internal/ceres/dense_normal_cholesky_solver.cc
|
||||||
@@ -121,21 +102,11 @@ internal/ceres/dynamic_compressed_row_jacobian_writer.cc
|
|||||||
internal/ceres/dynamic_compressed_row_jacobian_writer.h
|
internal/ceres/dynamic_compressed_row_jacobian_writer.h
|
||||||
internal/ceres/dynamic_compressed_row_sparse_matrix.cc
|
internal/ceres/dynamic_compressed_row_sparse_matrix.cc
|
||||||
internal/ceres/dynamic_compressed_row_sparse_matrix.h
|
internal/ceres/dynamic_compressed_row_sparse_matrix.h
|
||||||
internal/ceres/dynamic_sparse_normal_cholesky_solver.cc
|
|
||||||
internal/ceres/dynamic_sparse_normal_cholesky_solver.h
|
|
||||||
internal/ceres/eigensparse.cc
|
|
||||||
internal/ceres/eigensparse.h
|
|
||||||
internal/ceres/evaluator.cc
|
internal/ceres/evaluator.cc
|
||||||
internal/ceres/evaluator.h
|
internal/ceres/evaluator.h
|
||||||
internal/ceres/execution_summary.h
|
internal/ceres/execution_summary.h
|
||||||
internal/ceres/file.cc
|
internal/ceres/file.cc
|
||||||
internal/ceres/file.h
|
internal/ceres/file.h
|
||||||
internal/ceres/float_cxsparse.cc
|
|
||||||
internal/ceres/float_cxsparse.h
|
|
||||||
internal/ceres/float_suitesparse.cc
|
|
||||||
internal/ceres/float_suitesparse.h
|
|
||||||
internal/ceres/function_sample.cc
|
|
||||||
internal/ceres/function_sample.h
|
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_2.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_2.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_3.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_2_4.cc
|
internal/ceres/generated/partitioned_matrix_view_2_2_4.cc
|
||||||
@@ -147,12 +118,10 @@ internal/ceres/generated/partitioned_matrix_view_2_3_9.cc
|
|||||||
internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
|
internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_4.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_4.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_6.cc
|
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_8.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_8.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_9.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_9.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_4_d.cc
|
internal/ceres/generated/partitioned_matrix_view_2_4_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_2_d_d.cc
|
internal/ceres/generated/partitioned_matrix_view_2_d_d.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_3_3_3.cc
|
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_2.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_2.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_3.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_3.cc
|
||||||
internal/ceres/generated/partitioned_matrix_view_4_4_4.cc
|
internal/ceres/generated/partitioned_matrix_view_4_4_4.cc
|
||||||
@@ -169,18 +138,17 @@ internal/ceres/generated/schur_eliminator_2_3_9.cc
|
|||||||
internal/ceres/generated/schur_eliminator_2_3_d.cc
|
internal/ceres/generated/schur_eliminator_2_3_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_3.cc
|
internal/ceres/generated/schur_eliminator_2_4_3.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_4.cc
|
internal/ceres/generated/schur_eliminator_2_4_4.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_6.cc
|
|
||||||
internal/ceres/generated/schur_eliminator_2_4_8.cc
|
internal/ceres/generated/schur_eliminator_2_4_8.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_9.cc
|
internal/ceres/generated/schur_eliminator_2_4_9.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_4_d.cc
|
internal/ceres/generated/schur_eliminator_2_4_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_2_d_d.cc
|
internal/ceres/generated/schur_eliminator_2_d_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_3_3_3.cc
|
|
||||||
internal/ceres/generated/schur_eliminator_4_4_2.cc
|
internal/ceres/generated/schur_eliminator_4_4_2.cc
|
||||||
internal/ceres/generated/schur_eliminator_4_4_3.cc
|
internal/ceres/generated/schur_eliminator_4_4_3.cc
|
||||||
internal/ceres/generated/schur_eliminator_4_4_4.cc
|
internal/ceres/generated/schur_eliminator_4_4_4.cc
|
||||||
internal/ceres/generated/schur_eliminator_4_4_d.cc
|
internal/ceres/generated/schur_eliminator_4_4_d.cc
|
||||||
internal/ceres/generated/schur_eliminator_d_d_d.cc
|
internal/ceres/generated/schur_eliminator_d_d_d.cc
|
||||||
internal/ceres/generate_template_specializations.py
|
internal/ceres/generate_eliminator_specialization.py
|
||||||
|
internal/ceres/generate_partitioned_matrix_view_specializations.py
|
||||||
internal/ceres/gradient_checker.cc
|
internal/ceres/gradient_checker.cc
|
||||||
internal/ceres/gradient_checking_cost_function.cc
|
internal/ceres/gradient_checking_cost_function.cc
|
||||||
internal/ceres/gradient_checking_cost_function.h
|
internal/ceres/gradient_checking_cost_function.h
|
||||||
@@ -189,15 +157,12 @@ internal/ceres/gradient_problem_evaluator.h
|
|||||||
internal/ceres/gradient_problem_solver.cc
|
internal/ceres/gradient_problem_solver.cc
|
||||||
internal/ceres/graph_algorithms.h
|
internal/ceres/graph_algorithms.h
|
||||||
internal/ceres/graph.h
|
internal/ceres/graph.h
|
||||||
|
internal/ceres/householder_vector.h
|
||||||
internal/ceres/implicit_schur_complement.cc
|
internal/ceres/implicit_schur_complement.cc
|
||||||
internal/ceres/implicit_schur_complement.h
|
internal/ceres/implicit_schur_complement.h
|
||||||
internal/ceres/inner_product_computer.cc
|
internal/ceres/integral_types.h
|
||||||
internal/ceres/inner_product_computer.h
|
|
||||||
internal/ceres/invert_psd_matrix.h
|
|
||||||
internal/ceres/is_close.cc
|
internal/ceres/is_close.cc
|
||||||
internal/ceres/is_close.h
|
internal/ceres/is_close.h
|
||||||
internal/ceres/iterative_refiner.cc
|
|
||||||
internal/ceres/iterative_refiner.h
|
|
||||||
internal/ceres/iterative_schur_complement_solver.cc
|
internal/ceres/iterative_schur_complement_solver.cc
|
||||||
internal/ceres/iterative_schur_complement_solver.h
|
internal/ceres/iterative_schur_complement_solver.h
|
||||||
internal/ceres/lapack.cc
|
internal/ceres/lapack.cc
|
||||||
@@ -225,21 +190,14 @@ internal/ceres/low_rank_inverse_hessian.h
|
|||||||
internal/ceres/map_util.h
|
internal/ceres/map_util.h
|
||||||
internal/ceres/minimizer.cc
|
internal/ceres/minimizer.cc
|
||||||
internal/ceres/minimizer.h
|
internal/ceres/minimizer.h
|
||||||
|
internal/ceres/mutex.h
|
||||||
internal/ceres/normal_prior.cc
|
internal/ceres/normal_prior.cc
|
||||||
internal/ceres/pair_hash.h
|
|
||||||
internal/ceres/parallel_for_cxx.cc
|
|
||||||
internal/ceres/parallel_for.h
|
|
||||||
internal/ceres/parallel_for_nothreads.cc
|
|
||||||
internal/ceres/parallel_for_openmp.cc
|
|
||||||
internal/ceres/parallel_utils.cc
|
|
||||||
internal/ceres/parallel_utils.h
|
|
||||||
internal/ceres/parameter_block.h
|
internal/ceres/parameter_block.h
|
||||||
internal/ceres/parameter_block_ordering.cc
|
internal/ceres/parameter_block_ordering.cc
|
||||||
internal/ceres/parameter_block_ordering.h
|
internal/ceres/parameter_block_ordering.h
|
||||||
internal/ceres/partitioned_matrix_view.cc
|
internal/ceres/partitioned_matrix_view.cc
|
||||||
internal/ceres/partitioned_matrix_view.h
|
internal/ceres/partitioned_matrix_view.h
|
||||||
internal/ceres/partitioned_matrix_view_impl.h
|
internal/ceres/partitioned_matrix_view_impl.h
|
||||||
internal/ceres/partitioned_matrix_view_template.py
|
|
||||||
internal/ceres/polynomial.cc
|
internal/ceres/polynomial.cc
|
||||||
internal/ceres/polynomial.h
|
internal/ceres/polynomial.h
|
||||||
internal/ceres/preconditioner.cc
|
internal/ceres/preconditioner.cc
|
||||||
@@ -264,23 +222,14 @@ internal/ceres/schur_complement_solver.h
|
|||||||
internal/ceres/schur_eliminator.cc
|
internal/ceres/schur_eliminator.cc
|
||||||
internal/ceres/schur_eliminator.h
|
internal/ceres/schur_eliminator.h
|
||||||
internal/ceres/schur_eliminator_impl.h
|
internal/ceres/schur_eliminator_impl.h
|
||||||
internal/ceres/schur_eliminator_template.py
|
|
||||||
internal/ceres/schur_jacobi_preconditioner.cc
|
internal/ceres/schur_jacobi_preconditioner.cc
|
||||||
internal/ceres/schur_jacobi_preconditioner.h
|
internal/ceres/schur_jacobi_preconditioner.h
|
||||||
internal/ceres/schur_templates.cc
|
|
||||||
internal/ceres/schur_templates.h
|
|
||||||
internal/ceres/scoped_thread_token.h
|
|
||||||
internal/ceres/scratch_evaluate_preparer.cc
|
internal/ceres/scratch_evaluate_preparer.cc
|
||||||
internal/ceres/scratch_evaluate_preparer.h
|
internal/ceres/scratch_evaluate_preparer.h
|
||||||
internal/ceres/single_linkage_clustering.cc
|
|
||||||
internal/ceres/single_linkage_clustering.h
|
|
||||||
internal/ceres/small_blas_generic.h
|
|
||||||
internal/ceres/small_blas.h
|
internal/ceres/small_blas.h
|
||||||
internal/ceres/solver.cc
|
internal/ceres/solver.cc
|
||||||
internal/ceres/solver_utils.cc
|
internal/ceres/solver_utils.cc
|
||||||
internal/ceres/solver_utils.h
|
internal/ceres/solver_utils.h
|
||||||
internal/ceres/sparse_cholesky.cc
|
|
||||||
internal/ceres/sparse_cholesky.h
|
|
||||||
internal/ceres/sparse_matrix.cc
|
internal/ceres/sparse_matrix.cc
|
||||||
internal/ceres/sparse_matrix.h
|
internal/ceres/sparse_matrix.h
|
||||||
internal/ceres/sparse_normal_cholesky_solver.cc
|
internal/ceres/sparse_normal_cholesky_solver.cc
|
||||||
@@ -290,14 +239,7 @@ internal/ceres/split.h
|
|||||||
internal/ceres/stl_util.h
|
internal/ceres/stl_util.h
|
||||||
internal/ceres/stringprintf.cc
|
internal/ceres/stringprintf.cc
|
||||||
internal/ceres/stringprintf.h
|
internal/ceres/stringprintf.h
|
||||||
internal/ceres/subset_preconditioner.cc
|
|
||||||
internal/ceres/subset_preconditioner.h
|
|
||||||
internal/ceres/suitesparse.cc
|
|
||||||
internal/ceres/suitesparse.h
|
internal/ceres/suitesparse.h
|
||||||
internal/ceres/thread_pool.cc
|
|
||||||
internal/ceres/thread_pool.h
|
|
||||||
internal/ceres/thread_token_provider.cc
|
|
||||||
internal/ceres/thread_token_provider.h
|
|
||||||
internal/ceres/triplet_sparse_matrix.cc
|
internal/ceres/triplet_sparse_matrix.cc
|
||||||
internal/ceres/triplet_sparse_matrix.h
|
internal/ceres/triplet_sparse_matrix.h
|
||||||
internal/ceres/trust_region_minimizer.cc
|
internal/ceres/trust_region_minimizer.cc
|
||||||
@@ -309,10 +251,7 @@ internal/ceres/trust_region_step_evaluator.h
|
|||||||
internal/ceres/trust_region_strategy.cc
|
internal/ceres/trust_region_strategy.cc
|
||||||
internal/ceres/trust_region_strategy.h
|
internal/ceres/trust_region_strategy.h
|
||||||
internal/ceres/types.cc
|
internal/ceres/types.cc
|
||||||
internal/ceres/visibility_based_preconditioner.cc
|
|
||||||
internal/ceres/visibility_based_preconditioner.h
|
internal/ceres/visibility_based_preconditioner.h
|
||||||
internal/ceres/visibility.cc
|
|
||||||
internal/ceres/visibility.h
|
|
||||||
internal/ceres/wall_time.cc
|
internal/ceres/wall_time.cc
|
||||||
internal/ceres/wall_time.h
|
internal/ceres/wall_time.h
|
||||||
config/ceres/internal/config.h
|
config/ceres/internal/config.h
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
//
|
//
|
||||||
// Create CostFunctions as needed by the least squares framework, with
|
// Create CostFunctions as needed by the least squares framework, with
|
||||||
// Jacobians computed via automatic differentiation. For more
|
// Jacobians computed via automatic differentiation. For more
|
||||||
// information on automatic differentiation, see the wikipedia article
|
// information on automatic differentation, see the wikipedia article
|
||||||
// at http://en.wikipedia.org/wiki/Automatic_differentiation
|
// at http://en.wikipedia.org/wiki/Automatic_differentiation
|
||||||
//
|
//
|
||||||
// To get an auto differentiated cost function, you must define a class with a
|
// To get an auto differentiated cost function, you must define a class with a
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
// for a series of measurements, where there is an instance of the cost function
|
// for a series of measurements, where there is an instance of the cost function
|
||||||
// for each measurement k.
|
// for each measurement k.
|
||||||
//
|
//
|
||||||
// The actual cost added to the total problem is e^2, or (k - x'y)^2; however,
|
// The actual cost added to the total problem is e^2, or (k - x'k)^2; however,
|
||||||
// the squaring is implicitly done by the optimization framework.
|
// the squaring is implicitly done by the optimization framework.
|
||||||
//
|
//
|
||||||
// To write an auto-differentiable cost function for the above model, first
|
// To write an auto-differentiable cost function for the above model, first
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
// Dimension of x ---------------+ |
|
// Dimension of x ---------------+ |
|
||||||
// Dimension of y ------------------+
|
// Dimension of y ------------------+
|
||||||
//
|
//
|
||||||
// In this example, there is usually an instance for each measurement of k.
|
// In this example, there is usually an instance for each measumerent of k.
|
||||||
//
|
//
|
||||||
// In the instantiation above, the template parameters following
|
// In the instantiation above, the template parameters following
|
||||||
// "MyScalarCostFunctor", "1, 2, 2", describe the functor as computing a
|
// "MyScalarCostFunctor", "1, 2, 2", describe the functor as computing a
|
||||||
@@ -110,8 +110,12 @@
|
|||||||
// Dimension of x ------------------------------------+ |
|
// Dimension of x ------------------------------------+ |
|
||||||
// Dimension of y ---------------------------------------+
|
// Dimension of y ---------------------------------------+
|
||||||
//
|
//
|
||||||
|
// The framework can currently accommodate cost functions of up to 10
|
||||||
|
// independent variables, and there is no limit on the dimensionality
|
||||||
|
// of each of them.
|
||||||
|
//
|
||||||
// WARNING #1: Since the functor will get instantiated with different types for
|
// WARNING #1: Since the functor will get instantiated with different types for
|
||||||
// T, you must convert from other numeric types to T before mixing
|
// T, you must to convert from other numeric types to T before mixing
|
||||||
// computations with other variables of type T. In the example above, this is
|
// computations with other variables of type T. In the example above, this is
|
||||||
// seen where instead of using k_ directly, k_ is wrapped with T(k_).
|
// seen where instead of using k_ directly, k_ is wrapped with T(k_).
|
||||||
//
|
//
|
||||||
@@ -125,9 +129,8 @@
|
|||||||
#ifndef CERES_PUBLIC_AUTODIFF_COST_FUNCTION_H_
|
#ifndef CERES_PUBLIC_AUTODIFF_COST_FUNCTION_H_
|
||||||
#define CERES_PUBLIC_AUTODIFF_COST_FUNCTION_H_
|
#define CERES_PUBLIC_AUTODIFF_COST_FUNCTION_H_
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "ceres/internal/autodiff.h"
|
#include "ceres/internal/autodiff.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
#include "ceres/sized_cost_function.h"
|
#include "ceres/sized_cost_function.h"
|
||||||
#include "ceres/types.h"
|
#include "ceres/types.h"
|
||||||
#include "glog/logging.h"
|
#include "glog/logging.h"
|
||||||
@@ -135,7 +138,7 @@
|
|||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
// A cost function which computes the derivative of the cost with respect to
|
// A cost function which computes the derivative of the cost with respect to
|
||||||
// the parameters (a.k.a. the jacobian) using an auto differentiation framework.
|
// the parameters (a.k.a. the jacobian) using an autodifferentiation framework.
|
||||||
// The first template argument is the functor object, described in the header
|
// The first template argument is the functor object, described in the header
|
||||||
// comment. The second argument is the dimension of the residual (or
|
// comment. The second argument is the dimension of the residual (or
|
||||||
// ceres::DYNAMIC to indicate it will be set at runtime), and subsequent
|
// ceres::DYNAMIC to indicate it will be set at runtime), and subsequent
|
||||||
@@ -150,15 +153,27 @@ namespace ceres {
|
|||||||
// of residuals for a single autodiff cost function at runtime.
|
// of residuals for a single autodiff cost function at runtime.
|
||||||
template <typename CostFunctor,
|
template <typename CostFunctor,
|
||||||
int kNumResiduals, // Number of residuals, or ceres::DYNAMIC.
|
int kNumResiduals, // Number of residuals, or ceres::DYNAMIC.
|
||||||
int... Ns> // Number of parameters in each parameter block.
|
int N0, // Number of parameters in block 0.
|
||||||
class AutoDiffCostFunction : public SizedCostFunction<kNumResiduals, Ns...> {
|
int N1 = 0, // Number of parameters in block 1.
|
||||||
|
int N2 = 0, // Number of parameters in block 2.
|
||||||
|
int N3 = 0, // Number of parameters in block 3.
|
||||||
|
int N4 = 0, // Number of parameters in block 4.
|
||||||
|
int N5 = 0, // Number of parameters in block 5.
|
||||||
|
int N6 = 0, // Number of parameters in block 6.
|
||||||
|
int N7 = 0, // Number of parameters in block 7.
|
||||||
|
int N8 = 0, // Number of parameters in block 8.
|
||||||
|
int N9 = 0> // Number of parameters in block 9.
|
||||||
|
class AutoDiffCostFunction : public SizedCostFunction<kNumResiduals,
|
||||||
|
N0, N1, N2, N3, N4,
|
||||||
|
N5, N6, N7, N8, N9> {
|
||||||
public:
|
public:
|
||||||
// Takes ownership of functor. Uses the template-provided value for the
|
// Takes ownership of functor. Uses the template-provided value for the
|
||||||
// number of residuals ("kNumResiduals").
|
// number of residuals ("kNumResiduals").
|
||||||
explicit AutoDiffCostFunction(CostFunctor* functor) : functor_(functor) {
|
explicit AutoDiffCostFunction(CostFunctor* functor)
|
||||||
static_assert(kNumResiduals != DYNAMIC,
|
: functor_(functor) {
|
||||||
"Can't run the fixed-size constructor if the number of "
|
CHECK_NE(kNumResiduals, DYNAMIC)
|
||||||
"residuals is set to ceres::DYNAMIC.");
|
<< "Can't run the fixed-size constructor if the "
|
||||||
|
<< "number of residuals is set to ceres::DYNAMIC.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes ownership of functor. Ignores the template-provided
|
// Takes ownership of functor. Ignores the template-provided
|
||||||
@@ -168,10 +183,13 @@ class AutoDiffCostFunction : public SizedCostFunction<kNumResiduals, Ns...> {
|
|||||||
// numbers of residuals at runtime.
|
// numbers of residuals at runtime.
|
||||||
AutoDiffCostFunction(CostFunctor* functor, int num_residuals)
|
AutoDiffCostFunction(CostFunctor* functor, int num_residuals)
|
||||||
: functor_(functor) {
|
: functor_(functor) {
|
||||||
static_assert(kNumResiduals == DYNAMIC,
|
CHECK_EQ(kNumResiduals, DYNAMIC)
|
||||||
"Can't run the dynamic-size constructor if the number of "
|
<< "Can't run the dynamic-size constructor if the "
|
||||||
"residuals is not ceres::DYNAMIC.");
|
<< "number of residuals is not ceres::DYNAMIC.";
|
||||||
SizedCostFunction<kNumResiduals, Ns...>::set_num_residuals(num_residuals);
|
SizedCostFunction<kNumResiduals,
|
||||||
|
N0, N1, N2, N3, N4,
|
||||||
|
N5, N6, N7, N8, N9>
|
||||||
|
::set_num_residuals(num_residuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AutoDiffCostFunction() {}
|
virtual ~AutoDiffCostFunction() {}
|
||||||
@@ -179,28 +197,29 @@ class AutoDiffCostFunction : public SizedCostFunction<kNumResiduals, Ns...> {
|
|||||||
// Implementation details follow; clients of the autodiff cost function should
|
// Implementation details follow; clients of the autodiff cost function should
|
||||||
// not have to examine below here.
|
// not have to examine below here.
|
||||||
//
|
//
|
||||||
// To handle variadic cost functions, some template magic is needed. It's
|
// To handle varardic cost functions, some template magic is needed. It's
|
||||||
// mostly hidden inside autodiff.h.
|
// mostly hidden inside autodiff.h.
|
||||||
bool Evaluate(double const* const* parameters,
|
virtual bool Evaluate(double const* const* parameters,
|
||||||
double* residuals,
|
double* residuals,
|
||||||
double** jacobians) const override {
|
double** jacobians) const {
|
||||||
using ParameterDims =
|
|
||||||
typename SizedCostFunction<kNumResiduals, Ns...>::ParameterDims;
|
|
||||||
|
|
||||||
if (!jacobians) {
|
if (!jacobians) {
|
||||||
return internal::VariadicEvaluate<ParameterDims>(
|
return internal::VariadicEvaluate<
|
||||||
*functor_, parameters, residuals);
|
CostFunctor, double, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>
|
||||||
|
::Call(*functor_, parameters, residuals);
|
||||||
}
|
}
|
||||||
return internal::AutoDifferentiate<kNumResiduals, ParameterDims>(
|
return internal::AutoDiff<CostFunctor, double,
|
||||||
*functor_,
|
N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>::Differentiate(
|
||||||
parameters,
|
*functor_,
|
||||||
SizedCostFunction<kNumResiduals, Ns...>::num_residuals(),
|
parameters,
|
||||||
residuals,
|
SizedCostFunction<kNumResiduals,
|
||||||
jacobians);
|
N0, N1, N2, N3, N4,
|
||||||
};
|
N5, N6, N7, N8, N9>::num_residuals(),
|
||||||
|
residuals,
|
||||||
|
jacobians);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<CostFunctor> functor_;
|
internal::scoped_ptr<CostFunctor> functor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
@@ -1,151 +0,0 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
|
||||||
// http://ceres-solver.org/
|
|
||||||
//
|
|
||||||
// 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 Google Inc. nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without
|
|
||||||
// specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
|
|
||||||
//
|
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
|
||||||
|
|
||||||
#ifndef CERES_PUBLIC_AUTODIFF_FIRST_ORDER_FUNCTION_H_
|
|
||||||
#define CERES_PUBLIC_AUTODIFF_FIRST_ORDER_FUNCTION_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "ceres/first_order_function.h"
|
|
||||||
#include "ceres/internal/eigen.h"
|
|
||||||
#include "ceres/internal/fixed_array.h"
|
|
||||||
#include "ceres/jet.h"
|
|
||||||
#include "ceres/types.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// Create FirstOrderFunctions as needed by the GradientProblem
|
|
||||||
// framework, with gradients computed via automatic
|
|
||||||
// differentiation. For more information on automatic differentiation,
|
|
||||||
// see the wikipedia article at
|
|
||||||
// http://en.wikipedia.org/wiki/Automatic_differentiation
|
|
||||||
//
|
|
||||||
// To get an auto differentiated function, you must define a class
|
|
||||||
// with a templated operator() (a functor) that computes the cost
|
|
||||||
// function in terms of the template parameter T. The autodiff
|
|
||||||
// framework substitutes appropriate "jet" objects for T in order to
|
|
||||||
// compute the derivative when necessary, but this is hidden, and you
|
|
||||||
// should write the function as if T were a scalar type (e.g. a
|
|
||||||
// double-precision floating point number).
|
|
||||||
//
|
|
||||||
// The function must write the computed value in the last argument
|
|
||||||
// (the only non-const one) and return true to indicate
|
|
||||||
// success.
|
|
||||||
//
|
|
||||||
// For example, consider a scalar error e = x'y - a, where both x and y are
|
|
||||||
// two-dimensional column vector parameters, the prime sign indicates
|
|
||||||
// transposition, and a is a constant.
|
|
||||||
//
|
|
||||||
// To write an auto-differentiable FirstOrderFunction for the above model, first
|
|
||||||
// define the object
|
|
||||||
//
|
|
||||||
// class QuadraticCostFunctor {
|
|
||||||
// public:
|
|
||||||
// explicit QuadraticCostFunctor(double a) : a_(a) {}
|
|
||||||
// template <typename T>
|
|
||||||
// bool operator()(const T* const xy, T* cost) const {
|
|
||||||
// const T* const x = xy;
|
|
||||||
// const T* const y = xy + 2;
|
|
||||||
// *cost = x[0] * y[0] + x[1] * y[1] - T(a_);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private:
|
|
||||||
// double a_;
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// Note that in the declaration of operator() the input parameters xy come
|
|
||||||
// first, and are passed as const pointers to arrays of T. The
|
|
||||||
// output is the last parameter.
|
|
||||||
//
|
|
||||||
// Then given this class definition, the auto differentiated FirstOrderFunction
|
|
||||||
// for it can be constructed as follows.
|
|
||||||
//
|
|
||||||
// FirstOrderFunction* function =
|
|
||||||
// new AutoDiffFirstOrderFunction<QuadraticCostFunctor, 4>(
|
|
||||||
// new QuadraticCostFunctor(1.0)));
|
|
||||||
//
|
|
||||||
// In the instantiation above, the template parameters following
|
|
||||||
// "QuadraticCostFunctor", "4", describe the functor as computing a
|
|
||||||
// 1-dimensional output from a four dimensional vector.
|
|
||||||
//
|
|
||||||
// WARNING: Since the functor will get instantiated with different types for
|
|
||||||
// T, you must convert from other numeric types to T before mixing
|
|
||||||
// computations with other variables of type T. In the example above, this is
|
|
||||||
// seen where instead of using a_ directly, a_ is wrapped with T(a_).
|
|
||||||
|
|
||||||
template <typename FirstOrderFunctor, int kNumParameters>
|
|
||||||
class AutoDiffFirstOrderFunction : public FirstOrderFunction {
|
|
||||||
public:
|
|
||||||
// Takes ownership of functor.
|
|
||||||
explicit AutoDiffFirstOrderFunction(FirstOrderFunctor* functor)
|
|
||||||
: functor_(functor) {
|
|
||||||
static_assert(kNumParameters > 0, "kNumParameters must be positive");
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~AutoDiffFirstOrderFunction() {}
|
|
||||||
|
|
||||||
bool Evaluate(const double* const parameters,
|
|
||||||
double* cost,
|
|
||||||
double* gradient) const override {
|
|
||||||
if (gradient == nullptr) {
|
|
||||||
return (*functor_)(parameters, cost);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef Jet<double, kNumParameters> JetT;
|
|
||||||
internal::FixedArray<JetT, (256 * 7) / sizeof(JetT)> x(kNumParameters);
|
|
||||||
for (int i = 0; i < kNumParameters; ++i) {
|
|
||||||
x[i].a = parameters[i];
|
|
||||||
x[i].v.setZero();
|
|
||||||
x[i].v[i] = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
JetT output;
|
|
||||||
output.a = kImpossibleValue;
|
|
||||||
output.v.setConstant(kImpossibleValue);
|
|
||||||
|
|
||||||
if (!(*functor_)(x.data(), &output)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*cost = output.a;
|
|
||||||
VectorRef(gradient, kNumParameters) = output.v;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int NumParameters() const override { return kNumParameters; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<FirstOrderFunctor> functor_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ceres
|
|
||||||
|
|
||||||
#endif // CERES_PUBLIC_AUTODIFF_FIRST_ORDER_FUNCTION_H_
|
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -33,10 +33,9 @@
|
|||||||
#ifndef CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
|
#ifndef CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
|
||||||
#define CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
|
#define CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "ceres/internal/autodiff.h"
|
|
||||||
#include "ceres/local_parameterization.h"
|
#include "ceres/local_parameterization.h"
|
||||||
|
#include "ceres/internal/autodiff.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
@@ -108,20 +107,21 @@ namespace ceres {
|
|||||||
template <typename Functor, int kGlobalSize, int kLocalSize>
|
template <typename Functor, int kGlobalSize, int kLocalSize>
|
||||||
class AutoDiffLocalParameterization : public LocalParameterization {
|
class AutoDiffLocalParameterization : public LocalParameterization {
|
||||||
public:
|
public:
|
||||||
AutoDiffLocalParameterization() : functor_(new Functor()) {}
|
AutoDiffLocalParameterization() :
|
||||||
|
functor_(new Functor()) {}
|
||||||
|
|
||||||
// Takes ownership of functor.
|
// Takes ownership of functor.
|
||||||
explicit AutoDiffLocalParameterization(Functor* functor)
|
explicit AutoDiffLocalParameterization(Functor* functor) :
|
||||||
: functor_(functor) {}
|
functor_(functor) {}
|
||||||
|
|
||||||
virtual ~AutoDiffLocalParameterization() {}
|
virtual ~AutoDiffLocalParameterization() {}
|
||||||
bool Plus(const double* x,
|
virtual bool Plus(const double* x,
|
||||||
const double* delta,
|
const double* delta,
|
||||||
double* x_plus_delta) const override {
|
double* x_plus_delta) const {
|
||||||
return (*functor_)(x, delta, x_plus_delta);
|
return (*functor_)(x, delta, x_plus_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComputeJacobian(const double* x, double* jacobian) const override {
|
virtual bool ComputeJacobian(const double* x, double* jacobian) const {
|
||||||
double zero_delta[kLocalSize];
|
double zero_delta[kLocalSize];
|
||||||
for (int i = 0; i < kLocalSize; ++i) {
|
for (int i = 0; i < kLocalSize; ++i) {
|
||||||
zero_delta[i] = 0.0;
|
zero_delta[i] = 0.0;
|
||||||
@@ -133,18 +133,20 @@ class AutoDiffLocalParameterization : public LocalParameterization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const double* parameter_ptrs[2] = {x, zero_delta};
|
const double* parameter_ptrs[2] = {x, zero_delta};
|
||||||
double* jacobian_ptrs[2] = {NULL, jacobian};
|
double* jacobian_ptrs[2] = { NULL, jacobian };
|
||||||
return internal::AutoDifferentiate<
|
return internal::AutoDiff<Functor, double, kGlobalSize, kLocalSize>
|
||||||
kGlobalSize,
|
::Differentiate(*functor_,
|
||||||
internal::StaticParameterDims<kGlobalSize, kLocalSize>>(
|
parameter_ptrs,
|
||||||
*functor_, parameter_ptrs, kGlobalSize, x_plus_delta, jacobian_ptrs);
|
kGlobalSize,
|
||||||
|
x_plus_delta,
|
||||||
|
jacobian_ptrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GlobalSize() const override { return kGlobalSize; }
|
virtual int GlobalSize() const { return kGlobalSize; }
|
||||||
int LocalSize() const override { return kLocalSize; }
|
virtual int LocalSize() const { return kLocalSize; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Functor> functor_;
|
internal::scoped_ptr<Functor> functor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
4
extern/ceres/include/ceres/c_api.h
vendored
4
extern/ceres/include/ceres/c_api.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
/* Ceres Solver - A fast non-linear least squares minimizer
|
/* Ceres Solver - A fast non-linear least squares minimizer
|
||||||
* Copyright 2019 Google Inc. All rights reserved.
|
* Copyright 2015 Google Inc. All rights reserved.
|
||||||
* http://ceres-solver.org/
|
* http://ceres-solver.org/
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -143,4 +143,4 @@ CERES_EXPORT void ceres_solve(ceres_problem_t* problem);
|
|||||||
|
|
||||||
#include "ceres/internal/reenable_warnings.h"
|
#include "ceres/internal/reenable_warnings.h"
|
||||||
|
|
||||||
#endif /* CERES_PUBLIC_C_API_H_ */
|
#endif /* CERES_PUBLIC_C_API_H_ */
|
||||||
|
9
extern/ceres/include/ceres/ceres.h
vendored
9
extern/ceres/include/ceres/ceres.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -36,18 +36,12 @@
|
|||||||
|
|
||||||
#include "ceres/autodiff_cost_function.h"
|
#include "ceres/autodiff_cost_function.h"
|
||||||
#include "ceres/autodiff_local_parameterization.h"
|
#include "ceres/autodiff_local_parameterization.h"
|
||||||
#include "ceres/conditioned_cost_function.h"
|
|
||||||
#include "ceres/context.h"
|
|
||||||
#include "ceres/cost_function.h"
|
#include "ceres/cost_function.h"
|
||||||
#include "ceres/cost_function_to_functor.h"
|
#include "ceres/cost_function_to_functor.h"
|
||||||
#include "ceres/covariance.h"
|
#include "ceres/covariance.h"
|
||||||
#include "ceres/crs_matrix.h"
|
#include "ceres/crs_matrix.h"
|
||||||
#include "ceres/dynamic_autodiff_cost_function.h"
|
#include "ceres/dynamic_autodiff_cost_function.h"
|
||||||
#include "ceres/dynamic_cost_function.h"
|
|
||||||
#include "ceres/dynamic_cost_function_to_functor.h"
|
|
||||||
#include "ceres/dynamic_numeric_diff_cost_function.h"
|
#include "ceres/dynamic_numeric_diff_cost_function.h"
|
||||||
#include "ceres/evaluation_callback.h"
|
|
||||||
#include "ceres/gradient_checker.h"
|
|
||||||
#include "ceres/gradient_problem.h"
|
#include "ceres/gradient_problem.h"
|
||||||
#include "ceres/gradient_problem_solver.h"
|
#include "ceres/gradient_problem_solver.h"
|
||||||
#include "ceres/iteration_callback.h"
|
#include "ceres/iteration_callback.h"
|
||||||
@@ -55,7 +49,6 @@
|
|||||||
#include "ceres/local_parameterization.h"
|
#include "ceres/local_parameterization.h"
|
||||||
#include "ceres/loss_function.h"
|
#include "ceres/loss_function.h"
|
||||||
#include "ceres/numeric_diff_cost_function.h"
|
#include "ceres/numeric_diff_cost_function.h"
|
||||||
#include "ceres/numeric_diff_options.h"
|
|
||||||
#include "ceres/ordered_groups.h"
|
#include "ceres/ordered_groups.h"
|
||||||
#include "ceres/problem.h"
|
#include "ceres/problem.h"
|
||||||
#include "ceres/sized_cost_function.h"
|
#include "ceres/sized_cost_function.h"
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,12 +34,12 @@
|
|||||||
#ifndef CERES_PUBLIC_CONDITIONED_COST_FUNCTION_H_
|
#ifndef CERES_PUBLIC_CONDITIONED_COST_FUNCTION_H_
|
||||||
#define CERES_PUBLIC_CONDITIONED_COST_FUNCTION_H_
|
#define CERES_PUBLIC_CONDITIONED_COST_FUNCTION_H_
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ceres/cost_function.h"
|
#include "ceres/cost_function.h"
|
||||||
#include "ceres/internal/disable_warnings.h"
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
#include "ceres/types.h"
|
#include "ceres/types.h"
|
||||||
|
#include "ceres/internal/disable_warnings.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
@@ -77,19 +77,17 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction {
|
|||||||
// per-residual conditioner. Takes ownership of all of the wrapped cost
|
// per-residual conditioner. Takes ownership of all of the wrapped cost
|
||||||
// functions, or not, depending on the ownership parameter. Conditioners
|
// functions, or not, depending on the ownership parameter. Conditioners
|
||||||
// may be NULL, in which case the corresponding residual is not modified.
|
// may be NULL, in which case the corresponding residual is not modified.
|
||||||
//
|
|
||||||
// The conditioners can repeat.
|
|
||||||
ConditionedCostFunction(CostFunction* wrapped_cost_function,
|
ConditionedCostFunction(CostFunction* wrapped_cost_function,
|
||||||
const std::vector<CostFunction*>& conditioners,
|
const std::vector<CostFunction*>& conditioners,
|
||||||
Ownership ownership);
|
Ownership ownership);
|
||||||
virtual ~ConditionedCostFunction();
|
virtual ~ConditionedCostFunction();
|
||||||
|
|
||||||
bool Evaluate(double const* const* parameters,
|
virtual bool Evaluate(double const* const* parameters,
|
||||||
double* residuals,
|
double* residuals,
|
||||||
double** jacobians) const override;
|
double** jacobians) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<CostFunction> wrapped_cost_function_;
|
internal::scoped_ptr<CostFunction> wrapped_cost_function_;
|
||||||
std::vector<CostFunction*> conditioners_;
|
std::vector<CostFunction*> conditioners_;
|
||||||
Ownership ownership_;
|
Ownership ownership_;
|
||||||
};
|
};
|
||||||
|
56
extern/ceres/include/ceres/context.h
vendored
56
extern/ceres/include/ceres/context.h
vendored
@@ -1,56 +0,0 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
|
||||||
// http://ceres-solver.org/
|
|
||||||
//
|
|
||||||
// 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 Google Inc. nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without
|
|
||||||
// specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
|
|
||||||
//
|
|
||||||
// Author: vitus@google.com (Michael Vitus)
|
|
||||||
|
|
||||||
#ifndef CERES_PUBLIC_CONTEXT_H_
|
|
||||||
#define CERES_PUBLIC_CONTEXT_H_
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// A global context for processing data in Ceres. This provides a mechanism to
|
|
||||||
// allow Ceres to reuse items that are expensive to create between multiple
|
|
||||||
// calls; for example, thread pools. The same Context can be used on multiple
|
|
||||||
// Problems, either serially or in parallel. When using it with multiple
|
|
||||||
// Problems at the same time, they may end up contending for resources
|
|
||||||
// (e.g. threads) managed by the Context.
|
|
||||||
class Context {
|
|
||||||
public:
|
|
||||||
Context() {}
|
|
||||||
Context(const Context&) = delete;
|
|
||||||
void operator=(const Context&) = delete;
|
|
||||||
|
|
||||||
virtual ~Context() {}
|
|
||||||
|
|
||||||
// Creates a context object and the caller takes ownership.
|
|
||||||
static Context* Create();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ceres
|
|
||||||
|
|
||||||
#endif // CERES_PUBLIC_CONTEXT_H_
|
|
27
extern/ceres/include/ceres/cost_function.h
vendored
27
extern/ceres/include/ceres/cost_function.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,18 +44,18 @@
|
|||||||
#ifndef CERES_PUBLIC_COST_FUNCTION_H_
|
#ifndef CERES_PUBLIC_COST_FUNCTION_H_
|
||||||
#define CERES_PUBLIC_COST_FUNCTION_H_
|
#define CERES_PUBLIC_COST_FUNCTION_H_
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "ceres/internal/macros.h"
|
||||||
#include "ceres/internal/disable_warnings.h"
|
|
||||||
#include "ceres/internal/port.h"
|
#include "ceres/internal/port.h"
|
||||||
|
#include "ceres/types.h"
|
||||||
|
#include "ceres/internal/disable_warnings.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
// This class implements the computation of the cost (a.k.a. residual) terms as
|
// This class implements the computation of the cost (a.k.a. residual) terms as
|
||||||
// a function of the input (control) variables, and is the interface for users
|
// a function of the input (control) variables, and is the interface for users
|
||||||
// to describe their least squares problem to Ceres. In other words, this is the
|
// to describe their least squares problem to Ceres. In other words, this is the
|
||||||
// modeling layer between users and the Ceres optimizer. The signature of the
|
// modelling layer between users and the Ceres optimizer. The signature of the
|
||||||
// function (number and sizes of input parameter blocks and number of outputs)
|
// function (number and sizes of input parameter blocks and number of outputs)
|
||||||
// is stored in parameter_block_sizes_ and num_residuals_ respectively. User
|
// is stored in parameter_block_sizes_ and num_residuals_ respectively. User
|
||||||
// code inheriting from this class is expected to set these two members with the
|
// code inheriting from this class is expected to set these two members with the
|
||||||
@@ -64,8 +64,6 @@ namespace ceres {
|
|||||||
class CERES_EXPORT CostFunction {
|
class CERES_EXPORT CostFunction {
|
||||||
public:
|
public:
|
||||||
CostFunction() : num_residuals_(0) {}
|
CostFunction() : num_residuals_(0) {}
|
||||||
CostFunction(const CostFunction&) = delete;
|
|
||||||
void operator=(const CostFunction&) = delete;
|
|
||||||
|
|
||||||
virtual ~CostFunction() {}
|
virtual ~CostFunction() {}
|
||||||
|
|
||||||
@@ -117,24 +115,29 @@ class CERES_EXPORT CostFunction {
|
|||||||
double* residuals,
|
double* residuals,
|
||||||
double** jacobians) const = 0;
|
double** jacobians) const = 0;
|
||||||
|
|
||||||
const std::vector<int32_t>& parameter_block_sizes() const {
|
const std::vector<int32>& parameter_block_sizes() const {
|
||||||
return parameter_block_sizes_;
|
return parameter_block_sizes_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_residuals() const { return num_residuals_; }
|
int num_residuals() const {
|
||||||
|
return num_residuals_;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<int32_t>* mutable_parameter_block_sizes() {
|
std::vector<int32>* mutable_parameter_block_sizes() {
|
||||||
return ¶meter_block_sizes_;
|
return ¶meter_block_sizes_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_num_residuals(int num_residuals) { num_residuals_ = num_residuals; }
|
void set_num_residuals(int num_residuals) {
|
||||||
|
num_residuals_ = num_residuals;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Cost function signature metadata: number of inputs & their sizes,
|
// Cost function signature metadata: number of inputs & their sizes,
|
||||||
// number of outputs (residuals).
|
// number of outputs (residuals).
|
||||||
std::vector<int32_t> parameter_block_sizes_;
|
std::vector<int32> parameter_block_sizes_;
|
||||||
int num_residuals_;
|
int num_residuals_;
|
||||||
|
CERES_DISALLOW_COPY_AND_ASSIGN(CostFunction);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
//
|
//
|
||||||
// CostFunctionToFunctor is an adapter class that allows users to use
|
// CostFunctionToFunctor is an adapter class that allows users to use
|
||||||
// SizedCostFunction objects in templated functors which are to be used for
|
// SizedCostFunction objects in templated functors which are to be used for
|
||||||
// automatic differentiation. This allows the user to seamlessly mix
|
// automatic differentiation. This allows the user to seamlessly mix
|
||||||
// analytic, numeric and automatic differentiation.
|
// analytic, numeric and automatic differentiation.
|
||||||
//
|
//
|
||||||
// For example, let us assume that
|
// For example, let us assume that
|
||||||
@@ -38,15 +38,16 @@
|
|||||||
// class IntrinsicProjection : public SizedCostFunction<2, 5, 3> {
|
// class IntrinsicProjection : public SizedCostFunction<2, 5, 3> {
|
||||||
// public:
|
// public:
|
||||||
// IntrinsicProjection(const double* observation);
|
// IntrinsicProjection(const double* observation);
|
||||||
// bool Evaluate(double const* const* parameters,
|
// virtual bool Evaluate(double const* const* parameters,
|
||||||
// double* residuals,
|
// double* residuals,
|
||||||
// double** jacobians) const override;
|
// double** jacobians) const;
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// is a cost function that implements the projection of a point in its
|
// is a cost function that implements the projection of a point in its
|
||||||
// local coordinate system onto its image plane and subtracts it from
|
// local coordinate system onto its image plane and subtracts it from
|
||||||
// the observed point projection. It can compute its residual and
|
// the observed point projection. It can compute its residual and
|
||||||
// jacobians either via analytic or numerical differentiation.
|
// either via analytic or numerical differentiation can compute its
|
||||||
|
// jacobians.
|
||||||
//
|
//
|
||||||
// Now we would like to compose the action of this CostFunction with
|
// Now we would like to compose the action of this CostFunction with
|
||||||
// the action of camera extrinsics, i.e., rotation and
|
// the action of camera extrinsics, i.e., rotation and
|
||||||
@@ -86,83 +87,594 @@
|
|||||||
#ifndef CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
|
#ifndef CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
|
||||||
#define CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
|
#define CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <tuple>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ceres/cost_function.h"
|
#include "ceres/cost_function.h"
|
||||||
#include "ceres/dynamic_cost_function_to_functor.h"
|
#include "ceres/dynamic_cost_function_to_functor.h"
|
||||||
#include "ceres/internal/fixed_array.h"
|
#include "ceres/internal/fixed_array.h"
|
||||||
#include "ceres/internal/parameter_dims.h"
|
|
||||||
#include "ceres/internal/port.h"
|
#include "ceres/internal/port.h"
|
||||||
#include "ceres/types.h"
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
template <int kNumResiduals, int... Ns>
|
template <int kNumResiduals,
|
||||||
|
int N0, int N1 = 0, int N2 = 0, int N3 = 0, int N4 = 0,
|
||||||
|
int N5 = 0, int N6 = 0, int N7 = 0, int N8 = 0, int N9 = 0>
|
||||||
class CostFunctionToFunctor {
|
class CostFunctionToFunctor {
|
||||||
public:
|
public:
|
||||||
// Takes ownership of cost_function.
|
// Takes ownership of cost_function.
|
||||||
explicit CostFunctionToFunctor(CostFunction* cost_function)
|
explicit CostFunctionToFunctor(CostFunction* cost_function)
|
||||||
: cost_functor_(cost_function) {
|
: cost_functor_(cost_function) {
|
||||||
CHECK(cost_function != nullptr);
|
CHECK_NOTNULL(cost_function);
|
||||||
CHECK(kNumResiduals > 0 || kNumResiduals == DYNAMIC);
|
CHECK(kNumResiduals > 0 || kNumResiduals == DYNAMIC);
|
||||||
|
|
||||||
const std::vector<int32_t>& parameter_block_sizes =
|
// This block breaks the 80 column rule to keep it somewhat readable.
|
||||||
|
CHECK((!N1 && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
|
||||||
|
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
|
||||||
|
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) || // NOLINT
|
||||||
|
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0))) // NOLINT
|
||||||
|
<< "Zero block cannot precede a non-zero block. Block sizes are "
|
||||||
|
<< "(ignore trailing 0s): " << N0 << ", " << N1 << ", " << N2 << ", "
|
||||||
|
<< N3 << ", " << N4 << ", " << N5 << ", " << N6 << ", " << N7 << ", "
|
||||||
|
<< N8 << ", " << N9;
|
||||||
|
|
||||||
|
const std::vector<int32>& parameter_block_sizes =
|
||||||
cost_function->parameter_block_sizes();
|
cost_function->parameter_block_sizes();
|
||||||
const int num_parameter_blocks = ParameterDims::kNumParameterBlocks;
|
const int num_parameter_blocks =
|
||||||
|
(N0 > 0) + (N1 > 0) + (N2 > 0) + (N3 > 0) + (N4 > 0) +
|
||||||
|
(N5 > 0) + (N6 > 0) + (N7 > 0) + (N8 > 0) + (N9 > 0);
|
||||||
CHECK_EQ(static_cast<int>(parameter_block_sizes.size()),
|
CHECK_EQ(static_cast<int>(parameter_block_sizes.size()),
|
||||||
num_parameter_blocks);
|
num_parameter_blocks);
|
||||||
|
|
||||||
if (parameter_block_sizes.size() == num_parameter_blocks) {
|
CHECK_EQ(N0, parameter_block_sizes[0]);
|
||||||
for (int block = 0; block < num_parameter_blocks; ++block) {
|
if (parameter_block_sizes.size() > 1) CHECK_EQ(N1, parameter_block_sizes[1]); // NOLINT
|
||||||
CHECK_EQ(ParameterDims::GetDim(block), parameter_block_sizes[block])
|
if (parameter_block_sizes.size() > 2) CHECK_EQ(N2, parameter_block_sizes[2]); // NOLINT
|
||||||
<< "Parameter block size missmatch. The specified static parameter "
|
if (parameter_block_sizes.size() > 3) CHECK_EQ(N3, parameter_block_sizes[3]); // NOLINT
|
||||||
"block dimension does not match the one from the cost function.";
|
if (parameter_block_sizes.size() > 4) CHECK_EQ(N4, parameter_block_sizes[4]); // NOLINT
|
||||||
}
|
if (parameter_block_sizes.size() > 5) CHECK_EQ(N5, parameter_block_sizes[5]); // NOLINT
|
||||||
}
|
if (parameter_block_sizes.size() > 6) CHECK_EQ(N6, parameter_block_sizes[6]); // NOLINT
|
||||||
|
if (parameter_block_sizes.size() > 7) CHECK_EQ(N7, parameter_block_sizes[7]); // NOLINT
|
||||||
|
if (parameter_block_sizes.size() > 8) CHECK_EQ(N8, parameter_block_sizes[8]); // NOLINT
|
||||||
|
if (parameter_block_sizes.size() > 9) CHECK_EQ(N9, parameter_block_sizes[9]); // NOLINT
|
||||||
|
|
||||||
CHECK_EQ(accumulate(
|
CHECK_EQ(accumulate(parameter_block_sizes.begin(),
|
||||||
parameter_block_sizes.begin(), parameter_block_sizes.end(), 0),
|
parameter_block_sizes.end(), 0),
|
||||||
ParameterDims::kNumParameters);
|
N0 + N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 + N9);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Ts>
|
bool operator()(const double* x0, double* residuals) const {
|
||||||
bool operator()(const T* p1, Ts*... ps) const {
|
CHECK_NE(N0, 0);
|
||||||
// Add one because of residual block.
|
CHECK_EQ(N1, 0);
|
||||||
static_assert(sizeof...(Ts) + 1 == ParameterDims::kNumParameterBlocks + 1,
|
CHECK_EQ(N2, 0);
|
||||||
"Invalid number of parameter blocks specified.");
|
CHECK_EQ(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
|
||||||
auto params = std::make_tuple(p1, ps...);
|
return cost_functor_(&x0, residuals);
|
||||||
|
}
|
||||||
|
|
||||||
// Extract residual pointer from params. The residual pointer is the
|
bool operator()(const double* x0,
|
||||||
// last pointer.
|
const double* x1,
|
||||||
constexpr int kResidualIndex = ParameterDims::kNumParameterBlocks;
|
double* residuals) const {
|
||||||
T* residuals = std::get<kResidualIndex>(params);
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_EQ(N2, 0);
|
||||||
|
CHECK_EQ(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(2);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
// Extract parameter block pointers from params.
|
bool operator()(const double* x0,
|
||||||
using Indices =
|
const double* x1,
|
||||||
std::make_integer_sequence<int,
|
const double* x2,
|
||||||
ParameterDims::kNumParameterBlocks>;
|
double* residuals) const {
|
||||||
std::array<const T*, ParameterDims::kNumParameterBlocks> parameter_blocks =
|
CHECK_NE(N0, 0);
|
||||||
GetParameterPointers<T>(params, Indices());
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_EQ(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(3);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
return cost_functor_(parameter_blocks.data(), residuals);
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(4);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
const double* x4,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(5);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
parameter_blocks[4] = x4;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
const double* x4,
|
||||||
|
const double* x5,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(6);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
parameter_blocks[4] = x4;
|
||||||
|
parameter_blocks[5] = x5;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
const double* x4,
|
||||||
|
const double* x5,
|
||||||
|
const double* x6,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(7);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
parameter_blocks[4] = x4;
|
||||||
|
parameter_blocks[5] = x5;
|
||||||
|
parameter_blocks[6] = x6;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
const double* x4,
|
||||||
|
const double* x5,
|
||||||
|
const double* x6,
|
||||||
|
const double* x7,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_NE(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(8);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
parameter_blocks[4] = x4;
|
||||||
|
parameter_blocks[5] = x5;
|
||||||
|
parameter_blocks[6] = x6;
|
||||||
|
parameter_blocks[7] = x7;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
const double* x4,
|
||||||
|
const double* x5,
|
||||||
|
const double* x6,
|
||||||
|
const double* x7,
|
||||||
|
const double* x8,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_NE(N7, 0);
|
||||||
|
CHECK_NE(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(9);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
parameter_blocks[4] = x4;
|
||||||
|
parameter_blocks[5] = x5;
|
||||||
|
parameter_blocks[6] = x6;
|
||||||
|
parameter_blocks[7] = x7;
|
||||||
|
parameter_blocks[8] = x8;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator()(const double* x0,
|
||||||
|
const double* x1,
|
||||||
|
const double* x2,
|
||||||
|
const double* x3,
|
||||||
|
const double* x4,
|
||||||
|
const double* x5,
|
||||||
|
const double* x6,
|
||||||
|
const double* x7,
|
||||||
|
const double* x8,
|
||||||
|
const double* x9,
|
||||||
|
double* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_NE(N7, 0);
|
||||||
|
CHECK_NE(N8, 0);
|
||||||
|
CHECK_NE(N9, 0);
|
||||||
|
internal::FixedArray<const double*> parameter_blocks(10);
|
||||||
|
parameter_blocks[0] = x0;
|
||||||
|
parameter_blocks[1] = x1;
|
||||||
|
parameter_blocks[2] = x2;
|
||||||
|
parameter_blocks[3] = x3;
|
||||||
|
parameter_blocks[4] = x4;
|
||||||
|
parameter_blocks[5] = x5;
|
||||||
|
parameter_blocks[6] = x6;
|
||||||
|
parameter_blocks[7] = x7;
|
||||||
|
parameter_blocks[8] = x8;
|
||||||
|
parameter_blocks[9] = x9;
|
||||||
|
return cost_functor_(parameter_blocks.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0, JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_EQ(N1, 0);
|
||||||
|
CHECK_EQ(N2, 0);
|
||||||
|
CHECK_EQ(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
return cost_functor_(&x0, residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_EQ(N2, 0);
|
||||||
|
CHECK_EQ(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(2);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_EQ(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(3);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_EQ(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(4);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
const JetT* x4,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_EQ(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(5);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
jets[4] = x4;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
const JetT* x4,
|
||||||
|
const JetT* x5,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_EQ(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(6);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
jets[4] = x4;
|
||||||
|
jets[5] = x5;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
const JetT* x4,
|
||||||
|
const JetT* x5,
|
||||||
|
const JetT* x6,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_EQ(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(7);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
jets[4] = x4;
|
||||||
|
jets[5] = x5;
|
||||||
|
jets[6] = x6;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
const JetT* x4,
|
||||||
|
const JetT* x5,
|
||||||
|
const JetT* x6,
|
||||||
|
const JetT* x7,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_NE(N7, 0);
|
||||||
|
CHECK_EQ(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(8);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
jets[4] = x4;
|
||||||
|
jets[5] = x5;
|
||||||
|
jets[6] = x6;
|
||||||
|
jets[7] = x7;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
const JetT* x4,
|
||||||
|
const JetT* x5,
|
||||||
|
const JetT* x6,
|
||||||
|
const JetT* x7,
|
||||||
|
const JetT* x8,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_NE(N7, 0);
|
||||||
|
CHECK_NE(N8, 0);
|
||||||
|
CHECK_EQ(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(9);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
jets[4] = x4;
|
||||||
|
jets[5] = x5;
|
||||||
|
jets[6] = x6;
|
||||||
|
jets[7] = x7;
|
||||||
|
jets[8] = x8;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename JetT>
|
||||||
|
bool operator()(const JetT* x0,
|
||||||
|
const JetT* x1,
|
||||||
|
const JetT* x2,
|
||||||
|
const JetT* x3,
|
||||||
|
const JetT* x4,
|
||||||
|
const JetT* x5,
|
||||||
|
const JetT* x6,
|
||||||
|
const JetT* x7,
|
||||||
|
const JetT* x8,
|
||||||
|
const JetT* x9,
|
||||||
|
JetT* residuals) const {
|
||||||
|
CHECK_NE(N0, 0);
|
||||||
|
CHECK_NE(N1, 0);
|
||||||
|
CHECK_NE(N2, 0);
|
||||||
|
CHECK_NE(N3, 0);
|
||||||
|
CHECK_NE(N4, 0);
|
||||||
|
CHECK_NE(N5, 0);
|
||||||
|
CHECK_NE(N6, 0);
|
||||||
|
CHECK_NE(N7, 0);
|
||||||
|
CHECK_NE(N8, 0);
|
||||||
|
CHECK_NE(N9, 0);
|
||||||
|
internal::FixedArray<const JetT*> jets(10);
|
||||||
|
jets[0] = x0;
|
||||||
|
jets[1] = x1;
|
||||||
|
jets[2] = x2;
|
||||||
|
jets[3] = x3;
|
||||||
|
jets[4] = x4;
|
||||||
|
jets[5] = x5;
|
||||||
|
jets[6] = x6;
|
||||||
|
jets[7] = x7;
|
||||||
|
jets[8] = x8;
|
||||||
|
jets[9] = x9;
|
||||||
|
return cost_functor_(jets.get(), residuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using ParameterDims = internal::StaticParameterDims<Ns...>;
|
|
||||||
|
|
||||||
template <typename T, typename Tuple, int... Indices>
|
|
||||||
static std::array<const T*, ParameterDims::kNumParameterBlocks>
|
|
||||||
GetParameterPointers(const Tuple& paramPointers,
|
|
||||||
std::integer_sequence<int, Indices...>) {
|
|
||||||
return std::array<const T*, ParameterDims::kNumParameterBlocks>{
|
|
||||||
{std::get<Indices>(paramPointers)...}};
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicCostFunctionToFunctor cost_functor_;
|
DynamicCostFunctionToFunctor cost_functor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
79
extern/ceres/include/ceres/covariance.h
vendored
79
extern/ceres/include/ceres/covariance.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -31,13 +31,12 @@
|
|||||||
#ifndef CERES_PUBLIC_COVARIANCE_H_
|
#ifndef CERES_PUBLIC_COVARIANCE_H_
|
||||||
#define CERES_PUBLIC_COVARIANCE_H_
|
#define CERES_PUBLIC_COVARIANCE_H_
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ceres/internal/disable_warnings.h"
|
|
||||||
#include "ceres/internal/port.h"
|
#include "ceres/internal/port.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
#include "ceres/types.h"
|
#include "ceres/types.h"
|
||||||
|
#include "ceres/internal/disable_warnings.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ class CovarianceImpl;
|
|||||||
// Background
|
// Background
|
||||||
// ==========
|
// ==========
|
||||||
// One way to assess the quality of the solution returned by a
|
// One way to assess the quality of the solution returned by a
|
||||||
// non-linear least squares solver is to analyze the covariance of the
|
// non-linear least squares solve is to analyze the covariance of the
|
||||||
// solution.
|
// solution.
|
||||||
//
|
//
|
||||||
// Let us consider the non-linear regression problem
|
// Let us consider the non-linear regression problem
|
||||||
@@ -159,7 +158,7 @@ class CovarianceImpl;
|
|||||||
// Gauge Invariance
|
// Gauge Invariance
|
||||||
// ----------------
|
// ----------------
|
||||||
// In structure from motion (3D reconstruction) problems, the
|
// In structure from motion (3D reconstruction) problems, the
|
||||||
// reconstruction is ambiguous up to a similarity transform. This is
|
// reconstruction is ambiguous upto a similarity transform. This is
|
||||||
// known as a Gauge Ambiguity. Handling Gauges correctly requires the
|
// known as a Gauge Ambiguity. Handling Gauges correctly requires the
|
||||||
// use of SVD or custom inversion algorithms. For small problems the
|
// use of SVD or custom inversion algorithms. For small problems the
|
||||||
// user can use the dense algorithm. For more details see
|
// user can use the dense algorithm. For more details see
|
||||||
@@ -184,7 +183,7 @@ class CovarianceImpl;
|
|||||||
// Covariance::Options options;
|
// Covariance::Options options;
|
||||||
// Covariance covariance(options);
|
// Covariance covariance(options);
|
||||||
//
|
//
|
||||||
// std::vector<std::pair<const double*, const double*>> covariance_blocks;
|
// std::vector<std::pair<const double*, const double*> > covariance_blocks;
|
||||||
// covariance_blocks.push_back(make_pair(x, x));
|
// covariance_blocks.push_back(make_pair(x, x));
|
||||||
// covariance_blocks.push_back(make_pair(y, y));
|
// covariance_blocks.push_back(make_pair(y, y));
|
||||||
// covariance_blocks.push_back(make_pair(x, y));
|
// covariance_blocks.push_back(make_pair(x, y));
|
||||||
@@ -201,19 +200,19 @@ class CovarianceImpl;
|
|||||||
class CERES_EXPORT Covariance {
|
class CERES_EXPORT Covariance {
|
||||||
public:
|
public:
|
||||||
struct CERES_EXPORT Options {
|
struct CERES_EXPORT Options {
|
||||||
// Sparse linear algebra library to use when a sparse matrix
|
Options()
|
||||||
// factorization is being used to compute the covariance matrix.
|
#ifndef CERES_NO_SUITESPARSE
|
||||||
//
|
: algorithm_type(SUITE_SPARSE_QR),
|
||||||
// Currently this only applies to SPARSE_QR.
|
|
||||||
SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type =
|
|
||||||
#if !defined(CERES_NO_SUITESPARSE)
|
|
||||||
SUITE_SPARSE;
|
|
||||||
#else
|
#else
|
||||||
// Eigen's QR factorization is always available.
|
: algorithm_type(EIGEN_SPARSE_QR),
|
||||||
EIGEN_SPARSE;
|
|
||||||
#endif
|
#endif
|
||||||
|
min_reciprocal_condition_number(1e-14),
|
||||||
|
null_space_rank(0),
|
||||||
|
num_threads(1),
|
||||||
|
apply_loss_function(true) {
|
||||||
|
}
|
||||||
|
|
||||||
// Ceres supports two different algorithms for covariance
|
// Ceres supports three different algorithms for covariance
|
||||||
// estimation, which represent different tradeoffs in speed,
|
// estimation, which represent different tradeoffs in speed,
|
||||||
// accuracy and reliability.
|
// accuracy and reliability.
|
||||||
//
|
//
|
||||||
@@ -230,20 +229,23 @@ class CERES_EXPORT Covariance {
|
|||||||
// for small to moderate sized problems. It can handle
|
// for small to moderate sized problems. It can handle
|
||||||
// full-rank as well as rank deficient Jacobians.
|
// full-rank as well as rank deficient Jacobians.
|
||||||
//
|
//
|
||||||
// 2. SPARSE_QR uses the sparse QR factorization algorithm
|
// 2. EIGEN_SPARSE_QR uses the sparse QR factorization algorithm
|
||||||
// to compute the decomposition
|
// in Eigen to compute the decomposition
|
||||||
//
|
//
|
||||||
// Q * R = J
|
// Q * R = J
|
||||||
//
|
//
|
||||||
// [J'J]^-1 = [R*R']^-1
|
// [J'J]^-1 = [R*R']^-1
|
||||||
//
|
//
|
||||||
// SPARSE_QR is not capable of computing the covariance if the
|
// It is a moderately fast algorithm for sparse matrices.
|
||||||
// Jacobian is rank deficient. Depending on the value of
|
//
|
||||||
// Covariance::Options::sparse_linear_algebra_library_type, either
|
// 3. SUITE_SPARSE_QR uses the SuiteSparseQR sparse QR
|
||||||
// Eigen's Sparse QR factorization algorithm will be used or
|
// factorization algorithm. It uses dense linear algebra and is
|
||||||
// SuiteSparse's high performance SuiteSparseQR algorithm will be
|
// multi threaded, so for large sparse sparse matrices it is
|
||||||
// used.
|
// significantly faster than EIGEN_SPARSE_QR.
|
||||||
CovarianceAlgorithmType algorithm_type = SPARSE_QR;
|
//
|
||||||
|
// Neither EIGEN_SPARSE_QR not SUITE_SPARSE_QR are capable of
|
||||||
|
// computing the covariance if the Jacobian is rank deficient.
|
||||||
|
CovarianceAlgorithmType algorithm_type;
|
||||||
|
|
||||||
// If the Jacobian matrix is near singular, then inverting J'J
|
// If the Jacobian matrix is near singular, then inverting J'J
|
||||||
// will result in unreliable results, e.g, if
|
// will result in unreliable results, e.g, if
|
||||||
@@ -268,7 +270,7 @@ class CERES_EXPORT Covariance {
|
|||||||
// where min_sigma and max_sigma are the minimum and maxiumum
|
// where min_sigma and max_sigma are the minimum and maxiumum
|
||||||
// singular values of J respectively.
|
// singular values of J respectively.
|
||||||
//
|
//
|
||||||
// 2. SPARSE_QR
|
// 2. SUITE_SPARSE_QR and EIGEN_SPARSE_QR
|
||||||
//
|
//
|
||||||
// rank(J) < num_col(J)
|
// rank(J) < num_col(J)
|
||||||
//
|
//
|
||||||
@@ -276,7 +278,7 @@ class CERES_EXPORT Covariance {
|
|||||||
// sparse QR factorization algorithm. It is a fairly reliable
|
// sparse QR factorization algorithm. It is a fairly reliable
|
||||||
// indication of rank deficiency.
|
// indication of rank deficiency.
|
||||||
//
|
//
|
||||||
double min_reciprocal_condition_number = 1e-14;
|
double min_reciprocal_condition_number;
|
||||||
|
|
||||||
// When using DENSE_SVD, the user has more control in dealing with
|
// When using DENSE_SVD, the user has more control in dealing with
|
||||||
// singular and near singular covariance matrices.
|
// singular and near singular covariance matrices.
|
||||||
@@ -311,9 +313,9 @@ class CERES_EXPORT Covariance {
|
|||||||
//
|
//
|
||||||
// This option has no effect on the SUITE_SPARSE_QR and
|
// This option has no effect on the SUITE_SPARSE_QR and
|
||||||
// EIGEN_SPARSE_QR algorithms.
|
// EIGEN_SPARSE_QR algorithms.
|
||||||
int null_space_rank = 0;
|
int null_space_rank;
|
||||||
|
|
||||||
int num_threads = 1;
|
int num_threads;
|
||||||
|
|
||||||
// Even though the residual blocks in the problem may contain loss
|
// Even though the residual blocks in the problem may contain loss
|
||||||
// functions, setting apply_loss_function to false will turn off
|
// functions, setting apply_loss_function to false will turn off
|
||||||
@@ -321,7 +323,7 @@ class CERES_EXPORT Covariance {
|
|||||||
// function and in turn its effect on the covariance.
|
// function and in turn its effect on the covariance.
|
||||||
//
|
//
|
||||||
// TODO(sameergaarwal): Expand this based on Jim's experiments.
|
// TODO(sameergaarwal): Expand this based on Jim's experiments.
|
||||||
bool apply_loss_function = true;
|
bool apply_loss_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Covariance(const Options& options);
|
explicit Covariance(const Options& options);
|
||||||
@@ -350,9 +352,10 @@ class CERES_EXPORT Covariance {
|
|||||||
// covariance computation. Please see the documentation for
|
// covariance computation. Please see the documentation for
|
||||||
// Covariance::Options for more on the conditions under which this
|
// Covariance::Options for more on the conditions under which this
|
||||||
// function returns false.
|
// function returns false.
|
||||||
bool Compute(const std::vector<std::pair<const double*, const double*>>&
|
bool Compute(
|
||||||
covariance_blocks,
|
const std::vector<std::pair<const double*,
|
||||||
Problem* problem);
|
const double*> >& covariance_blocks,
|
||||||
|
Problem* problem);
|
||||||
|
|
||||||
// Compute a part of the covariance matrix.
|
// Compute a part of the covariance matrix.
|
||||||
//
|
//
|
||||||
@@ -425,8 +428,8 @@ class CERES_EXPORT Covariance {
|
|||||||
// a square matrix whose row and column count is equal to the sum of
|
// a square matrix whose row and column count is equal to the sum of
|
||||||
// the sizes of the individual parameter blocks. The covariance
|
// the sizes of the individual parameter blocks. The covariance
|
||||||
// matrix will be a row-major matrix.
|
// matrix will be a row-major matrix.
|
||||||
bool GetCovarianceMatrix(const std::vector<const double*>& parameter_blocks,
|
bool GetCovarianceMatrix(const std::vector<const double *> ¶meter_blocks,
|
||||||
double* covariance_matrix) const;
|
double *covariance_matrix);
|
||||||
|
|
||||||
// Return the covariance matrix corresponding to parameter_blocks
|
// Return the covariance matrix corresponding to parameter_blocks
|
||||||
// in the tangent space if a local parameterization is associated
|
// in the tangent space if a local parameterization is associated
|
||||||
@@ -445,10 +448,10 @@ class CERES_EXPORT Covariance {
|
|||||||
// blocks. The covariance matrix will be a row-major matrix.
|
// blocks. The covariance matrix will be a row-major matrix.
|
||||||
bool GetCovarianceMatrixInTangentSpace(
|
bool GetCovarianceMatrixInTangentSpace(
|
||||||
const std::vector<const double*>& parameter_blocks,
|
const std::vector<const double*>& parameter_blocks,
|
||||||
double* covariance_matrix) const;
|
double* covariance_matrix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<internal::CovarianceImpl> impl_;
|
internal::scoped_ptr<internal::CovarianceImpl> impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
5
extern/ceres/include/ceres/crs_matrix.h
vendored
5
extern/ceres/include/ceres/crs_matrix.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -32,9 +32,8 @@
|
|||||||
#define CERES_PUBLIC_CRS_MATRIX_H_
|
#define CERES_PUBLIC_CRS_MATRIX_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ceres/internal/disable_warnings.h"
|
|
||||||
#include "ceres/internal/port.h"
|
#include "ceres/internal/port.h"
|
||||||
|
#include "ceres/internal/disable_warnings.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
|
|
||||||
|
436
extern/ceres/include/ceres/cubic_interpolation.h
vendored
436
extern/ceres/include/ceres/cubic_interpolation.h
vendored
@@ -1,436 +0,0 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
|
||||||
// http://ceres-solver.org/
|
|
||||||
//
|
|
||||||
// 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 Google Inc. nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without
|
|
||||||
// specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
|
|
||||||
//
|
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
|
||||||
|
|
||||||
#ifndef CERES_PUBLIC_CUBIC_INTERPOLATION_H_
|
|
||||||
#define CERES_PUBLIC_CUBIC_INTERPOLATION_H_
|
|
||||||
|
|
||||||
#include "Eigen/Core"
|
|
||||||
#include "ceres/internal/port.h"
|
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// Given samples from a function sampled at four equally spaced points,
|
|
||||||
//
|
|
||||||
// p0 = f(-1)
|
|
||||||
// p1 = f(0)
|
|
||||||
// p2 = f(1)
|
|
||||||
// p3 = f(2)
|
|
||||||
//
|
|
||||||
// Evaluate the cubic Hermite spline (also known as the Catmull-Rom
|
|
||||||
// spline) at a point x that lies in the interval [0, 1].
|
|
||||||
//
|
|
||||||
// This is also the interpolation kernel (for the case of a = 0.5) as
|
|
||||||
// proposed by R. Keys, in:
|
|
||||||
//
|
|
||||||
// "Cubic convolution interpolation for digital image processing".
|
|
||||||
// IEEE Transactions on Acoustics, Speech, and Signal Processing
|
|
||||||
// 29 (6): 1153-1160.
|
|
||||||
//
|
|
||||||
// For more details see
|
|
||||||
//
|
|
||||||
// http://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
||||||
// http://en.wikipedia.org/wiki/Bicubic_interpolation
|
|
||||||
//
|
|
||||||
// f if not NULL will contain the interpolated function values.
|
|
||||||
// dfdx if not NULL will contain the interpolated derivative values.
|
|
||||||
template <int kDataDimension>
|
|
||||||
void CubicHermiteSpline(const Eigen::Matrix<double, kDataDimension, 1>& p0,
|
|
||||||
const Eigen::Matrix<double, kDataDimension, 1>& p1,
|
|
||||||
const Eigen::Matrix<double, kDataDimension, 1>& p2,
|
|
||||||
const Eigen::Matrix<double, kDataDimension, 1>& p3,
|
|
||||||
const double x,
|
|
||||||
double* f,
|
|
||||||
double* dfdx) {
|
|
||||||
typedef Eigen::Matrix<double, kDataDimension, 1> VType;
|
|
||||||
const VType a = 0.5 * (-p0 + 3.0 * p1 - 3.0 * p2 + p3);
|
|
||||||
const VType b = 0.5 * (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3);
|
|
||||||
const VType c = 0.5 * (-p0 + p2);
|
|
||||||
const VType d = p1;
|
|
||||||
|
|
||||||
// Use Horner's rule to evaluate the function value and its
|
|
||||||
// derivative.
|
|
||||||
|
|
||||||
// f = ax^3 + bx^2 + cx + d
|
|
||||||
if (f != NULL) {
|
|
||||||
Eigen::Map<VType>(f, kDataDimension) = d + x * (c + x * (b + x * a));
|
|
||||||
}
|
|
||||||
|
|
||||||
// dfdx = 3ax^2 + 2bx + c
|
|
||||||
if (dfdx != NULL) {
|
|
||||||
Eigen::Map<VType>(dfdx, kDataDimension) = c + x * (2.0 * b + 3.0 * a * x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Given as input an infinite one dimensional grid, which provides the
|
|
||||||
// following interface.
|
|
||||||
//
|
|
||||||
// class Grid {
|
|
||||||
// public:
|
|
||||||
// enum { DATA_DIMENSION = 2; };
|
|
||||||
// void GetValue(int n, double* f) const;
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// Here, GetValue gives the value of a function f (possibly vector
|
|
||||||
// valued) for any integer n.
|
|
||||||
//
|
|
||||||
// The enum DATA_DIMENSION indicates the dimensionality of the
|
|
||||||
// function being interpolated. For example if you are interpolating
|
|
||||||
// rotations in axis-angle format over time, then DATA_DIMENSION = 3.
|
|
||||||
//
|
|
||||||
// CubicInterpolator uses cubic Hermite splines to produce a smooth
|
|
||||||
// approximation to it that can be used to evaluate the f(x) and f'(x)
|
|
||||||
// at any point on the real number line.
|
|
||||||
//
|
|
||||||
// For more details on cubic interpolation see
|
|
||||||
//
|
|
||||||
// http://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
||||||
//
|
|
||||||
// Example usage:
|
|
||||||
//
|
|
||||||
// const double data[] = {1.0, 2.0, 5.0, 6.0};
|
|
||||||
// Grid1D<double, 1> grid(data, 0, 4);
|
|
||||||
// CubicInterpolator<Grid1D<double, 1>> interpolator(grid);
|
|
||||||
// double f, dfdx;
|
|
||||||
// interpolator.Evaluator(1.5, &f, &dfdx);
|
|
||||||
template <typename Grid>
|
|
||||||
class CubicInterpolator {
|
|
||||||
public:
|
|
||||||
explicit CubicInterpolator(const Grid& grid) : grid_(grid) {
|
|
||||||
// The + casts the enum into an int before doing the
|
|
||||||
// comparison. It is needed to prevent
|
|
||||||
// "-Wunnamed-type-template-args" related errors.
|
|
||||||
CHECK_GE(+Grid::DATA_DIMENSION, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Evaluate(double x, double* f, double* dfdx) const {
|
|
||||||
const int n = std::floor(x);
|
|
||||||
Eigen::Matrix<double, Grid::DATA_DIMENSION, 1> p0, p1, p2, p3;
|
|
||||||
grid_.GetValue(n - 1, p0.data());
|
|
||||||
grid_.GetValue(n, p1.data());
|
|
||||||
grid_.GetValue(n + 1, p2.data());
|
|
||||||
grid_.GetValue(n + 2, p3.data());
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(p0, p1, p2, p3, x - n, f, dfdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following two Evaluate overloads are needed for interfacing
|
|
||||||
// with automatic differentiation. The first is for when a scalar
|
|
||||||
// evaluation is done, and the second one is for when Jets are used.
|
|
||||||
void Evaluate(const double& x, double* f) const { Evaluate(x, f, NULL); }
|
|
||||||
|
|
||||||
template <typename JetT>
|
|
||||||
void Evaluate(const JetT& x, JetT* f) const {
|
|
||||||
double fx[Grid::DATA_DIMENSION], dfdx[Grid::DATA_DIMENSION];
|
|
||||||
Evaluate(x.a, fx, dfdx);
|
|
||||||
for (int i = 0; i < Grid::DATA_DIMENSION; ++i) {
|
|
||||||
f[i].a = fx[i];
|
|
||||||
f[i].v = dfdx[i] * x.v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Grid& grid_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// An object that implements an infinite one dimensional grid needed
|
|
||||||
// by the CubicInterpolator where the source of the function values is
|
|
||||||
// an array of type T on the interval
|
|
||||||
//
|
|
||||||
// [begin, ..., end - 1]
|
|
||||||
//
|
|
||||||
// Since the input array is finite and the grid is infinite, values
|
|
||||||
// outside this interval needs to be computed. Grid1D uses the value
|
|
||||||
// from the nearest edge.
|
|
||||||
//
|
|
||||||
// The function being provided can be vector valued, in which case
|
|
||||||
// kDataDimension > 1. The dimensional slices of the function maybe
|
|
||||||
// interleaved, or they maybe stacked, i.e, if the function has
|
|
||||||
// kDataDimension = 2, if kInterleaved = true, then it is stored as
|
|
||||||
//
|
|
||||||
// f01, f02, f11, f12 ....
|
|
||||||
//
|
|
||||||
// and if kInterleaved = false, then it is stored as
|
|
||||||
//
|
|
||||||
// f01, f11, .. fn1, f02, f12, .. , fn2
|
|
||||||
//
|
|
||||||
template <typename T, int kDataDimension = 1, bool kInterleaved = true>
|
|
||||||
struct Grid1D {
|
|
||||||
public:
|
|
||||||
enum { DATA_DIMENSION = kDataDimension };
|
|
||||||
|
|
||||||
Grid1D(const T* data, const int begin, const int end)
|
|
||||||
: data_(data), begin_(begin), end_(end), num_values_(end - begin) {
|
|
||||||
CHECK_LT(begin, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE void GetValue(const int n, double* f) const {
|
|
||||||
const int idx = std::min(std::max(begin_, n), end_ - 1) - begin_;
|
|
||||||
if (kInterleaved) {
|
|
||||||
for (int i = 0; i < kDataDimension; ++i) {
|
|
||||||
f[i] = static_cast<double>(data_[kDataDimension * idx + i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < kDataDimension; ++i) {
|
|
||||||
f[i] = static_cast<double>(data_[i * num_values_ + idx]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const T* data_;
|
|
||||||
const int begin_;
|
|
||||||
const int end_;
|
|
||||||
const int num_values_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Given as input an infinite two dimensional grid like object, which
|
|
||||||
// provides the following interface:
|
|
||||||
//
|
|
||||||
// struct Grid {
|
|
||||||
// enum { DATA_DIMENSION = 1 };
|
|
||||||
// void GetValue(int row, int col, double* f) const;
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// Where, GetValue gives us the value of a function f (possibly vector
|
|
||||||
// valued) for any pairs of integers (row, col), and the enum
|
|
||||||
// DATA_DIMENSION indicates the dimensionality of the function being
|
|
||||||
// interpolated. For example if you are interpolating a color image
|
|
||||||
// with three channels (Red, Green & Blue), then DATA_DIMENSION = 3.
|
|
||||||
//
|
|
||||||
// BiCubicInterpolator uses the cubic convolution interpolation
|
|
||||||
// algorithm of R. Keys, to produce a smooth approximation to it that
|
|
||||||
// can be used to evaluate the f(r,c), df(r, c)/dr and df(r,c)/dc at
|
|
||||||
// any point in the real plane.
|
|
||||||
//
|
|
||||||
// For more details on the algorithm used here see:
|
|
||||||
//
|
|
||||||
// "Cubic convolution interpolation for digital image processing".
|
|
||||||
// Robert G. Keys, IEEE Trans. on Acoustics, Speech, and Signal
|
|
||||||
// Processing 29 (6): 1153-1160, 1981.
|
|
||||||
//
|
|
||||||
// http://en.wikipedia.org/wiki/Cubic_Hermite_spline
|
|
||||||
// http://en.wikipedia.org/wiki/Bicubic_interpolation
|
|
||||||
//
|
|
||||||
// Example usage:
|
|
||||||
//
|
|
||||||
// const double data[] = {1.0, 3.0, -1.0, 4.0,
|
|
||||||
// 3.6, 2.1, 4.2, 2.0,
|
|
||||||
// 2.0, 1.0, 3.1, 5.2};
|
|
||||||
// Grid2D<double, 1> grid(data, 3, 4);
|
|
||||||
// BiCubicInterpolator<Grid2D<double, 1>> interpolator(grid);
|
|
||||||
// double f, dfdr, dfdc;
|
|
||||||
// interpolator.Evaluate(1.2, 2.5, &f, &dfdr, &dfdc);
|
|
||||||
|
|
||||||
template <typename Grid>
|
|
||||||
class BiCubicInterpolator {
|
|
||||||
public:
|
|
||||||
explicit BiCubicInterpolator(const Grid& grid) : grid_(grid) {
|
|
||||||
// The + casts the enum into an int before doing the
|
|
||||||
// comparison. It is needed to prevent
|
|
||||||
// "-Wunnamed-type-template-args" related errors.
|
|
||||||
CHECK_GE(+Grid::DATA_DIMENSION, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Evaluate the interpolated function value and/or its
|
|
||||||
// derivative. Uses the nearest point on the grid boundary if r or
|
|
||||||
// c is out of bounds.
|
|
||||||
void Evaluate(
|
|
||||||
double r, double c, double* f, double* dfdr, double* dfdc) const {
|
|
||||||
// BiCubic interpolation requires 16 values around the point being
|
|
||||||
// evaluated. We will use pij, to indicate the elements of the
|
|
||||||
// 4x4 grid of values.
|
|
||||||
//
|
|
||||||
// col
|
|
||||||
// p00 p01 p02 p03
|
|
||||||
// row p10 p11 p12 p13
|
|
||||||
// p20 p21 p22 p23
|
|
||||||
// p30 p31 p32 p33
|
|
||||||
//
|
|
||||||
// The point (r,c) being evaluated is assumed to lie in the square
|
|
||||||
// defined by p11, p12, p22 and p21.
|
|
||||||
|
|
||||||
const int row = std::floor(r);
|
|
||||||
const int col = std::floor(c);
|
|
||||||
|
|
||||||
Eigen::Matrix<double, Grid::DATA_DIMENSION, 1> p0, p1, p2, p3;
|
|
||||||
|
|
||||||
// Interpolate along each of the four rows, evaluating the function
|
|
||||||
// value and the horizontal derivative in each row.
|
|
||||||
Eigen::Matrix<double, Grid::DATA_DIMENSION, 1> f0, f1, f2, f3;
|
|
||||||
Eigen::Matrix<double, Grid::DATA_DIMENSION, 1> df0dc, df1dc, df2dc, df3dc;
|
|
||||||
|
|
||||||
grid_.GetValue(row - 1, col - 1, p0.data());
|
|
||||||
grid_.GetValue(row - 1, col, p1.data());
|
|
||||||
grid_.GetValue(row - 1, col + 1, p2.data());
|
|
||||||
grid_.GetValue(row - 1, col + 2, p3.data());
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(
|
|
||||||
p0, p1, p2, p3, c - col, f0.data(), df0dc.data());
|
|
||||||
|
|
||||||
grid_.GetValue(row, col - 1, p0.data());
|
|
||||||
grid_.GetValue(row, col, p1.data());
|
|
||||||
grid_.GetValue(row, col + 1, p2.data());
|
|
||||||
grid_.GetValue(row, col + 2, p3.data());
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(
|
|
||||||
p0, p1, p2, p3, c - col, f1.data(), df1dc.data());
|
|
||||||
|
|
||||||
grid_.GetValue(row + 1, col - 1, p0.data());
|
|
||||||
grid_.GetValue(row + 1, col, p1.data());
|
|
||||||
grid_.GetValue(row + 1, col + 1, p2.data());
|
|
||||||
grid_.GetValue(row + 1, col + 2, p3.data());
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(
|
|
||||||
p0, p1, p2, p3, c - col, f2.data(), df2dc.data());
|
|
||||||
|
|
||||||
grid_.GetValue(row + 2, col - 1, p0.data());
|
|
||||||
grid_.GetValue(row + 2, col, p1.data());
|
|
||||||
grid_.GetValue(row + 2, col + 1, p2.data());
|
|
||||||
grid_.GetValue(row + 2, col + 2, p3.data());
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(
|
|
||||||
p0, p1, p2, p3, c - col, f3.data(), df3dc.data());
|
|
||||||
|
|
||||||
// Interpolate vertically the interpolated value from each row and
|
|
||||||
// compute the derivative along the columns.
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(f0, f1, f2, f3, r - row, f, dfdr);
|
|
||||||
if (dfdc != NULL) {
|
|
||||||
// Interpolate vertically the derivative along the columns.
|
|
||||||
CubicHermiteSpline<Grid::DATA_DIMENSION>(
|
|
||||||
df0dc, df1dc, df2dc, df3dc, r - row, dfdc, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following two Evaluate overloads are needed for interfacing
|
|
||||||
// with automatic differentiation. The first is for when a scalar
|
|
||||||
// evaluation is done, and the second one is for when Jets are used.
|
|
||||||
void Evaluate(const double& r, const double& c, double* f) const {
|
|
||||||
Evaluate(r, c, f, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename JetT>
|
|
||||||
void Evaluate(const JetT& r, const JetT& c, JetT* f) const {
|
|
||||||
double frc[Grid::DATA_DIMENSION];
|
|
||||||
double dfdr[Grid::DATA_DIMENSION];
|
|
||||||
double dfdc[Grid::DATA_DIMENSION];
|
|
||||||
Evaluate(r.a, c.a, frc, dfdr, dfdc);
|
|
||||||
for (int i = 0; i < Grid::DATA_DIMENSION; ++i) {
|
|
||||||
f[i].a = frc[i];
|
|
||||||
f[i].v = dfdr[i] * r.v + dfdc[i] * c.v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Grid& grid_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// An object that implements an infinite two dimensional grid needed
|
|
||||||
// by the BiCubicInterpolator where the source of the function values
|
|
||||||
// is an grid of type T on the grid
|
|
||||||
//
|
|
||||||
// [(row_start, col_start), ..., (row_start, col_end - 1)]
|
|
||||||
// [ ... ]
|
|
||||||
// [(row_end - 1, col_start), ..., (row_end - 1, col_end - 1)]
|
|
||||||
//
|
|
||||||
// Since the input grid is finite and the grid is infinite, values
|
|
||||||
// outside this interval needs to be computed. Grid2D uses the value
|
|
||||||
// from the nearest edge.
|
|
||||||
//
|
|
||||||
// The function being provided can be vector valued, in which case
|
|
||||||
// kDataDimension > 1. The data maybe stored in row or column major
|
|
||||||
// format and the various dimensional slices of the function maybe
|
|
||||||
// interleaved, or they maybe stacked, i.e, if the function has
|
|
||||||
// kDataDimension = 2, is stored in row-major format and if
|
|
||||||
// kInterleaved = true, then it is stored as
|
|
||||||
//
|
|
||||||
// f001, f002, f011, f012, ...
|
|
||||||
//
|
|
||||||
// A commonly occuring example are color images (RGB) where the three
|
|
||||||
// channels are stored interleaved.
|
|
||||||
//
|
|
||||||
// If kInterleaved = false, then it is stored as
|
|
||||||
//
|
|
||||||
// f001, f011, ..., fnm1, f002, f012, ...
|
|
||||||
template <typename T,
|
|
||||||
int kDataDimension = 1,
|
|
||||||
bool kRowMajor = true,
|
|
||||||
bool kInterleaved = true>
|
|
||||||
struct Grid2D {
|
|
||||||
public:
|
|
||||||
enum { DATA_DIMENSION = kDataDimension };
|
|
||||||
|
|
||||||
Grid2D(const T* data,
|
|
||||||
const int row_begin,
|
|
||||||
const int row_end,
|
|
||||||
const int col_begin,
|
|
||||||
const int col_end)
|
|
||||||
: data_(data),
|
|
||||||
row_begin_(row_begin),
|
|
||||||
row_end_(row_end),
|
|
||||||
col_begin_(col_begin),
|
|
||||||
col_end_(col_end),
|
|
||||||
num_rows_(row_end - row_begin),
|
|
||||||
num_cols_(col_end - col_begin),
|
|
||||||
num_values_(num_rows_ * num_cols_) {
|
|
||||||
CHECK_GE(kDataDimension, 1);
|
|
||||||
CHECK_LT(row_begin, row_end);
|
|
||||||
CHECK_LT(col_begin, col_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE void GetValue(const int r, const int c, double* f) const {
|
|
||||||
const int row_idx =
|
|
||||||
std::min(std::max(row_begin_, r), row_end_ - 1) - row_begin_;
|
|
||||||
const int col_idx =
|
|
||||||
std::min(std::max(col_begin_, c), col_end_ - 1) - col_begin_;
|
|
||||||
|
|
||||||
const int n = (kRowMajor) ? num_cols_ * row_idx + col_idx
|
|
||||||
: num_rows_ * col_idx + row_idx;
|
|
||||||
|
|
||||||
if (kInterleaved) {
|
|
||||||
for (int i = 0; i < kDataDimension; ++i) {
|
|
||||||
f[i] = static_cast<double>(data_[kDataDimension * n + i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < kDataDimension; ++i) {
|
|
||||||
f[i] = static_cast<double>(data_[i * num_values_ + n]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const T* data_;
|
|
||||||
const int row_begin_;
|
|
||||||
const int row_end_;
|
|
||||||
const int col_begin_;
|
|
||||||
const int col_end_;
|
|
||||||
const int num_rows_;
|
|
||||||
const int num_cols_;
|
|
||||||
const int num_values_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ceres
|
|
||||||
|
|
||||||
#endif // CERES_PUBLIC_CUBIC_INTERPOLATOR_H_
|
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -28,22 +28,7 @@
|
|||||||
//
|
//
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
||||||
// mierle@gmail.com (Keir Mierle)
|
// mierle@gmail.com (Keir Mierle)
|
||||||
|
//
|
||||||
#ifndef CERES_PUBLIC_DYNAMIC_AUTODIFF_COST_FUNCTION_H_
|
|
||||||
#define CERES_PUBLIC_DYNAMIC_AUTODIFF_COST_FUNCTION_H_
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <memory>
|
|
||||||
#include <numeric>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "ceres/dynamic_cost_function.h"
|
|
||||||
#include "ceres/internal/fixed_array.h"
|
|
||||||
#include "ceres/jet.h"
|
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// This autodiff implementation differs from the one found in
|
// This autodiff implementation differs from the one found in
|
||||||
// autodiff_cost_function.h by supporting autodiff on cost functions
|
// autodiff_cost_function.h by supporting autodiff on cost functions
|
||||||
// with variable numbers of parameters with variable sizes. With the
|
// with variable numbers of parameters with variable sizes. With the
|
||||||
@@ -58,7 +43,7 @@ namespace ceres {
|
|||||||
// bool operator()(T const* const* parameters, T* residuals) const {
|
// bool operator()(T const* const* parameters, T* residuals) const {
|
||||||
// // Use parameters[i] to access the i'th parameter block.
|
// // Use parameters[i] to access the i'th parameter block.
|
||||||
// }
|
// }
|
||||||
// };
|
// }
|
||||||
//
|
//
|
||||||
// Since the sizing of the parameters is done at runtime, you must
|
// Since the sizing of the parameters is done at runtime, you must
|
||||||
// also specify the sizes after creating the dynamic autodiff cost
|
// also specify the sizes after creating the dynamic autodiff cost
|
||||||
@@ -75,17 +60,40 @@ namespace ceres {
|
|||||||
// default, controlled by the Stride template parameter) with each
|
// default, controlled by the Stride template parameter) with each
|
||||||
// pass. There is a tradeoff with the size of the passes; you may want
|
// pass. There is a tradeoff with the size of the passes; you may want
|
||||||
// to experiment with the stride.
|
// to experiment with the stride.
|
||||||
|
|
||||||
|
#ifndef CERES_PUBLIC_DYNAMIC_AUTODIFF_COST_FUNCTION_H_
|
||||||
|
#define CERES_PUBLIC_DYNAMIC_AUTODIFF_COST_FUNCTION_H_
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <numeric>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ceres/cost_function.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
|
#include "ceres/jet.h"
|
||||||
|
#include "glog/logging.h"
|
||||||
|
|
||||||
|
namespace ceres {
|
||||||
|
|
||||||
template <typename CostFunctor, int Stride = 4>
|
template <typename CostFunctor, int Stride = 4>
|
||||||
class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
class DynamicAutoDiffCostFunction : public CostFunction {
|
||||||
public:
|
public:
|
||||||
explicit DynamicAutoDiffCostFunction(CostFunctor* functor)
|
explicit DynamicAutoDiffCostFunction(CostFunctor* functor)
|
||||||
: functor_(functor) {}
|
: functor_(functor) {}
|
||||||
|
|
||||||
virtual ~DynamicAutoDiffCostFunction() {}
|
virtual ~DynamicAutoDiffCostFunction() {}
|
||||||
|
|
||||||
bool Evaluate(double const* const* parameters,
|
void AddParameterBlock(int size) {
|
||||||
double* residuals,
|
mutable_parameter_block_sizes()->push_back(size);
|
||||||
double** jacobians) const override {
|
}
|
||||||
|
|
||||||
|
void SetNumResiduals(int num_residuals) {
|
||||||
|
set_num_residuals(num_residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool Evaluate(double const* const* parameters,
|
||||||
|
double* residuals,
|
||||||
|
double** jacobians) const {
|
||||||
CHECK_GT(num_residuals(), 0)
|
CHECK_GT(num_residuals(), 0)
|
||||||
<< "You must call DynamicAutoDiffCostFunction::SetNumResiduals() "
|
<< "You must call DynamicAutoDiffCostFunction::SetNumResiduals() "
|
||||||
<< "before DynamicAutoDiffCostFunction::Evaluate().";
|
<< "before DynamicAutoDiffCostFunction::Evaluate().";
|
||||||
@@ -104,23 +112,20 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
|||||||
// depends on.
|
// depends on.
|
||||||
//
|
//
|
||||||
// To work around this issue, the solution here is to evaluate the
|
// To work around this issue, the solution here is to evaluate the
|
||||||
// jacobians in a series of passes, each one computing Stride *
|
// jacobians in a series of passes, each one computing Stripe *
|
||||||
// num_residuals() derivatives. This is done with small, fixed-size jets.
|
// num_residuals() derivatives. This is done with small, fixed-size jets.
|
||||||
const int num_parameter_blocks =
|
const int num_parameter_blocks = parameter_block_sizes().size();
|
||||||
static_cast<int>(parameter_block_sizes().size());
|
const int num_parameters = std::accumulate(parameter_block_sizes().begin(),
|
||||||
const int num_parameters = std::accumulate(
|
parameter_block_sizes().end(),
|
||||||
parameter_block_sizes().begin(), parameter_block_sizes().end(), 0);
|
0);
|
||||||
|
|
||||||
// Allocate scratch space for the strided evaluation.
|
// Allocate scratch space for the strided evaluation.
|
||||||
using JetT = Jet<double, Stride>;
|
std::vector<Jet<double, Stride> > input_jets(num_parameters);
|
||||||
internal::FixedArray<JetT, (256 * 7) / sizeof(JetT)> input_jets(
|
std::vector<Jet<double, Stride> > output_jets(num_residuals());
|
||||||
num_parameters);
|
|
||||||
internal::FixedArray<JetT, (256 * 7) / sizeof(JetT)> output_jets(
|
|
||||||
num_residuals());
|
|
||||||
|
|
||||||
// Make the parameter pack that is sent to the functor (reused).
|
// Make the parameter pack that is sent to the functor (reused).
|
||||||
internal::FixedArray<Jet<double, Stride>*> jet_parameters(
|
std::vector<Jet<double, Stride>* > jet_parameters(num_parameter_blocks,
|
||||||
num_parameter_blocks, nullptr);
|
static_cast<Jet<double, Stride>* >(NULL));
|
||||||
int num_active_parameters = 0;
|
int num_active_parameters = 0;
|
||||||
|
|
||||||
// To handle constant parameters between non-constant parameter blocks, the
|
// To handle constant parameters between non-constant parameter blocks, the
|
||||||
@@ -167,8 +172,8 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
|||||||
// Evaluate all of the strides. Each stride is a chunk of the derivative to
|
// Evaluate all of the strides. Each stride is a chunk of the derivative to
|
||||||
// evaluate, typically some size proportional to the size of the SIMD
|
// evaluate, typically some size proportional to the size of the SIMD
|
||||||
// registers of the CPU.
|
// registers of the CPU.
|
||||||
int num_strides = static_cast<int>(
|
int num_strides = static_cast<int>(ceil(num_active_parameters /
|
||||||
ceil(num_active_parameters / static_cast<float>(Stride)));
|
static_cast<float>(Stride)));
|
||||||
|
|
||||||
int current_derivative_section = 0;
|
int current_derivative_section = 0;
|
||||||
int current_derivative_section_cursor = 0;
|
int current_derivative_section_cursor = 0;
|
||||||
@@ -178,7 +183,7 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
|||||||
// non-constant #Stride parameters.
|
// non-constant #Stride parameters.
|
||||||
const int initial_derivative_section = current_derivative_section;
|
const int initial_derivative_section = current_derivative_section;
|
||||||
const int initial_derivative_section_cursor =
|
const int initial_derivative_section_cursor =
|
||||||
current_derivative_section_cursor;
|
current_derivative_section_cursor;
|
||||||
|
|
||||||
int active_parameter_count = 0;
|
int active_parameter_count = 0;
|
||||||
parameter_cursor = 0;
|
parameter_cursor = 0;
|
||||||
@@ -188,9 +193,9 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
|||||||
++j, parameter_cursor++) {
|
++j, parameter_cursor++) {
|
||||||
input_jets[parameter_cursor].v.setZero();
|
input_jets[parameter_cursor].v.setZero();
|
||||||
if (active_parameter_count < Stride &&
|
if (active_parameter_count < Stride &&
|
||||||
parameter_cursor >=
|
parameter_cursor >= (
|
||||||
(start_derivative_section[current_derivative_section] +
|
start_derivative_section[current_derivative_section] +
|
||||||
current_derivative_section_cursor)) {
|
current_derivative_section_cursor)) {
|
||||||
if (jacobians[i] != NULL) {
|
if (jacobians[i] != NULL) {
|
||||||
input_jets[parameter_cursor].v[active_parameter_count] = 1.0;
|
input_jets[parameter_cursor].v[active_parameter_count] = 1.0;
|
||||||
++active_parameter_count;
|
++active_parameter_count;
|
||||||
@@ -217,9 +222,9 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
|||||||
for (int j = 0; j < parameter_block_sizes()[i];
|
for (int j = 0; j < parameter_block_sizes()[i];
|
||||||
++j, parameter_cursor++) {
|
++j, parameter_cursor++) {
|
||||||
if (active_parameter_count < Stride &&
|
if (active_parameter_count < Stride &&
|
||||||
parameter_cursor >=
|
parameter_cursor >= (
|
||||||
(start_derivative_section[current_derivative_section] +
|
start_derivative_section[current_derivative_section] +
|
||||||
current_derivative_section_cursor)) {
|
current_derivative_section_cursor)) {
|
||||||
if (jacobians[i] != NULL) {
|
if (jacobians[i] != NULL) {
|
||||||
for (int k = 0; k < num_residuals(); ++k) {
|
for (int k = 0; k < num_residuals(); ++k) {
|
||||||
jacobians[i][k * parameter_block_sizes()[i] + j] =
|
jacobians[i][k * parameter_block_sizes()[i] + j] =
|
||||||
@@ -247,7 +252,7 @@ class DynamicAutoDiffCostFunction : public DynamicCostFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<CostFunctor> functor_;
|
internal::scoped_ptr<CostFunctor> functor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
@@ -1,56 +0,0 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
|
||||||
// http://ceres-solver.org/
|
|
||||||
//
|
|
||||||
// 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 Google Inc. nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without
|
|
||||||
// specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
|
|
||||||
//
|
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
|
||||||
|
|
||||||
#ifndef CERES_PUBLIC_DYNAMIC_COST_FUNCTION_H_
|
|
||||||
#define CERES_PUBLIC_DYNAMIC_COST_FUNCTION_H_
|
|
||||||
|
|
||||||
#include "ceres/cost_function.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// A common base class for DynamicAutoDiffCostFunction and
|
|
||||||
// DynamicNumericDiffCostFunction which depend on methods that can add
|
|
||||||
// parameter blocks and set the number of residuals at run time.
|
|
||||||
class CERES_EXPORT DynamicCostFunction : public CostFunction {
|
|
||||||
public:
|
|
||||||
~DynamicCostFunction() {}
|
|
||||||
|
|
||||||
virtual void AddParameterBlock(int size) {
|
|
||||||
mutable_parameter_block_sizes()->push_back(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void SetNumResiduals(int num_residuals) {
|
|
||||||
set_num_residuals(num_residuals);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ceres
|
|
||||||
|
|
||||||
#endif // CERES_PUBLIC_DYNAMIC_COST_FUNCTION_H_
|
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -28,20 +28,7 @@
|
|||||||
//
|
//
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
||||||
// dgossow@google.com (David Gossow)
|
// dgossow@google.com (David Gossow)
|
||||||
|
//
|
||||||
#ifndef CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_
|
|
||||||
#define CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <numeric>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "ceres/dynamic_cost_function.h"
|
|
||||||
#include "ceres/internal/fixed_array.h"
|
|
||||||
#include "ceres/internal/port.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// DynamicCostFunctionToFunctor allows users to use CostFunction
|
// DynamicCostFunctionToFunctor allows users to use CostFunction
|
||||||
// objects in templated functors which are to be used for automatic
|
// objects in templated functors which are to be used for automatic
|
||||||
// differentiation. It works similar to CostFunctionToFunctor, with the
|
// differentiation. It works similar to CostFunctionToFunctor, with the
|
||||||
@@ -53,9 +40,9 @@ namespace ceres {
|
|||||||
// class IntrinsicProjection : public CostFunction {
|
// class IntrinsicProjection : public CostFunction {
|
||||||
// public:
|
// public:
|
||||||
// IntrinsicProjection(const double* observation);
|
// IntrinsicProjection(const double* observation);
|
||||||
// bool Evaluate(double const* const* parameters,
|
// virtual bool Evaluate(double const* const* parameters,
|
||||||
// double* residuals,
|
// double* residuals,
|
||||||
// double** jacobians) const override;
|
// double** jacobians) const;
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// is a cost function that implements the projection of a point in its
|
// is a cost function that implements the projection of a point in its
|
||||||
@@ -100,12 +87,26 @@ namespace ceres {
|
|||||||
// private:
|
// private:
|
||||||
// DynamicCostFunctionToFunctor intrinsic_projection_;
|
// DynamicCostFunctionToFunctor intrinsic_projection_;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
#ifndef CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_
|
||||||
|
#define CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ceres/cost_function.h"
|
||||||
|
#include "ceres/internal/fixed_array.h"
|
||||||
|
#include "ceres/internal/port.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
|
|
||||||
|
namespace ceres {
|
||||||
|
|
||||||
class DynamicCostFunctionToFunctor {
|
class DynamicCostFunctionToFunctor {
|
||||||
public:
|
public:
|
||||||
// Takes ownership of cost_function.
|
// Takes ownership of cost_function.
|
||||||
explicit DynamicCostFunctionToFunctor(CostFunction* cost_function)
|
explicit DynamicCostFunctionToFunctor(CostFunction* cost_function)
|
||||||
: cost_function_(cost_function) {
|
: cost_function_(cost_function) {
|
||||||
CHECK(cost_function != nullptr);
|
CHECK_NOTNULL(cost_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(double const* const* parameters, double* residuals) const {
|
bool operator()(double const* const* parameters, double* residuals) const {
|
||||||
@@ -114,13 +115,12 @@ class DynamicCostFunctionToFunctor {
|
|||||||
|
|
||||||
template <typename JetT>
|
template <typename JetT>
|
||||||
bool operator()(JetT const* const* inputs, JetT* output) const {
|
bool operator()(JetT const* const* inputs, JetT* output) const {
|
||||||
const std::vector<int32_t>& parameter_block_sizes =
|
const std::vector<int32>& parameter_block_sizes =
|
||||||
cost_function_->parameter_block_sizes();
|
cost_function_->parameter_block_sizes();
|
||||||
const int num_parameter_blocks =
|
const int num_parameter_blocks = parameter_block_sizes.size();
|
||||||
static_cast<int>(parameter_block_sizes.size());
|
|
||||||
const int num_residuals = cost_function_->num_residuals();
|
const int num_residuals = cost_function_->num_residuals();
|
||||||
const int num_parameters = std::accumulate(
|
const int num_parameters = std::accumulate(parameter_block_sizes.begin(),
|
||||||
parameter_block_sizes.begin(), parameter_block_sizes.end(), 0);
|
parameter_block_sizes.end(), 0);
|
||||||
|
|
||||||
internal::FixedArray<double> parameters(num_parameters);
|
internal::FixedArray<double> parameters(num_parameters);
|
||||||
internal::FixedArray<double*> parameter_blocks(num_parameter_blocks);
|
internal::FixedArray<double*> parameter_blocks(num_parameter_blocks);
|
||||||
@@ -130,8 +130,8 @@ class DynamicCostFunctionToFunctor {
|
|||||||
|
|
||||||
// Build a set of arrays to get the residuals and jacobians from
|
// Build a set of arrays to get the residuals and jacobians from
|
||||||
// the CostFunction wrapped by this functor.
|
// the CostFunction wrapped by this functor.
|
||||||
double* parameter_ptr = parameters.data();
|
double* parameter_ptr = parameters.get();
|
||||||
double* jacobian_ptr = jacobians.data();
|
double* jacobian_ptr = jacobians.get();
|
||||||
for (int i = 0; i < num_parameter_blocks; ++i) {
|
for (int i = 0; i < num_parameter_blocks; ++i) {
|
||||||
parameter_blocks[i] = parameter_ptr;
|
parameter_blocks[i] = parameter_ptr;
|
||||||
jacobian_blocks[i] = jacobian_ptr;
|
jacobian_blocks[i] = jacobian_ptr;
|
||||||
@@ -141,9 +141,9 @@ class DynamicCostFunctionToFunctor {
|
|||||||
jacobian_ptr += num_residuals * parameter_block_sizes[i];
|
jacobian_ptr += num_residuals * parameter_block_sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cost_function_->Evaluate(parameter_blocks.data(),
|
if (!cost_function_->Evaluate(parameter_blocks.get(),
|
||||||
residuals.data(),
|
residuals.get(),
|
||||||
jacobian_blocks.data())) {
|
jacobian_blocks.get())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ class DynamicCostFunctionToFunctor {
|
|||||||
output[i].v.setZero();
|
output[i].v.setZero();
|
||||||
|
|
||||||
for (int j = 0; j < num_parameter_blocks; ++j) {
|
for (int j = 0; j < num_parameter_blocks; ++j) {
|
||||||
const int32_t block_size = parameter_block_sizes[j];
|
const int32 block_size = parameter_block_sizes[j];
|
||||||
for (int k = 0; k < parameter_block_sizes[j]; ++k) {
|
for (int k = 0; k < parameter_block_sizes[j]; ++k) {
|
||||||
output[i].v +=
|
output[i].v +=
|
||||||
jacobian_blocks[j][i * block_size + k] * inputs[j][k].v;
|
jacobian_blocks[j][i * block_size + k] * inputs[j][k].v;
|
||||||
@@ -182,7 +182,7 @@ class DynamicCostFunctionToFunctor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<CostFunction> cost_function_;
|
internal::scoped_ptr<CostFunction> cost_function_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -30,24 +30,7 @@
|
|||||||
// sameeragarwal@google.com (Sameer Agarwal)
|
// sameeragarwal@google.com (Sameer Agarwal)
|
||||||
// thadh@gmail.com (Thad Hughes)
|
// thadh@gmail.com (Thad Hughes)
|
||||||
// tbennun@gmail.com (Tal Ben-Nun)
|
// tbennun@gmail.com (Tal Ben-Nun)
|
||||||
|
//
|
||||||
#ifndef CERES_PUBLIC_DYNAMIC_NUMERIC_DIFF_COST_FUNCTION_H_
|
|
||||||
#define CERES_PUBLIC_DYNAMIC_NUMERIC_DIFF_COST_FUNCTION_H_
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <memory>
|
|
||||||
#include <numeric>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "ceres/dynamic_cost_function.h"
|
|
||||||
#include "ceres/internal/eigen.h"
|
|
||||||
#include "ceres/internal/numeric_diff.h"
|
|
||||||
#include "ceres/internal/parameter_dims.h"
|
|
||||||
#include "ceres/numeric_diff_options.h"
|
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// This numeric diff implementation differs from the one found in
|
// This numeric diff implementation differs from the one found in
|
||||||
// numeric_diff_cost_function.h by supporting numericdiff on cost
|
// numeric_diff_cost_function.h by supporting numericdiff on cost
|
||||||
// functions with variable numbers of parameters with variable
|
// functions with variable numbers of parameters with variable
|
||||||
@@ -59,9 +42,7 @@ namespace ceres {
|
|||||||
// numeric diff; the expected interface for the cost functors is:
|
// numeric diff; the expected interface for the cost functors is:
|
||||||
//
|
//
|
||||||
// struct MyCostFunctor {
|
// struct MyCostFunctor {
|
||||||
// bool operator()(double const*
|
// bool operator()(double const* const* parameters, double* residuals) const {
|
||||||
// const* parameters,
|
|
||||||
// double* residuals) const {
|
|
||||||
// // Use parameters[i] to access the i'th parameter block.
|
// // Use parameters[i] to access the i'th parameter block.
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@@ -75,14 +56,34 @@ namespace ceres {
|
|||||||
// cost_function.AddParameterBlock(5);
|
// cost_function.AddParameterBlock(5);
|
||||||
// cost_function.AddParameterBlock(10);
|
// cost_function.AddParameterBlock(10);
|
||||||
// cost_function.SetNumResiduals(21);
|
// cost_function.SetNumResiduals(21);
|
||||||
|
|
||||||
|
#ifndef CERES_PUBLIC_DYNAMIC_NUMERIC_DIFF_COST_FUNCTION_H_
|
||||||
|
#define CERES_PUBLIC_DYNAMIC_NUMERIC_DIFF_COST_FUNCTION_H_
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <numeric>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ceres/cost_function.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
|
#include "ceres/internal/eigen.h"
|
||||||
|
#include "ceres/internal/numeric_diff.h"
|
||||||
|
#include "ceres/numeric_diff_options.h"
|
||||||
|
#include "glog/logging.h"
|
||||||
|
|
||||||
|
namespace ceres {
|
||||||
|
|
||||||
template <typename CostFunctor, NumericDiffMethodType method = CENTRAL>
|
template <typename CostFunctor, NumericDiffMethodType method = CENTRAL>
|
||||||
class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
class DynamicNumericDiffCostFunction : public CostFunction {
|
||||||
public:
|
public:
|
||||||
explicit DynamicNumericDiffCostFunction(
|
explicit DynamicNumericDiffCostFunction(
|
||||||
const CostFunctor* functor,
|
const CostFunctor* functor,
|
||||||
Ownership ownership = TAKE_OWNERSHIP,
|
Ownership ownership = TAKE_OWNERSHIP,
|
||||||
const NumericDiffOptions& options = NumericDiffOptions())
|
const NumericDiffOptions& options = NumericDiffOptions())
|
||||||
: functor_(functor), ownership_(ownership), options_(options) {}
|
: functor_(functor),
|
||||||
|
ownership_(ownership),
|
||||||
|
options_(options) {
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~DynamicNumericDiffCostFunction() {
|
virtual ~DynamicNumericDiffCostFunction() {
|
||||||
if (ownership_ != TAKE_OWNERSHIP) {
|
if (ownership_ != TAKE_OWNERSHIP) {
|
||||||
@@ -90,22 +91,28 @@ class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Evaluate(double const* const* parameters,
|
void AddParameterBlock(int size) {
|
||||||
double* residuals,
|
mutable_parameter_block_sizes()->push_back(size);
|
||||||
double** jacobians) const override {
|
}
|
||||||
|
|
||||||
|
void SetNumResiduals(int num_residuals) {
|
||||||
|
set_num_residuals(num_residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool Evaluate(double const* const* parameters,
|
||||||
|
double* residuals,
|
||||||
|
double** jacobians) const {
|
||||||
using internal::NumericDiff;
|
using internal::NumericDiff;
|
||||||
CHECK_GT(num_residuals(), 0)
|
CHECK_GT(num_residuals(), 0)
|
||||||
<< "You must call DynamicNumericDiffCostFunction::SetNumResiduals() "
|
<< "You must call DynamicNumericDiffCostFunction::SetNumResiduals() "
|
||||||
<< "before DynamicNumericDiffCostFunction::Evaluate().";
|
<< "before DynamicNumericDiffCostFunction::Evaluate().";
|
||||||
|
|
||||||
const std::vector<int32_t>& block_sizes = parameter_block_sizes();
|
const std::vector<int32>& block_sizes = parameter_block_sizes();
|
||||||
CHECK(!block_sizes.empty())
|
CHECK(!block_sizes.empty())
|
||||||
<< "You must call DynamicNumericDiffCostFunction::AddParameterBlock() "
|
<< "You must call DynamicNumericDiffCostFunction::AddParameterBlock() "
|
||||||
<< "before DynamicNumericDiffCostFunction::Evaluate().";
|
<< "before DynamicNumericDiffCostFunction::Evaluate().";
|
||||||
|
|
||||||
const bool status =
|
const bool status = EvaluateCostFunctor(parameters, residuals);
|
||||||
internal::VariadicEvaluate<internal::DynamicParameterDims>(
|
|
||||||
*functor_.get(), parameters, residuals);
|
|
||||||
if (jacobians == NULL || !status) {
|
if (jacobians == NULL || !status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -116,8 +123,8 @@ class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
|||||||
std::vector<double*> parameters_references_copy(block_sizes.size());
|
std::vector<double*> parameters_references_copy(block_sizes.size());
|
||||||
parameters_references_copy[0] = ¶meters_copy[0];
|
parameters_references_copy[0] = ¶meters_copy[0];
|
||||||
for (size_t block = 1; block < block_sizes.size(); ++block) {
|
for (size_t block = 1; block < block_sizes.size(); ++block) {
|
||||||
parameters_references_copy[block] =
|
parameters_references_copy[block] = parameters_references_copy[block - 1]
|
||||||
parameters_references_copy[block - 1] + block_sizes[block - 1];
|
+ block_sizes[block - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the parameters into the local temp space.
|
// Copy the parameters into the local temp space.
|
||||||
@@ -129,20 +136,18 @@ class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
|||||||
|
|
||||||
for (size_t block = 0; block < block_sizes.size(); ++block) {
|
for (size_t block = 0; block < block_sizes.size(); ++block) {
|
||||||
if (jacobians[block] != NULL &&
|
if (jacobians[block] != NULL &&
|
||||||
!NumericDiff<CostFunctor,
|
!NumericDiff<CostFunctor, method, DYNAMIC,
|
||||||
method,
|
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
|
||||||
ceres::DYNAMIC,
|
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
|
||||||
internal::DynamicParameterDims,
|
DYNAMIC, DYNAMIC>::EvaluateJacobianForParameterBlock(
|
||||||
ceres::DYNAMIC,
|
functor_.get(),
|
||||||
ceres::DYNAMIC>::
|
residuals,
|
||||||
EvaluateJacobianForParameterBlock(functor_.get(),
|
options_,
|
||||||
residuals,
|
this->num_residuals(),
|
||||||
options_,
|
block,
|
||||||
this->num_residuals(),
|
block_sizes[block],
|
||||||
block,
|
¶meters_references_copy[0],
|
||||||
block_sizes[block],
|
jacobians[block])) {
|
||||||
¶meters_references_copy[0],
|
|
||||||
jacobians[block])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +155,31 @@ class DynamicNumericDiffCostFunction : public DynamicCostFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<const CostFunctor> functor_;
|
bool EvaluateCostFunctor(double const* const* parameters,
|
||||||
|
double* residuals) const {
|
||||||
|
return EvaluateCostFunctorImpl(functor_.get(),
|
||||||
|
parameters,
|
||||||
|
residuals,
|
||||||
|
functor_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper templates to allow evaluation of a functor or a
|
||||||
|
// CostFunction.
|
||||||
|
bool EvaluateCostFunctorImpl(const CostFunctor* functor,
|
||||||
|
double const* const* parameters,
|
||||||
|
double* residuals,
|
||||||
|
const void* /* NOT USED */) const {
|
||||||
|
return (*functor)(parameters, residuals);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EvaluateCostFunctorImpl(const CostFunctor* functor,
|
||||||
|
double const* const* parameters,
|
||||||
|
double* residuals,
|
||||||
|
const CostFunction* /* NOT USED */) const {
|
||||||
|
return functor->Evaluate(parameters, residuals, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal::scoped_ptr<const CostFunctor> functor_;
|
||||||
Ownership ownership_;
|
Ownership ownership_;
|
||||||
NumericDiffOptions options_;
|
NumericDiffOptions options_;
|
||||||
};
|
};
|
||||||
|
80
extern/ceres/include/ceres/evaluation_callback.h
vendored
80
extern/ceres/include/ceres/evaluation_callback.h
vendored
@@ -1,80 +0,0 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
|
||||||
// http://ceres-solver.org/
|
|
||||||
//
|
|
||||||
// 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 Google Inc. nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without
|
|
||||||
// specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
|
|
||||||
//
|
|
||||||
// Author: mierle@gmail.com (Keir Mierle)
|
|
||||||
|
|
||||||
#ifndef CERES_PUBLIC_EVALUATION_CALLBACK_H_
|
|
||||||
#define CERES_PUBLIC_EVALUATION_CALLBACK_H_
|
|
||||||
|
|
||||||
#include "ceres/internal/port.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// Using this callback interface, Ceres can notify you when it is
|
|
||||||
// about to evaluate the residuals or jacobians. With the callback,
|
|
||||||
// you can share computation between residual blocks by doing the
|
|
||||||
// shared computation in PrepareForEvaluation() before Ceres calls
|
|
||||||
// CostFunction::Evaluate(). It also enables caching results between a
|
|
||||||
// pure residual evaluation and a residual & jacobian evaluation, via
|
|
||||||
// the new_evaluation_point argument.
|
|
||||||
//
|
|
||||||
// One use case for this callback is if the cost function compute is
|
|
||||||
// moved to the GPU. In that case, the prepare call does the actual
|
|
||||||
// cost function evaluation, and subsequent calls from Ceres to the
|
|
||||||
// actual cost functions merely copy the results from the GPU onto the
|
|
||||||
// corresponding blocks for Ceres to plug into the solver.
|
|
||||||
//
|
|
||||||
// NOTE: Ceres provides no mechanism to share data other than the
|
|
||||||
// notification from the callback. Users must provide access to
|
|
||||||
// pre-computed shared data to their cost functions behind the scenes;
|
|
||||||
// this all happens without Ceres knowing.
|
|
||||||
//
|
|
||||||
// One approach is to put a pointer to the shared data in each cost
|
|
||||||
// function (recommended) or to use a global shared variable
|
|
||||||
// (discouraged; bug-prone). As far as Ceres is concerned, it is
|
|
||||||
// evaluating cost functions like any other; it just so happens that
|
|
||||||
// behind the scenes the cost functions reuse pre-computed data to
|
|
||||||
// execute faster.
|
|
||||||
class CERES_EXPORT EvaluationCallback {
|
|
||||||
public:
|
|
||||||
virtual ~EvaluationCallback() {}
|
|
||||||
|
|
||||||
// Called before Ceres requests residuals or jacobians for a given setting of
|
|
||||||
// the parameters. User parameters (the double* values provided to the cost
|
|
||||||
// functions) are fixed until the next call to PrepareForEvaluation(). If
|
|
||||||
// new_evaluation_point == true, then this is a new point that is different
|
|
||||||
// from the last evaluated point. Otherwise, it is the same point that was
|
|
||||||
// evaluated previously (either jacobian or residual) and the user can use
|
|
||||||
// cached results from previous evaluations.
|
|
||||||
virtual void PrepareForEvaluation(bool evaluate_jacobians,
|
|
||||||
bool new_evaluation_point) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ceres
|
|
||||||
|
|
||||||
#endif // CERES_PUBLIC_EVALUATION_CALLBACK_H_
|
|
@@ -1,54 +0,0 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
|
||||||
// http://ceres-solver.org/
|
|
||||||
//
|
|
||||||
// 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 Google Inc. nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without
|
|
||||||
// specific prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
|
|
||||||
//
|
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
|
||||||
|
|
||||||
#ifndef CERES_PUBLIC_FIRST_ORDER_FUNCTION_H_
|
|
||||||
#define CERES_PUBLIC_FIRST_ORDER_FUNCTION_H_
|
|
||||||
|
|
||||||
#include "ceres/internal/port.h"
|
|
||||||
|
|
||||||
namespace ceres {
|
|
||||||
|
|
||||||
// A FirstOrderFunction object implements the evaluation of a function
|
|
||||||
// and its gradient.
|
|
||||||
class CERES_EXPORT FirstOrderFunction {
|
|
||||||
public:
|
|
||||||
virtual ~FirstOrderFunction() {}
|
|
||||||
|
|
||||||
// cost is never null. gradient may be null. The return value
|
|
||||||
// indicates whether the evaluation was successful or not.
|
|
||||||
virtual bool Evaluate(const double* const parameters,
|
|
||||||
double* cost,
|
|
||||||
double* gradient) const = 0;
|
|
||||||
virtual int NumParameters() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ceres
|
|
||||||
|
|
||||||
#endif // CERES_PUBLIC_FIRST_ORDER_FUNCTION_H_
|
|
@@ -26,39 +26,45 @@
|
|||||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// Author: sameeragarwal@google.com (Sameer Agarwal)
|
// Author: keir@google.com (Keir Mierle)
|
||||||
|
//
|
||||||
|
// Portable floating point classification. The names are picked such that they
|
||||||
|
// do not collide with macros. For example, "isnan" in C99 is a macro and hence
|
||||||
|
// does not respect namespaces.
|
||||||
|
//
|
||||||
|
// TODO(keir): Finish porting!
|
||||||
|
|
||||||
#ifndef CERES_INTERNAL_SINGLE_LINKAGE_CLUSTERING_H_
|
#ifndef CERES_PUBLIC_FPCLASSIFY_H_
|
||||||
#define CERES_INTERNAL_SINGLE_LINKAGE_CLUSTERING_H_
|
#define CERES_PUBLIC_FPCLASSIFY_H_
|
||||||
|
|
||||||
#include <unordered_map>
|
#if defined(_MSC_VER)
|
||||||
#include "ceres/graph.h"
|
#include <float.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
struct SingleLinkageClusteringOptions {
|
#if defined(_MSC_VER)
|
||||||
// Graph edges with edge weight less than min_similarity are ignored
|
|
||||||
// during the clustering process.
|
|
||||||
double min_similarity = 0.99;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Compute a partitioning of the vertices of the graph using the
|
inline bool IsFinite (double x) { return _finite(x) != 0; }
|
||||||
// single linkage clustering algorithm. Edges with weight less than
|
inline bool IsInfinite(double x) { return _finite(x) == 0 && _isnan(x) == 0; }
|
||||||
// SingleLinkageClusteringOptions::min_similarity will be ignored.
|
inline bool IsNaN (double x) { return _isnan(x) != 0; }
|
||||||
//
|
inline bool IsNormal (double x) { // NOLINT
|
||||||
// membership upon return will contain a mapping from the vertices of
|
const int classification = _fpclass(x);
|
||||||
// the graph to an integer indicating the identity of the cluster that
|
return (classification == _FPCLASS_NN || classification == _FPCLASS_PN);
|
||||||
// it belongs to.
|
}
|
||||||
//
|
|
||||||
// The return value of this function is the number of clusters
|
# else
|
||||||
// identified by the algorithm.
|
|
||||||
int ComputeSingleLinkageClustering(
|
// These definitions are for the normal Unix suspects.
|
||||||
const SingleLinkageClusteringOptions& options,
|
inline bool IsFinite (double x) { return std::isfinite(x); }
|
||||||
const WeightedGraph<int>& graph,
|
inline bool IsInfinite(double x) { return std::isinf(x); }
|
||||||
std::unordered_map<int, int>* membership);
|
inline bool IsNaN (double x) { return std::isnan(x); }
|
||||||
|
inline bool IsNormal (double x) { return std::isnormal(x); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
|
||||||
#endif // CERES_INTERNAL_SINGLE_LINKAGE_CLUSTERING_H_
|
#endif // CERES_PUBLIC_FPCLASSIFY_H_
|
23
extern/ceres/include/ceres/gradient_checker.h
vendored
23
extern/ceres/include/ceres/gradient_checker.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,14 +34,15 @@
|
|||||||
#ifndef CERES_PUBLIC_GRADIENT_CHECKER_H_
|
#ifndef CERES_PUBLIC_GRADIENT_CHECKER_H_
|
||||||
#define CERES_PUBLIC_GRADIENT_CHECKER_H_
|
#define CERES_PUBLIC_GRADIENT_CHECKER_H_
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "ceres/cost_function.h"
|
#include "ceres/cost_function.h"
|
||||||
#include "ceres/dynamic_numeric_diff_cost_function.h"
|
#include "ceres/dynamic_numeric_diff_cost_function.h"
|
||||||
#include "ceres/internal/eigen.h"
|
#include "ceres/internal/eigen.h"
|
||||||
#include "ceres/internal/fixed_array.h"
|
#include "ceres/internal/fixed_array.h"
|
||||||
|
#include "ceres/internal/macros.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
#include "ceres/local_parameterization.h"
|
#include "ceres/local_parameterization.h"
|
||||||
#include "glog/logging.h"
|
#include "glog/logging.h"
|
||||||
|
|
||||||
@@ -63,13 +64,13 @@ namespace ceres {
|
|||||||
//
|
//
|
||||||
// How to use: Fill in an array of pointers to parameter blocks for your
|
// How to use: Fill in an array of pointers to parameter blocks for your
|
||||||
// CostFunction, and then call Probe(). Check that the return value is 'true'.
|
// CostFunction, and then call Probe(). Check that the return value is 'true'.
|
||||||
class CERES_EXPORT GradientChecker {
|
class GradientChecker {
|
||||||
public:
|
public:
|
||||||
// This will not take ownership of the cost function or local
|
// This will not take ownership of the cost function or local
|
||||||
// parameterizations.
|
// parameterizations.
|
||||||
//
|
//
|
||||||
// function: The cost function to probe.
|
// function: The cost function to probe.
|
||||||
// local_parameterizations: A vector of local parameterizations for each
|
// local_parameterization: A vector of local parameterizations for each
|
||||||
// parameter. May be NULL or contain NULL pointers to indicate that the
|
// parameter. May be NULL or contain NULL pointers to indicate that the
|
||||||
// respective parameter does not have a local parameterization.
|
// respective parameter does not have a local parameterization.
|
||||||
// options: Options to use for numerical differentiation.
|
// options: Options to use for numerical differentiation.
|
||||||
@@ -79,7 +80,7 @@ class CERES_EXPORT GradientChecker {
|
|||||||
const NumericDiffOptions& options);
|
const NumericDiffOptions& options);
|
||||||
|
|
||||||
// Contains results from a call to Probe for later inspection.
|
// Contains results from a call to Probe for later inspection.
|
||||||
struct CERES_EXPORT ProbeResults {
|
struct ProbeResults {
|
||||||
// The return value of the cost function.
|
// The return value of the cost function.
|
||||||
bool return_value;
|
bool return_value;
|
||||||
|
|
||||||
@@ -99,10 +100,10 @@ class CERES_EXPORT GradientChecker {
|
|||||||
// Derivatives as computed by the cost function in local space.
|
// Derivatives as computed by the cost function in local space.
|
||||||
std::vector<Matrix> local_jacobians;
|
std::vector<Matrix> local_jacobians;
|
||||||
|
|
||||||
// Derivatives as computed by numerical differentiation in local space.
|
// Derivatives as computed by nuerical differentiation in local space.
|
||||||
std::vector<Matrix> numeric_jacobians;
|
std::vector<Matrix> numeric_jacobians;
|
||||||
|
|
||||||
// Derivatives as computed by numerical differentiation in local space.
|
// Derivatives as computed by nuerical differentiation in local space.
|
||||||
std::vector<Matrix> local_numeric_jacobians;
|
std::vector<Matrix> local_numeric_jacobians;
|
||||||
|
|
||||||
// Contains the maximum relative error found in the local Jacobians.
|
// Contains the maximum relative error found in the local Jacobians.
|
||||||
@@ -136,13 +137,11 @@ class CERES_EXPORT GradientChecker {
|
|||||||
ProbeResults* results) const;
|
ProbeResults* results) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GradientChecker() = delete;
|
CERES_DISALLOW_IMPLICIT_CONSTRUCTORS(GradientChecker);
|
||||||
GradientChecker(const GradientChecker&) = delete;
|
|
||||||
void operator=(const GradientChecker&) = delete;
|
|
||||||
|
|
||||||
std::vector<const LocalParameterization*> local_parameterizations_;
|
std::vector<const LocalParameterization*> local_parameterizations_;
|
||||||
const CostFunction* function_;
|
const CostFunction* function_;
|
||||||
std::unique_ptr<CostFunction> finite_diff_cost_function_;
|
internal::scoped_ptr<CostFunction> finite_diff_cost_function_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
25
extern/ceres/include/ceres/gradient_problem.h
vendored
25
extern/ceres/include/ceres/gradient_problem.h
vendored
@@ -1,5 +1,5 @@
|
|||||||
// Ceres Solver - A fast non-linear least squares minimizer
|
// Ceres Solver - A fast non-linear least squares minimizer
|
||||||
// Copyright 2019 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// http://ceres-solver.org/
|
// http://ceres-solver.org/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
@@ -31,10 +31,9 @@
|
|||||||
#ifndef CERES_PUBLIC_GRADIENT_PROBLEM_H_
|
#ifndef CERES_PUBLIC_GRADIENT_PROBLEM_H_
|
||||||
#define CERES_PUBLIC_GRADIENT_PROBLEM_H_
|
#define CERES_PUBLIC_GRADIENT_PROBLEM_H_
|
||||||
|
|
||||||
#include <memory>
|
#include "ceres/internal/macros.h"
|
||||||
|
|
||||||
#include "ceres/first_order_function.h"
|
|
||||||
#include "ceres/internal/port.h"
|
#include "ceres/internal/port.h"
|
||||||
|
#include "ceres/internal/scoped_ptr.h"
|
||||||
#include "ceres/local_parameterization.h"
|
#include "ceres/local_parameterization.h"
|
||||||
|
|
||||||
namespace ceres {
|
namespace ceres {
|
||||||
@@ -106,9 +105,21 @@ class CERES_EXPORT GradientProblem {
|
|||||||
bool Plus(const double* x, const double* delta, double* x_plus_delta) const;
|
bool Plus(const double* x, const double* delta, double* x_plus_delta) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<FirstOrderFunction> function_;
|
internal::scoped_ptr<FirstOrderFunction> function_;
|
||||||
std::unique_ptr<LocalParameterization> parameterization_;
|
internal::scoped_ptr<LocalParameterization> parameterization_;
|
||||||
std::unique_ptr<double[]> scratch_;
|
internal::scoped_array<double> scratch_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// A FirstOrderFunction object implements the evaluation of a function
|
||||||
|
// and its gradient.
|
||||||
|
class CERES_EXPORT FirstOrderFunction {
|
||||||
|
public:
|
||||||
|
virtual ~FirstOrderFunction() {}
|
||||||
|
// cost is never NULL. gradient may be null.
|
||||||
|
virtual bool Evaluate(const double* const parameters,
|
||||||
|
double* cost,
|
||||||
|
double* gradient) const = 0;
|
||||||
|
virtual int NumParameters() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ceres
|
} // namespace ceres
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user