Compare commits

..

20 Commits

Author SHA1 Message Date
Dalai Felinto
0883bde0fb Map Alt + Tweaks to expected behaviours (rotate, zoom, move - LMB, RMB, MMB) 2015-08-25 11:41:10 -03:00
Dalai Felinto
c558d72228 Increase stability of WALK_MOUSE_MOVEVERTICAL mode (MMB) by doing only one movement at a time 2015-08-25 11:07:30 -03:00
Dalai Felinto
88620cd265 Take redraw and base speed into consideration for mouse move
This way speed modifiers (shift/alt) works and overall speed is more constant
2015-08-24 17:28:18 -03:00
Dalai Felinto
689357025e Fix lookaround twist the view after awhile 2015-08-24 17:28:17 -03:00
Dalai Felinto
61a8f65847 Set default walk speed 10x faster 2015-08-24 17:28:16 -03:00
Dalai Felinto
49b9d501cb F (focus) shortcut to view_selected 2015-08-24 16:00:55 -03:00
Dalai Felinto
a963bd4b6f Basic interaction file for unreal (LMB selection only at the moment) 2015-08-24 13:36:33 -03:00
Dalai Felinto
f3cf950739 Merge remote-tracking branch 'origin/master' into epic-navigation
Conflicts:
	source/blender/blenlib/BLI_math_vector.h
	source/blender/blenlib/intern/math_vector_inline.c
	source/blender/editors/space_view3d/view3d_walk.c
	source/blender/makesrna/intern/rna_wm.c
2015-08-24 11:32:59 -03:00
Dalai Felinto
6d8677f044 Fixup for MMB and LMB moves not working, introduced in last commit 2014-11-13 23:45:10 -02:00
Dalai Felinto
f7d79aed17 Final adjustments to keymap 2014-11-13 22:56:25 -02:00
Dalai Felinto
95b13efdb5 Cleanup pre-review 2014-11-13 22:49:04 -02:00
Dalai Felinto
13582b885f Navigation fully working
* Now you can start navigating with the arrows keys directly.
2014-11-13 22:34:09 -02:00
Dalai Felinto
4cdbe99aee Keymap for arrows keys (and +, -) 2014-11-13 20:52:28 -02:00
Dalai Felinto
8581f9e7f3 Support for non-modal navigation (arrows) 2014-11-13 20:52:28 -02:00
Dalai Felinto
984f444494 Merge remote-tracking branch 'origin/master' into epic-navigation 2014-11-13 20:51:20 -02:00
Dalai Felinto
370ee98863 All mouse modes working:
* RMB + Drag :
  left/right | rotates horizontally
  up/down    | rotates  vertically

* LMB + Drag :
  left/right | rotates horizontally
  up/down    | move forward/backward

* MMB + Drag :
  left/right | straft (mode sideways)
  up/down    | move up/down
2014-11-03 17:44:06 -02:00
Dalai Felinto
1137eefa11 Merge remote-tracking branch 'origin/master' into epic-navigation 2014-11-03 17:43:42 -02:00
Dalai Felinto
e6966f3a65 View3D: Walk Navigation - initial support for Unreal Engine modes and keymap
Implemented:
* Mouse is reset back to its original location after the operation exits
* New Mouse Modes (see below)
* Trackpad support
* (keymap to enter and exit the walk navigation for the different mouse
   modes)

Mouse Modes (wip):
* RMB + Drag : fully working
* LMB + Drag : rotation working, needs to move forward
* MMB + Drag : needs to move everywhere

(note, WASD work when using the mouse modes as well, just like in Unreal
Engine)

Not implemented yet:
* Direct (non-modal) keys: (arrow keys + PLUSPAD + MINUSPAD)

* G: game mode (equivalent of the 'show as render' option), GKEY may
  be hardcoded in some places, so we may have to map it to something
  else, but at least it will be nice to create an operator to toggle the
  'show as render' option + the GLSL mode or something similar.

* Non-OSX support to UNTOUCH mouse/trackpad event

* Bugfix for mouse event still being called after UNTOUCH is detected
  (this makes the operator to be called again if we swipe the mousepad
  too fast and untouch quickly).

* F: Focus funcionality: Teleport to selected object

* All the other keys: I'm still not sure if we should try to map all the
  Unreal Engine keyboard or only the basic navigation shortcuts

  The main keys/functionality that need to be decided to be
  implemented/included are:

  * Z/C Change camera zoom (field of view)
  * F11 to set fullscreen (the new editor fullscreen)
  * Ctrl (or Cmd) + 1, 2, 3, ..., 0 to store the current view
  * 1, 2, 3, ..., 0 to restore a saved view

All viewport controls in Unreal Engine:
https://docs.unrealengine.com/latest/INT/Engine/UI/LevelEditor/Viewports/ViewportControls/index.html
2014-10-31 00:26:40 -02:00
Dalai Felinto
5aa0c1435b New math function: negate_v2_int() 2014-10-31 00:16:06 -02:00
Dalai Felinto
8793d7cdd8 New "Mouse/Trackpad" Untouch event for trackpads (OSX only for now) 2014-10-31 00:15:37 -02:00
1327 changed files with 18933 additions and 30918 deletions

View File

@@ -511,11 +511,7 @@ if(APPLE)
endif()
execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
if(${MAC_SYS} MATCHES 15)
set(OSX_SYSTEM 10.11)
# throw an error here, older cmake cannot handle 2 digit subversion!
cmake_minimum_required(VERSION 3.0.0)
elseif(${MAC_SYS} MATCHES 14)
if(${MAC_SYS} MATCHES 14)
set(OSX_SYSTEM 10.10)
# throw an error here, older cmake cannot handle 2 digit subversion!
cmake_minimum_required(VERSION 3.0.0)
@@ -532,11 +528,13 @@ if(APPLE)
else()
set(OSX_SYSTEM unsupported)
endif()
message(STATUS "Detected system-version: " ${OSX_SYSTEM})
# workaround for incorrect cmake xcode lookup for developer previews - XCODE_VERSION does not take xcode-select path into accout
# but would always look into /Applications/Xcode.app while dev versions are named Xcode<version>-DP<preview_number>
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_CHECK OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "/Contents/Developer" "" XCODE_BUNDLE ${XCODE_CHECK}) # truncate to bundlepath in any case
message(STATUS "Xcode-bundle : " ${XCODE_BUNDLE})
if(${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -564,8 +562,8 @@ if(APPLE)
string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
unset(XCODE_VERS_BUILD_NR)
endif()
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")
message(STATUS "Detected Xcode-version: " ${XCODE_VERSION})
if(${XCODE_VERSION} VERSION_LESS 4.3)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE) # use guaranteed existing sdk
@@ -2322,21 +2320,9 @@ endif()
if(WITH_IMAGE_OPENJPEG)
if(WITH_SYSTEM_OPENJPEG)
# dealt with above
set(OPENJPEG_DEFINES "")
else()
set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
set(OPENJPEG_DEFINES "-DOPJ_STATIC")
set(OPENJPEG_LIBRARIES "extern_openjpeg")
endif()
# Special handling of Windows platform where openjpeg is always static.
if(WIN32)
set(OPENJPEG_DEFINES "-DOPJ_STATIC")
endif()
endif()
if(WITH_LZO)
if(NOT WITH_SYSTEM_LZO)
set(LZO_LIBRARIES "extern_minilzo")
add_definitions(-DOPJ_STATIC)
endif()
endif()

View File

@@ -122,7 +122,7 @@ endif
# Build Blender
all: FORCE
@echo
@echo Configuring Blender in \"$(BUILD_DIR)\" ...
@echo Configuring Blender ...
# # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
# # $(CMAKE_CONFIG); \

View File

@@ -331,10 +331,7 @@ if env['OURPLATFORM']=='darwin':
print B.bc.OKGREEN + "Available SDK's: \n" + B.bc.ENDC + MACOSX_SDK_CHECK.replace('\t', '')
if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found
if 'OS X 10.11' in MACOSX_SDK_CHECK:
env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.11.sdk'
elif 'OS X 10.10' in MACOSX_SDK_CHECK:
if 'OS X 10.10' in MACOSX_SDK_CHECK:
env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.10.sdk'
elif 'OS X 10.9' in MACOSX_SDK_CHECK:

View File

@@ -35,8 +35,6 @@ required-numpy: \
-- "$@" \
)
COMMANDLINE=$@
DISTRO=""
RPM=""
SRC="$HOME/src/blender-deps"
@@ -44,7 +42,6 @@ INST="/opt/lib"
TMP="/tmp"
CWD=$PWD
INFO_PATH=$CWD
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# Do not install some optional, potentially conflicting libs by default...
WITH_ALL=false
@@ -1379,7 +1376,19 @@ compile_LLVM() {
cd $_src
# XXX Ugly patching hack!
patch -p1 -i "$SCRIPT_DIR/install_deps_patches/llvm.patch"
cat << EOF | patch -p1
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 1)
-set(PACKAGE_VERSION "\${LLVM_VERSION_MAJOR}.\${LLVM_VERSION_MINOR}svn")
+set(PACKAGE_VERSION "\${LLVM_VERSION_MAJOR}.\${LLVM_VERSION_MINOR}")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
EOF
cd $CWD
@@ -1449,10 +1458,10 @@ compile_OSL() {
# Clean install if needed!
magic_compile_check osl-$OSL_VERSION $osl_magic
if [ $? -eq 1 -o $OSL_FORCE_REBUILD == true ]; then
#~ if [ $? -eq 1 -o $OSL_FORCE_REBUILD == true ]; then
#~ rm -Rf $_src # XXX Radical, but not easy to change remote repo fully automatically
clean_OSL
fi
#~ clean_OSL
#~ fi
if [ ! -d $_inst ]; then
INFO "Building OpenShadingLanguage-$OSL_VERSION"
@@ -1481,9 +1490,6 @@ compile_OSL() {
# Stick to same rev as windows' libs...
git checkout $OSL_SOURCE_REPO_UID
git reset --hard
# XXX Ugly patching hack!
patch -p1 -i "$SCRIPT_DIR/install_deps_patches/osl.patch"
fi
# Always refresh the whole build!
@@ -1525,9 +1531,6 @@ compile_OSL() {
fi
fi
#~ cmake_d="$cmake_d -D CMAKE_EXPORT_COMPILE_COMMANDS=ON"
#~ cmake_d="$cmake_d -D CMAKE_VERBOSE_MAKEFILE=ON"
cmake $cmake_d ..
make -j$THREADS && make install
@@ -2533,7 +2536,7 @@ install_RPM() {
if $NUMPY_SKIP; then
WARNING "Skipping NumPy installation, as requested..."
else
check_package_version_ge_RPM python3-numpy $NUMPY_VERSION_MIN
check_package_version_match_RPM python3-numpy $NUMPY_VERSION_MIN
if [ $? -eq 0 ]; then
install_packages_RPM python3-numpy
elif $NUMPY_REQUIRED; then
@@ -3117,10 +3120,6 @@ print_info() {
PRINT "Often, changes in the libs built by this script, or in your distro package, cannot be handled simply, so..."
PRINT ""
PRINT ""
PRINT "Ran with:"
PRINT " install_deps.sh $COMMANDLINE"
PRINT ""
PRINT ""
PRINT "If you're using CMake add this to your configuration flags:"
_buildargs=""

View File

@@ -1,12 +0,0 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 1)
-set(PACKAGE_VERSION "\${LLVM_VERSION_MAJOR}.\${LLVM_VERSION_MINOR}svn")
+set(PACKAGE_VERSION "\${LLVM_VERSION_MAJOR}.\${LLVM_VERSION_MINOR}")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

View File

@@ -1,12 +0,0 @@
--- a/src/shaders/CMakeLists.txt
+++ b/src/shaders/CMakeLists.txt
@@ -27,7 +27,7 @@ macro (osl_compile oslsrc objlist headers)
message (STATUS "cmd: ${CMAKE_CURRENT_BINARY_DIR}/../oslc/oslc ${oslsrc}")
endif ()
add_custom_command (OUTPUT ${osofile}
- COMMAND "${CMAKE_CURRENT_BINARY_DIR}/../oslc/oslc" ${oslsrc}
+ COMMAND "${CMAKE_CURRENT_BINARY_DIR}/../oslc/oslc" "-o" ${osofile} ${oslsrc}
MAIN_DEPENDENCY ${oslsrc}
DEPENDS ${${headers}} ${oslsrc} "${CMAKE_CURRENT_BINARY_DIR}/stdosl.h" "${CMAKE_CURRENT_BINARY_DIR}/../oslc/oslc"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

View File

@@ -1,5 +1,5 @@
#CC = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang"
#CXX = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang++"
CC = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang"
CXX = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang++"
MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64

View File

@@ -52,10 +52,7 @@ if 'cmake' in builder:
cmake_options.append(['-G', '"Visual Studio 12 2013"'])
cmake_options.append("-C../blender.git/build_files/cmake/config/blender_full.cmake")
if 'win32' not in builder:
cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=1")
else:
cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=0")
cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=1")
# configure and make
retcode = subprocess.call(['cmake', blender_dir] + cmake_options)
if retcode != 0:

View File

@@ -10,9 +10,9 @@ set(MY_WC_COMMIT_TIMESTAMP 0)
# Guess if this is a git working copy and then look up the revision
if(EXISTS ${SOURCE_DIR}/.git)
# The FindGit.cmake module is part of the standard distribution
find_package(Git)
include(FindGit)
if(GIT_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
message(STATUS "-- Found Git: ${GIT_EXECUTABLE}")
execute_process(COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${SOURCE_DIR}

View File

@@ -50,8 +50,6 @@ from os.path import join, dirname, normpath, relpath, exists
def create_nb_project_main():
from xml.sax.saxutils import escape
files = list(source_list(SOURCE_DIR, filename_check=is_project_file))
files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
files_rel.sort()
@@ -209,8 +207,8 @@ def create_nb_project_main():
build_cmd = "${MAKE} -f Makefile"
clean_cmd = "${MAKE} -f Makefile clean"
f.write(' <buildCommand>%s</buildCommand>\n' % escape(build_cmd))
f.write(' <cleanCommand>%s</cleanCommand>\n' % escape(clean_cmd))
f.write(' <buildCommand>%s</buildCommand>\n' % build_cmd)
f.write(' <cleanCommand>%s</cleanCommand>\n' % clean_cmd)
f.write(' <executablePath>./bin/blender</executablePath>\n')
del build_cmd, clean_cmd
@@ -221,7 +219,7 @@ def create_nb_project_main():
f.write(' </incDir>\n')
f.write(' <preprocessorList>\n')
for cdef in defines:
f.write(' <Elem>%s</Elem>\n' % escape(cdef))
f.write(' <Elem>%s</Elem>\n' % cdef)
f.write(' </preprocessorList>\n')
f.write(' <cTool>\n')

View File

@@ -48,6 +48,7 @@ set(WITH_OPENCOLORIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENMP OFF CACHE BOOL "" FORCE)
set(WITH_OPENNL OFF CACHE BOOL "" FORCE)
set(WITH_PYTHON_INSTALL OFF CACHE BOOL "" FORCE)
set(WITH_RAYOPTIMIZATION OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)

View File

@@ -212,8 +212,6 @@ function(blender_add_lib_nolist
add_library(${name} ${sources})
target_link_libraries(${name} ${lib_depends})
# works fine without having the includes
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${sources}")
@@ -231,13 +229,10 @@ function(blender_add_lib
sources
includes
includes_sys
libs
)
blender_add_lib_nolist(${name} "${sources}" "${includes}" "${includes_sys}")
target_link_libraries(${name} "${libs}")
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
endfunction()
@@ -474,8 +469,7 @@ endfunction()
function(SETUP_BLENDER_SORTED_LIBS)
# get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
set(BLENDER_LINK_LIBS)
get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
list(APPEND BLENDER_LINK_LIBS
bf_windowmanager
@@ -1288,7 +1282,7 @@ function(data_to_c
add_custom_command(
OUTPUT ${file_to}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
COMMAND "$<TARGET_FILE:datatoc>" ${file_from} ${file_to}
COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${file_from} ${file_to}
DEPENDS ${file_from} datatoc)
set_source_files_properties(${file_to} PROPERTIES GENERATED TRUE)
@@ -1313,7 +1307,7 @@ function(data_to_c_simple
add_custom_command(
OUTPUT ${_file_to}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
COMMAND "$<TARGET_FILE:datatoc>" ${_file_from} ${_file_to}
COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${_file_from} ${_file_to}
DEPENDS ${_file_from} datatoc)
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
@@ -1346,8 +1340,8 @@ function(data_to_c_simple_icons
OUTPUT ${_file_from} ${_file_to}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
#COMMAND python3 ${CMAKE_SOURCE_DIR}/source/blender/datatoc/datatoc_icon.py ${_path_from_abs} ${_file_from}
COMMAND "$<TARGET_FILE:datatoc_icon>" ${_path_from_abs} ${_file_from}
COMMAND "$<TARGET_FILE:datatoc>" ${_file_from} ${_file_to}
COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc_icon ${_path_from_abs} ${_file_from}
COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc ${_file_from} ${_file_to}
DEPENDS
${_icon_files}
datatoc_icon
@@ -1416,7 +1410,7 @@ function(msgfmt_simple
add_custom_command(
OUTPUT ${_file_to}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path}
COMMAND "$<TARGET_FILE:msgfmt>" ${_file_from} ${_file_to}
COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/msgfmt ${_file_from} ${_file_to}
DEPENDS msgfmt ${_file_from})
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)

View File

@@ -21,9 +21,9 @@ SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
# Get the build revision, note that this can get out-of-sync, so for packaging run cmake first.
set(MY_WC_HASH "unknown")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
find_package(Git)
include(FindGit)
if(GIT_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
message(STATUS "-- Found Git: ${GIT_EXECUTABLE}")
execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
@@ -37,8 +37,7 @@ unset(MY_WC_HASH)
# Force Package Name
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LOWER}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
# RPM packages
@@ -74,7 +73,6 @@ if(WIN32)
set(CPACK_WIX_PRODUCT_ICON ${CMAKE_SOURCE_DIR}/source/icons/winblender.ico)
set(CPACK_WIX_UPGRADE_GUID "B767E4FD-7DE7-4094-B051-3AE62E13A17A")
set(CPACK_WIX_TEMPLATE ${LIBDIR}/package/installer_wix/WIX.template)
set(CPACK_WIX_UI_BANNER ${LIBDIR}/package/installer_wix/WIX_UI_BANNER.bmp)
set(CPACK_WIX_UI_DIALOG ${LIBDIR}/package/installer_wix/WIX_UI_DIALOG.bmp)

View File

@@ -796,8 +796,6 @@ def AppIt(target=None, source=None, env=None):
commands.getoutput(cmd)
cmd = 'cp -R %s/release/site-packages/ %s/%s.app/Contents/Resources/%s/python/lib/python%s/site-packages/'%(libdir,installdir,binary,VERSION,env['BF_PYTHON_VERSION'])
commands.getoutput(cmd)
cmd = 'cp -r %s/python/bin -d %s/%s.app/Contents/Resources/%s/python/'%(libdir,installdir,binary,VERSION)
commands.getoutput(cmd)
cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(installdir,binary, binary)
commands.getoutput(cmd)

View File

@@ -1,7 +1,6 @@
"""
Basic Sound Playback
++++++++++++++++++++
This script shows how to use the classes: :class:`Device`, :class:`Factory` and
:class:`Handle`.
"""

View File

@@ -1,7 +1,6 @@
"""
Texture Replacement
+++++++++++++++++++
Example of how to replace a texture in game with an external image.
``createTexture()`` and ``removeTexture()`` are to be called from a
module Python Controller.

View File

@@ -1,7 +1,6 @@
"""
Basic Handler Example
+++++++++++++++++++++
This script shows the most simple example of adding a handler.
"""

View File

@@ -7,9 +7,8 @@ act on specified rather than the selected or active data, or to execute an
operator in the different part of the user interface.
The context overrides are passed as a dictionary, with keys matching the context
member names in bpy.context.
For example to override ``bpy.context.active_object``,
you would pass ``{'active_object': object}``.
member names in bpy.context. For example to override bpy.context.active_object,
you would pass {'active_object': object}.
"""
# remove all objects in scene rather than the selected ones

View File

@@ -3,21 +3,21 @@ Calling Operators
-----------------
Provides python access to calling operators, this includes operators written in
C, Python or macros.
C, Python or Macros.
Only keyword arguments can be used to pass operator properties.
Operators don't have return values as you might expect,
instead they return a set() which is made up of:
``{'RUNNING_MODAL', 'CANCELLED', 'FINISHED', 'PASS_THROUGH'}``.
Common return values are ``{'FINISHED'}`` and ``{'CANCELLED'}``.
Operators don't have return values as you might expect, instead they return a
set() which is made up of: {'RUNNING_MODAL', 'CANCELLED', 'FINISHED',
'PASS_THROUGH'}.
Common return values are {'FINISHED'} and {'CANCELLED'}.
Calling an operator in the wrong context will raise a ``RuntimeError``,
Calling an operator in the wrong context will raise a RuntimeError,
there is a poll() method to avoid this problem.
Note that the operator ID (bl_idname) in this example is ``mesh.subdivide``,
``bpy.ops`` is just the access path for python.
Note that the operator ID (bl_idname) in this example is 'mesh.subdivide',
'bpy.ops' is just the access path for python.
Keywords and Positional Arguments
@@ -32,9 +32,9 @@ There are 3 optional positional arguments (documented in detail below).
bpy.ops.test.operator(override_context, execution_context, undo)
- override_context - ``dict`` type.
- execution_context - ``str`` (enum).
- undo - ``bool`` type.
* override_context - dict type
* execution_context - string (enum)
* undo - boolean
Each of these arguments is optional, but must be given in the order above.

View File

@@ -8,8 +8,7 @@ bl_info = {
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Object",
}
"category": "Object"}
import bpy

View File

@@ -1,7 +1,6 @@
"""
Submenus
++++++++
This menu demonstrates some different functions.
"""
import bpy

View File

@@ -1,7 +1,6 @@
"""
Extending Menus
+++++++++++++++
When creating menus for addons you can't reference menus in Blender's default
scripts.
Instead, the addon can add menu items to existing menus.

View File

@@ -1,7 +1,6 @@
"""
Basic Menu Example
++++++++++++++++++
Here is an example of a simple menu. Menus differ from panels in that they must
reference from a header, panel or another menu.

View File

@@ -7,10 +7,10 @@ for more flexible mesh editing from python see :mod:`bmesh`.
Blender stores 4 main arrays to define mesh geometry.
- :class:`Mesh.vertices` (3 points in space)
- :class:`Mesh.edges` (reference 2 vertices)
- :class:`Mesh.loops` (reference a single vertex and edge)
- :class:`Mesh.polygons`: (reference a range of loops)
* :class:`Mesh.vertices` (3 points in space)
* :class:`Mesh.edges` (reference 2 vertices)
* :class:`Mesh.loops` (reference a single vertex and edge)
* :class:`Mesh.polygons`: (reference a range of loops)
Each polygon reference a slice in the loop array, this way, polygons do not store vertices or corner data such as UV's directly,

View File

@@ -1,7 +1,6 @@
"""
Poll Function
+++++++++++++++
The :class:`NodeTree.poll` function determines if a node tree is visible
in the given context (similar to how :class:`Panel.poll`
and :class:`Menu.poll` define visibility). If it returns False,

View File

@@ -1,7 +1,6 @@
"""
Basic Object Operations Example
+++++++++++++++++++++++++++++++
This script demonstrates basic operations on object like creating new
object, placing it into scene, selecting it and making it active.
"""

View File

@@ -1,7 +1,6 @@
"""
Invoke Function
+++++++++++++++
:class:`Operator.invoke` is used to initialize the operator from the context
at the moment the operator is called.
invoke() is typically used to assign properties which are then used by

View File

@@ -4,7 +4,7 @@ Calling a File Selector
This example shows how an operator can use the file selector.
Notice the invoke function calls a window manager method and returns
``{'RUNNING_MODAL'}``, this means the file selector stays open and the operator does not
RUNNING_MODAL, this means the file selector stays open and the operator does not
exit immediately after invoke finishes.
The file selector runs the operator, calling :class:`Operator.execute` when the

View File

@@ -1,7 +1,6 @@
"""
Dialog Box
++++++++++
This operator uses its :class:`Operator.invoke` function to call a popup.
"""
import bpy

View File

@@ -1,7 +1,6 @@
"""
Custom Drawing
++++++++++++++
By default operator properties use an automatic user interface layout.
If you need more control you can create your own layout with a
:class:`Operator.draw` function.

View File

@@ -1,9 +1,8 @@
"""
Modal Execution
+++++++++++++++
This operator defines a :class:`Operator.modal` function which running,
handling events until it returns ``{'FINISHED'}`` or ``{'CANCELLED'}``.
handling events until it returns {'FINISHED'} or {'CANCELLED'}.
Grab, Rotate, Scale and Fly-Mode are examples of modal operators.
They are especially useful for interactive tools,
@@ -11,9 +10,9 @@ your operator can have its own state where keys toggle options as the operator
runs.
:class:`Operator.invoke` is used to initialize the operator as being by
returning ``{'RUNNING_MODAL'}``, initializing the modal loop.
returning {'RUNNING_MODAL'}, initializing the modal loop.
Notice ``__init__()`` and ``__del__()`` are declared.
Notice __init__() and __del__() are declared.
For other operator types they are not useful but for modal operators they will
be called before the :class:`Operator.invoke` and after the operator finishes.
"""

View File

@@ -1,7 +1,6 @@
"""
Basic Operator Example
++++++++++++++++++++++
This script shows simple operator which prints a message.
Since the operator only has an :class:`Operator.execute` function it takes no

View File

@@ -1,7 +1,6 @@
"""
Simple Object Panel
+++++++++++++++++++
This panel has a :class:`Panel.poll` and :class:`Panel.draw_header` function,
even though the contents is basic this closely resembles blenders panels.
"""

View File

@@ -1,7 +1,6 @@
"""
Basic Panel Example
+++++++++++++++++++
This script is a simple panel which will draw into the object properties
section.

View File

@@ -1,8 +1,7 @@
"""
Advanced UIList Example - Filtering and Reordering
++++++++++++++++++++++++++++++++++++++++++++++++++
This script is an extended version of the ``UIList`` subclass used to show vertex groups. It is not used 'as is',
This script is an extended version of the UIList subclass used to show vertex groups. It is not used 'as is',
because iterating over all vertices in a 'draw' function is a very bad idea for UI performances! However, it's a good
example of how to create/use filtering/reordering callbacks.
"""

View File

@@ -1,192 +0,0 @@
# Draws an off-screen buffer and display it in the corner of the view.
import bpy
from bgl import *
class OffScreenDraw(bpy.types.Operator):
bl_idname = "view3d.offscreen_draw"
bl_label = "View3D Offscreen Draw"
_handle_calc = None
_handle_draw = None
is_enabled = False
# manage draw handler
@staticmethod
def draw_callback_px(self, context):
scene = context.scene
aspect_ratio = scene.render.resolution_x / scene.render.resolution_y
self._update_offscreen(context, self._offscreen)
self._opengl_draw(context, self._texture, aspect_ratio, 0.2)
@staticmethod
def handle_add(self, context):
OffScreenDraw._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
self.draw_callback_px, (self, context),
'WINDOW', 'POST_PIXEL',
)
@staticmethod
def handle_remove():
if OffScreenDraw._handle_draw is not None:
bpy.types.SpaceView3D.draw_handler_remove(OffScreenDraw._handle_draw, 'WINDOW')
OffScreenDraw._handle_draw = None
# off-screen buffer
@staticmethod
def _setup_offscreen(context):
import gpu
scene = context.scene
aspect_ratio = scene.render.resolution_x / scene.render.resolution_y
try:
offscreen = gpu.offscreen.new(512, int(512 / aspect_ratio))
except Exception as e:
print(e)
offscreen = None
return offscreen
@staticmethod
def _update_offscreen(context, offscreen):
scene = context.scene
render = scene.render
camera = scene.camera
modelview_matrix = camera.matrix_world.inverted()
projection_matrix = camera.calc_matrix_camera(
render.resolution_x,
render.resolution_y,
render.pixel_aspect_x,
render.pixel_aspect_y,
)
offscreen.draw_view3d(
scene,
context.space_data,
context.region,
projection_matrix,
modelview_matrix,
)
@staticmethod
def _opengl_draw(context, texture, aspect_ratio, scale):
"""
OpenGL code to draw a rectangle in the viewport
"""
glDisable(GL_DEPTH_TEST)
# view setup
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
glOrtho(-1, 1, -1, 1, -15, 15)
gluLookAt(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
act_tex = Buffer(GL_INT, 1)
glGetIntegerv(GL_TEXTURE_2D, act_tex)
viewport = Buffer(GL_INT, 4)
glGetIntegerv(GL_VIEWPORT, viewport)
width = int(scale * viewport[2])
height = int(width / aspect_ratio)
glViewport(viewport[0], viewport[1], width, height)
glScissor(viewport[0], viewport[1], width, height)
# draw routine
glEnable(GL_TEXTURE_2D)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, texture)
texco = [(1, 1), (0, 1), (0, 0), (1, 0)]
verco = [(1.0, 1.0), (-1.0, 1.0), (-1.0, -1.0), (1.0, -1.0)]
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
glColor4f(1.0, 1.0, 1.0, 1.0)
glBegin(GL_QUADS)
for i in range(4):
glTexCoord3f(texco[i][0], texco[i][1], 0.0)
glVertex2f(verco[i][0], verco[i][1])
glEnd()
# restoring settings
glBindTexture(GL_TEXTURE_2D, act_tex[0])
glDisable(GL_TEXTURE_2D)
# reset view
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
glViewport(viewport[0], viewport[1], viewport[2], viewport[3])
glScissor(viewport[0], viewport[1], viewport[2], viewport[3])
# operator functions
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def modal(self, context, event):
if context.area:
context.area.tag_redraw()
return {'PASS_THROUGH'}
def invoke(self, context, event):
if OffScreenDraw.is_enabled:
self.cancel(context)
return {'FINISHED'}
else:
self._offscreen = OffScreenDraw._setup_offscreen(context)
if self._offscreen:
self._texture = self._offscreen.color_texture
else:
self.report({'ERROR'}, "Error initializing offscreen buffer. More details in the console")
return {'CANCELLED'}
OffScreenDraw.handle_add(self, context)
OffScreenDraw.is_enabled = True
if context.area:
context.area.tag_redraw()
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def cancel(self, context):
OffScreenDraw.handle_remove()
OffScreenDraw.is_enabled = False
if context.area:
context.area.tag_redraw()
def register():
bpy.utils.register_class(OffScreenDraw)
def unregister():
bpy.utils.unregister_class(OffScreenDraw)
if __name__ == "__main__":
register()

View File

@@ -258,8 +258,7 @@ General functions
Sets the world gravity.
:arg gravity: gravity vector
:type gravity: Vector((fx, fy, fz))
:type gravity: list [fx, fy, fz]
.. function:: getSpectrum()
@@ -338,28 +337,6 @@ General functions
.. warning: Not implimented yet
.. function:: getAnimRecordFrame()
Gets the current frame number used for recording animations. This
number is incremented automatically by Blender when the "Record
animation" feature is turned on.
:rtype: int
.. function:: setAnimRecordFrame(framenr)
Sets the current frame number used for recording animations. This
number is automatically incremented by Blender when the "Record
animation" feature is turned on.
The frame number Must be non-negative, unless Blender has
:attr:`bpy.types.UserPreferencesEdit.use_negative_frames` enabled
in its user preferences. Only use non-negative numbers to be on
the safe side, unless you know what you are doing.
:arg framenr: The new frame number.
:type framenr: int
.. function:: getExitKey()
Gets the key used to exit the game engine

View File

@@ -8,8 +8,7 @@ Intro
.. module:: bge.render
Example of using a :class:`bge.types.SCA_MouseSensor`,
and two :class:`bge.types.KX_ObjectActuator` to implement MouseLook:
Example of using a :class:`bge.types.SCA_MouseSensor`, and two :class:`bge.types.KX_ObjectActuator` to implement MouseLook:
.. note::
This can also be achieved with the :class:`bge.types.KX_MouseActuator`.
@@ -78,9 +77,7 @@ Constants
.. DATA:: VSYNC_ADAPTIVE
Enables adaptive vsync if supported.
Adaptive vsync enables vsync if the framerate is above the monitors refresh rate.
Otherwise, vsync is diabled if the framerate is too low.
Enables adaptive vsync if supported. Adaptive vsync enables vsync if the framerate is above the monitors refresh rate. Otherwise, vsync is diabled if the framerate is too low.
.. data:: LEFT_EYE
@@ -111,55 +108,40 @@ Functions
Set the width and height of the window (in pixels). This also works for fullscreen applications.
.. note:: Only works in the standalone player, not the Blender-embedded player.
:arg width: width in pixels
:type width: integer
:arg height: height in pixels
:type height: integer
.. function:: setFullScreen(enable)
Set whether or not the window should be fullscreen.
.. note:: Only works in the standalone player, not the Blender-embedded player.
:arg enable: ``True`` to set full screen, ``False`` to set windowed.
:type enable: bool
.. function:: getFullScreen()
Returns whether or not the window is fullscreen.
.. note:: Only works in the standalone player, not the Blender-embedded player; there it always returns False.
:rtype: bool
.. function:: getDisplayDimensions()
Get the display dimensions, in pixels, of the display (e.g., the
monitor). Can return the size of the entire view, so the
combination of all monitors; for example, ``(3840, 1080)`` for two
side-by-side 1080p monitors.
Get the actual display dimensions, in pixels, of the physical display (e.g., the monitor).
:rtype: tuple (width, height)
:type dimension: list [width,heigh]
.. function:: makeScreenshot(filename)
Writes an image file with the current displayed frame.
The image is written to *'filename'*.
The path may be absolute (eg. ``/home/foo/image``) or relative when started with
``//`` (eg. ``//image``). Note that absolute paths are not portable between platforms.
If the filename contains a ``#``,
it will be replaced by an incremental index so that screenshots can be taken multiple
times without overwriting the previous ones (eg. ``image-#``).
The image is written to *'filename'*. The path may be absolute (eg. "/home/foo/image") or relative when started with
"//" (eg. "//image"). Note that absolute paths are not portable between platforms.
If the filename contains a "#", it will be replaced by an incremental index so that screenshots can be taken multiple
times without overwriting the previous ones (eg. "image-#").
Settings for the image are taken from the render settings (file format and respective settings,
gamma and colospace conversion, etc).
The image resolution matches the framebuffer, meaning, the window size and aspect ratio.
When running from the standalone player, instead of the embedded player, only PNG files are supported.
Additional color conversions are also not supported.
Settings for the image are taken from the render settings (file format and respective settings, gamma and colospace
conversion, etc). The image resolution matches the framebuffer, meaning, the window size and aspect ratio.
When running from the standalone player, instead of the embedded player, only PNG files are supported. Additional
color conversions are also not supported.
:arg filename: path and name of the file to write
:type filename: string
@@ -167,14 +149,13 @@ Functions
.. function:: enableVisibility(visible)
Deprecated; doesn't do anything.
Doesn't really do anything...
.. function:: showMouse(visible)
Enables or disables the operating system mouse cursor.
:arg visible:
:type visible: boolean
@@ -182,15 +163,15 @@ Functions
Sets the mouse cursor position.
:arg x: X-coordinate in screen pixel coordinates.
:type x: integer
:arg y: Y-coordinate in screen pixel coordinates.
:type y: integer
.. function:: setBackgroundColor(rgba)
Deprecated and no longer functional. Use :py:meth:`bge.types.KX_WorldInfo.backgroundColor` instead.
Sets the window background color. (Deprecated: use KX_WorldInfo.background_color)
:type rgba: list [r, g, b, a]
.. function:: setEyeSeparation(eyesep)
@@ -234,7 +215,6 @@ Functions
Set the material mode to use for OpenGL rendering.
:arg mode: material mode
:type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
.. note:: Changes will only affect newly created scenes.
@@ -251,17 +231,14 @@ Functions
Enables or disables a GLSL material setting.
:arg setting:
:type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
:arg enable:
:type enable: boolean
.. function:: getGLSLMaterialSetting(setting)
.. function:: getGLSLMaterialSetting(setting, enable)
Get the state of a GLSL material setting.
:arg setting:
:type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
:rtype: boolean
@@ -322,28 +299,24 @@ Functions
Show or hide the framerate.
:arg enable:
:type enable: boolean
.. function:: showProfile(enable)
Show or hide the profile.
:arg enable:
:type enable: boolean
.. function:: showProperties(enable)
Show or hide the debug properties.
:arg enable:
:type enable: boolean
.. function:: autoDebugList(enable)
Enable or disable auto adding debug properties to the debug list.
:arg enable:
:type enable: boolean
.. function:: clearDebugList()

View File

@@ -25,7 +25,7 @@ base class --- :class:`PyObjectPlus`
The maximum number of jumps a character can perform before having to touch the ground. By default this is set to 1. 2 allows for a double jump, etc.
:type: int in [0, 255], default 1
:type: int
.. attribute:: jumpCount

View File

@@ -133,11 +133,10 @@ base class --- :class:`PyObjectPlus`
Returns the contraint type (read only)
:type: integer
- :class:`~bge.constraints.POINTTOPOINT_CONSTRAINT`
- :class:`~bge.constraints.LINEHINGE_CONSTRAINT`
- :class:`~bge.constraints.ANGULAR_CONSTRAINT`
- :class:`~bge.constraints.CONETWIST_CONSTRAINT`
- :class:`~bge.constraints.VEHICLE_CONSTRAINT`
- :class:`~bge.constraints.GENERIC_6DOF_CONSTRAINT`
- 1 = :class:`~bge.constraints.POINTTOPOINT_CONSTRAINT`
- 2 = :class:`~bge.constraints.LINEHINGE_CONSTRAINT`
- 3 = :class:`~bge.constraints.ANGULAR_CONSTRAINT`
- 4 = :class:`~bge.constraints.CONETWIST_CONSTRAINT`
- 11 = :class:`~bge.constraints.VEHICLE_CONSTRAINT`
- 12 = :class:`~bge.constraints.GENERIC_6DOF_CONSTRAINT`

View File

@@ -799,7 +799,7 @@ base class --- :class:`SCA_IObject`
:return: the first object hit or None if no object or object does not match prop
:rtype: :class:`KX_GameObject`
.. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly, mask)
.. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly)
Look from a point/object to another point/object and find first object hit within dist that matches prop.
if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit.
@@ -851,8 +851,6 @@ base class --- :class:`SCA_IObject`
* 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping.
:type poly: integer
:arg mask: collision mask: The collision mask (16 layers mapped to a 16-bit integer) is combined with each object's collision group, to hit only a subset of the objects in the scene. Only those objects for which ``collisionGroup & mask`` is true can be hit.
:type mask: bitfield
:return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
* object, hitpoint and hitnormal are None if no hit.

View File

@@ -0,0 +1,65 @@
KX_IpoActuator(SCA_IActuator)
=============================
.. module:: bge.types
base class --- :class:`SCA_IActuator`
.. class:: KX_IpoActuator(SCA_IActuator)
IPO actuator activates an animation.
.. attribute:: frameStart
Start frame.
:type: float
.. attribute:: frameEnd
End frame.
:type: float
.. attribute:: propName
Use this property to define the Ipo position.
:type: string
.. attribute:: framePropName
Assign this property this action current frame number.
:type: string
.. attribute:: mode
Play mode for the ipo. Can be on of :ref:`these constants <ipo-actuator>`
:type: integer
.. attribute:: useIpoAsForce
Apply Ipo as a global or local force depending on the local option (dynamic objects only).
:type: boolean
.. attribute:: useIpoAdd
Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag.
:type: boolean
.. attribute:: useIpoLocal
Let the ipo acts in local coordinates, used in Force and Add mode.
:type: boolean
.. attribute:: useChildren
Update IPO on all children Objects as well.
:type: boolean

View File

@@ -25,12 +25,6 @@ base class --- :class:`PyObjectPlus`
:type: callable
.. attribute:: finished
The current status of the lib load.
:type: boolean
.. attribute:: progress
The current progress of the lib load as a normalized value from 0.0 to 1.0.

View File

@@ -63,17 +63,17 @@ base class --- :class:`PyObjectPlus`
The color of the mist. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Mist and background color sould always set to the same color.
:type: :class:`mathutils.Color`
:type: :class:`mathutils.Vector`
.. attribute:: backgroundColor
The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Mist and background color sould always set to the same color.
:type: :class:`mathutils.Color`
:type: :class:`mathutils.Vector`
.. attribute:: ambientColor
The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
:type: :class:`mathutils.Color`
:type: :class:`mathutils.Vector`

File diff suppressed because it is too large Load Diff

View File

@@ -16,24 +16,24 @@ and in the game engine.
.. warning::
The API provided by this module is subject to change.
The data exposed by the API are are closely related to Blender's internal GLSL code
and may change if the GLSL code is modified (e.g. new uniform type).
The API provided by this module should be consider unstable. The data exposed by the API
are are closely related to Blender's internal GLSL code and may change if the GLSL code
is modified (e.g. new uniform type).
Constants
=========
GLSL Data Type
GLSL data type
--------------
.. _data-type:
Type of GLSL data.
For shader uniforms, the data type determines which ``glUniform`` function
For shader uniforms, the data type determines which glUniform function
variant to use to send the uniform value to the GPU.
For vertex attributes, the data type determines which ``glVertexAttrib`` function
For vertex attributes, the data type determines which glVertexAttrib function
variant to use to send the vertex attribute to the GPU.
See export_shader_
@@ -42,37 +42,53 @@ See export_shader_
one integer
:value: 1
.. data:: GPU_DATA_1F
one float
:value: 2
.. data:: GPU_DATA_2F
two floats
:value: 3
.. data:: GPU_DATA_3F
three floats
:value: 4
.. data:: GPU_DATA_4F
four floats
:value: 5
.. data:: GPU_DATA_9F
matrix 3x3 in column-major order
:value: 6
.. data:: GPU_DATA_16F
matrix 4x4 in column-major order
:value: 7
.. data:: GPU_DATA_4UB
four unsigned byte
:value: 8
GLSL Uniform Types
------------------
GLSL uniform type
-----------------
.. _uniform-type:
@@ -85,7 +101,7 @@ The calculation of some of the uniforms is based on matrices available in the sc
.. _mat4_cam_to_world:
.. _mat4_world_to_cam:
``mat4_cam_to_world``
*mat4_cam_to_world*
Model matrix of the camera. OpenGL 4x4 matrix that converts
camera local coordinates to world coordinates. In blender this is obtained from the
'matrix_world' attribute of the camera object.
@@ -96,7 +112,7 @@ The calculation of some of the uniforms is based on matrices available in the sc
.. _mat4_object_to_world:
.. _mat4_world_to_object:
``mat4_object_to_world``
*mat4_object_to_world*
Model matrix of the object that is being rendered. OpenGL 4x4 matric that converts
object local coordinates to world coordinates. In blender this is obtained from the
'matrix_world' attribute of the object.
@@ -106,7 +122,7 @@ The calculation of some of the uniforms is based on matrices available in the sc
.. _mat4_lamp_to_world:
.. _mat4_world_to_lamp:
``mat4_lamp_to_world``
*mat4_lamp_to_world*
Model matrix of the lamp lighting the object. OpenGL 4x4 matrix that converts lamp
local coordinates to world coordinates. In blender this is obtained from the
'matrix_world' attribute of the lamp object.
@@ -114,305 +130,151 @@ The calculation of some of the uniforms is based on matrices available in the sc
Some uniform will need the *mat4_world_to_lamp* matrix
computed as the inverse of this matrix.
.. note::
Any uniforms used for view projections or transformations (object, lamp matrices for eg),
can only be set once per frame.
GLSL Object Uniforms
^^^^^^^^^^^^^^^^^^^^
.. note::
- Object transformations and color must be set before drawing the object.
- There is at most one uniform of these types per shader.
.. data:: GPU_DYNAMIC_OBJECT_VIEWMAT
A matrix that converts world coordinates to camera coordinates (see mat4_world_to_cam_).
The uniform is a 4x4 GL matrix that converts world coordinates to
camera coordinates (see mat4_world_to_cam_). Can be set once per frame.
There is at most one uniform of that type per shader.
:type: matrix4x4
:value: 1
.. data:: GPU_DYNAMIC_OBJECT_MAT
A matrix that converts object coordinates to world coordinates (see mat4_object_to_world_).
The uniform is a 4x4 GL matrix that converts object coordinates
to world coordinates (see mat4_object_to_world_). Must be set before drawing the object.
There is at most one uniform of that type per shader.
:type: matrix4x4
:value: 2
.. data:: GPU_DYNAMIC_OBJECT_VIEWIMAT
The uniform is a 4x4 GL matrix that converts coordinates
in camera space to world coordinates (see mat4_cam_to_world_).
Can be set once per frame.
There is at most one uniform of that type per shader.
:type: matrix4x4
:value: 3
.. data:: GPU_DYNAMIC_OBJECT_IMAT
The uniform is a 4x4 GL matrix that converts world coodinates
to object coordinates (see mat4_world_to_object_).
Must be set before drawing the object.
There is at most one uniform of that type per shader.
:type: matrix4x4
:value: 4
.. data:: GPU_DYNAMIC_OBJECT_COLOR
An RGB color + alpha defined at object level.
Each values between 0.0 and 1.0.
The uniform is a vector of 4 float representing a RGB color + alpha defined at object level.
Each values between 0.0 and 1.0. In blender it corresponds to the 'color' attribute of the object.
Must be set before drawing the object.
There is at most one uniform of that type per shader.
See :class:`bpy.types.Object.color`.
:type: float4
.. data:: GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE
Multiplier for bump-map scaling.
:type: float
GLSL Lamp Uniforms
^^^^^^^^^^^^^^^^^^
.. note::
There is one uniform of that type per lamp lighting the material.
:value: 5
.. data:: GPU_DYNAMIC_LAMP_DYNVEC
Represents the direction of light in camera space.
The uniform is a vector of 3 float representing the direction of light in camera space.
In Blender, this is computed by
Computed as:
mat4_world_to_cam_ * (-vec3_lamp_Z_axis)
mat4_world_to_cam_ * (-vec3_lamp_Z_axis)
.. note::
- The lamp Z axis points to the opposite direction of light.
- The norm of the vector should be unit length.
as the lamp Z axis points to the opposite direction of light.
The norm of the vector should be unity. Can be set once per frame.
There is one uniform of that type per lamp lighting the material.
:type: float3
:value: 6
.. data:: GPU_DYNAMIC_LAMP_DYNCO
Represents the position of the light in camera space.
The uniform is a vector of 3 float representing the position of the light in camera space.
Computed as
Computed as:
mat4_world_to_cam_ * vec3_lamp_pos
mat4_world_to_cam_ * vec3_lamp_pos
:type: float3
Can be set once per frame.
There is one uniform of that type per lamp lighting the material.
:value: 7
.. data:: GPU_DYNAMIC_LAMP_DYNIMAT
Matrix that converts vector in camera space to lamp space.
The uniform is a 4x4 GL matrix that converts vector in camera space to lamp space.
Computed as
Computed as:
mat4_world_to_lamp_ * mat4_cam_to_world_
mat4_world_to_lamp_ * mat4_cam_to_world_
:type: matrix4x4
Can be set once per frame.
There is one uniform of that type per lamp lighting the material.
:value: 8
.. data:: GPU_DYNAMIC_LAMP_DYNPERSMAT
Matrix that converts a vector in camera space to shadow buffer depth space.
The uniform is a 4x4 GL matrix that converts a vector in camera space to shadow buffer depth space.
Computed as
Computed as:
mat4_perspective_to_depth_ * mat4_lamp_to_perspective_ * mat4_world_to_lamp_ * mat4_cam_to_world_.
mat4_perspective_to_depth_ * mat4_lamp_to_perspective_ * mat4_world_to_lamp_ * mat4_cam_to_world_.
.. _mat4_perspective_to_depth:
``mat4_perspective_to_depth`` is a fixed matrix defined as follow::
*mat4_perspective_to_depth* is a fixed matrix defined as follow::
0.5 0.0 0.0 0.5
0.0 0.5 0.0 0.5
0.0 0.0 0.5 0.5
0.0 0.0 0.0 1.0
.. note::
This uniform can be set once per frame. There is one uniform of that type per lamp casting shadow in the scene.
- There is one uniform of that type per lamp casting shadow in the scene.
:type: matrix4x4
:value: 9
.. data:: GPU_DYNAMIC_LAMP_DYNENERGY
See :class:`bpy.types.Lamp.energy`.
The uniform is a single float representing the lamp energy. In blender it corresponds
to the 'energy' attribute of the lamp data block.
There is one uniform of that type per lamp lighting the material.
:type: float
:value: 10
.. data:: GPU_DYNAMIC_LAMP_DYNCOL
See :class:`bpy.types.Lamp.color`.
The uniform is a vector of 3 float representing the lamp color.
Color elements are between 0.0 and 1.0. In blender it corresponds
to the 'color' attribute of the lamp data block.
There is one uniform of that type per lamp lighting the material.
:type: float3
.. data:: GPU_DYNAMIC_LAMP_DISTANCE
See :class:`bpy.types.Lamp.distance`.
:type: float
.. data:: GPU_DYNAMIC_LAMP_ATT1
See
:class:`bpy.types.PointLamp.linear_attenuation`,
:class:`bpy.types.SpotLamp.linear_attenuation`.
:type: float
.. data:: GPU_DYNAMIC_LAMP_ATT2
See
:class:`bpy.types.PointLamp.quadratic_attenuation`,
:class:`bpy.types.SpotLamp.quadratic_attenuation`.
:type: float
.. data:: GPU_DYNAMIC_LAMP_SPOTSIZE
See :class:`bpy.types.SpotLamp.spot_size`.
:type: float
.. data:: GPU_DYNAMIC_LAMP_SPOTBLEND
See :class:`bpy.types.SpotLamp.spot_blend`.
:type: float
.. data:: GPU_DYNAMIC_LAMP_SPOTSCALE
Represents the SpotLamp local scale.
:type: float2
GLSL Sampler Uniforms
^^^^^^^^^^^^^^^^^^^^^
:value: 11
.. data:: GPU_DYNAMIC_SAMPLER_2DBUFFER
Represents an internal texture used for certain effect
The uniform is an integer representing an internal texture used for certain effect
(color band, etc).
:type: integer
:value: 12
.. data:: GPU_DYNAMIC_SAMPLER_2DIMAGE
Represents a texture loaded from an image file.
The uniform is an integer representing a texture loaded from an image file.
:type: integer
:value: 13
.. data:: GPU_DYNAMIC_SAMPLER_2DSHADOW
Represents a texture loaded from a shadow buffer file.
The uniform is an float representing the bumpmap scaling.
:type: integer
:value: 14
.. data:: GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE
The uniform is an integer representing a shadow buffer corresponding to a lamp
casting shadow.
:value: 15
GLSL Mist Uniforms
^^^^^^^^^^^^^^^^^^
.. data:: GPU_DYNAMIC_MIST_ENABLE:
See :class:`bpy.types.WorldMistSettings.use_mist`.
:type: float (0 or 1)
.. data:: GPU_DYNAMIC_MIST_START
See :class:`bpy.types.WorldMistSettings.start`.
:type: float
See :class:`bpy.types.WorldMistSettings.depth`.
.. data:: GPU_DYNAMIC_MIST_DISTANCE
:type: float
See :class:`bpy.types.WorldMistSettings.intensity`.
.. data:: GPU_DYNAMIC_MIST_INTENSITY
:type: float
.. data:: GPU_DYNAMIC_MIST_TYPE
See :class:`bpy.types.WorldMistSettings.falloff`.
:type: float (used as an index into the type)
.. data:: GPU_DYNAMIC_MIST_COLOR
GLSL World Uniforms
^^^^^^^^^^^^^^^^^^^
.. data:: GPU_DYNAMIC_HORIZON_COLOR
See :class:`bpy.types.World.horizon_color`.
:type: float3
.. data:: GPU_DYNAMIC_AMBIENT_COLOR
See :class:`bpy.types.World.ambient_color`.
:type: float3
GLSL Material Uniforms
^^^^^^^^^^^^^^^^^^^^^^
.. data:: GPU_DYNAMIC_MAT_DIFFRGB
See :class:`bpy.types.Material.diffuse_color`.
:type: float3
.. data:: GPU_DYNAMIC_MAT_REF
See :class:`bpy.types.Material.diffuse_intensity`.
:type: float
.. data:: GPU_DYNAMIC_MAT_SPECRGB
See :class:`bpy.types.Material.specular_color`.
:type: float3
.. data:: GPU_DYNAMIC_MAT_SPEC
See :class:`bpy.types.Material.specular_intensity`.
:type: float
.. data:: GPU_DYNAMIC_MAT_HARD
See :class:`bpy.types.Material.specular_hardness`.
:type: float
.. data:: GPU_DYNAMIC_MAT_EMIT
See :class:`bpy.types.Material.emit`.
:type: float
.. data:: GPU_DYNAMIC_MAT_AMB
See :class:`bpy.types.Material.ambient`.
:type: float
.. data:: GPU_DYNAMIC_MAT_ALPHA
See :class:`bpy.types.Material.alpha`.
:type: float
GLSL Attribute Type
GLSL attribute type
-------------------
.. _attribute-type:
@@ -429,7 +291,9 @@ layer that contains the vertex attribute.
.. code-block:: python
mesh.uv_layers[attribute["name"]]
mesh.uv_textures[attribute["name"]]
:value: 5
.. data:: CD_MCOL
@@ -442,6 +306,8 @@ layer that contains the vertex attribute.
mesh.vertex_colors[attribute["name"]]
:value: 6
.. data:: CD_ORCO
Vertex attribute is original coordinates. Data type is vector 3 float.
@@ -453,6 +319,8 @@ layer that contains the vertex attribute.
mesh.vertices
:value: 14
.. data:: CD_TANGENT
Vertex attribute is the tangent vector. Data type is vector 4 float.
@@ -462,6 +330,8 @@ layer that contains the vertex attribute.
C function to compute the tangent layer from the other layers can be obtained from
blender.org.
:value: 18
Functions
=========
@@ -471,12 +341,8 @@ Functions
.. function:: export_shader(scene,material)
Extracts the GLSL shader producing the visual effect of material in scene for the purpose of
reusing the shader in an external engine.
This function is meant to be used in material exporter
so that the GLSL shader can be exported entirely.
The return value is a dictionary containing the
reusing the shader in an external engine. This function is meant to be used in material exporter
so that the GLSL shader can be exported entirely. The return value is a dictionary containing the
shader source code and all associated data.
:arg scene: the scene in which the material in rendered.
@@ -488,91 +354,76 @@ Functions
The dictionary contains the following elements:
- ``["fragment"]``: string
* ["fragment"] : string
fragment shader source code.
- ``["vertex"]``: string
* ["vertex"] : string
vertex shader source code.
- ``["uniforms"]``: sequence
* ["uniforms"] : sequence
list of uniforms used in fragment shader, can be empty list. Each element of the
sequence is a dictionary with the following elements:
- ``["varname"]``: string
* ["varname"] : string
name of the uniform in the fragment shader. Always of the form 'unf<number>'.
- ``["datatype"]``: integer
* ["datatype"] : integer
data type of the uniform variable. Can be one of the following:
.. hlist::
:columns: 2
* :data:`gpu.GPU_DATA_1I` : use glUniform1i
* :data:`gpu.GPU_DATA_1F` : use glUniform1fv
* :data:`gpu.GPU_DATA_2F` : use glUniform2fv
* :data:`gpu.GPU_DATA_3F` : use glUniform3fv
* :data:`gpu.GPU_DATA_4F` : use glUniform4fv
* :data:`gpu.GPU_DATA_9F` : use glUniformMatrix3fv
* :data:`gpu.GPU_DATA_16F` : use glUniformMatrix4fv
- :data:`gpu.GPU_DATA_1I` : use ``glUniform1i``
- :data:`gpu.GPU_DATA_1F` : use ``glUniform1fv``
- :data:`gpu.GPU_DATA_2F` : use ``glUniform2fv``
- :data:`gpu.GPU_DATA_3F` : use ``glUniform3fv``
- :data:`gpu.GPU_DATA_4F` : use ``glUniform4fv``
- :data:`gpu.GPU_DATA_9F` : use ``glUniformMatrix3fv``
- :data:`gpu.GPU_DATA_16F` : use ``glUniformMatrix4fv``
- ``["type"]``: integer
* ["type"] : integer
type of uniform, determines the origin and method of calculation. See uniform-type_.
Depending on the type, more elements will be be present.
- ``["lamp"]``: :class:`bpy.types.Object`
Reference to the lamp object from which the uniforms value are extracted.
Set for the following uniforms types:
* ["lamp"] : :class:`bpy.types.Object`
Reference to the lamp object from which the uniforms value are extracted. Set for the following uniforms types:
.. hlist::
:columns: 2
:columns: 3
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNVEC`
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNCO`
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNIMAT`
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT`
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNENERGY`
- :data:`gpu.GPU_DYNAMIC_LAMP_DYNCOL`
- :data:`gpu.GPU_DYNAMIC_SAMPLER_2DSHADOW`
* :data:`gpu.GPU_DYNAMIC_LAMP_DYNVEC`
* :data:`gpu.GPU_DYNAMIC_LAMP_DYNCO`
* :data:`gpu.GPU_DYNAMIC_LAMP_DYNIMAT`
* :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT`
* :data:`gpu.GPU_DYNAMIC_LAMP_DYNENERGY`
* :data:`gpu.GPU_DYNAMIC_LAMP_DYNCOL`
* :data:`gpu.GPU_DYNAMIC_SAMPLER_2DSHADOW`
Notes:
- The uniforms
:data:`gpu.GPU_DYNAMIC_LAMP_DYNVEC`,
:data:`gpu.GPU_DYNAMIC_LAMP_DYNCO`,
:data:`gpu.GPU_DYNAMIC_LAMP_DYNIMAT` and
:data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT`
refer to the lamp object position and orientation,
both of can be derived from the object world matrix:
* The uniforms :data:`gpu.GPU_DYNAMIC_LAMP_DYNVEC`, :data:`gpu.GPU_DYNAMIC_LAMP_DYNCO`, :data:`gpu.GPU_DYNAMIC_LAMP_DYNIMAT` and :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT`
refer to the lamp object position and orientation, both of can be derived from the object world matrix:
.. code-block:: python
obmat = uniform["lamp"].matrix_world
where obmat is the mat4_lamp_to_world_ matrix of the lamp as a 2 dimensional array,
the lamp world location location is in ``obmat[3]``.
the lamp world location location is in obmat[3].
- The uniform types
:data:`gpu.GPU_DYNAMIC_LAMP_DYNENERGY` and
:data:`gpu.GPU_DYNAMIC_LAMP_DYNCOL`
refer to the lamp data bloc that you get from:
* The uniform types :data:`gpu.GPU_DYNAMIC_LAMP_DYNENERGY` and :data:`gpu.GPU_DYNAMIC_LAMP_DYNCOL` refer to the lamp data bloc that you get from:
.. code-block:: python
la = uniform["lamp"].data
from which you get ``lamp.energy`` and ``lamp.color``
from which you get la.energy and la.color
- Lamp duplication is not supported: if you have duplicated lamps in your scene
* Lamp duplication is not supported: if you have duplicated lamps in your scene
(i.e. lamp that are instantiated by dupligroup, etc), this element will only
give you a reference to the orignal lamp and you will not know which instance
of the lamp it is refering too. You can still handle that case in the exporter
by distributing the uniforms amongst the duplicated lamps.
- ``["image"]``: :class:`bpy.types.Image`
Reference to the image databloc.
Set for uniform type
:data:`gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE`.
You can get the image data from:
* ["image"] : :class:`bpy.types.Image`
Reference to the image databloc. Set for uniform type :data:`gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE`. You can get the image data from:
.. code-block:: python
@@ -581,63 +432,60 @@ Functions
# image size as a 2-dimensional array of int
uniform["image"].size
- ``["texnumber"]``: integer
* ["texnumber"] : integer
Channel number to which the texture is bound when drawing the object.
Set for uniform types
:data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`,
:data:`gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE` and
:data:`gpu.GPU_DYNAMIC_SAMPLER_2DSHADOW`.
Set for uniform types :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`, :data:`gpu.GPU_DYNAMIC_SAMPLER_2DIMAGE` and :data:`gpu.GPU_DYNAMIC_SAMPLER_2DSHADOW`.
This is provided for information only: when reusing the shader outside blencer,
you are free to assign the textures to the channel of your choice and to pass
that number channel to the GPU in the uniform.
- ``["texpixels"]``: byte array
texture data for uniform type :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`.
Although the corresponding uniform is a 2D sampler,
the texture is always a 1D texture of n x 1 pixel.
The texture size n is provided in ["texsize"] element.
* ["texpixels"] : byte array
texture data for uniform type :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`. Although
the corresponding uniform is a 2D sampler, the texture is always a 1D texture
of n x 1 pixel. The texture size n is provided in ["texsize"] element.
These texture are only used for computer generated texture (colorband, etc).
The texture data is provided so that you can make a real image out of it in the exporter.
The texture data is provided so that you can make a real image out of it in the
exporter.
- ``["texsize"]``: integer
* ["texsize"] : integer
horizontal size of texture for uniform type :data:`gpu.GPU_DYNAMIC_SAMPLER_2DBUFFER`.
The texture data is in ["texpixels"].
- ``["attributes"]``: sequence
* ["attributes"] : sequence
list of attributes used in vertex shader, can be empty. Blender doesn't use
standard attributes except for vertex position and normal. All other vertex
attributes must be passed using the generic ``glVertexAttrib`` functions.
attributes must be passed using the generic glVertexAttrib functions.
The attribute data can be found in the derived mesh custom data using RNA.
Each element of the sequence is a dictionary containing the following elements:
- ``["varname"]``: string
* ["varname"] : string
name of the uniform in the vertex shader. Always of the form 'att<number>'.
- ``["datatype"]``: integer
* ["datatype"] : integer
data type of vertex attribute, can be one of the following:
- :data:`gpu.GPU_DATA_2F`: use ``glVertexAttrib2fv``
- :data:`gpu.GPU_DATA_3F`: use ``glVertexAttrib3fv``
- :data:`gpu.GPU_DATA_4F`: use ``glVertexAttrib4fv``
- :data:`gpu.GPU_DATA_4UB`: use ``glVertexAttrib4ubv``
* :data:`gpu.GPU_DATA_2F` : use glVertexAttrib2fv
* :data:`gpu.GPU_DATA_3F` : use glVertexAttrib3fv
* :data:`gpu.GPU_DATA_4F` : use glVertexAttrib4fv
* :data:`gpu.GPU_DATA_4UB` : use glVertexAttrib4ubv
- ``["number"]``: integer
Generic attribute number. This is provided for information only.
Blender doesn't use ``glBindAttribLocation`` to place generic attributes at specific location,
* ["number"] : integer
generic attribute number. This is provided for information only. Blender
doesn't use glBindAttribLocation to place generic attributes at specific location,
it lets the shader compiler place the attributes automatically and query the
placement with ``glGetAttribLocation``.
The result of this placement is returned in this element.
placement with glGetAttribLocation. The result of this placement is returned in
this element.
When using this shader in a render engine, you should either use
``glBindAttribLocation`` to force the attribute at this location or use
``glGetAttribLocation`` to get the placement chosen by the compiler of your GPU.
glBindAttribLocation to force the attribute at this location or use
glGetAttribLocation to get the placement chosen by the compiler of your GPU.
- ``["type"]``: integer
* ["type"] : integer
type of the mesh custom data from which the vertex attribute is loaded.
See attribute-type_.
- ``["name"]``: string or integer
* ["name"] : string or integer
custom data layer name, used for attribute type :data:`gpu.CD_MTFACE` and :data:`gpu.CD_MCOL`.
Example:
@@ -664,14 +512,14 @@ Notes
.. _mat4_lamp_to_perspective:
#. Calculation of the ``mat4_lamp_to_perspective`` matrix for a spot lamp.
1. Calculation of the *mat4_lamp_to_perspective* matrix for a spot lamp.
The following pseudo code shows how the ``mat4_lamp_to_perspective`` matrix is computed
The following pseudo code shows how the *mat4_lamp_to_perspective* matrix is computed
in blender for uniforms of :data:`gpu.GPU_DYNAMIC_LAMP_DYNPERSMAT` type:
.. code-block:: python
# Get the lamp datablock with:
#Get the lamp datablock with:
lamp = bpy.data.objects[uniform["lamp"]].data
# Compute the projection matrix:
@@ -683,11 +531,11 @@ Notes
# The size of the projection plane is computed with the usual formula:
wsize = lamp.clista * tan(lamp.spotsize/2)
# And the projection matrix:
#And the projection matrix:
mat4_lamp_to_perspective = glFrustum(-wsize, wsize, -wsize, wsize, lamp.clista, lamp.clipend)
#. Creation of the shadow map for a spot lamp.
2. Creation of the shadow map for a spot lamp.
The shadow map is the depth buffer of a render performed by placing the camera at the
spot light position. The size of the shadow map is given by the attribute ``lamp.bufsize``:
spot light position. The size of the shadow map is given by the attribute lamp.bufsize :
shadow map size in pixel, same size in both dimensions.

View File

@@ -114,9 +114,9 @@ This example shows loading a script in as a module and executing a module functi
.. code-block:: python
import myscript
import importlib
import imp
importlib.reload(myscript)
imp.reload(myscript)
myscript.main()
@@ -143,8 +143,8 @@ this example adds the current blend files directory to the search path, then loa
sys.path.append(blend_dir)
import myscript
import importlib
importlib.reload(myscript)
import imp
imp.reload(myscript)
myscript.main()
@@ -307,7 +307,7 @@ Since it's possible to access data which has been removed (see Gotcha's),
this can be hard to track down the cause of crashes.
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 2x slower
which is why the option isn't enabled in release builds.

View File

@@ -163,9 +163,6 @@ def main():
for i, l in enumerate(b):
l = l.strip()
# casts
l = l.replace("(int)", "")
l = l.replace("{", "(")
l = l.replace("}", ")")

View File

@@ -261,7 +261,6 @@ else:
"bpy.utils.previews",
"bpy_extras",
"gpu",
"gpu.offscreen",
"mathutils",
"mathutils.geometry",
"mathutils.bvhtree",
@@ -473,18 +472,6 @@ else:
_BPY_PROP_COLLECTION_ID = "collection"
def escape_rst(text):
""" Escape plain text which may contain characters used by RST.
"""
return text.translate(escape_rst.trans)
escape_rst.trans = str.maketrans({
"`": "\\`",
"|": "\\|",
"*": "\\*",
"\\": "\\\\",
})
def is_struct_seq(value):
return isinstance(value, tuple) and type(tuple) != tuple and hasattr(value, "n_fields")
@@ -1152,7 +1139,7 @@ def pycontext2sphinx(basepath):
def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
""" write a bullet point list of enum + descriptions
""" write a bullet point list of enum + descrptons
"""
if use_empty_descriptions:
@@ -1167,7 +1154,7 @@ def pyrna_enum2sphinx(prop, use_empty_descriptions=False):
if ok:
return "".join(["* ``%s`` %s.\n" %
(identifier,
", ".join(escape_rst(val) for val in (name, description) if val),
", ".join(val for val in (name, description) if val),
)
for identifier, name, description in prop.enum_items
])
@@ -1613,7 +1600,7 @@ def write_rst_contents(basepath):
fw("\n")
# fw("`A PDF version of this document is also available <%s>`_\n" % BLENDER_PDF_FILENAME)
fw("This site can be downloaded for offline use `Download the full Documentation (zipped HTML files) <%s>`_\n" % BLENDER_ZIP_FILENAME)
fw("This site can be downloaded for offline use `Download the full Documentation (zipped HTML files)<%s>`_\n" % BLENDER_ZIP_FILENAME)
fw("\n")
@@ -1660,9 +1647,7 @@ def write_rst_contents(basepath):
# mathutils
"mathutils", "mathutils.geometry", "mathutils.bvhtree", "mathutils.kdtree", "mathutils.noise",
# misc
"freestyle", "bgl", "blf",
"gpu", "gpu.offscreen",
"aud", "bpy_extras",
"freestyle", "bgl", "blf", "gpu", "aud", "bpy_extras",
# bmesh, submodules are in own page
"bmesh",
)
@@ -1802,7 +1787,6 @@ def write_rst_importable_modules(basepath):
# C_modules
"aud" : "Audio System",
"blf" : "Font Drawing",
"gpu.offscreen" : "GPU Off-Screen Buffer",
"bmesh" : "BMesh Module",
"bmesh.types" : "BMesh Types",
"bmesh.utils" : "BMesh Utilities",

View File

@@ -18,10 +18,8 @@ DO_OUT_HTML=true
DO_OUT_HTML_ZIP=true
DO_OUT_PDF=false
if [ -z $BLENDER_BIN ] ; then
BLENDER_BIN="./blender.bin"
fi
BLENDER="./blender.bin"
SSH_USER=$1
SSH_HOST=$SSH_USER"@blender.org"
SSH_UPLOAD="/data/www/vhosts/www.blender.org/api" # blender_python_api_VERSION, added after
@@ -54,7 +52,7 @@ SPHINXBASE=doc/python_api
if $DO_EXE_BLENDER ; then
# dont delete existing docs, now partial updates are used for quick builds.
$BLENDER_BIN --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
$BLENDER --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
fi

View File

@@ -34,14 +34,8 @@ set(SRC
eigen3_capi.h
intern/eigenvalues.cc
intern/svd.cc
intern/eigenvalues.h
intern/svd.h
)
set(LIB
)
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -28,6 +28,5 @@
#define __EIGEN3_C_API_H__
#include "intern/eigenvalues.h"
#include "intern/svd.h"
#endif /* __EIGEN3_C_API_H__ */

View File

@@ -1,72 +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.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_SVD_C_API_CC__
#define __EIGEN3_SVD_C_API_CC__
/* Eigen gives annoying huge amount of warnings here, silence them! */
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlogical-op"
#endif
#include <Eigen/Core>
#include <Eigen/SVD>
#include "svd.h"
using Eigen::JacobiSVD;
using Eigen::NoQRPreconditioner;
using Eigen::ComputeThinU;
using Eigen::ComputeThinV;
using Eigen::MatrixXf;
using Eigen::VectorXf;
using Eigen::Map;
void EG3_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
{
/* Since our matrix is squared, we can use thinU/V. */
unsigned int flags = (r_U ? ComputeThinU : 0) | (r_V ? ComputeThinV : 0);
/* Blender and Eigen matrices are both column-major. */
JacobiSVD<MatrixXf, NoQRPreconditioner> svd(Map<MatrixXf>((float *)matrix, size, size), flags);
if (r_U) {
Map<MatrixXf>(r_U, size, size) = svd.matrixU();
}
if (r_S) {
Map<VectorXf>(r_S, size) = svd.singularValues();
}
if (r_V) {
Map<MatrixXf>(r_V, size, size) = svd.matrixV();
}
}
#endif /* __EIGEN3_SVD_C_API_CC__ */

View File

@@ -1,40 +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.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_SVD_C_API_H__
#define __EIGEN3_SVD_C_API_H__
#ifdef __cplusplus
extern "C" {
#endif
void EG3_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V);
#ifdef __cplusplus
}
#endif
#endif /* __EIGEN3_SVD_C_API_H__ */

View File

@@ -32,11 +32,7 @@ set(SRC
include/binreloc.h
)
set(LIB
)
add_definitions(-DENABLE_BINRELOC)
blender_add_lib(extern_binreloc "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_binreloc "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -403,4 +403,4 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif()
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -169,4 +169,4 @@ if(WITH_BOOST)
)
endif()
blender_add_lib(extern_carve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_carve "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -37,10 +37,6 @@ set(SRC
src/clew.c
)
set(LIB
)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -78,13 +78,13 @@ extern "C" {
#define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_API_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_API_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#else
#define CL_EXTENSION_WEAK_LINK
#define CL_API_SUFFIX__VERSION_1_0
@@ -2484,7 +2484,7 @@ PFNCLCREATEFROMGLTEXTURE3D)(cl_context /* context */,
#ifdef __APPLE__
# pragma GCC diagnostic pop // ignored "-Wignored-attributes"
#endif
/* cl_khr_gl_sharing extension */
#define cl_khr_gl_sharing 1
@@ -2781,7 +2781,7 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH
#define CLEW_ERROR_ATEXIT_FAILED -2 //!< Error code for failing to queue the closing of the dynamic library to atexit()
//! \brief Load OpenCL dynamic library and set function entry points
int clewInit (void);
int clewInit ();
//! \brief Convert an OpenCL error code to its string equivalent
const char* clewErrorString (cl_int error);

View File

@@ -378,15 +378,5 @@ const char* clewErrorString(cl_int error)
, "CL_INVALID_DEVICE_PARTITION_COUNT" // -68
};
static const int num_errors = sizeof(strings) / sizeof(strings[0]);
if (error == -1001) {
return "CL_PLATFORM_NOT_FOUND_KHR";
}
if (error > 0 || -error >= num_errors) {
return "Unknown OpenCL error";
}
return strings[-error];
}

View File

@@ -38,4 +38,4 @@ set(SRC
Include/UFconfig.h
)
blender_add_lib(extern_colamd "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_colamd "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -37,8 +37,4 @@ set(SRC
src/cuew.c
)
set(LIB
)
blender_add_lib(extern_cuew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_cuew "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -47,10 +47,6 @@ set(SRC
include/GL/wglew.h
)
set(LIB
)
add_definitions(${GL_DEFINITIONS})
if(WITH_GLEW_MX)
@@ -58,4 +54,4 @@ if(WITH_GLEW_MX)
endif()
blender_add_lib(extern_glew_es "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_glew_es "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -51,4 +51,4 @@ if(WITH_GLEW_MX)
add_definitions(-DGLEW_MX)
endif()
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,5 @@
/*
** The OpenGL Extension Wrangler Library
** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
@@ -201,12 +200,12 @@ typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
#ifndef GLX_VERSION_1_3
#define GLX_VERSION_1_3 1
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_RGBA_BIT 0x00000001
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_WINDOW_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_PBUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
@@ -387,19 +386,6 @@ typedef Bool ( * PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx);
#endif /* GLX_AMD_gpu_association */
/* --------------------- GLX_ARB_context_flush_control --------------------- */
#ifndef GLX_ARB_context_flush_control
#define GLX_ARB_context_flush_control 1
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#define GLXEW_ARB_context_flush_control GLXEW_GET_VAR(__GLXEW_ARB_context_flush_control)
#endif /* GLX_ARB_context_flush_control */
/* ------------------------- GLX_ARB_create_context ------------------------ */
#ifndef GLX_ARB_create_context
@@ -451,8 +437,8 @@ typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBCo
#ifndef GLX_ARB_fbconfig_float
#define GLX_ARB_fbconfig_float 1
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
#define GLX_RGBA_FLOAT_BIT 0x00000004
#define GLX_RGBA_FLOAT_TYPE 0x20B9
#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float)
@@ -679,19 +665,6 @@ typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context
#endif /* GLX_EXT_scene_marker */
/* -------------------------- GLX_EXT_stereo_tree -------------------------- */
#ifndef GLX_EXT_stereo_tree
#define GLX_EXT_stereo_tree 1
#define GLX_STEREO_NOTIFY_EXT 0x00000000
#define GLX_STEREO_NOTIFY_MASK_EXT 0x00000001
#define GLX_STEREO_TREE_EXT 0x20F5
#define GLXEW_EXT_stereo_tree GLXEW_GET_VAR(__GLXEW_EXT_stereo_tree)
#endif /* GLX_EXT_stereo_tree */
/* -------------------------- GLX_EXT_swap_control ------------------------- */
#ifndef GLX_EXT_swap_control
@@ -858,38 +831,6 @@ typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo
#endif /* GLX_MESA_pixmap_colormap */
/* ------------------------ GLX_MESA_query_renderer ------------------------ */
#ifndef GLX_MESA_query_renderer
#define GLX_MESA_query_renderer 1
#define GLX_RENDERER_VENDOR_ID_MESA 0x8183
#define GLX_RENDERER_DEVICE_ID_MESA 0x8184
#define GLX_RENDERER_VERSION_MESA 0x8185
#define GLX_RENDERER_ACCELERATED_MESA 0x8186
#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187
#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188
#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189
#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A
#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B
#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C
#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D
#define GLX_RENDERER_ID_MESA 0x818E
typedef Bool ( * PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int* value);
typedef const char* ( * PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);
typedef Bool ( * PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display* dpy, int screen, int renderer, int attribute, unsigned int *value);
typedef const char* ( * PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);
#define glXQueryCurrentRendererIntegerMESA GLXEW_GET_FUN(__glewXQueryCurrentRendererIntegerMESA)
#define glXQueryCurrentRendererStringMESA GLXEW_GET_FUN(__glewXQueryCurrentRendererStringMESA)
#define glXQueryRendererIntegerMESA GLXEW_GET_FUN(__glewXQueryRendererIntegerMESA)
#define glXQueryRendererStringMESA GLXEW_GET_FUN(__glewXQueryRendererStringMESA)
#define GLXEW_MESA_query_renderer GLXEW_GET_VAR(__GLXEW_MESA_query_renderer)
#endif /* GLX_MESA_query_renderer */
/* ------------------------ GLX_MESA_release_buffers ----------------------- */
#ifndef GLX_MESA_release_buffers
@@ -934,21 +875,6 @@ typedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval);
#endif /* GLX_MESA_swap_control */
/* --------------------------- GLX_NV_copy_buffer -------------------------- */
#ifndef GLX_NV_copy_buffer
#define GLX_NV_copy_buffer 1
typedef void ( * PFNGLXCOPYBUFFERSUBDATANVPROC) (Display* dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
typedef void ( * PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display* dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#define glXCopyBufferSubDataNV GLXEW_GET_FUN(__glewXCopyBufferSubDataNV)
#define glXNamedCopyBufferSubDataNV GLXEW_GET_FUN(__glewXNamedCopyBufferSubDataNV)
#define GLXEW_NV_copy_buffer GLXEW_GET_VAR(__GLXEW_NV_copy_buffer)
#endif /* GLX_NV_copy_buffer */
/* --------------------------- GLX_NV_copy_image --------------------------- */
#ifndef GLX_NV_copy_image
@@ -962,19 +888,6 @@ typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx,
#endif /* GLX_NV_copy_image */
/* ------------------------ GLX_NV_delay_before_swap ----------------------- */
#ifndef GLX_NV_delay_before_swap
#define GLX_NV_delay_before_swap 1
typedef Bool ( * PFNGLXDELAYBEFORESWAPNVPROC) (Display* dpy, GLXDrawable drawable, GLfloat seconds);
#define glXDelayBeforeSwapNV GLXEW_GET_FUN(__glewXDelayBeforeSwapNV)
#define GLXEW_NV_delay_before_swap GLXEW_GET_VAR(__GLXEW_NV_delay_before_swap)
#endif /* GLX_NV_delay_before_swap */
/* -------------------------- GLX_NV_float_buffer -------------------------- */
#ifndef GLX_NV_float_buffer
@@ -1080,10 +993,10 @@ typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoC
#endif /* GLX_NV_video_capture */
/* ---------------------------- GLX_NV_video_out --------------------------- */
/* -------------------------- GLX_NV_video_output -------------------------- */
#ifndef GLX_NV_video_out
#define GLX_NV_video_out 1
#ifndef GLX_NV_video_output
#define GLX_NV_video_output 1
#define GLX_VIDEO_OUT_COLOR_NV 0x20C3
#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4
@@ -1110,9 +1023,9 @@ typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf,
#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV)
#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV)
#define GLXEW_NV_video_out GLXEW_GET_VAR(__GLXEW_NV_video_out)
#define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output)
#endif /* GLX_NV_video_out */
#endif /* GLX_NV_video_output */
/* -------------------------- GLX_OML_swap_method -------------------------- */
@@ -1198,10 +1111,10 @@ typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, i
#ifndef GLX_SGIX_fbconfig
#define GLX_SGIX_fbconfig 1
#define GLX_RGBA_BIT_SGIX 0x00000001
#define GLX_WINDOW_BIT_SGIX 0x00000001
#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
#define GLX_RGBA_BIT_SGIX 0x00000001
#define GLX_PIXMAP_BIT_SGIX 0x00000002
#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
#define GLX_SCREEN_EXT 0x800C
#define GLX_DRAWABLE_TYPE_SGIX 0x8010
#define GLX_RENDER_TYPE_SGIX 0x8011
@@ -1238,8 +1151,8 @@ typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLX
#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001
#define GLX_PIPE_RECT_SGIX 0x00000001
#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002
#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003
#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004
#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
@@ -1305,8 +1218,8 @@ typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Disp
#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
#define GLX_PBUFFER_BIT_SGIX 0x00000004
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
@@ -1560,11 +1473,6 @@ GLXEW_FUN_EXPORT PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA;
GLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC __glewXQueryCurrentRendererIntegerMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC __glewXQueryCurrentRendererStringMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYRENDERERINTEGERMESAPROC __glewXQueryRendererIntegerMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYRENDERERSTRINGMESAPROC __glewXQueryRendererStringMESA;
GLXEW_FUN_EXPORT PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;
GLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
@@ -1572,13 +1480,8 @@ GLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
GLXEW_FUN_EXPORT PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA;
GLXEW_FUN_EXPORT PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA;
GLXEW_FUN_EXPORT PFNGLXCOPYBUFFERSUBDATANVPROC __glewXCopyBufferSubDataNV;
GLXEW_FUN_EXPORT PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC __glewXNamedCopyBufferSubDataNV;
GLXEW_FUN_EXPORT PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;
GLXEW_FUN_EXPORT PFNGLXDELAYBEFORESWAPNVPROC __glewXDelayBeforeSwapNV;
GLXEW_FUN_EXPORT PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;
GLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;
@@ -1671,7 +1574,6 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_3;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_4;
GLXEW_VAR_EXPORT GLboolean __GLXEW_3DFX_multisample;
GLXEW_VAR_EXPORT GLboolean __GLXEW_AMD_gpu_association;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_context_flush_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_profile;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_robustness;
@@ -1691,7 +1593,6 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_import_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_scene_marker;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_stereo_tree;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control_tear;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;
@@ -1701,20 +1602,17 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_INTEL_swap_event;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_agp_offset;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_query_renderer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_release_buffers;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_image;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_delay_before_swap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_float_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_multisample_coverage;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_present_video;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_swap_group;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_vertex_array_range;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_capture;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_out;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_output;
GLXEW_VAR_EXPORT GLboolean __GLXEW_OML_swap_method;
GLXEW_VAR_EXPORT GLboolean __GLXEW_OML_sync_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_blended_overlay;
@@ -1755,12 +1653,11 @@ GLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const GLXEWContext *ctx,
#else /* GLEW_MX */
GLEWAPI GLenum GLEWAPIENTRY glxewInit ();
GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);
#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)
#define GLXEW_GET_FUN(x) x
GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);
#endif /* GLEW_MX */
GLEWAPI GLboolean GLEWAPIENTRY glxewGetExtension (const char *name);

View File

@@ -1,6 +1,5 @@
/*
** The OpenGL Extension Wrangler Library
** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
@@ -183,19 +182,6 @@ typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, in
#endif /* WGL_ARB_buffer_region */
/* --------------------- WGL_ARB_context_flush_control --------------------- */
#ifndef WGL_ARB_context_flush_control
#define WGL_ARB_context_flush_control 1
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#define WGLEW_ARB_context_flush_control WGLEW_GET_VAR(__WGLEW_ARB_context_flush_control)
#endif /* WGL_ARB_context_flush_control */
/* ------------------------- WGL_ARB_create_context ------------------------ */
#ifndef WGL_ARB_create_context
@@ -942,19 +928,6 @@ typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcNa
#endif /* WGL_NV_copy_image */
/* ------------------------ WGL_NV_delay_before_swap ----------------------- */
#ifndef WGL_NV_delay_before_swap
#define WGL_NV_delay_before_swap 1
typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);
#define wglDelayBeforeSwapNV WGLEW_GET_FUN(__wglewDelayBeforeSwapNV)
#define WGLEW_NV_delay_before_swap WGLEW_GET_VAR(__WGLEW_NV_delay_before_swap)
#endif /* WGL_NV_delay_before_swap */
/* -------------------------- WGL_NV_float_buffer -------------------------- */
#ifndef WGL_NV_float_buffer
@@ -1318,8 +1291,6 @@ WGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV;
WGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;
WGLEW_FUN_EXPORT PFNWGLDELAYBEFORESWAPNVPROC __wglewDelayBeforeSwapNV;
WGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;
WGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;
WGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;
@@ -1363,7 +1334,6 @@ WGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample;
WGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_context_flush_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness;
@@ -1401,7 +1371,6 @@ WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_delay_before_swap;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage;
@@ -1434,12 +1403,11 @@ GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx,
#else /* GLEW_MX */
GLEWAPI GLenum GLEWAPIENTRY wglewInit ();
GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);
#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x)
#define WGLEW_GET_FUN(x) x
GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);
#endif /* GLEW_MX */
GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name);

4848
extern/glew/src/glew.c vendored

File diff suppressed because it is too large Load Diff

View File

@@ -69,8 +69,4 @@ set(SRC
include/gtest/internal/gtest-type-util.h
)
set(LIB
)
blender_add_lib(extern_gtest "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_gtest "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -72,11 +72,6 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
)
endif()
set(LIB
extern_ceres
extern_glog
)
if(WITH_LIBMV)
TEST_SHARED_PTR_SUPPORT()
if(SHARED_PTR_FOUND)
@@ -224,7 +219,7 @@ if(WITH_LIBMV)
if(WITH_GTESTS)
blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "" "" "")
blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "" "")
BLENDER_SRC_GTEST("libmv_predict_tracks" "./libmv/autotrack/predict_tracks_test.cc" "libmv_test_dataset;extern_libmv;extern_ceres")
BLENDER_SRC_GTEST("libmv_tracks" "./libmv/autotrack/tracks_test.cc" "libmv_test_dataset;extern_libmv;extern_ceres")
@@ -264,8 +259,7 @@ else()
)
endif()
blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
unset(LIB)
blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}")
if(WITH_LIBMV)
add_subdirectory(third_party)
@@ -351,5 +345,5 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
)
endif()
blender_add_lib(extern_glog "${GLOG_SRC}" "${INC}" "${INC_SYS}" "")
blender_add_lib(extern_glog "${GLOG_SRC}" "${INC}" "${INC_SYS}")
endif()

View File

@@ -61,8 +61,7 @@ class ArrayND : public BaseArray {
Resize(s0, s1, s2);
}
ArrayND(T* data, int s0, int s1, int s2)
: shape_(0), strides_(0), data_(data), own_data_(false) {
ArrayND(T* data, int s0, int s1, int s2) : data_(data), own_data_(false) {
Resize(s0, s1, s2);
}

View File

@@ -80,6 +80,7 @@ set(SRC
internal/ceres/gradient_problem.cc
internal/ceres/gradient_problem_solver.cc
internal/ceres/implicit_schur_complement.cc
internal/ceres/incomplete_lq_factorization.cc
internal/ceres/iterative_schur_complement_solver.cc
internal/ceres/lapack.cc
internal/ceres/levenberg_marquardt_strategy.cc
@@ -208,6 +209,7 @@ set(SRC
internal/ceres/graph_algorithms.h
internal/ceres/graph.h
internal/ceres/implicit_schur_complement.h
internal/ceres/incomplete_lq_factorization.h
internal/ceres/integral_types.h
internal/ceres/iterative_schur_complement_solver.h
internal/ceres/lapack.h
@@ -268,7 +270,6 @@ if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
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_4.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_d.cc
internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
@@ -287,7 +288,6 @@ if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
internal/ceres/generated/schur_eliminator_2_2_d.cc
internal/ceres/generated/schur_eliminator_2_3_3.cc
internal/ceres/generated/schur_eliminator_2_3_4.cc
internal/ceres/generated/schur_eliminator_2_3_6.cc
internal/ceres/generated/schur_eliminator_2_3_9.cc
internal/ceres/generated/schur_eliminator_2_3_d.cc
internal/ceres/generated/schur_eliminator_2_4_3.cc
@@ -356,4 +356,4 @@ else()
endif()
endif()
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}")

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python
# NOTE: This file is automatically generated by bundle.sh script
# If you're doing changes in this file, please update template

View File

@@ -129,7 +129,7 @@ set(INC
)
set(INC_SYS
\${EIGEN3_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)
set(SRC

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -30,16 +30,13 @@
// Default (empty) configuration options for Ceres.
//
// IMPORTANT: Most users of Ceres will not use this file, when
// compiling Ceres with CMake, CMake will configure a new
// config.h with the currently selected Ceres compile
// options in <BUILD_DIR>/config, which will be added to
// the include path for compilation, and installed with the
// public Ceres headers. However, for some users of Ceres
// who compile without CMake (Android), this file ensures
// that Ceres will compile, with the user either specifying
// manually the Ceres compile options, or passing them
// directly through the compiler.
// IMPORTANT: Most users of Ceres will not use this file, when compiling Ceres
// with CMake, CMake will configure a new config.h with the currently
// selected Ceres compile options and copy it into the source
// directory before compilation. However, for some users of Ceres
// who compile without CMake, this file ensures that Ceres will
// compile, with the user either specifying manually the Ceres
// compile options, or passing them directly through the compiler.
#ifndef CERES_PUBLIC_INTERNAL_CONFIG_H_
#define CERES_PUBLIC_INTERNAL_CONFIG_H_

View File

@@ -157,6 +157,8 @@ internal/ceres/graph_algorithms.h
internal/ceres/graph.h
internal/ceres/implicit_schur_complement.cc
internal/ceres/implicit_schur_complement.h
internal/ceres/incomplete_lq_factorization.cc
internal/ceres/incomplete_lq_factorization.h
internal/ceres/integral_types.h
internal/ceres/iterative_schur_complement_solver.cc
internal/ceres/iterative_schur_complement_solver.h

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -33,9 +33,9 @@
#ifndef CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
#define CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
#include "ceres/local_parameterization.h"
#include "ceres/internal/autodiff.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/local_parameterization.h"
namespace ceres {

View File

@@ -1,6 +1,6 @@
/* Ceres Solver - A fast non-linear least squares minimizer
* Copyright 2015 Google Inc. All rights reserved.
* http://ceres-solver.org/
* Copyright 2013 Google Inc. All rights reserved.
* http://code.google.com/p/ceres-solver/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -78,7 +78,7 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction {
// functions, or not, depending on the ownership parameter. Conditioners
// may be NULL, in which case the corresponding residual is not modified.
ConditionedCostFunction(CostFunction* wrapped_cost_function,
const std::vector<CostFunction*>& conditioners,
const vector<CostFunction*>& conditioners,
Ownership ownership);
virtual ~ConditionedCostFunction();
@@ -88,7 +88,7 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction {
private:
internal::scoped_ptr<CostFunction> wrapped_cost_function_;
std::vector<CostFunction*> conditioners_;
vector<CostFunction*> conditioners_;
Ownership ownership_;
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -115,7 +115,7 @@ class CERES_EXPORT CostFunction {
double* residuals,
double** jacobians) const = 0;
const std::vector<int32>& parameter_block_sizes() const {
const vector<int32>& parameter_block_sizes() const {
return parameter_block_sizes_;
}
@@ -124,7 +124,7 @@ class CERES_EXPORT CostFunction {
}
protected:
std::vector<int32>* mutable_parameter_block_sizes() {
vector<int32>* mutable_parameter_block_sizes() {
return &parameter_block_sizes_;
}
@@ -135,7 +135,7 @@ class CERES_EXPORT CostFunction {
private:
// Cost function signature metadata: number of inputs & their sizes,
// number of outputs (residuals).
std::vector<int32> parameter_block_sizes_;
vector<int32> parameter_block_sizes_;
int num_residuals_;
CERES_DISALLOW_COPY_AND_ASSIGN(CostFunction);
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -29,7 +29,7 @@
// Author: sameeragarwal@google.com (Sameer Agarwal)
//
// CostFunctionToFunctor is an adapter class that allows users to use
// SizedCostFunction objects in templated functors which are to be used for
// CostFunction objects in templated functors which are to be used for
// automatic differentiation. This allows the user to seamlessly mix
// analytic, numeric and automatic differentiation.
//
@@ -37,7 +37,7 @@
//
// class IntrinsicProjection : public SizedCostFunction<2, 5, 3> {
// public:
// IntrinsicProjection(const double* observation);
// IntrinsicProjection(const double* observations);
// virtual bool Evaluate(double const* const* parameters,
// double* residuals,
// double** jacobians) const;
@@ -62,8 +62,10 @@
// Then we can now do the following,
//
// struct CameraProjection {
// CameraProjection(const double* observation)
// : intrinsic_projection_(new IntrinsicProjection(observation)) {
// CameraProjection(double* observation) {
// intrinsic_projection_.reset(
// new CostFunctionToFunctor<2, 5, 3>(
// new IntrinsicProjection(observation_)));
// }
// template <typename T>
// bool operator()(const T* rotation,
@@ -77,11 +79,11 @@
// // Note that we call intrinsic_projection_, just like it was
// // any other templated functor.
//
// return intrinsic_projection_(intrinsics, transformed_point, residual);
// return (*intrinsic_projection_)(intrinsics, transformed_point, residual);
// }
//
// private:
// CostFunctionToFunctor<2,5,3> intrinsic_projection_;
// scoped_ptr<CostFunctionToFunctor<2,5,3> > intrinsic_projection_;
// };
#ifndef CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
@@ -91,7 +93,6 @@
#include <vector>
#include "ceres/cost_function.h"
#include "ceres/dynamic_cost_function_to_functor.h"
#include "ceres/internal/fixed_array.h"
#include "ceres/internal/port.h"
#include "ceres/internal/scoped_ptr.h"
@@ -103,29 +104,28 @@ template <int kNumResiduals,
int N5 = 0, int N6 = 0, int N7 = 0, int N8 = 0, int N9 = 0>
class CostFunctionToFunctor {
public:
// Takes ownership of cost_function.
explicit CostFunctionToFunctor(CostFunction* cost_function)
: cost_functor_(cost_function) {
: cost_function_(cost_function) {
CHECK_NOTNULL(cost_function);
CHECK(kNumResiduals > 0 || kNumResiduals == DYNAMIC);
// 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
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0)))
<< "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 =
const vector<int32>& parameter_block_sizes =
cost_function->parameter_block_sizes();
const int num_parameter_blocks =
(N0 > 0) + (N1 > 0) + (N2 > 0) + (N3 > 0) + (N4 > 0) +
@@ -160,7 +160,7 @@ class CostFunctionToFunctor {
CHECK_EQ(N8, 0);
CHECK_EQ(N9, 0);
return cost_functor_(&x0, residuals);
return cost_function_->Evaluate(&x0, residuals, NULL);
}
bool operator()(const double* x0,
@@ -179,7 +179,7 @@ class CostFunctionToFunctor {
internal::FixedArray<const double*> parameter_blocks(2);
parameter_blocks[0] = x0;
parameter_blocks[1] = x1;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -200,7 +200,7 @@ class CostFunctionToFunctor {
parameter_blocks[0] = x0;
parameter_blocks[1] = x1;
parameter_blocks[2] = x2;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -223,7 +223,7 @@ class CostFunctionToFunctor {
parameter_blocks[1] = x1;
parameter_blocks[2] = x2;
parameter_blocks[3] = x3;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -248,7 +248,7 @@ class CostFunctionToFunctor {
parameter_blocks[2] = x2;
parameter_blocks[3] = x3;
parameter_blocks[4] = x4;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -275,7 +275,7 @@ class CostFunctionToFunctor {
parameter_blocks[3] = x3;
parameter_blocks[4] = x4;
parameter_blocks[5] = x5;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -304,7 +304,7 @@ class CostFunctionToFunctor {
parameter_blocks[4] = x4;
parameter_blocks[5] = x5;
parameter_blocks[6] = x6;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -335,7 +335,7 @@ class CostFunctionToFunctor {
parameter_blocks[5] = x5;
parameter_blocks[6] = x6;
parameter_blocks[7] = x7;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -368,7 +368,7 @@ class CostFunctionToFunctor {
parameter_blocks[6] = x6;
parameter_blocks[7] = x7;
parameter_blocks[8] = x8;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
bool operator()(const double* x0,
@@ -403,7 +403,7 @@ class CostFunctionToFunctor {
parameter_blocks[7] = x7;
parameter_blocks[8] = x8;
parameter_blocks[9] = x9;
return cost_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
template <typename JetT>
@@ -418,7 +418,7 @@ class CostFunctionToFunctor {
CHECK_EQ(N7, 0);
CHECK_EQ(N8, 0);
CHECK_EQ(N9, 0);
return cost_functor_(&x0, residuals);
return EvaluateWithJets(&x0, residuals);
}
template <typename JetT>
@@ -438,7 +438,7 @@ class CostFunctionToFunctor {
internal::FixedArray<const JetT*> jets(2);
jets[0] = x0;
jets[1] = x1;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -460,7 +460,7 @@ class CostFunctionToFunctor {
jets[0] = x0;
jets[1] = x1;
jets[2] = x2;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -484,7 +484,7 @@ class CostFunctionToFunctor {
jets[1] = x1;
jets[2] = x2;
jets[3] = x3;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -510,7 +510,7 @@ class CostFunctionToFunctor {
jets[2] = x2;
jets[3] = x3;
jets[4] = x4;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -538,7 +538,7 @@ class CostFunctionToFunctor {
jets[3] = x3;
jets[4] = x4;
jets[5] = x5;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -568,7 +568,7 @@ class CostFunctionToFunctor {
jets[4] = x4;
jets[5] = x5;
jets[6] = x6;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -600,7 +600,7 @@ class CostFunctionToFunctor {
jets[5] = x5;
jets[6] = x6;
jets[7] = x7;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -634,7 +634,7 @@ class CostFunctionToFunctor {
jets[6] = x6;
jets[7] = x7;
jets[8] = x8;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -670,11 +670,79 @@ class CostFunctionToFunctor {
jets[7] = x7;
jets[8] = x8;
jets[9] = x9;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
private:
DynamicCostFunctionToFunctor cost_functor_;
template <typename JetT>
bool EvaluateWithJets(const JetT** inputs, JetT* output) const {
const int kNumParameters = N0 + N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 + N9;
const vector<int32>& parameter_block_sizes =
cost_function_->parameter_block_sizes();
const int num_parameter_blocks = parameter_block_sizes.size();
const int num_residuals = cost_function_->num_residuals();
internal::FixedArray<double> parameters(kNumParameters);
internal::FixedArray<double*> parameter_blocks(num_parameter_blocks);
internal::FixedArray<double> jacobians(num_residuals * kNumParameters);
internal::FixedArray<double*> jacobian_blocks(num_parameter_blocks);
internal::FixedArray<double> residuals(num_residuals);
// Build a set of arrays to get the residuals and jacobians from
// the CostFunction wrapped by this functor.
double* parameter_ptr = parameters.get();
double* jacobian_ptr = jacobians.get();
for (int i = 0; i < num_parameter_blocks; ++i) {
parameter_blocks[i] = parameter_ptr;
jacobian_blocks[i] = jacobian_ptr;
for (int j = 0; j < parameter_block_sizes[i]; ++j) {
*parameter_ptr++ = inputs[i][j].a;
}
jacobian_ptr += num_residuals * parameter_block_sizes[i];
}
if (!cost_function_->Evaluate(parameter_blocks.get(),
residuals.get(),
jacobian_blocks.get())) {
return false;
}
// Now that we have the incoming Jets, which are carrying the
// partial derivatives of each of the inputs w.r.t to some other
// underlying parameters. The derivative of the outputs of the
// cost function w.r.t to the same underlying parameters can now
// be computed by applying the chain rule.
//
// d output[i] d output[i] d input[j]
// -------------- = sum_j ----------- * ------------
// d parameter[k] d input[j] d parameter[k]
//
// d input[j]
// -------------- = inputs[j], so
// d parameter[k]
//
// outputJet[i] = sum_k jacobian[i][k] * inputJet[k]
//
// The following loop, iterates over the residuals, computing one
// output jet at a time.
for (int i = 0; i < num_residuals; ++i) {
output[i].a = residuals[i];
output[i].v.setZero();
for (int j = 0; j < num_parameter_blocks; ++j) {
const int32 block_size = parameter_block_sizes[j];
for (int k = 0; k < parameter_block_sizes[j]; ++k) {
output[i].v +=
jacobian_blocks[j][i * block_size + k] * inputs[j][k].v;
}
}
}
return true;
}
private:
internal::scoped_ptr<CostFunction> cost_function_;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -183,7 +183,7 @@ class CovarianceImpl;
// Covariance::Options options;
// Covariance covariance(options);
//
// std::vector<std::pair<const double*, const double*> > covariance_blocks;
// vector<pair<const double*, const double*> > covariance_blocks;
// covariance_blocks.push_back(make_pair(x, x));
// covariance_blocks.push_back(make_pair(y, y));
// covariance_blocks.push_back(make_pair(x, y));
@@ -353,11 +353,10 @@ class CERES_EXPORT Covariance {
// Covariance::Options for more on the conditions under which this
// function returns false.
bool Compute(
const std::vector<std::pair<const double*,
const double*> >& covariance_blocks,
const vector<pair<const double*, const double*> >& covariance_blocks,
Problem* problem);
// Return the block of the cross-covariance matrix corresponding to
// Return the block of the covariance matrix corresponding to
// parameter_block1 and parameter_block2.
//
// Compute must be called before the first call to
@@ -374,26 +373,6 @@ class CERES_EXPORT Covariance {
const double* parameter_block2,
double* covariance_block) const;
// Return the block of the cross-covariance matrix corresponding to
// parameter_block1 and parameter_block2.
// Returns cross-covariance in the tangent space if a local
// parameterization is associated with either parameter block;
// else returns cross-covariance in the ambient space.
//
// Compute must be called before the first call to
// GetCovarianceBlock and the pair <parameter_block1,
// parameter_block2> OR the pair <parameter_block2,
// parameter_block1> must have been present in the vector
// covariance_blocks when Compute was called. Otherwise
// GetCovarianceBlock will return false.
//
// covariance_block must point to a memory location that can store a
// parameter_block1_local_size x parameter_block2_local_size matrix. The
// returned covariance will be a row-major matrix.
bool GetCovarianceBlockInTangentSpace(const double* parameter_block1,
const double* parameter_block2,
double* covariance_block) const;
private:
internal::scoped_ptr<internal::CovarianceImpl> impl_;
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -74,9 +74,9 @@ struct CERES_EXPORT CRSMatrix {
// cols = [ 1, 3, 1, 2, 3, 0, 1]
// values = [10, 4, 2, -3, 2, 1, 2]
std::vector<int> cols;
std::vector<int> rows;
std::vector<double> values;
vector<int> cols;
vector<int> rows;
vector<double> values;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -120,18 +120,18 @@ class DynamicAutoDiffCostFunction : public CostFunction {
0);
// Allocate scratch space for the strided evaluation.
std::vector<Jet<double, Stride> > input_jets(num_parameters);
std::vector<Jet<double, Stride> > output_jets(num_residuals());
vector<Jet<double, Stride> > input_jets(num_parameters);
vector<Jet<double, Stride> > output_jets(num_residuals());
// Make the parameter pack that is sent to the functor (reused).
std::vector<Jet<double, Stride>* > jet_parameters(num_parameter_blocks,
vector<Jet<double, Stride>* > jet_parameters(num_parameter_blocks,
static_cast<Jet<double, Stride>* >(NULL));
int num_active_parameters = 0;
// To handle constant parameters between non-constant parameter blocks, the
// start position --- a raw parameter index --- of each contiguous block of
// non-constant parameters is recorded in start_derivative_section.
std::vector<int> start_derivative_section;
vector<int> start_derivative_section;
bool in_derivative_section = false;
int parameter_cursor = 0;

View File

@@ -1,190 +0,0 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 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)
// dgossow@google.com (David Gossow)
//
// DynamicCostFunctionToFunctor allows users to use CostFunction
// objects in templated functors which are to be used for automatic
// differentiation. It works similar to CostFunctionToFunctor, with the
// difference that it allows you to wrap a cost function with dynamic numbers
// of parameters and residuals.
//
// For example, let us assume that
//
// class IntrinsicProjection : public CostFunction {
// public:
// IntrinsicProjection(const double* observation);
// virtual bool Evaluate(double const* const* parameters,
// double* residuals,
// double** jacobians) const;
// };
//
// is a cost function that implements the projection of a point in its
// local coordinate system onto its image plane and subtracts it from
// the observed point projection. It can compute its residual and
// either via analytic or numerical differentiation can compute its
// jacobians. The intrinsics are passed in as parameters[0] and the point as
// parameters[1].
//
// Now we would like to compose the action of this CostFunction with
// the action of camera extrinsics, i.e., rotation and
// translation. Say we have a templated function
//
// template<typename T>
// void RotateAndTranslatePoint(double const* const* parameters,
// double* residuals);
//
// Then we can now do the following,
//
// struct CameraProjection {
// CameraProjection(const double* observation)
// : intrinsic_projection_.(new IntrinsicProjection(observation)) {
// }
// template <typename T>
// bool operator()(T const* const* parameters,
// T* residual) const {
// const T* rotation = parameters[0];
// const T* translation = parameters[1];
// const T* intrinsics = parameters[2];
// const T* point = parameters[3];
// T transformed_point[3];
// RotateAndTranslatePoint(rotation, translation, point, transformed_point);
//
// // Note that we call intrinsic_projection_, just like it was
// // any other templated functor.
// const T* projection_parameters[2];
// projection_parameters[0] = intrinsics;
// projection_parameters[1] = transformed_point;
// return intrinsic_projection_(projection_parameters, residual);
// }
//
// private:
// 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 {
public:
// Takes ownership of cost_function.
explicit DynamicCostFunctionToFunctor(CostFunction* cost_function)
: cost_function_(cost_function) {
CHECK_NOTNULL(cost_function);
}
bool operator()(double const* const* parameters, double* residuals) const {
return cost_function_->Evaluate(parameters, residuals, NULL);
}
template <typename JetT>
bool operator()(JetT const* const* inputs, JetT* output) const {
const std::vector<int32>& parameter_block_sizes =
cost_function_->parameter_block_sizes();
const int num_parameter_blocks = parameter_block_sizes.size();
const int num_residuals = cost_function_->num_residuals();
const int num_parameters = std::accumulate(parameter_block_sizes.begin(),
parameter_block_sizes.end(), 0);
internal::FixedArray<double> parameters(num_parameters);
internal::FixedArray<double*> parameter_blocks(num_parameter_blocks);
internal::FixedArray<double> jacobians(num_residuals * num_parameters);
internal::FixedArray<double*> jacobian_blocks(num_parameter_blocks);
internal::FixedArray<double> residuals(num_residuals);
// Build a set of arrays to get the residuals and jacobians from
// the CostFunction wrapped by this functor.
double* parameter_ptr = parameters.get();
double* jacobian_ptr = jacobians.get();
for (int i = 0; i < num_parameter_blocks; ++i) {
parameter_blocks[i] = parameter_ptr;
jacobian_blocks[i] = jacobian_ptr;
for (int j = 0; j < parameter_block_sizes[i]; ++j) {
*parameter_ptr++ = inputs[i][j].a;
}
jacobian_ptr += num_residuals * parameter_block_sizes[i];
}
if (!cost_function_->Evaluate(parameter_blocks.get(),
residuals.get(),
jacobian_blocks.get())) {
return false;
}
// Now that we have the incoming Jets, which are carrying the
// partial derivatives of each of the inputs w.r.t to some other
// underlying parameters. The derivative of the outputs of the
// cost function w.r.t to the same underlying parameters can now
// be computed by applying the chain rule.
//
// d output[i] d output[i] d input[j]
// -------------- = sum_j ----------- * ------------
// d parameter[k] d input[j] d parameter[k]
//
// d input[j]
// -------------- = inputs[j], so
// d parameter[k]
//
// outputJet[i] = sum_k jacobian[i][k] * inputJet[k]
//
// The following loop, iterates over the residuals, computing one
// output jet at a time.
for (int i = 0; i < num_residuals; ++i) {
output[i].a = residuals[i];
output[i].v.setZero();
for (int j = 0; j < num_parameter_blocks; ++j) {
const int32 block_size = parameter_block_sizes[j];
for (int k = 0; k < parameter_block_sizes[j]; ++k) {
output[i].v +=
jacobian_blocks[j][i * block_size + k] * inputs[j][k].v;
}
}
}
return true;
}
private:
internal::scoped_ptr<CostFunction> cost_function_;
};
} // namespace ceres
#endif // CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -29,7 +29,6 @@
// Author: mierle@gmail.com (Keir Mierle)
// sameeragarwal@google.com (Sameer Agarwal)
// thadh@gmail.com (Thad Hughes)
// tbennun@gmail.com (Tal Ben-Nun)
//
// This numeric diff implementation differs from the one found in
// numeric_diff_cost_function.h by supporting numericdiff on cost
@@ -42,6 +41,7 @@
// numeric diff; the expected interface for the cost functors is:
//
// struct MyCostFunctor {
// template<typename T>
// bool operator()(double const* const* parameters, double* residuals) const {
// // Use parameters[i] to access the i'th parameter block.
// }
@@ -68,37 +68,19 @@
#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, NumericDiffMethod method = CENTRAL>
class DynamicNumericDiffCostFunction : public CostFunction {
public:
explicit DynamicNumericDiffCostFunction(
const CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
const NumericDiffOptions& options = NumericDiffOptions())
explicit DynamicNumericDiffCostFunction(const CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
double relative_step_size = 1e-6)
: functor_(functor),
ownership_(ownership),
options_(options) {
}
// Deprecated. New users should avoid using this constructor. Instead, use the
// constructor with NumericDiffOptions.
DynamicNumericDiffCostFunction(
const CostFunctor* functor,
Ownership ownership,
double relative_step_size)
: functor_(functor),
ownership_(ownership),
options_() {
LOG(WARNING) << "This constructor is deprecated and will be removed in "
"a future version. Please use the NumericDiffOptions "
"constructor instead.";
options_.relative_step_size = relative_step_size;
relative_step_size_(relative_step_size) {
}
virtual ~DynamicNumericDiffCostFunction() {
@@ -118,12 +100,11 @@ class DynamicNumericDiffCostFunction : public CostFunction {
virtual bool Evaluate(double const* const* parameters,
double* residuals,
double** jacobians) const {
using internal::NumericDiff;
CHECK_GT(num_residuals(), 0)
<< "You must call DynamicNumericDiffCostFunction::SetNumResiduals() "
<< "before DynamicNumericDiffCostFunction::Evaluate().";
const std::vector<int32>& block_sizes = parameter_block_sizes();
const vector<int32>& block_sizes = parameter_block_sizes();
CHECK(!block_sizes.empty())
<< "You must call DynamicNumericDiffCostFunction::AddParameterBlock() "
<< "before DynamicNumericDiffCostFunction::Evaluate().";
@@ -135,8 +116,8 @@ class DynamicNumericDiffCostFunction : public CostFunction {
// Create local space for a copy of the parameters which will get mutated.
int parameters_size = accumulate(block_sizes.begin(), block_sizes.end(), 0);
std::vector<double> parameters_copy(parameters_size);
std::vector<double*> parameters_references_copy(block_sizes.size());
vector<double> parameters_copy(parameters_size);
vector<double*> parameters_references_copy(block_sizes.size());
parameters_references_copy[0] = &parameters_copy[0];
for (int block = 1; block < block_sizes.size(); ++block) {
parameters_references_copy[block] = parameters_references_copy[block - 1]
@@ -152,18 +133,12 @@ class DynamicNumericDiffCostFunction : public CostFunction {
for (int block = 0; block < block_sizes.size(); ++block) {
if (jacobians[block] != NULL &&
!NumericDiff<CostFunctor, method, DYNAMIC,
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
DYNAMIC, DYNAMIC>::EvaluateJacobianForParameterBlock(
functor_.get(),
residuals,
options_,
this->num_residuals(),
!EvaluateJacobianForParameterBlock(block_sizes[block],
block,
block_sizes[block],
relative_step_size_,
residuals,
&parameters_references_copy[0],
jacobians[block])) {
jacobians)) {
return false;
}
}
@@ -171,6 +146,91 @@ class DynamicNumericDiffCostFunction : public CostFunction {
}
private:
bool EvaluateJacobianForParameterBlock(const int parameter_block_size,
const int parameter_block,
const double relative_step_size,
double const* residuals_at_eval_point,
double** parameters,
double** jacobians) const {
using Eigen::Map;
using Eigen::Matrix;
using Eigen::Dynamic;
using Eigen::RowMajor;
typedef Matrix<double, Dynamic, 1> ResidualVector;
typedef Matrix<double, Dynamic, 1> ParameterVector;
typedef Matrix<double, Dynamic, Dynamic, RowMajor> JacobianMatrix;
int num_residuals = this->num_residuals();
Map<JacobianMatrix> parameter_jacobian(jacobians[parameter_block],
num_residuals,
parameter_block_size);
// Mutate one element at a time and then restore.
Map<ParameterVector> x_plus_delta(parameters[parameter_block],
parameter_block_size);
ParameterVector x(x_plus_delta);
ParameterVector step_size = x.array().abs() * relative_step_size;
// To handle cases where a paremeter is exactly zero, instead use
// the mean step_size for the other dimensions.
double fallback_step_size = step_size.sum() / step_size.rows();
if (fallback_step_size == 0.0) {
// If all the parameters are zero, there's no good answer. Use the given
// relative step_size as absolute step_size and hope for the best.
fallback_step_size = relative_step_size;
}
// For each parameter in the parameter block, use finite
// differences to compute the derivative for that parameter.
for (int j = 0; j < parameter_block_size; ++j) {
if (step_size(j) == 0.0) {
// The parameter is exactly zero, so compromise and use the
// mean step_size from the other parameters. This can break in
// many cases, but it's hard to pick a good number without
// problem specific knowledge.
step_size(j) = fallback_step_size;
}
x_plus_delta(j) = x(j) + step_size(j);
ResidualVector residuals(num_residuals);
if (!EvaluateCostFunctor(parameters, &residuals[0])) {
// Something went wrong; bail.
return false;
}
// Compute this column of the jacobian in 3 steps:
// 1. Store residuals for the forward part.
// 2. Subtract residuals for the backward (or 0) part.
// 3. Divide out the run.
parameter_jacobian.col(j).matrix() = residuals;
double one_over_h = 1 / step_size(j);
if (method == CENTRAL) {
// Compute the function on the other side of x(j).
x_plus_delta(j) = x(j) - step_size(j);
if (!EvaluateCostFunctor(parameters, &residuals[0])) {
// Something went wrong; bail.
return false;
}
parameter_jacobian.col(j) -= residuals;
one_over_h /= 2;
} else {
// Forward difference only; reuse existing residuals evaluation.
parameter_jacobian.col(j) -=
Map<const ResidualVector>(residuals_at_eval_point, num_residuals);
}
x_plus_delta(j) = x(j); // Restore x_plus_delta.
// Divide out the run to get slope.
parameter_jacobian.col(j) *= one_over_h;
}
return true;
}
bool EvaluateCostFunctor(double const* const* parameters,
double* residuals) const {
return EvaluateCostFunctorImpl(functor_.get(),
@@ -197,7 +257,7 @@ class DynamicNumericDiffCostFunction : public CostFunction {
internal::scoped_ptr<const CostFunctor> functor_;
Ownership ownership_;
NumericDiffOptions options_;
const double relative_step_size_;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -50,9 +50,26 @@ namespace ceres {
inline bool IsFinite (double x) { return _finite(x) != 0; }
inline bool IsInfinite(double x) { return _finite(x) == 0 && _isnan(x) == 0; }
inline bool IsNaN (double x) { return _isnan(x) != 0; }
inline bool IsNormal (double x) { // NOLINT
const int classification = _fpclass(x);
return (classification == _FPCLASS_NN || classification == _FPCLASS_PN);
inline bool IsNormal (double x) {
int classification = _fpclass(x);
return classification == _FPCLASS_NN ||
classification == _FPCLASS_PN;
}
#elif defined(ANDROID) && defined(_STLPORT_VERSION)
// On Android, when using the STLPort, the C++ isnan and isnormal functions
// are defined as macros.
inline bool IsNaN (double x) { return isnan(x); }
inline bool IsNormal (double x) { return isnormal(x); }
// On Android NDK r6, when using STLPort, the isinf and isfinite functions are
// not available, so reimplement them.
inline bool IsInfinite(double x) {
return x == std::numeric_limits<double>::infinity() ||
x == -std::numeric_limits<double>::infinity();
}
inline bool IsFinite(double x) {
return !isnan(x) && !IsInfinite(x);
}
# else

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -78,10 +78,10 @@ class GradientChecker {
// block.
// Derivatives as computed by the cost function.
std::vector<Matrix> term_jacobians;
vector<Matrix> term_jacobians;
// Derivatives as computed by finite differencing.
std::vector<Matrix> finite_difference_jacobians;
vector<Matrix> finite_difference_jacobians;
// Infinity-norm of term_jacobians - finite_difference_jacobians.
double error_jacobians;
@@ -119,7 +119,7 @@ class GradientChecker {
// Do a consistency check between the term and the template parameters.
CHECK_EQ(M, term->num_residuals());
const int num_residuals = M;
const std::vector<int32>& block_sizes = term->parameter_block_sizes();
const vector<int32>& block_sizes = term->parameter_block_sizes();
const int num_blocks = block_sizes.size();
CHECK_LE(num_blocks, 5) << "Unable to test functions that take more "

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -81,7 +81,7 @@ class CERES_EXPORT GradientProblemSolver {
// Returns true if the options struct has a valid
// configuration. Returns false otherwise, and fills in *error
// with a message describing the problem.
bool IsValid(std::string* error) const;
bool IsValid(string* error) const;
// Minimizer options ----------------------------------------
LineSearchDirectionType line_search_direction_type;
@@ -261,7 +261,7 @@ class CERES_EXPORT GradientProblemSolver {
// executed, then set update_state_every_iteration to true.
//
// The solver does NOT take ownership of these pointers.
std::vector<IterationCallback*> callbacks;
vector<IterationCallback*> callbacks;
};
struct CERES_EXPORT Summary {
@@ -269,11 +269,11 @@ class CERES_EXPORT GradientProblemSolver {
// A brief one line description of the state of the solver after
// termination.
std::string BriefReport() const;
string BriefReport() const;
// A full multiline description of the state of the solver after
// termination.
std::string FullReport() const;
string FullReport() const;
bool IsSolutionUsable() const;
@@ -281,7 +281,7 @@ class CERES_EXPORT GradientProblemSolver {
TerminationType termination_type;
// Reason why the solver terminated.
std::string message;
string message;
// Cost of the problem (value of the objective function) before
// the optimization.
@@ -292,7 +292,7 @@ class CERES_EXPORT GradientProblemSolver {
double final_cost;
// IterationSummary for each minimizer iteration in order.
std::vector<IterationSummary> iterations;
vector<IterationSummary> iterations;
// Sum total of all time spent inside Ceres when Solve is called.
double total_time_in_seconds;
@@ -303,10 +303,6 @@ class CERES_EXPORT GradientProblemSolver {
// Time (in seconds) spent evaluating the gradient.
double gradient_evaluation_time_in_seconds;
// Time (in seconds) spent minimizing the interpolating polynomial
// to compute the next candidate step size as part of a line search.
double line_search_polynomial_minimization_time_in_seconds;
// Number of parameters in the probem.
int num_parameters;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -214,15 +214,15 @@ struct AutoDiff {
// This block breaks the 80 column rule to keep it somewhat readable.
DCHECK_GT(num_outputs, 0);
DCHECK((!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
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0)))
<< "Zero block cannot precede a non-zero block. Block sizes are "
<< "(ignore trailing 0s): " << N0 << ", " << N1 << ", " << N2 << ", "
<< N3 << ", " << N4 << ", " << N5 << ", " << N6 << ", " << N7 << ", "

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -28,9 +28,8 @@
//
// Author: sameeragarwal@google.com (Sameer Agarwal)
// mierle@gmail.com (Keir Mierle)
// tbennun@gmail.com (Tal Ben-Nun)
//
// Finite differencing routines used by NumericDiffCostFunction.
// Finite differencing routine used by NumericDiffCostFunction.
#ifndef CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
#define CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
@@ -38,12 +37,9 @@
#include <cstring>
#include "Eigen/Dense"
#include "Eigen/StdVector"
#include "ceres/cost_function.h"
#include "ceres/internal/fixed_array.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/internal/variadic_evaluate.h"
#include "ceres/numeric_diff_options.h"
#include "ceres/types.h"
#include "glog/logging.h"
@@ -82,7 +78,7 @@ bool EvaluateImpl(const CostFunctor* functor,
// specializations for member functions. The alternative is to repeat the main
// class for differing numbers of parameters, which is also unfortunate.
template <typename CostFunctor,
NumericDiffMethodType kMethod,
NumericDiffMethod kMethod,
int kNumResiduals,
int N0, int N1, int N2, int N3, int N4,
int N5, int N6, int N7, int N8, int N9,
@@ -92,11 +88,9 @@ struct NumericDiff {
// Mutates parameters but must restore them before return.
static bool EvaluateJacobianForParameterBlock(
const CostFunctor* functor,
const double* residuals_at_eval_point,
const NumericDiffOptions& options,
double const* residuals_at_eval_point,
const double relative_step_size,
int num_residuals,
int parameter_block_index,
int parameter_block_size,
double **parameters,
double *jacobian) {
using Eigen::Map;
@@ -104,14 +98,8 @@ struct NumericDiff {
using Eigen::RowMajor;
using Eigen::ColMajor;
const int num_residuals_internal =
const int NUM_RESIDUALS =
(kNumResiduals != ceres::DYNAMIC ? kNumResiduals : num_residuals);
const int parameter_block_index_internal =
(kParameterBlock != ceres::DYNAMIC ? kParameterBlock :
parameter_block_index);
const int parameter_block_size_internal =
(kParameterBlockSize != ceres::DYNAMIC ? kParameterBlockSize :
parameter_block_size);
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
@@ -127,288 +115,73 @@ struct NumericDiff {
JacobianMatrix;
Map<JacobianMatrix> parameter_jacobian(jacobian,
num_residuals_internal,
parameter_block_size_internal);
NUM_RESIDUALS,
kParameterBlockSize);
Map<ParameterVector> x_plus_delta(
parameters[parameter_block_index_internal],
parameter_block_size_internal);
// Mutate 1 element at a time and then restore.
Map<ParameterVector> x_plus_delta(parameters[kParameterBlock],
kParameterBlockSize);
ParameterVector x(x_plus_delta);
ParameterVector step_size = x.array().abs() *
((kMethod == RIDDERS) ? options.ridders_relative_initial_step_size :
options.relative_step_size);
ParameterVector step_size = x.array().abs() * relative_step_size;
// It is not a good idea to make the step size arbitrarily
// small. This will lead to problems with round off and numerical
// instability when dividing by the step size. The general
// recommendation is to not go down below sqrt(epsilon).
double min_step_size = std::sqrt(std::numeric_limits<double>::epsilon());
// For Ridders' method, the initial step size is required to be large,
// thus ridders_relative_initial_step_size is used.
if (kMethod == RIDDERS) {
min_step_size = std::max(min_step_size,
options.ridders_relative_initial_step_size);
}
// To handle cases where a parameter is exactly zero, instead use
// the mean step_size for the other dimensions. If all the
// parameters are zero, there's no good answer. Take
// relative_step_size as a guess and hope for the best.
const double fallback_step_size =
(step_size.sum() == 0)
? relative_step_size
: step_size.sum() / step_size.rows();
// For each parameter in the parameter block, use finite differences to
// compute the derivative for that parameter.
FixedArray<double> temp_residual_array(num_residuals_internal);
FixedArray<double> residual_array(num_residuals_internal);
Map<ResidualVector> residuals(residual_array.get(),
num_residuals_internal);
for (int j = 0; j < parameter_block_size_internal; ++j) {
const double delta = std::max(min_step_size, step_size(j));
ResidualVector residuals(NUM_RESIDUALS);
for (int j = 0; j < kParameterBlockSize; ++j) {
const double delta =
(step_size(j) == 0.0) ? fallback_step_size : step_size(j);
if (kMethod == RIDDERS) {
if (!EvaluateRiddersJacobianColumn(functor, j, delta,
options,
num_residuals_internal,
parameter_block_size_internal,
x.data(),
residuals_at_eval_point,
parameters,
x_plus_delta.data(),
temp_residual_array.get(),
residual_array.get())) {
return false;
}
} else {
if (!EvaluateJacobianColumn(functor, j, delta,
num_residuals_internal,
parameter_block_size_internal,
x.data(),
residuals_at_eval_point,
parameters,
x_plus_delta.data(),
temp_residual_array.get(),
residual_array.get())) {
return false;
}
}
parameter_jacobian.col(j).matrix() = residuals;
}
return true;
}
static bool EvaluateJacobianColumn(const CostFunctor* functor,
int parameter_index,
double delta,
int num_residuals,
int parameter_block_size,
const double* x_ptr,
const double* residuals_at_eval_point,
double** parameters,
double* x_plus_delta_ptr,
double* temp_residuals_ptr,
double* residuals_ptr) {
using Eigen::Map;
using Eigen::Matrix;
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
Map<const ParameterVector> x(x_ptr, parameter_block_size);
Map<ParameterVector> x_plus_delta(x_plus_delta_ptr,
parameter_block_size);
Map<ResidualVector> residuals(residuals_ptr, num_residuals);
Map<ResidualVector> temp_residuals(temp_residuals_ptr, num_residuals);
// Mutate 1 element at a time and then restore.
x_plus_delta(parameter_index) = x(parameter_index) + delta;
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, residuals.data(), functor)) {
return false;
}
// Compute this column of the jacobian in 3 steps:
// 1. Store residuals for the forward part.
// 2. Subtract residuals for the backward (or 0) part.
// 3. Divide out the run.
double one_over_delta = 1.0 / delta;
if (kMethod == CENTRAL || kMethod == RIDDERS) {
// Compute the function on the other side of x(parameter_index).
x_plus_delta(parameter_index) = x(parameter_index) - delta;
x_plus_delta(j) = x(j) + delta;
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, temp_residuals.data(), functor)) {
functor, parameters, residuals.data(), functor)) {
return false;
}
residuals -= temp_residuals;
one_over_delta /= 2;
} else {
// Forward difference only; reuse existing residuals evaluation.
residuals -=
Map<const ResidualVector>(residuals_at_eval_point,
num_residuals);
}
// Compute this column of the jacobian in 3 steps:
// 1. Store residuals for the forward part.
// 2. Subtract residuals for the backward (or 0) part.
// 3. Divide out the run.
parameter_jacobian.col(j) = residuals;
// Restore x_plus_delta.
x_plus_delta(parameter_index) = x(parameter_index);
double one_over_delta = 1.0 / delta;
if (kMethod == CENTRAL) {
// Compute the function on the other side of x(j).
x_plus_delta(j) = x(j) - delta;
// Divide out the run to get slope.
residuals *= one_over_delta;
return true;
}
// This numeric difference implementation uses adaptive differentiation
// on the parameters to obtain the Jacobian matrix. The adaptive algorithm
// is based on Ridders' method for adaptive differentiation, which creates
// a Romberg tableau from varying step sizes and extrapolates the
// intermediate results to obtain the current computational error.
//
// References:
// C.J.F. Ridders, Accurate computation of F'(x) and F'(x) F"(x), Advances
// in Engineering Software (1978), Volume 4, Issue 2, April 1982,
// Pages 75-76, ISSN 0141-1195,
// http://dx.doi.org/10.1016/S0141-1195(82)80057-0.
static bool EvaluateRiddersJacobianColumn(
const CostFunctor* functor,
int parameter_index,
double delta,
const NumericDiffOptions& options,
int num_residuals,
int parameter_block_size,
const double* x_ptr,
const double* residuals_at_eval_point,
double** parameters,
double* x_plus_delta_ptr,
double* temp_residuals_ptr,
double* residuals_ptr) {
using Eigen::Map;
using Eigen::Matrix;
using Eigen::aligned_allocator;
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kNumResiduals, Eigen::Dynamic> ResidualCandidateMatrix;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
Map<const ParameterVector> x(x_ptr, parameter_block_size);
Map<ParameterVector> x_plus_delta(x_plus_delta_ptr,
parameter_block_size);
Map<ResidualVector> residuals(residuals_ptr, num_residuals);
Map<ResidualVector> temp_residuals(temp_residuals_ptr, num_residuals);
// In order for the algorithm to converge, the step size should be
// initialized to a value that is large enough to produce a significant
// change in the function.
// As the derivative is estimated, the step size decreases.
// By default, the step sizes are chosen so that the middle column
// of the Romberg tableau uses the input delta.
double current_step_size = delta *
pow(options.ridders_step_shrink_factor,
options.max_num_ridders_extrapolations / 2);
// Double-buffering temporary differential candidate vectors
// from previous step size.
ResidualCandidateMatrix stepsize_candidates_a(
num_residuals,
options.max_num_ridders_extrapolations);
ResidualCandidateMatrix stepsize_candidates_b(
num_residuals,
options.max_num_ridders_extrapolations);
ResidualCandidateMatrix* current_candidates = &stepsize_candidates_a;
ResidualCandidateMatrix* previous_candidates = &stepsize_candidates_b;
// Represents the computational error of the derivative. This variable is
// initially set to a large value, and is set to the difference between
// current and previous finite difference extrapolations.
// norm_error is supposed to decrease as the finite difference tableau
// generation progresses, serving both as an estimate for differentiation
// error and as a measure of differentiation numerical stability.
double norm_error = std::numeric_limits<double>::max();
// Loop over decreasing step sizes until:
// 1. Error is smaller than a given value (ridders_epsilon),
// 2. Maximal order of extrapolation reached, or
// 3. Extrapolation becomes numerically unstable.
for (int i = 0; i < options.max_num_ridders_extrapolations; ++i) {
// Compute the numerical derivative at this step size.
if (!EvaluateJacobianColumn(functor, parameter_index, current_step_size,
num_residuals,
parameter_block_size,
x.data(),
residuals_at_eval_point,
parameters,
x_plus_delta.data(),
temp_residuals.data(),
current_candidates->col(0).data())) {
// Something went wrong; bail.
return false;
}
// Store initial results.
if (i == 0) {
residuals = current_candidates->col(0);
}
// Shrink differentiation step size.
current_step_size /= options.ridders_step_shrink_factor;
// Extrapolation factor for Richardson acceleration method (see below).
double richardson_factor = options.ridders_step_shrink_factor *
options.ridders_step_shrink_factor;
for (int k = 1; k <= i; ++k) {
// Extrapolate the various orders of finite differences using
// the Richardson acceleration method.
current_candidates->col(k) =
(richardson_factor * current_candidates->col(k - 1) -
previous_candidates->col(k - 1)) / (richardson_factor - 1.0);
richardson_factor *= options.ridders_step_shrink_factor *
options.ridders_step_shrink_factor;
// Compute the difference between the previous value and the current.
double candidate_error = std::max(
(current_candidates->col(k) -
current_candidates->col(k - 1)).norm(),
(current_candidates->col(k) -
previous_candidates->col(k - 1)).norm());
// If the error has decreased, update results.
if (candidate_error <= norm_error) {
norm_error = candidate_error;
residuals = current_candidates->col(k);
// If the error is small enough, stop.
if (norm_error < options.ridders_epsilon) {
break;
}
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, residuals.data(), functor)) {
return false;
}
parameter_jacobian.col(j) -= residuals;
one_over_delta /= 2;
} else {
// Forward difference only; reuse existing residuals evaluation.
parameter_jacobian.col(j) -=
Map<const ResidualVector>(residuals_at_eval_point, NUM_RESIDUALS);
}
x_plus_delta(j) = x(j); // Restore x_plus_delta.
// After breaking out of the inner loop, declare convergence.
if (norm_error < options.ridders_epsilon) {
break;
}
// Check to see if the current gradient estimate is numerically unstable.
// If so, bail out and return the last stable result.
if (i > 0) {
double tableau_error = (current_candidates->col(i) -
previous_candidates->col(i - 1)).norm();
// Compare current error to the chosen candidate's error.
if (tableau_error >= 2 * norm_error) {
break;
}
}
std::swap(current_candidates, previous_candidates);
// Divide out the run to get slope.
parameter_jacobian.col(j) *= one_over_delta;
}
return true;
}
};
template <typename CostFunctor,
NumericDiffMethodType kMethod,
NumericDiffMethod kMethod,
int kNumResiduals,
int N0, int N1, int N2, int N3, int N4,
int N5, int N6, int N7, int N8, int N9,
@@ -419,22 +192,11 @@ struct NumericDiff<CostFunctor, kMethod, kNumResiduals,
// Mutates parameters but must restore them before return.
static bool EvaluateJacobianForParameterBlock(
const CostFunctor* functor,
const double* residuals_at_eval_point,
const NumericDiffOptions& options,
double const* residuals_at_eval_point,
const double relative_step_size,
const int num_residuals,
const int parameter_block_index,
const int parameter_block_size,
double **parameters,
double *jacobian) {
// Silence unused parameter compiler warnings.
(void)functor;
(void)residuals_at_eval_point;
(void)options;
(void)num_residuals;
(void)parameter_block_index;
(void)parameter_block_size;
(void)parameters;
(void)jacobian;
LOG(FATAL) << "Control should never reach here.";
return true;
}

Some files were not shown because too many files have changed in this diff Show More