Merge branch 'blender-v2.82-release'
authorPhilipp Oeser <info@graphics-engineer.com>
Wed, 29 Jan 2020 19:25:35 +0000 (20:25 +0100)
committerPhilipp Oeser <info@graphics-engineer.com>
Wed, 29 Jan 2020 19:29:20 +0000 (20:29 +0100)
Merge conflict in source/blender/gpu/GPU_texture.h

344 files changed:
CMakeLists.txt
build_files/build_environment/cmake/harvest.cmake
build_files/build_environment/install_deps.sh
build_files/cmake/platform/platform_unix.cmake
build_files/package_spec/build_debian.sh [deleted file]
build_files/package_spec/debian/changelog [deleted file]
build_files/package_spec/debian/compat [deleted file]
build_files/package_spec/debian/control [deleted file]
build_files/package_spec/debian/copyright [deleted file]
build_files/package_spec/debian/docs [deleted file]
build_files/package_spec/debian/menu [deleted file]
build_files/package_spec/debian/rules [deleted file]
build_files/package_spec/debian/source/format [deleted file]
build_files/package_spec/debian/watch [deleted file]
build_files/package_spec/pacman/PKGBUILD [deleted file]
build_files/package_spec/pacman/blender.install [deleted file]
build_files/package_spec/rpm/blender.spec.in [deleted file]
doc/doxygen/Doxyfile
doc/python_api/examples/gpu.5.py
intern/cycles/device/device_optix.cpp
intern/cycles/kernel/shaders/node_ies_light.osl
intern/cycles/kernel/shaders/node_mapping.osl
intern/cycles/kernel/shaders/node_vector_math.osl
intern/cycles/kernel/shaders/node_voronoi_texture.osl
intern/cycles/kernel/shaders/node_white_noise_texture.osl
intern/cycles/kernel/svm/svm_white_noise.h
intern/cycles/render/nodes.cpp
intern/cycles/render/shader.cpp
intern/ghost/GHOST_IWindow.h
intern/ghost/GHOST_Types.h
intern/ghost/intern/GHOST_C-api.cpp
intern/ghost/intern/GHOST_ContextEGL.cpp
intern/ghost/intern/GHOST_ContextEGL.h
intern/ghost/intern/GHOST_EventButton.h
intern/ghost/intern/GHOST_EventCursor.h
intern/ghost/intern/GHOST_EventPrinter.cpp
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_WindowCocoa.h
intern/ghost/intern/GHOST_WindowCocoa.mm
intern/ghost/intern/GHOST_WindowNULL.h
intern/ghost/intern/GHOST_WindowSDL.h
intern/ghost/intern/GHOST_WindowViewCocoa.h
intern/ghost/intern/GHOST_WindowWin32.cpp
intern/ghost/intern/GHOST_WindowWin32.h
intern/ghost/intern/GHOST_WindowX11.cpp
intern/ghost/intern/GHOST_WindowX11.h
intern/guardedalloc/MEM_guardedalloc.h
intern/guardedalloc/intern/mallocn.c
intern/guardedalloc/intern/mallocn_intern.h
intern/guardedalloc/intern/mallocn_lockfree_impl.c
intern/libmv/CMakeLists.txt
intern/libmv/bundle.sh
release/datafiles/locale
release/datafiles/userdef/userdef_default_theme.c
release/scripts/addons
release/scripts/addons_contrib
release/scripts/modules/rna_prop_ui.py
release/scripts/presets/keyconfig/keymap_data/blender_default.py
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
release/scripts/startup/bl_operators/vertexpaint_dirt.py
release/scripts/startup/bl_ui/properties_data_empty.py
release/scripts/startup/bl_ui/properties_data_light.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_sequencer.py
release/scripts/startup/bl_ui/space_text.py
release/scripts/startup/bl_ui/space_toolsystem_common.py
release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
release/scripts/startup/bl_ui/space_userpref.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/alembic/intern/abc_curves.cc
source/blender/alembic/intern/abc_hair.cc
source/blender/alembic/intern/abc_mball.cc
source/blender/alembic/intern/abc_mesh.cc
source/blender/alembic/intern/abc_nurbs.cc
source/blender/alembic/intern/alembic_capi.cc
source/blender/blenfont/intern/blf.c
source/blender/blenkernel/BKE_animsys.h
source/blender/blenkernel/BKE_blender_version.h
source/blender/blenkernel/BKE_cloth.h
source/blender/blenkernel/BKE_lightprobe.h
source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/library_query.c
source/blender/blenkernel/intern/lightprobe.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/workspace.c
source/blender/blenlib/BLI_rect.h
source/blender/blenlib/intern/delaunay_2d.c
source/blender/blenlib/intern/rct.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_280.c
source/blender/blenloader/intern/versioning_defaults.c
source/blender/blenloader/intern/versioning_userdef.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/bmesh/tools/bmesh_intersect_edges.c
source/blender/bmesh/tools/bmesh_intersect_edges.h
source/blender/collada/BCAnimationCurve.h
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentImporter.cpp
source/blender/collada/EffectExporter.cpp
source/blender/collada/Materials.cpp
source/blender/collada/MeshImporter.cpp
source/blender/collada/collada_utils.cpp
source/blender/collada/collada_utils.h
source/blender/compositor/operations/COM_CompositorOperation.cpp
source/blender/compositor/operations/COM_ImageOperation.h
source/blender/compositor/operations/COM_OutputFileOperation.cpp
source/blender/compositor/operations/COM_PreviewOperation.cpp
source/blender/compositor/operations/COM_RenderLayersProg.h
source/blender/compositor/operations/COM_SplitOperation.cpp
source/blender/compositor/operations/COM_TextureOperation.h
source/blender/compositor/operations/COM_ViewerOperation.cpp
source/blender/depsgraph/CMakeLists.txt
source/blender/depsgraph/intern/builder/deg_builder.cc
source/blender/depsgraph/intern/builder/deg_builder_cache.cc
source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc
source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
source/blender/depsgraph/intern/builder/deg_builder_rna.cc
source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
source/blender/depsgraph/intern/debug/deg_debug.cc
source/blender/depsgraph/intern/debug/deg_debug.h
source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc
source/blender/depsgraph/intern/debug/deg_time_average.h [new file with mode: 0644]
source/blender/depsgraph/intern/depsgraph.cc
source/blender/depsgraph/intern/depsgraph.h
source/blender/depsgraph/intern/depsgraph_build.cc
source/blender/depsgraph/intern/depsgraph_debug.cc
source/blender/depsgraph/intern/depsgraph_physics.cc
source/blender/depsgraph/intern/depsgraph_query.cc
source/blender/depsgraph/intern/depsgraph_query_foreach.cc
source/blender/depsgraph/intern/depsgraph_query_iter.cc
source/blender/depsgraph/intern/depsgraph_relation.cc [new file with mode: 0644]
source/blender/depsgraph/intern/depsgraph_relation.h [new file with mode: 0644]
source/blender/depsgraph/intern/depsgraph_tag.cc
source/blender/depsgraph/intern/depsgraph_update.cc
source/blender/depsgraph/intern/eval/deg_eval.cc
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
source/blender/depsgraph/intern/eval/deg_eval_flush.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc [new file with mode: 0644]
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.h [new file with mode: 0644]
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc
source/blender/depsgraph/intern/node/deg_node.cc
source/blender/depsgraph/intern/node/deg_node.h
source/blender/depsgraph/intern/node/deg_node_component.cc
source/blender/depsgraph/intern/node/deg_node_component.h
source/blender/depsgraph/intern/node/deg_node_factory.cc
source/blender/depsgraph/intern/node/deg_node_id.cc
source/blender/depsgraph/intern/node/deg_node_id.h
source/blender/depsgraph/intern/node/deg_node_operation.cc
source/blender/depsgraph/intern/node/deg_node_time.cc
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/overlay/overlay_armature.c
source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
source/blender/draw/engines/workbench/workbench_deferred.c
source/blender/draw/engines/workbench/workbench_forward.c
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache.h
source/blender/draw/intern/draw_cache_extract.h
source/blender/draw/intern/draw_cache_extract_mesh.c
source/blender/draw/intern/draw_cache_impl.h
source/blender/draw/intern/draw_cache_impl_mesh.c
source/blender/draw/intern/draw_cache_impl_particles.c
source/blender/editors/animation/time_scrub_ui.c
source/blender/editors/curve/editcurve_paint.c
source/blender/editors/gpencil/annotate_paint.c
source/blender/editors/gpencil/gpencil_brush.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/include/ED_screen.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface_align.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_region_hud.c
source/blender/editors/interface/interface_region_menu_popup.c
source/blender/editors/interface/interface_region_popover.c
source/blender/editors/interface/interface_region_popup.c
source/blender/editors/interface/interface_region_search.c
source/blender/editors/interface/interface_region_tooltip.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/interface/view2d.c
source/blender/editors/io/io_alembic.c
source/blender/editors/io/io_collada.c
source/blender/editors/mesh/editmesh_automerge.c
source/blender/editors/mesh/editmesh_extrude_spin.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/screen/area.c
source/blender/editors/screen/area_query.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_action/action_data.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_console/console_draw.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_file/fsmenu.h
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_info/info_draw.c
source/blender/editors/space_info/textview.c
source/blender/editors/space_info/textview.h
source/blender/editors/space_nla/nla_buttons.c
source/blender/editors/space_nla/nla_edit.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_modifier.c
source/blender/editors/space_sequencer/sequencer_select.c
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_statusbar/space_statusbar.c
source/blender/editors/space_topbar/space_topbar.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_draw.c [deleted file]
source/blender/editors/transform/transform_ops.c
source/blender/editors/undo/ed_undo.c
source/blender/freestyle/intern/application/AppConfig.cpp
source/blender/freestyle/intern/application/AppConfig.h
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
source/blender/freestyle/intern/system/PythonInterpreter.h
source/blender/gpu/intern/gpu_buffers.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_texture.c
source/blender/gpu/shaders/material/gpu_shader_material_math.glsl
source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl
source/blender/gpu/shaders/material/gpu_shader_material_tex_white_noise.glsl
source/blender/gpu/shaders/material/gpu_shader_material_vector_math.glsl
source/blender/imbuf/intern/bmp.c
source/blender/imbuf/intern/oiio/openimageio_api.cpp
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/makesdna/DNA_armature_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_screen_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/RNA_define.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/rna_define.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nla.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/makesrna/intern/rna_wm.c
source/blender/makesrna/intern/rna_workspace.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_dynamicpaint.c
source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
source/blender/physics/intern/BPH_mass_spring.cpp
source/blender/python/mathutils/mathutils_geometry.c
source/blender/usd/CMakeLists.txt
source/blender/usd/intern/usd_capi.cc
source/blender/windowmanager/CMakeLists.txt
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_toolsystem.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
source/blender/windowmanager/intern/wm_cursors.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_query.c [new file with mode: 0644]
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_toolsystem.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm_event_system.h
source/blender/windowmanager/wm_event_types.h
source/creator/creator_signals.c
tests/gtests/CMakeLists.txt
tests/gtests/blenlib/BLI_array_store_test.cc
tests/gtests/blenlib/BLI_delaunay_2d_test.cc
tests/gtests/blenlib/BLI_ghash_performance_test.cc
tests/gtests/blenlib/BLI_heap_simple_test.cc
tests/gtests/blenlib/BLI_heap_test.cc
tests/gtests/blenlib/BLI_kdopbvh_test.cc
tests/gtests/blenlib/BLI_listbase_test.cc
tests/gtests/blenlib/BLI_memiter_test.cc
tests/gtests/blenlib/BLI_polyfill_2d_test.cc
tests/gtests/blenlib/BLI_task_performance_test.cc
tests/gtests/blenlib/BLI_task_test.cc
tests/gtests/blenloader/CMakeLists.txt
tests/gtests/blenloader/blendfile_loading_base_test.cc
tests/gtests/ffmpeg/CMakeLists.txt [new file with mode: 0644]
tests/gtests/ffmpeg/ffmpeg_codecs.cc [new file with mode: 0644]
tests/gtests/guardedalloc/guardedalloc_alignment_test.cc
tests/gtests/usd/CMakeLists.txt
tests/python/CMakeLists.txt
tests/python/bevel_operator.py [new file with mode: 0644]
tests/python/bl_pyapi_mathutils.py
tests/python/boolean_operator.py [new file with mode: 0644]
tests/python/modifiers.py [new file with mode: 0644]
tests/python/modules/mesh_test.py [new file with mode: 0644]
tests/python/modules/test_utils.py
tests/python/operators.py [new file with mode: 0644]

index bbb528607c8d53d63388ab8ff0270b08b4d0e608..17e4ec23ed952c05735aa1be48d6641609ceb53f 100644 (file)
@@ -978,7 +978,7 @@ if(WITH_GL_PROFILE_ES20)
       )
     endif()
 
-    list(APPEND BLENDER_GL_LIBRARIES OPENGLES_LIBRARY)
+    list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}")
 
   else()
     set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file")
@@ -1038,7 +1038,10 @@ else()
 endif()
 
 if(WITH_GL_EGL)
-  list(APPEND GL_DEFINITIONS -DWITH_GL_EGL)
+  find_package(OpenGL REQUIRED EGL)
+  list(APPEND BLENDER_GL_LIBRARIES OpenGL::EGL)
+
+  list(APPEND GL_DEFINITIONS -DWITH_GL_EGL -DGLEW_EGL -DGLEW_INC_EGL)
 
   if(WITH_SYSTEM_GLES)
     if(NOT OPENGLES_EGL_LIBRARY)
@@ -1048,7 +1051,7 @@ if(WITH_GL_EGL)
       )
     endif()
 
-    list(APPEND BLENDER_GL_LIBRARIES OPENGLES_EGL_LIBRARY)
+    list(APPEND BLENDER_GL_LIBRARIES ${OPENGLES_EGL_LIBRARY})
 
   else()
     set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file")
@@ -1088,10 +1091,6 @@ else()
   list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
 endif()
 
-if(WITH_GL_EGL)
-  list(APPEND GL_DEFINITIONS -DWITH_EGL)
-endif()
-
 #-----------------------------------------------------------------------------
 # Configure OpenMP.
 if(WITH_OPENMP)
@@ -1163,10 +1162,6 @@ else()
       list(APPEND GL_DEFINITIONS -DGL_ES_VERSION_1_0=0 -DGL_ES_VERSION_CL_1_1=0 -DGL_ES_VERSION_CM_1_1=0)
     endif()
 
-    if(WITH_GL_EGL)
-      list(APPEND GL_DEFINITIONS -DGLEW_INC_EGL)
-    endif()
-
     set(BLENDER_GLEW_LIBRARIES extern_glew_es bf_intern_glew_mx)
 
   else()
index 5b5c254b150b0dd5f2c465a527c1449a37638c77..5fb62e330af4913d45ee8a347f9ad4558ce119b7 100644 (file)
@@ -62,14 +62,8 @@ if(BUILD_MODE STREQUAL Debug)
         # OpenImageIO
     COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_d.lib &&
         ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO_Util.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_Util_d.lib &&
-        # python
-        ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/python/ ${HARVEST_TARGET}/python/ &&
         # hdf5
         ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/hdf5/lib ${HARVEST_TARGET}/hdf5/lib &&
-        # numpy
-        ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_numpy_${NUMPY_SHORT_VERSION}d.tar.gz &&
-        # python
-        ${CMAKE_COMMAND} -E copy ${LIBDIR}/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz ${HARVEST_TARGET}/Release/python${PYTHON_SHORT_VERSION_NO_DOTS}_d.tar.gz
     DEPENDS Package_Python
   )
 endif()
index dd15fb0d2eda1650de3d7e3c2c2cf6b128b8bd56..bc9ee80281060f567d7fde516c4c5a48fe965918 100755 (executable)
 
 # A shell script installing/building all needed dependencies to build Blender, for some Linux distributions.
 
-##### Args and Help Handling #####
+# ----------------------------------------------------------------------------
+# Debugging Helpers
+#
+# Use for developing this script (keep first).
+
+# Useful for debugging this script:
+USE_DEBUG_TRAP=${USE_DEBUG_TRAP:-0}
+USE_DEBUG_LOG=${USE_DEBUG_LOG:-0}
+
+# Print the line that exits.
+if [ $USE_DEBUG_TRAP -ne 0 ]; then
+  err_report() {
+    echo "Error on line $1"
+    exit 1
+  }
+  trap 'err_report $LINENO' ERR
+fi
+
+# Noisy, show every line that runs with it's line number.
+if [ $USE_DEBUG_LOG -ne 0 ]; then
+  PS4='\e[0;33m$(printf %4d ${LINENO}):\e\033[0m '
+  set -x
+fi
+
+# ----------------------------------------------------------------------------
+# Args and Help Handling
 
 # Parse command line!
 ARGS=$( \
@@ -305,7 +330,8 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     --skip-ffmpeg
         Unconditionally skip FFMpeg installation/building.\""
 
-##### Main Vars #####
+# ----------------------------------------------------------------------------
+# Main Vars
 
 DO_SHOW_DEPS=false
 
@@ -447,7 +473,8 @@ LANG_BACK=$LANG
 LANG=""
 export LANG
 
-##### Generic Helpers #####
+# ----------------------------------------------------------------------------
+# Generic Helpers
 
 BLACK=$(tput setaf 0)
 RED=$(tput setaf 1)
@@ -489,7 +516,8 @@ PRINT() {
   _echo "$@"
 }
 
-##### Args Handling #####
+# ----------------------------------------------------------------------------
+# Args Handling
 
 # Finish parsing the commandline args.
 eval set -- "$ARGS"
@@ -892,7 +920,8 @@ CXXFLAGS_BACK=$CXXFLAGS
 CXXFLAGS="$CXXFLAGS -std=c++11"
 export CXXFLAGS
 
-#### Show Dependencies ####
+# ----------------------------------------------------------------------------
+# Show Dependencies
 
 # Need those to be after we defined versions...
 DEPS_COMMON_INFO="\"COMMON DEPENDENCIES:
@@ -940,9 +969,8 @@ if [ "$DO_SHOW_DEPS" = true ]; then
   exit 0
 fi
 
-
-
-##### Generic Helpers #####
+# ----------------------------------------------------------------------------
+# Generic Helpers
 
 # Check return code of wget for success...
 download() {
@@ -965,15 +993,25 @@ download() {
   fi
 }
 
+version_sanitize() {
+  # Remove suffix such as '1.3_RC2', keeping only '1.3'.
+  # Needed for numeric comparisons.
+  local val=$(sed -r 's/^([^_]+).*/\1/' <<< "$1")
+  # Remove trailing punctuation such as '1.0.', keeping only '1.0'.
+  val=$(sed -r 's/[[:punct:]]*$//g' <<< "$val")
+  echo $val
+}
+
 # Return 0 if $1 = $2 (i.e. 1.01.0 = 1.1, but 1.1.1 != 1.1), else 1.
 # $1 and $2 should be version numbers made of numbers only.
 version_eq() {
-  backIFS=$IFS
-  IFS='.'
+  local VER_1=$(version_sanitize "$1")
+  local VER_2=$(version_sanitize "$2")
+  local IFS='.'
 
   # Split both version numbers into their numeric elements.
-  arr1=( $1 )
-  arr2=( $2 )
+  arr1=( $VER_1 )
+  arr2=( $VER_2 )
 
   ret=1
 
@@ -983,8 +1021,8 @@ version_eq() {
     _t=$count1
     count1=$count2
     count2=$_t
-    arr1=( $2 )
-    arr2=( $1 )
+    arr1=( $VER_2 )
+    arr2=( $VER_1 )
   fi
 
   ret=0
@@ -1004,7 +1042,6 @@ version_eq() {
     fi
   done
 
-  IFS=$backIFS
   return $ret
 }
 
@@ -1035,12 +1072,13 @@ version_ge_lt() {
 # $1 and $2 should be version numbers made of numbers only.
 # $1 should be at least as long as $2!
 version_match() {
-  backIFS=$IFS
-  IFS='.'
+  local VER_1=$(version_sanitize "$1")
+  local VER_2=$(version_sanitize "$2")
+  local IFS='.'
 
   # Split both version numbers into their numeric elements.
-  arr1=( $1 )
-  arr2=( $2 )
+  arr1=( $VER_1 )
+  arr2=( $VER_2 )
 
   ret=1
 
@@ -1057,11 +1095,12 @@ version_match() {
     done
   fi
 
-  IFS=$backIFS
   return $ret
 }
 
-##### Generic compile helpers #####
+# ----------------------------------------------------------------------------
+# Generic compile helpers
+
 prepare_opt() {
   INFO "Ensuring $INST exists and is writable by us"
   if [ ! $SUDO ]; then
@@ -1123,7 +1162,9 @@ run_ldconfig() {
   PRINT ""
 }
 
-#### Build Python ####
+# ----------------------------------------------------------------------------
+# Build Python
+
 _init_python() {
   _src=$SRC/Python-$PYTHON_VERSION
   _git=false
@@ -1192,7 +1233,9 @@ compile_Python() {
   fi
 }
 
-##### Build Numpy #####
+# ----------------------------------------------------------------------------
+# Build Numpy
+
 _init_numpy() {
   _src=$SRC/numpy-$NUMPY_VERSION
   _git=false
@@ -1259,7 +1302,9 @@ compile_Numpy() {
   fi
 }
 
-#### Build Boost ####
+# ----------------------------------------------------------------------------
+# Build Boost
+
 _init_boost() {
   _src=$SRC/boost-$BOOST_VERSION
   _git=false
@@ -1337,7 +1382,9 @@ compile_Boost() {
   run_ldconfig "boost"
 }
 
-#### Build OCIO ####
+# ----------------------------------------------------------------------------
+# Build OCIO
+
 _init_ocio() {
   _src=$SRC/OpenColorIO-$OCIO_VERSION
   if [ "$OCIO_USE_REPO" = true ]; then
@@ -1452,7 +1499,9 @@ compile_OCIO() {
   run_ldconfig "ocio"
 }
 
-#### Build ILMBase ####
+# ----------------------------------------------------------------------------
+# Build ILMBase
+
 _init_ilmbase() {
   _src=$SRC/ILMBase-$ILMBASE_VERSION
   _git=false
@@ -1543,7 +1592,9 @@ compile_ILMBASE() {
   magic_compile_set ilmbase-$ILMBASE_VERSION $ilmbase_magic
 }
 
-#### Build OpenEXR ####
+# ----------------------------------------------------------------------------
+# Build OpenEXR
+
 _init_openexr() {
   _src=$SRC/OpenEXR-$OPENEXR_VERSION
   _git=true
@@ -1663,7 +1714,9 @@ compile_OPENEXR() {
   run_ldconfig "openexr"
 }
 
-#### Build OIIO ####
+# ----------------------------------------------------------------------------
+# Build OIIO
+
 _init_oiio() {
   _src=$SRC/OpenImageIO-$OIIO_VERSION
   _git=true
@@ -1804,7 +1857,9 @@ compile_OIIO() {
   run_ldconfig "oiio"
 }
 
-#### Build LLVM ####
+# ----------------------------------------------------------------------------
+# Build LLVM
+
 _init_llvm() {
   _src=$SRC/LLVM-$LLVM_VERSION
   _src_clang=$SRC/CLANG-$LLVM_VERSION
@@ -1904,7 +1959,9 @@ compile_LLVM() {
   fi
 }
 
-#### Build OSL ####
+# ----------------------------------------------------------------------------
+# Build OSL
+
 _init_osl() {
   _src=$SRC/OpenShadingLanguage-$OSL_VERSION
   _git=true
@@ -2034,7 +2091,9 @@ compile_OSL() {
   run_ldconfig "osl"
 }
 
-#### Build OSD ####
+# ----------------------------------------------------------------------------
+# Build OSD
+
 _init_osd() {
   _src=$SRC/OpenSubdiv-$OSD_VERSION
   _git=true
@@ -2131,7 +2190,9 @@ compile_OSD() {
   run_ldconfig "osd"
 }
 
-#### Build Blosc ####
+# ----------------------------------------------------------------------------
+# Build Blosc
+
 _init_blosc() {
   _src=$SRC/c-blosc-$OPENVDB_BLOSC_VERSION
   _git=false
@@ -2218,7 +2279,9 @@ compile_BLOSC() {
   run_ldconfig "blosc"
 }
 
-#### Build OpenVDB ####
+# ----------------------------------------------------------------------------
+# Build OpenVDB
+
 _init_openvdb() {
   _src=$SRC/openvdb-$OPENVDB_VERSION
   _git=false
@@ -2319,7 +2382,9 @@ compile_OPENVDB() {
   run_ldconfig "openvdb"
 }
 
-#### Build Alembic ####
+# ----------------------------------------------------------------------------
+# Build Alembic
+
 _init_alembic() {
   _src=$SRC/alembic-$ALEMBIC_VERSION
   _git=false
@@ -2412,7 +2477,9 @@ compile_ALEMBIC() {
   run_ldconfig "alembic"
 }
 
-#### Build OpenCOLLADA ####
+# ----------------------------------------------------------------------------
+# Build OpenCOLLADA
+
 _init_opencollada() {
   _src=$SRC/OpenCOLLADA-$OPENCOLLADA_VERSION
   _git=true
@@ -2504,7 +2571,9 @@ compile_OpenCOLLADA() {
   fi
 }
 
-#### Build Embree ####
+# ----------------------------------------------------------------------------
+# Build Embree
+
 _init_embree() {
   _src=$SRC/embree-$EMBREE_VERSION
   _git=true
@@ -2599,7 +2668,9 @@ compile_Embree() {
   fi
 }
 
-#### Build OpenImageDenoise ####
+# ----------------------------------------------------------------------------
+# Build OpenImageDenoise
+
 _init_oidn() {
   _src=$SRC/oidn-$OIDN_VERSION
   _git=true
@@ -2691,7 +2762,9 @@ compile_OIDN() {
   run_ldconfig "oidn"
 }
 
-#### Build FFMPEG ####
+# ----------------------------------------------------------------------------
+# Build FFMPEG
+
 _init_ffmpeg() {
   _src=$SRC/ffmpeg-$FFMPEG_VERSION
   _inst=$INST/ffmpeg-$FFMPEG_VERSION
@@ -2806,7 +2879,9 @@ compile_FFmpeg() {
 }
 
 
-#### Install on DEB-like ####
+# ----------------------------------------------------------------------------
+# Install on DEB-like
+
 get_package_version_DEB() {
     dpkg-query -W -f '${Version}' $1 | sed -r 's/([0-9]+:)?(([0-9]+\.?)+([0-9]+)).*/\2/'
 }
@@ -3341,7 +3416,9 @@ install_DEB() {
 }
 
 
-#### Install on RPM-like ####
+# ----------------------------------------------------------------------------
+# Install on RPM-like
+
 rpm_flavour() {
   if [ -f /etc/redhat-release ]; then
     if [ "`grep '[6-7]\.' /etc/redhat-release`" ]; then
@@ -3936,7 +4013,9 @@ install_RPM() {
 }
 
 
-#### Install on ARCH-like ####
+# ----------------------------------------------------------------------------
+# Install on ARCH-like
+
 get_package_version_ARCH() {
   pacman -Si $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+?(([0-9]+\.?)+).*/\1/'
 }
@@ -4056,7 +4135,7 @@ install_ARCH() {
   fi
 
   if [ "$WITH_JACK" = true ]; then
-    _packages="$_packages jack"
+    _packages="$_packages jack2"
   fi
 
   PRINT ""
@@ -4426,7 +4505,8 @@ install_ARCH() {
 }
 
 
-#### Install on other distro (very limited!) ####
+# ----------------------------------------------------------------------------
+# Install on other distro (very limited!)
 
 install_OTHER() {
   PRINT ""
@@ -4621,7 +4701,8 @@ install_OTHER() {
   fi
 }
 
-#### Printing User Info ####
+# ----------------------------------------------------------------------------
+# Printing User Info
 
 print_info_ffmpeglink_DEB() {
   dpkg -L $_packages | grep -e ".*\/lib[^\/]\+\.so" | gawk '{ printf(nlines ? "'"$_ffmpeg_list_sep"'%s" : "%s", gensub(/.*lib([^\/]+)\.so/, "\\1", "g", $0)); nlines++ }'
@@ -4713,7 +4794,7 @@ print_info() {
   _1="-D PYTHON_VERSION=$PYTHON_VERSION_MIN"
   PRINT "  $_1"
   _buildargs="$_buildargs $_1"
-  if [ -d $INST/python-$PYTHON_VERSION_MIN ]; then
+  if [ -d "$INST/python-$PYTHON_VERSION_MIN" ]; then
     _1="-D PYTHON_ROOT_DIR=$INST/python-$PYTHON_VERSION_MIN"
     PRINT "  $_1"
     _buildargs="$_buildargs $_1"
@@ -4889,7 +4970,9 @@ print_info() {
   PRINT "  cmake $_buildargs ."
 }
 
-#### "Main" ####
+# ----------------------------------------------------------------------------
+# "Main"
+
 # Detect distribution type used on this machine
 if [ -f /etc/debian_version ]; then
   DISTRO="DEB"
index 5d46ee751af178a1e14537754e5600b22a69cd37..e09287f05d9932c5f32c6d4bc75d883d0b9f6aee 100644 (file)
@@ -53,6 +53,10 @@ if(EXISTS ${LIBDIR})
   set(CMAKE_PREFIX_PATH ${LIBDIR}/zlib ${LIB_SUBDIRS})
   set(WITH_STATIC_LIBS ON)
   set(WITH_OPENMP_STATIC ON)
+  set(Boost_NO_BOOST_CMAKE ON)
+  set(BOOST_ROOT ${LIBDIR}/boost)
+  set(BOOST_LIBRARYDIR ${LIBDIR}/boost/lib)
+  set(Boost_NO_SYSTEM_PATHS ON)
 endif()
 
 if(WITH_STATIC_LIBS)
diff --git a/build_files/package_spec/build_debian.sh b/build_files/package_spec/build_debian.sh
deleted file mode 100755 (executable)
index a6d9442..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-# Builds a debian package from SVN source.
-#
-# For parallel builds use:
-#  DEB_BUILD_OPTIONS="parallel=5" sh build_files/package_spec/build_debian.sh
-
-# this needs to run in the root dir.
-cd $(dirname $0)/../../
-rm -rf debian
-cp -a build_files/package_spec/debian .
-
-
-# Get values from blender to use in debian/changelog.
-# value may be formatted: 35042:35051M
-BLENDER_REVISION=$(svnversion | cut -d: -f2 | tr -dc 0-9)
-
-blender_version=$(grep BLENDER_VERSION source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
-blender_version_char=$(sed -ne 's/.*BLENDER_VERSION_CHAR.*\([a-z]\)$/\1/p' source/blender/blenkernel/BKE_blender.h)
-BLENDER_VERSION=$(expr $blender_version / 100).$(expr $blender_version % 100)
-
-# map the version a -> 1, to conform to debian naming convention
-# not to be confused with blender's internal subversions
-if [ "$blender_version_char" ]; then
-    BLENDER_VERSION=${BLENDER_VERSION}.$(expr index abcdefghijklmnopqrstuvwxyz $blender_version_char)
-fi
-
-DEB_VERSION=${BLENDER_VERSION}+svn${BLENDER_REVISION}-bf
-
-# update debian/changelog
-dch -b -v $DEB_VERSION "New upstream SVN snapshot."
-
-
-# run the rules makefile
-rm -rf get-orig-source
-debian/rules get-orig-source SVN_URL=.
-mv *.gz ../
-
-# build the package
-debuild -i -us -uc -b
-
-
-# remove temp dir
-rm -rf debian
diff --git a/build_files/package_spec/debian/changelog b/build_files/package_spec/debian/changelog
deleted file mode 100644 (file)
index 0559bb0..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-blender (2.56+svn34749-bf) unstable; urgency=low
-
-  * New upstream SVN snapshot.
-
- -- Dan Eicher <dan@trollwerks.org>  Wed, 09 Feb 2011 18:55:24 -0700
diff --git a/build_files/package_spec/debian/compat b/build_files/package_spec/debian/compat
deleted file mode 100644 (file)
index 7f8f011..0000000
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/build_files/package_spec/debian/control b/build_files/package_spec/debian/control
deleted file mode 100644 (file)
index addd717..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-Source: blender
-Section: graphics
-Priority: extra
-Maintainer: Dan Eicher <dan@trollwerks.org>
-Build-Depends: debhelper (>= 7.0.50~), cmake, python3, python, libfreetype6-dev, libglu1-mesa-dev, libilmbase-dev, libopenexr-dev, libjpeg62-dev, libopenal-dev, libpng12-dev, libsdl-dev, libtiff4-dev, libx11-dev, libxi-dev, zlib1g-dev, python3.2-dev, libopenjpeg-dev
-Standards-Version: 3.9.1
-Homepage: http://blender.org/
-X-Python3-Version: >= 3.2, << 3.3
-
-Package: blender-snapshot
-Architecture: any
-Depends: ${shlibs:Depends}, ${python3:Depends}, ${misc:Depends}
-Provides: blender
-Conflicts: blender
-Replaces: blender
-Description: Very fast and versatile 3D modeller/renderer
- Blender is an integrated 3d suite for modelling, animation, rendering,
- post-production, interactive creation and playback (games). Blender has its
- own particular user interface, which is implemented entirely in OpenGL and
- designed with speed in mind. Python bindings are available for scripting;
- import/export features for popular file formats like 3D Studio and Wavefront
- Obj are implemented as scripts by the community. Stills, animations, models
- for games or other third party engines and interactive content in the form of
- a standalone binary and/or a web plug-in are common products of Blender use.
diff --git a/build_files/package_spec/debian/copyright b/build_files/package_spec/debian/copyright
deleted file mode 100644 (file)
index 0f72872..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-This work was packaged for Debian by:
-
-    Dan Eicher <dan@trollwerks.org> on Tue, 08 Feb 2011 21:59:32 -0700
-
-It was downloaded from:
-
-    http://blender.org
-
-Copyright: 
-
-    Copyright (C) 2002-2011 Blender Foundation
-
-License:
-
-    This package 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 package 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, see <http://www.gnu.org/licenses/>
-
-On Debian systems, the complete text of the GNU General
-Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
-
-
-The Debian packaging is:
-
-    Copyright (C) 2011 Dan Eicher <dan@trollwerks.org>
-
-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.
-
-
diff --git a/build_files/package_spec/debian/docs b/build_files/package_spec/debian/docs
deleted file mode 100644 (file)
index 8868452..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-release/text/copyright.txt
-release/text/readme.html
diff --git a/build_files/package_spec/debian/menu b/build_files/package_spec/debian/menu
deleted file mode 100644 (file)
index d69c735..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-?package(blender-snapshot):needs="X11" section="Applications/Graphics"\
-  longtitle="Blender 3D modeler / renderer"\
-  icon="/usr/share/icons/hicolor/scalable/apps/blender.svg"\
-  title="blender" command="/usr/bin/blender"
diff --git a/build_files/package_spec/debian/rules b/build_files/package_spec/debian/rules
deleted file mode 100755 (executable)
index 7a3d2d5..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-
-SVN_URL := https://svn.blender.org/svnroot/bf-blender/trunk/blender
-REV := $(shell dpkg-parsechangelog | sed -rne 's,^Version: .*[+~]svn([0-9]+).*,\1,p')
-VER := $(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
-REL := $(shell dpkg-parsechangelog | sed -rne 's,^Version: ([0-9]+\.[0-9]+).*,\1,p')
-TARBALL = blender_$(VER).orig.tar.gz
-BLDDIR = debian/cmake
-
-%:
-       dh $@ -Scmake -B$(BLDDIR) --parallel --with python3 --without python-support
-
-override_dh_auto_configure:
-       # blender spesific CMake options
-       dh_auto_configure -- \
-               -DCMAKE_BUILD_TYPE:STRING=Release \
-               -DWITH_INSTALL_PORTABLE:BOOL=OFF \
-               -DWITH_PYTHON_INSTALL:BOOL=OFF \
-               -DWITH_OPENCOLLADA:BOOL=OFF
-
-override_dh_auto_test:
-       # don't run CTest
-
-override_dh_install:
-       dh_install
-
-       # remove duplicated docs
-       rm -rf debian/blender-snapshot/usr/share/doc/blender
-
-override_dh_python3:
-       dh_python3 -V 3.2-3.3 /usr/share/blender/$(REL)/scripts
-
-get-orig-source:
-       rm -rf get-orig-source $(TARBALL)
-       mkdir get-orig-source
-       if [ "$(SVN_URL)" = . ] && [ `svnversion` = "$(REV)" ]; then \
-               svn -q export . get-orig-source/blender-$(VER); \
-       else \
-               svn -q export -r $(REV) $(SVN_URL) get-orig-source/blender-$(VER); \
-       fi
-       GZIP='--best --no-name' tar czf $(TARBALL) -C get-orig-source blender-$(VER)
-       rm -rf get-orig-source
-       @echo "$(TARBALL) created; move it to the right destination to build the package"
diff --git a/build_files/package_spec/debian/source/format b/build_files/package_spec/debian/source/format
deleted file mode 100644 (file)
index 163aaf8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/build_files/package_spec/debian/watch b/build_files/package_spec/debian/watch
deleted file mode 100644 (file)
index 0f8473b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-version=3
-opts=uversionmangle=s/[a-z]$/.$&/;s/[j-s]$/1$&/;s/[t-z]$/2$&/;tr/a-z/1-90-90-6/ \
-http://download.blender.org/source/blender-([0-9.]+[a-z]?)\.tar\.gz
diff --git a/build_files/package_spec/pacman/PKGBUILD b/build_files/package_spec/pacman/PKGBUILD
deleted file mode 100644 (file)
index aea5acd..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-# Maintainer: Campbell Barton <ideasman42 at gmail dot com>
-
-# custom blender vars
-blender_srcdir=$(dirname $startdir)"/../.."
-blender_version=$(grep "BLENDER_VERSION\s" $blender_srcdir/source/blender/blenkernel/BKE_blender_version.h | awk '{print $3}')
-blender_version=$(expr $blender_version / 100).$(expr $blender_version % 100)  # 256 -> 2.56
-blender_version_char=$(sed -ne 's/.*BLENDER_VERSION_CHAR.*\([a-z]\)$/\1/p' $blender_srcdir/source/blender/blenkernel/BKE_blender_version.h)
-# blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}')
-
-# map the version a -> 1
-# not to be confused with blender's internal subversions
-if [ "$blender_version_char" ]; then
-  blender_version_full=${blender_version}.$(expr index abcdefghijklmnopqrstuvwxyz $blender_version_char)
-else
-  blender_version_full=${blender_version}
-fi
-
-blender_ver_string=$blender_version+git$blender_version_full
-
-pkgname=blender-snapshot
-pkgver=$blender_ver_string
-pkgrel=1
-pkgdesc="A fully integrated 3D graphics creation suite"
-arch=('i686' 'x86_64')
-url="www.blender.org"
-license=('GPL')
-groups=()
-depends=('libjpeg' 'libpng' 'openjpeg' 'libtiff' 'openexr'  'python>=3.5'
-         'gettext' 'libxi' 'libxmu' 'mesa' 'freetype2' 'openal' 'sdl'
-         'libsndfile' 'ffmpeg')
-makedepends=('cmake' 'git')
-optdepends=()
-provides=()
-conflicts=('blender')
-replaces=('blender')
-backup=()
-options=()
-install=blender.install
-# use current git to make the package.
-# source=(http://download.blender.org/source/$pkgname-$pkgver.tar.gz)
-# md5sums=('27edb80c82c25252d43d6a01980d953a') #generate with 'makepkg -g'
-source=()
-md5sums=()
-noextract=()
-
-build() {
-  mkdir -p $srcdir/build
-  cd $srcdir/build
-  cmake $blender_srcdir \
-    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-    -DCMAKE_BUILD_TYPE:STRING=Release \
-    -DWITH_INSTALL_PORTABLE:BOOL=OFF \
-    -DWITH_PYTHON_INSTALL:BOOL=OFF \
-    -DWITH_OPENCOLLADA:BOOL=OFF
-
-  make $MAKEFLAGS
-}
-
-package() {
-  cd $srcdir/build
-  make DESTDIR="$pkgdir" install
-  python -m compileall \
-  $pkgdir/usr/share/blender/$blender_version/scripts/startup \
-  $pkgdir/usr/share/blender/$blender_version/scripts/modules \
-  $pkgdir/usr/share/blender/$blender_version/scripts/addons
-}
diff --git a/build_files/package_spec/pacman/blender.install b/build_files/package_spec/pacman/blender.install
deleted file mode 100644 (file)
index f2d37ec..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-post_install() {
-  cat << EOF
-
-NOTE
-----
-Happy blending!
-
-EOF
-  echo "update desktop mime database..."
-  update-desktop-database
-}
-
-post_upgrade() {
-  post_install $1
-}
-
-pre_remove() {
-  /bin/true
-}
-
-post_remove() {
-  echo "update desktop mime database..."
-  update-desktop-database
-}
-
-op=$1
-shift
-
-$op $*
diff --git a/build_files/package_spec/rpm/blender.spec.in b/build_files/package_spec/rpm/blender.spec.in
deleted file mode 100644 (file)
index e75cc8e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- rpm-spec -*-
-%global __python %{__python3}
-%global blender_api @CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@
-
-%define _rpmdir @CPACK_RPM_DIRECTORY@
-%define _rpmfilename @CPACK_RPM_FILE_NAME@
-%define _unpackaged_files_terminate_build 0
-%define _topdir @CPACK_RPM_DIRECTORY@
-
-BuildRoot:      @CPACK_RPM_DIRECTORY@/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@
-Summary:        @CPACK_RPM_PACKAGE_SUMMARY@
-Name:           @CPACK_RPM_PACKAGE_NAME@
-Version:        @CPACK_RPM_PACKAGE_VERSION@
-Release:        @CPACK_RPM_PACKAGE_RELEASE@%{?dist}
-License:        @CPACK_RPM_PACKAGE_LICENSE@
-Group:          @CPACK_RPM_PACKAGE_GROUP@
-Vendor:         @CPACK_RPM_PACKAGE_VENDOR@
-Epoch:          1
-
-Requires(post):   desktop-file-utils
-Requires(post):   shared-mime-info
-Requires(postun): desktop-file-utils
-Requires(postun): shared-mime-info
-
-Provides:         blender(ABI) = %{blender_api}
-Provides:         blender-fonts = %{?epoch:%{epoch}:}%{version}-%{release}
-
-Obsoletes:        blender-fonts <= 2.49a-9
-
-%description
-Blender is an integrated 3d suite for modelling, animation, rendering,
-post-production, interactive creation and playback (games). Blender has its
-own particular user interface, which is implemented entirely in OpenGL and
-designed with speed in mind. Python bindings are available for scripting;
-import/export features for popular file formats like 3D Studio and Wavefront
-Obj are implemented as scripts by the community. Stills, animations, models
-for games or other third party engines and interactive content in the form of
-a standalone binary and/or a web plug-in are common products of Blender use.
-
-# This is a shortcutted spec file generated by CMake RPM generator
-# we skip _install step because CPack does that for us.
-# We do only save CPack installed tree in _prepr
-# and then restore it in build.
-%prep
-mv ${RPM_BUILD_ROOT} "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot"
-
-%install
-if [ -e ${RPM_BUILD_ROOT} ];
-then
-  rm -rf ${RPM_BUILD_ROOT}
-fi
-mv "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot" ${RPM_BUILD_ROOT}
-
-rm -f ${RPM_BUILD_ROOT}%{_bindir}/blender-thumbnailer.py
-
-%find_lang %{name}
-
-%clean
-rm -rf ${RPM_BUILD_ROOT}
-
-%post
-touch --no-create %{_datadir}/icons/hicolor
-if [ -x %{_bindir}/gtk-update-icon-cache ]; then
-  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor
-fi 
-%{_bindir}/update-desktop-database %{_datadir}/applications || :
-
-%postun
-%{_bindir}/update-desktop-database %{_datadir}/applications
-touch --no-create %{_datadir}/icons/hicolor
-if [ -x %{_bindir}/gtk-update-icon-cache ]; then
-  %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor
-fi || :
-
-%files -f blender.lang
-%defattr(-,root,root,-)
-%{_bindir}/%{name}
-%{_datadir}/%{name}/%{blender_api}/datafiles/fonts
-%{_datadir}/%{name}/%{blender_api}/datafiles/colormanagement
-%{_datadir}/%{name}/%{blender_api}/datafiles/locale/languages
-%{_datadir}/%{name}/%{blender_api}/scripts
-%{_datadir}/icons/hicolor/*/apps/%{name}.*
-%{_datadir}/applications/%{name}.desktop
-%{_datadir}/doc/%{name}
-%{_mandir}/man1/%{name}.*
-
-%changelog
-@CPACK_RPM_SPEC_CHANGELOG@
index c07a80bf0d564f636d3eb75a28f1b515221f95d5..ecd60957f2b9f4f13604a59a558445328d075fe8 100644 (file)
@@ -38,7 +38,7 @@ PROJECT_NAME           = Blender
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = "V2.82"
+PROJECT_NUMBER         = "V2.83"
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a
index 855f9a28e4483df78bec364462823af2fe0ffc18..e05290a9442988d9ccf9cec8c87d48b6efac2a51 100644 (file)
@@ -4,6 +4,7 @@ Mesh with Random Vertex Colors
 """
 import bpy
 import gpu
+import bgl
 import numpy as np
 from random import random
 from gpu_extras.batch import batch_for_shader
@@ -30,7 +31,9 @@ batch = batch_for_shader(
 
 
 def draw():
+    bgl.glEnable(bgl.GL_DEPTH_TEST)
     batch.draw(shader)
+    bgl.glDisable(bgl.GL_DEPTH_TEST)
 
 
 bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
index 8a8eef0e05984d9559e38fd641aedb6fc79385b1..c1106b367ca01aa21f0c232b10b9b1b575525f7b 100644 (file)
@@ -1188,8 +1188,8 @@ class OptiXDevice : public Device {
                                            out_data,
                                            sizes.outputSizeInBytes,
                                            &out_handle,
-                                           &compacted_size_prop,
-                                           1));
+                                           background ? &compacted_size_prop : NULL,
+                                           background ? 1 : 0));
 
     // Wait for all operations to finish
     check_result_cuda_ret(cuStreamSynchronize(NULL));
index 6e9181cde40dd7be8862021bc97a2e7c8184b19f..4d881eb3b65971787af74dd64d40dd5ac1748902 100644 (file)
@@ -31,7 +31,7 @@ shader node_ies_light(int use_mapping = 0,
     p = transform(mapping, p);
   }
 
-  p = normalize(p);
+  p = normalize((vector)p);
 
   float v_angle = acos(-p[2]);
   float h_angle = atan2(p[0], p[1]) + M_PI;
index 8eed0ae9c48a89eb6218973f783934e1ed3a7a48..e8a9d940eda5cc688020411e0e55b0fdee2fe718 100644 (file)
@@ -65,7 +65,7 @@ shader node_mapping(string type = "point",
     VectorOut = transform(euler_to_mat(Rotation), (VectorIn * Scale));
   }
   else if (type == "normal") {
-    VectorOut = normalize(transform(euler_to_mat(Rotation), safe_divide(VectorIn, Scale)));
+    VectorOut = normalize((vector)transform(euler_to_mat(Rotation), safe_divide(VectorIn, Scale)));
   }
   else {
     warning("%s", "Unknown Mapping vector type!");
index fd5e27aa144e93d80cb63caa61aefe6d8483bc03..4fa9b3bb57b7c59db149f640b94f620db3c6d4a7 100644 (file)
@@ -92,7 +92,7 @@ shader node_vector_math(string type = "add",
     Vector = ceil(Vector1);
   }
   else if (type == "modulo") {
-    Vector = mod(Vector1, Vector2);
+    Vector = fmod(Vector1, Vector2);
   }
   else if (type == "fraction") {
     Vector = Vector1 - floor(Vector1);
index 5de4aeef943b886e881f43e1c34487e5097fb1c2..10a9f7a6329fcb45ae4b9f5aaf95d932801fce74 100644 (file)
@@ -603,7 +603,7 @@ void voronoi_distance_to_edge_3d(vector3 coord, float randomness, output float o
         vector3 perpendicularToEdge = vectorToPoint - vectorToClosest;
         if (dot(perpendicularToEdge, perpendicularToEdge) > 0.0001) {
           float distanceToEdge = dot((vectorToClosest + vectorToPoint) / 2.0,
-                                     normalize(perpendicularToEdge));
+                                     normalize((vector)perpendicularToEdge));
           minDistance = min(minDistance, distanceToEdge);
         }
       }
index f026fb4ab392f6aab297b2e181090378ce8a5d8f..95f91d25e5e267b3e140fc8248be8014890e8297 100644 (file)
  */
 
 #include "stdosl.h"
+#include "vector2.h"
+#include "vector4.h"
+#include "node_hash.h"
+
+#define vector3 point
 
 shader node_white_noise_texture(string dimensions = "3D",
                                 point Vector = point(0.0, 0.0, 0.0),
                                 float W = 0.0,
-                                output float Value = 0.0)
+                                output float Value = 0.0,
+                                output color Color = 0.0)
 {
   if (dimensions == "1D") {
     Value = noise("hash", W);
+    Color = hash_float_to_color(W);
   }
   else if (dimensions == "2D") {
     Value = noise("hash", Vector[0], Vector[1]);
+    Color = hash_vector2_to_color(vector2(Vector[0], Vector[1]));
   }
   else if (dimensions == "3D") {
     Value = noise("hash", Vector);
+    Color = hash_vector3_to_color(vector3(Vector[0], Vector[1], Vector[2]));
   }
   else if (dimensions == "4D") {
     Value = noise("hash", Vector, W);
+    Color = hash_vector4_to_color(vector4(Vector[0], Vector[1], Vector[2], W));
   }
   else {
     warning("%s", "Unknown dimension!");
index 71d4591d25d7aa2f94458c433b344d395d6bc7f3..b30d85acaecb750123c37964ee848539df559b68 100644 (file)
@@ -21,35 +21,61 @@ ccl_device void svm_node_tex_white_noise(KernelGlobals *kg,
                                          float *stack,
                                          uint dimensions,
                                          uint inputs_stack_offsets,
-                                         uint value_stack_offset,
+                                         uint ouptuts_stack_offsets,
                                          int *offset)
 {
-  uint vector_stack_offset, w_stack_offset;
+  uint vector_stack_offset, w_stack_offset, value_stack_offset, color_stack_offset;
   svm_unpack_node_uchar2(inputs_stack_offsets, &vector_stack_offset, &w_stack_offset);
+  svm_unpack_node_uchar2(ouptuts_stack_offsets, &value_stack_offset, &color_stack_offset);
 
   float3 vector = stack_load_float3(stack, vector_stack_offset);
   float w = stack_load_float(stack, w_stack_offset);
 
-  float value;
-  switch (dimensions) {
-    case 1:
-      value = hash_float_to_float(w);
-      break;
-    case 2:
-      value = hash_float2_to_float(make_float2(vector.x, vector.y));
-      break;
-    case 3:
-      value = hash_float3_to_float(vector);
-      break;
-    case 4:
-      value = hash_float4_to_float(make_float4(vector.x, vector.y, vector.z, w));
-      break;
-    default:
-      value = 0.0f;
-      kernel_assert(0);
-      break;
+  if (stack_valid(color_stack_offset)) {
+    float3 color;
+    switch (dimensions) {
+      case 1:
+        color = hash_float_to_float3(w);
+        break;
+      case 2:
+        color = hash_float2_to_float3(make_float2(vector.x, vector.y));
+        break;
+      case 3:
+        color = hash_float3_to_float3(vector);
+        break;
+      case 4:
+        color = hash_float4_to_float3(make_float4(vector.x, vector.y, vector.z, w));
+        break;
+      default:
+        color = make_float3(1.0f, 0.0f, 1.0f);
+        kernel_assert(0);
+        break;
+    }
+    stack_store_float3(stack, color_stack_offset, color);
+  }
+
+  if (stack_valid(value_stack_offset)) {
+    float value;
+    switch (dimensions) {
+      case 1:
+        value = hash_float_to_float(w);
+        break;
+      case 2:
+        value = hash_float2_to_float(make_float2(vector.x, vector.y));
+        break;
+      case 3:
+        value = hash_float3_to_float(vector);
+        break;
+      case 4:
+        value = hash_float4_to_float(make_float4(vector.x, vector.y, vector.z, w));
+        break;
+      default:
+        value = 0.0f;
+        kernel_assert(0);
+        break;
+    }
+    stack_store_float(stack, value_stack_offset, value);
   }
-  stack_store_float(stack, value_stack_offset, value);
 }
 
 CCL_NAMESPACE_END
index e4339b4074432c1ce57126e4f7f41154176a044c..bdab2a99897f39e3cc3b14364c5e66e7e21b1c9a 100644 (file)
@@ -1288,6 +1288,7 @@ NODE_DEFINE(WhiteNoiseTextureNode)
   SOCKET_IN_FLOAT(w, "W", 0.0f);
 
   SOCKET_OUT_FLOAT(value, "Value");
+  SOCKET_OUT_COLOR(color, "Color");
 
   return type;
 }
@@ -1301,15 +1302,17 @@ void WhiteNoiseTextureNode::compile(SVMCompiler &compiler)
   ShaderInput *vector_in = input("Vector");
   ShaderInput *w_in = input("W");
   ShaderOutput *value_out = output("Value");
+  ShaderOutput *color_out = output("Color");
 
   int vector_stack_offset = compiler.stack_assign(vector_in);
   int w_stack_offset = compiler.stack_assign(w_in);
   int value_stack_offset = compiler.stack_assign(value_out);
+  int color_stack_offset = compiler.stack_assign(color_out);
 
   compiler.add_node(NODE_TEX_WHITE_NOISE,
                     dimensions,
                     compiler.encode_uchar4(vector_stack_offset, w_stack_offset),
-                    value_stack_offset);
+                    compiler.encode_uchar4(value_stack_offset, color_stack_offset));
 }
 
 void WhiteNoiseTextureNode::compile(OSLCompiler &compiler)
index da04ef63295accad1b1ed2068cfe1a51bdd19384..661208c6463c1a9e9abf9556b26662227b6f60b9 100644 (file)
@@ -317,7 +317,8 @@ void Shader::tag_update(Scene *scene)
    * has use_mis set to false. We are quite close to release now, so
    * better to be safe.
    */
-  if (this == scene->background->get_shader(scene) && scene->light_manager->has_background_light(scene)) {
+  if (this == scene->background->get_shader(scene) &&
+      scene->light_manager->has_background_light(scene)) {
     scene->light_manager->need_update = true;
   }
 
index c19d4bdf6bd156935d470bfc403b1829b171c78a..07133d86ce45441185458f4b143d8a13268caef8 100644 (file)
@@ -247,7 +247,11 @@ class GHOST_IWindow {
    * Returns the tablet data (pressure etc).
    * \return The tablet data (pressure etc).
    */
-  virtual const GHOST_TabletData *GetTabletData() = 0;
+  virtual const GHOST_TabletData &GetTabletData()
+  {
+    /* Default state when no tablet is used, for systems without tablet support. */
+    return GHOST_TABLET_DATA_DEFAULT;
+  }
 
   /***************************************************************************************
    * Progress bar functionality
index fab315e5f131c97ba8d5105e324fd7516dd5c091..98dd1de867f6573a3b1cf05dab259cab85f797c8 100644 (file)
@@ -101,6 +101,12 @@ typedef struct GHOST_TabletData {
   float Ytilt; /* as above */
 } GHOST_TabletData;
 
+static const GHOST_TabletData GHOST_TABLET_DATA_DEFAULT = {
+    GHOST_kTabletModeNone, /* No tablet connected. */
+    1.0f,                  /* Pressure */
+    0.0f,                  /* Xtilt */
+    0.0f};                 /* Ytilt */
+
 typedef enum {
   GHOST_kNotVisible = 0,
   GHOST_kPartiallyVisible,
@@ -409,11 +415,15 @@ typedef struct {
   GHOST_TInt32 x;
   /** The y-coordinate of the cursor position. */
   GHOST_TInt32 y;
+  /** Associated tablet data. */
+  GHOST_TabletData tablet;
 } GHOST_TEventCursorData;
 
 typedef struct {
   /** The mask of the mouse button. */
   GHOST_TButtonMask button;
+  /** Associated tablet data. */
+  GHOST_TabletData tablet;
 } GHOST_TEventButtonData;
 
 typedef struct {
@@ -426,7 +436,8 @@ typedef enum {
   GHOST_kTrackpadEventScroll,
   GHOST_kTrackpadEventRotate,
   GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
-  GHOST_kTrackpadEventMagnify
+  GHOST_kTrackpadEventMagnify,
+  GHOST_kTrackpadEventSmartMagnify
 } GHOST_TTrackpadEventSubTypes;
 
 typedef struct {
index 1bed7afdfc43532ba9f1dbc83332b54c8d232846..3c3860bd2c080d622e572a183cb0c2b9815b70ba 100644 (file)
@@ -708,7 +708,7 @@ void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api)
 
 const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
 {
-  return ((GHOST_IWindow *)windowhandle)->GetTabletData();
+  return &((GHOST_IWindow *)windowhandle)->GetTabletData();
 }
 
 GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
index d4eeda2a9effcb21dae547aa4184fe8a1d7e2f32..e072f0823f345524dba0f690d7007816be57dcc2 100644 (file)
@@ -37,7 +37,7 @@
   case code: \
     return #code;
 
-static const char *get_egl_error_enum_string(EGLenum error)
+static const char *get_egl_error_enum_string(EGLint error)
 {
   switch (error) {
     CASE_CODE_RETURN_STR(EGL_SUCCESS)
@@ -60,7 +60,7 @@ static const char *get_egl_error_enum_string(EGLenum error)
   }
 }
 
-static const char *get_egl_error_message_string(EGLenum error)
+static const char *get_egl_error_message_string(EGLint error)
 {
   switch (error) {
     case EGL_SUCCESS:
@@ -129,7 +129,7 @@ static const char *get_egl_error_message_string(EGLenum error)
 static bool egl_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL)
 {
   if (!result) {
-    EGLenum error = eglGetError();
+    const EGLint error = eglGetError();
 
     const char *code = get_egl_error_enum_string(error);
     const char *msg = get_egl_error_message_string(error);
@@ -140,13 +140,13 @@ static bool egl_chk(bool result, const char *file = NULL, int line = 0, const ch
             file,
             line,
             text,
-            error,
+            static_cast<unsigned int>(error),
             code ? code : "<Unknown>",
             msg ? msg : "<Unknown>");
 #else
     fprintf(stderr,
             "EGL Error (0x%04X): %s: %s\n",
-            error,
+            static_cast<unsigned int>(error),
             code ? code : "<Unknown>",
             msg ? msg : "<Unknown>");
 #endif
@@ -225,8 +225,6 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual,
           choose_api(api, s_gl_sharedContext, s_gles_sharedContext, s_vg_sharedContext)),
       m_sharedCount(choose_api(api, s_gl_sharedCount, s_gles_sharedCount, s_vg_sharedCount))
 {
-  assert(m_nativeWindow != 0);
-  assert(m_nativeDisplay != NULL);
 }
 
 GHOST_ContextEGL::~GHOST_ContextEGL()
@@ -253,8 +251,6 @@ GHOST_ContextEGL::~GHOST_ContextEGL()
 
     if (m_surface != EGL_NO_SURFACE)
       EGL_CHK(::eglDestroySurface(m_display, m_surface));
-
-    EGL_CHK(::eglTerminate(m_display));
   }
 }
 
@@ -307,18 +303,35 @@ GHOST_TSuccess GHOST_ContextEGL::releaseDrawingContext()
   if (m_display) {
     bindAPI(m_api);
 
-    return EGL_CHK(::eglMakeCurrent(m_display, None, None, NULL)) ? GHOST_kSuccess :
-                                                                    GHOST_kFailure;
+    return EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) ?
+               GHOST_kSuccess :
+               GHOST_kFailure;
   }
   else {
     return GHOST_kFailure;
   }
 }
 
-void GHOST_ContextEGL::initContextEGLEW()
+bool GHOST_ContextEGL::initContextEGLEW()
 {
-  if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK)
+  /* We have to manually get this function before we can call eglewInit, since
+   * it requires a display argument. glewInit() does the same, but we only want
+   * to intialize EGLEW here. */
+  eglGetDisplay = (PFNEGLGETDISPLAYPROC)eglGetProcAddress("eglGetDisplay");
+  if (eglGetDisplay == NULL) {
+    return false;
+  }
+
+  if (!EGL_CHK((m_display = ::eglGetDisplay(m_nativeDisplay)) != EGL_NO_DISPLAY)) {
+    return false;
+  }
+
+  if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK) {
     fprintf(stderr, "Warning! EGLEW failed to initialize properly.\n");
+    return false;
+  }
+
+  return true;
 }
 
 static const std::string &api_string(EGLenum api)
@@ -341,6 +354,10 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
 
   m_stereoVisual = false;  // It doesn't matter what the Window wants.
 
+  if (!initContextEGLEW()) {
+    return GHOST_kFailure;
+  }
+
 #ifdef WITH_GL_ANGLE
   // d3dcompiler_XX.dll needs to be loaded before ANGLE will work
   if (s_d3dcompiler == NULL) {
@@ -360,11 +377,6 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
   EGLSurface prev_read = eglGetCurrentSurface(EGL_READ);
   EGLContext prev_context = eglGetCurrentContext();
 
-  m_display = ::eglGetDisplay(m_nativeDisplay);
-
-  if (!EGL_CHK(m_display != EGL_NO_DISPLAY))
-    return GHOST_kFailure;
-
   EGLint egl_major, egl_minor;
 
   if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor)))
@@ -375,8 +387,6 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
   if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
     goto error;
 
-  initContextEGLEW();
-
   if (!bindAPI(m_api))
     goto error;
 
@@ -419,6 +429,10 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
               egl_minor);
     }
   }
+  else {
+    attrib_list.push_back(EGL_RENDERABLE_TYPE);
+    attrib_list.push_back(EGL_OPENGL_BIT);
+  }
 
   attrib_list.push_back(EGL_RED_SIZE);
   attrib_list.push_back(8);
@@ -434,6 +448,12 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
   attrib_list.push_back(8);
 #endif
 
+  if (m_nativeWindow == 0) {
+    // off-screen surface
+    attrib_list.push_back(EGL_SURFACE_TYPE);
+    attrib_list.push_back(EGL_PBUFFER_BIT);
+  }
+
   attrib_list.push_back(EGL_NONE);
 
   EGLConfig config;
@@ -445,7 +465,19 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
   if (num_config != 1)  // num_config should be exactly 1
     goto error;
 
-  m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
+  if (m_nativeWindow != 0) {
+    m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
+  }
+  else {
+    static const EGLint pb_attrib_list[] = {
+        EGL_WIDTH,
+        1,
+        EGL_HEIGHT,
+        1,
+        EGL_NONE,
+    };
+    m_surface = ::eglCreatePbufferSurface(m_display, config, pb_attrib_list);
+  }
 
   if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
     goto error;
index cd6b0c959b7ed6e00304a7ac555088404b07ee39..da5ca7ef93f96929e6f99e2e5c03df6e574f19e0 100644 (file)
@@ -102,7 +102,7 @@ class GHOST_ContextEGL : public GHOST_Context {
   GHOST_TSuccess getSwapInterval(int &intervalOut);
 
  private:
-  void initContextEGLEW();
+  bool initContextEGLEW();
 
   EGLNativeDisplayType m_nativeDisplay;
   EGLNativeWindowType m_nativeWindow;
index da1dc929f4fa165a5b1f5acbed4ae691f53d5994..0f9d3b7e6bc3328e7cf0d1adf228b618d0f20baa 100644 (file)
@@ -46,6 +46,7 @@ class GHOST_EventButton : public GHOST_Event {
       : GHOST_Event(time, type, window)
   {
     m_buttonEventData.button = button;
+    m_buttonEventData.tablet = window->GetTabletData();
     m_data = &m_buttonEventData;
   }
 
index ac40f78569d7827920f3703f11714d9eb5c3e43a..41597db216aa5588a1697aab05e1af47f7db6960 100644 (file)
@@ -48,6 +48,7 @@ class GHOST_EventCursor : public GHOST_Event {
   {
     m_cursorEventData.x = x;
     m_cursorEventData.y = y;
+    m_cursorEventData.tablet = window->GetTabletData();
     m_data = &m_cursorEventData;
   }
 
index 119c9f28223449e1d4b7a5ba26001c1e20d3f047..e459da39d1471eb5e39eb718f22101ce6f72bb14 100644 (file)
@@ -39,7 +39,7 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
   if (event->getType() == GHOST_kEventWindowUpdate)
     return false;
 
-  std::cout << "\nGHOST_EventPrinter::processEvent, time: " << (GHOST_TInt32)event->getTime()
+  std::cout << "GHOST_EventPrinter::processEvent, time: " << (GHOST_TInt32)event->getTime()
             << ", type: ";
   switch (event->getType()) {
     case GHOST_kEventUnknown:
@@ -164,6 +164,8 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event)
       break;
   }
 
+  std::cout << std::endl;
+
   std::cout.flush();
 
   return handled;
index 2f597aee4760b0556d7d37f7b27b28723db9bed4..b0e11bd4a968ceab10054e258c917026b7847116 100644 (file)
@@ -1451,11 +1451,10 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT
       break;
 
     case NSEventTypeTabletProximity:
-      ct.Pressure = 0;
-      ct.Xtilt = 0;
-      ct.Ytilt = 0;
+      /* Reset tablet data when device enters proximity or leaves. */
+      ct = GHOST_TABLET_DATA_DEFAULT;
       if ([event isEnteringProximity]) {
-        // pointer is entering tablet area proximity
+        /* Pointer is entering tablet area proximity. */
         switch ([event pointingDeviceType]) {
           case NSPointingDeviceTypePen:
             ct.Active = GHOST_kTabletModeStylus;
@@ -1466,14 +1465,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT
           case NSPointingDeviceTypeCursor:
           case NSPointingDeviceTypeUnknown:
           default:
-            ct.Active = GHOST_kTabletModeNone;
             break;
         }
       }
-      else {
-        // pointer is leaving - return to mouse
-        ct.Active = GHOST_kTabletModeNone;
-      }
       break;
 
     default:
@@ -1524,46 +1518,45 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
 
   switch ([event type]) {
     case NSEventTypeLeftMouseDown:
+      handleTabletEvent(event);  // Update window tablet state to be included in event.
       pushEvent(new GHOST_EventButton(
           [event timestamp] * 1000, GHOST_kEventButtonDown, window, GHOST_kButtonMaskLeft));
-      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       break;
     case NSEventTypeRightMouseDown:
+      handleTabletEvent(event);  // Update window tablet state to be included in event.
       pushEvent(new GHOST_EventButton(
           [event timestamp] * 1000, GHOST_kEventButtonDown, window, GHOST_kButtonMaskRight));
-      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       break;
     case NSEventTypeOtherMouseDown:
+      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       pushEvent(new GHOST_EventButton([event timestamp] * 1000,
                                       GHOST_kEventButtonDown,
                                       window,
                                       convertButton([event buttonNumber])));
-      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       break;
 
     case NSEventTypeLeftMouseUp:
+      handleTabletEvent(event);  // Update window tablet state to be included in event.
       pushEvent(new GHOST_EventButton(
           [event timestamp] * 1000, GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft));
-      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       break;
     case NSEventTypeRightMouseUp:
+      handleTabletEvent(event);  // Update window tablet state to be included in event.
       pushEvent(new GHOST_EventButton(
           [event timestamp] * 1000, GHOST_kEventButtonUp, window, GHOST_kButtonMaskRight));
-      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       break;
     case NSEventTypeOtherMouseUp:
+      handleTabletEvent(event);  // Update window tablet state to be included in event.
       pushEvent(new GHOST_EventButton([event timestamp] * 1000,
                                       GHOST_kEventButtonUp,
                                       window,
                                       convertButton([event buttonNumber])));
-      handleTabletEvent(event);  // Handle tablet events combined with mouse events
       break;
 
     case NSEventTypeLeftMouseDragged:
     case NSEventTypeRightMouseDragged:
     case NSEventTypeOtherMouseDragged:
-      // Handle tablet events combined with mouse events
-      handleTabletEvent(event);
+      handleTabletEvent(event);  // Update window tablet state to be included in event.
 
     case NSEventTypeMouseMoved: {
       GHOST_TGrabCursorMode grab_mode = window->getCursorGrabMode();
@@ -1733,6 +1726,19 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
                                         0));
     } break;
 
+    case NSEventTypeSmartMagnify: {
+      NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
+      GHOST_TInt32 x, y;
+      window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
+      pushEvent(new GHOST_EventTrackpad([event timestamp] * 1000,
+                                        window,
+                                        GHOST_kTrackpadEventSmartMagnify,
+                                        x,
+                                        y,
+                                        0,
+                                        0));
+    } break;
+
     case NSEventTypeRotate: {
       NSPoint mousePos = [cocoawindow mouseLocationOutsideOfEventStream];
       GHOST_TInt32 x, y;
index fa2fc9fff377cb33497d4a7f813125bdc5447a9d..4a4016cbca1ea4ed185c5c7f7637c71eb3f7fd23 100644 (file)
@@ -443,6 +443,13 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent)
       ::DispatchMessageW(&msg);
       hasEventHandled = true;
     }
+
+    /* PeekMessage above is allowed to dispatch messages to the wndproc without us
+     * noticing, so we need to check the event manager here to see if there are
+     * events waiting in the queue.
+     */
+    hasEventHandled |= this->m_eventManager->getNumEvents() > 0;
+
   } while (waitForEvent && !hasEventHandled);
 
   return hasEventHandled;
@@ -894,6 +901,7 @@ GHOST_Event *GHOST_SystemWin32::processPointerEvent(GHOST_TEventType type,
 
   switch (type) {
     case GHOST_kEventButtonDown:
+      /* Update window tablet data to be included in event. */
       window->setTabletData(&pointerInfo.tabletData);
       eventHandled = true;
       return new GHOST_EventButton(
@@ -903,6 +911,7 @@ GHOST_Event *GHOST_SystemWin32::processPointerEvent(GHOST_TEventType type,
       return new GHOST_EventButton(
           system->getMilliSeconds(), GHOST_kEventButtonUp, window, pointerInfo.buttonMask);
     case GHOST_kEventCursorMove:
+      /* Update window tablet data to be included in event. */
       window->setTabletData(&pointerInfo.tabletData);
       eventHandled = true;
       return new GHOST_EventCursor(system->getMilliSeconds(),
@@ -1451,7 +1460,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
         ////////////////////////////////////////////////////////////////////////
         case WM_CLOSE:
           /* The WM_CLOSE message is sent as a signal that a window
-           * or an application should terminate. */
+           * or an application should terminate. Restore if minimized. */
+          if (IsIconic(hwnd)) {
+            ShowWindow(hwnd, SW_RESTORE);
+          }
           event = processWindowEvent(GHOST_kEventWindowClose, window);
           break;
         case WM_ACTIVATE:
index c50ff8e74265b8acc5c3857f19892eb1ed5c30e7..4c77dbd7abe737ddb94942fee89e5f7a71158552 100644 (file)
@@ -50,6 +50,7 @@
 
 #if defined(WITH_GL_EGL)
 #  include "GHOST_ContextEGL.h"
+#  include <EGL/eglext.h>
 #else
 #  include "GHOST_ContextGLX.h"
 #endif
@@ -243,6 +244,10 @@ GHOST_SystemX11::~GHOST_SystemX11()
   clearXInputDevices();
 #endif /* WITH_X11_XINPUT */
 
+#ifdef WITH_GL_EGL
+  ::eglTerminate(::eglGetDisplay(m_display));
+#endif
+
   if (m_xkb_descr) {
     XkbFreeKeyboard(m_xkb_descr, XkbAllComponentsMask, true);
   }
@@ -406,17 +411,39 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
 #endif
 
   const int profile_mask =
-#if defined(WITH_GL_PROFILE_CORE)
+#ifdef WITH_GL_EGL
+#  if defined(WITH_GL_PROFILE_CORE)
+      EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
+#  elif defined(WITH_GL_PROFILE_COMPAT)
+      EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
+#  else
+#    error  // must specify either core or compat at build time
+#  endif
+#else
+#  if defined(WITH_GL_PROFILE_CORE)
       GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
-#elif defined(WITH_GL_PROFILE_COMPAT)
+#  elif defined(WITH_GL_PROFILE_COMPAT)
       GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-#else
-#  error  // must specify either core or compat at build time
+#  else
+#    error  // must specify either core or compat at build time
+#  endif
 #endif
 
   GHOST_Context *context;
 
   for (int minor = 5; minor >= 0; --minor) {
+#if defined(WITH_GL_EGL)
+    context = new GHOST_ContextEGL(false,
+                                   EGLNativeWindowType(nullptr),
+                                   EGLNativeDisplayType(m_display),
+                                   profile_mask,
+                                   4,
+                                   minor,
+                                   GHOST_OPENGL_EGL_CONTEXT_FLAGS |
+                                       (false ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
+                                   GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+                                   EGL_OPENGL_API);
+#else
     context = new GHOST_ContextGLX(false,
                                    (Window)NULL,
                                    m_display,
@@ -427,6 +454,7 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
                                    GHOST_OPENGL_GLX_CONTEXT_FLAGS |
                                        (false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
                                    GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
+#endif
 
     if (context->initializeDrawingContext())
       return context;
@@ -434,6 +462,18 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
       delete context;
   }
 
+#if defined(WITH_GL_EGL)
+  context = new GHOST_ContextEGL(false,
+                                 EGLNativeWindowType(nullptr),
+                                 EGLNativeDisplayType(m_display),
+                                 profile_mask,
+                                 3,
+                                 3,
+                                 GHOST_OPENGL_EGL_CONTEXT_FLAGS |
+                                     (false ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
+                                 GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+                                 EGL_OPENGL_API);
+#else
   context = new GHOST_ContextGLX(false,
                                  (Window)NULL,
                                  m_display,
@@ -444,6 +484,7 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext()
                                  GHOST_OPENGL_GLX_CONTEXT_FLAGS |
                                      (false ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
                                  GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
+#endif
 
   if (context->initializeDrawingContext())
     return context;
@@ -823,7 +864,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
    * in the future we could have a ghost call window->CheckTabletProximity()
    * but for now enough parts of the code are checking 'Active'
    * - campbell */
-  if (window->GetTabletData()->Active != GHOST_kTabletModeNone) {
+  if (window->GetTabletData().Active != GHOST_kTabletModeNone) {
     bool any_proximity = false;
 
     for (GHOST_TabletX11 &xtablet : m_xtablets) {
@@ -834,7 +875,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 
     if (!any_proximity) {
       // printf("proximity disable\n");
-      window->GetTabletData()->Active = GHOST_kTabletModeNone;
+      window->GetTabletData().Active = GHOST_kTabletModeNone;
     }
   }
 #endif /* WITH_X11_XINPUT */
@@ -855,7 +896,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
       XMotionEvent &xme = xe->xmotion;
 
 #ifdef WITH_X11_XINPUT
-      bool is_tablet = window->GetTabletData()->Active != GHOST_kTabletModeNone;
+      bool is_tablet = window->GetTabletData().Active != GHOST_kTabletModeNone;
 #else
       bool is_tablet = false;
 #endif
@@ -1395,7 +1436,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
           /* stroke might begin without leading ProxyIn event,
            * this happens when window is opened when stylus is already hovering
            * around tablet surface */
-          window->GetTabletData()->Active = xtablet.mode;
+          window->GetTabletData().Active = xtablet.mode;
 
           /* Note: This event might be generated with incomplete dataset
            * (don't exactly know why, looks like in some cases, if the value does not change,
@@ -1408,7 +1449,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
      ((void)(val = data->axis_data[axis - axis_first]), true))
 
           if (AXIS_VALUE_GET(2, axis_value)) {
-            window->GetTabletData()->Pressure = axis_value / ((float)xtablet.PressureLevels);
+            window->GetTabletData().Pressure = axis_value / ((float)xtablet.PressureLevels);
           }
 
           /* the (short) cast and the & 0xffff is bizarre and unexplained anywhere,
@@ -1420,12 +1461,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
            * check this. --mont29
            */
           if (AXIS_VALUE_GET(3, axis_value)) {
-            window->GetTabletData()->Xtilt = (short)(axis_value & 0xffff) /
-                                             ((float)xtablet.XtiltLevels);
+            window->GetTabletData().Xtilt = (short)(axis_value & 0xffff) /
+                                            ((float)xtablet.XtiltLevels);
           }
           if (AXIS_VALUE_GET(4, axis_value)) {
-            window->GetTabletData()->Ytilt = (short)(axis_value & 0xffff) /
-                                             ((float)xtablet.YtiltLevels);
+            window->GetTabletData().Ytilt = (short)(axis_value & 0xffff) /
+                                            ((float)xtablet.YtiltLevels);
           }
 
 #  undef AXIS_VALUE_GET
@@ -1436,10 +1477,10 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
             continue;
           }
 
-          window->GetTabletData()->Active = xtablet.mode;
+          window->GetTabletData().Active = xtablet.mode;
         }
         else if (xe->type == xtablet.ProxOutEvent) {
-          window->GetTabletData()->Active = GHOST_kTabletModeNone;
+          window->GetTabletData().Active = GHOST_kTabletModeNone;
         }
       }
 #endif  // WITH_X11_XINPUT
index d260d0eacbc62beff938e176b607bfd484d7795e..a49949c2c8db679b16234390e044fd1cc814e0fe 100644 (file)
@@ -222,9 +222,9 @@ class GHOST_WindowCocoa : public GHOST_Window {
 
   bool isDialog() const;
 
-  const GHOST_TabletData *GetTabletData()
+  const GHOST_TabletData &GetTabletData()
   {
-    return &m_tablet;
+    return m_tablet;
   }
 
   GHOST_TabletData &GetCocoaTabletData()
index 43e35faf8080bdbcdc42029dc3d6c1ce3d9575e7..6470bb22fef508009d443aafded41b11d089e069 100644 (file)
@@ -387,7 +387,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
 
   setTitle(title);
 
-  m_tablet.Active = GHOST_kTabletModeNone;
+  m_tablet = GHOST_TABLET_DATA_DEFAULT;
 
   CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
   [windowDelegate setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
index 29f3eee7cce66b0772be414b721f0850e9b878e5..db40075e6ca17ad230ba2de2d5b3ae9f8c7cd094 100644 (file)
@@ -31,11 +31,6 @@ class GHOST_SystemNULL;
 
 class GHOST_WindowNULL : public GHOST_Window {
  public:
-  const GHOST_TabletData *GetTabletData()
-  {
-    return NULL;
-  }
-
   GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor)
   {
     return GHOST_kSuccess;
index d9342de4d698a3bcbb0b0f30f19e918831f84571..6332ce584d2cb58195879ff899a58932dd07b503 100644 (file)
@@ -48,11 +48,6 @@ class GHOST_WindowSDL : public GHOST_Window {
   SDL_Cursor *m_sdl_custom_cursor;
 
  public:
-  const GHOST_TabletData *GetTabletData()
-  {
-    return NULL;
-  }
-
   GHOST_WindowSDL(GHOST_SystemSDL *system,
                   const STR_String &title,
                   GHOST_TInt32 left,
index cee40924b7313810903958a92f7956f3721f952d..14c70382916343fd39b05b98f355b17a907d48f6 100644 (file)
   systemCocoa->handleMouseEvent(event);
 }
 
+- (void)smartMagnifyWithEvent:(NSEvent *)event
+{
+  systemCocoa->handleMouseEvent(event);
+}
+
 - (void)rotateWithEvent:(NSEvent *)event
 {
   systemCocoa->handleMouseEvent(event);
index fd9e0240b1b1d8cdd18272e6c879a1c2abb04b87..2ab0e837efb6ce2236140e9f627e80048dc731c5 100644 (file)
@@ -89,8 +89,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
 {
   // Initialize tablet variables
   memset(&m_wintab, 0, sizeof(m_wintab));
-  memset(&m_tabletData, 0, sizeof(m_tabletData));
-  m_tabletData.Active = GHOST_kTabletModeNone;
+  m_tabletData = GHOST_TABLET_DATA_DEFAULT;
 
   // Create window
   if (state != GHOST_kWindowStateFullScreen) {
@@ -645,6 +644,9 @@ GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order)
     hWndToRaise = ::GetWindow(m_hWnd, GW_HWNDNEXT); /* the window to raise */
   }
   else {
+    if (getState() == GHOST_kWindowStateMinimized) {
+      setState(GHOST_kWindowStateNormal);
+    }
     hWndInsertAfter = HWND_TOP;
     hWndToRaise = NULL;
   }
@@ -1085,10 +1087,7 @@ void GHOST_WindowWin32::setTabletData(GHOST_TabletData *pTabletData)
     m_tabletData = *pTabletData;
   }
   else {
-    m_tabletData.Active = GHOST_kTabletModeNone;
-    m_tabletData.Pressure = 1.0f;
-    m_tabletData.Xtilt = 0.0f;
-    m_tabletData.Ytilt = 0.0f;
+    m_tabletData = GHOST_TABLET_DATA_DEFAULT;
   }
 }
 
@@ -1150,8 +1149,6 @@ void GHOST_WindowWin32::processWin32TabletInitEvent()
         m_wintab.maxAzimuth = m_wintab.maxAltitude = 0;
       }
     }
-
-    m_tabletData.Active = GHOST_kTabletModeNone;
   }
 
   m_tabletData.Active = GHOST_kTabletModeNone;
index f72f03855fdef32593d7318b53e4bac9d88973b3..4795539e0f92c89a9e1c0c43ed4619169f4a98d4 100644 (file)
@@ -392,9 +392,9 @@ class GHOST_WindowWin32 : public GHOST_Window {
   HCURSOR getStandardCursor(GHOST_TStandardCursor shape) const;
   void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
 
-  const GHOST_TabletData *GetTabletData()
+  const GHOST_TabletData &GetTabletData()
   {
-    return &m_tabletData;
+    return m_tabletData;
   }
 
   void setTabletData(GHOST_TabletData *tabletData);
index ae8d705fe4aa0764deaac9fe801e1fec31fd8b97..349b11728bdf2d00469fb860e226aeaf5b81c6c7 100644 (file)
@@ -25,6 +25,7 @@
 #include <X11/cursorfont.h>
 #include <X11/Xatom.h>
 #include <X11/Xutil.h>
+#include <X11/Xmd.h>
 #ifdef WITH_X11_ALPHA
 #  include <X11/extensions/Xrender.h>
 #endif
@@ -38,8 +39,9 @@
 #  include "GHOST_DropTargetX11.h"
 #endif
 
-#if defined(WITH_GL_EGL)
+#ifdef WITH_GL_EGL
 #  include "GHOST_ContextEGL.h"
+#  include <EGL/eglext.h>
 #else
 #  include "GHOST_ContextGLX.h"
 #endif
@@ -101,6 +103,18 @@ enum {
 #define _NET_WM_STATE_ADD 1
 // #define _NET_WM_STATE_TOGGLE 2 // UNUSED
 
+#ifdef WITH_GL_EGL
+
+static XVisualInfo *x11_visualinfo_from_egl(Display *display)
+{
+  int num_visuals;
+  XVisualInfo vinfo_template;
+  vinfo_template.screen = DefaultScreen(display);
+  return XGetVisualInfo(display, VisualScreenMask, &vinfo_template, &num_visuals);
+}
+
+#else
+
 static XVisualInfo *x11_visualinfo_from_glx(Display *display,
                                             bool stereoVisual,
                                             bool needAlpha,
@@ -124,11 +138,11 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
     return NULL;
   }
   glx_version = glx_major * 100 + glx_minor;
-#ifndef WITH_X11_ALPHA
+#  ifndef WITH_X11_ALPHA
   (void)glx_version;
-#endif
+#  endif
 
-#ifdef WITH_X11_ALPHA
+#  ifdef WITH_X11_ALPHA
   if (needAlpha && glx_version >= 103 &&
       (glXChooseFBConfig || (glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddressARB(
                                  (const GLubyte *)"glXChooseFBConfig")) != NULL) &&
@@ -170,7 +184,7 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
     }
   }
   else
-#endif
+#  endif
   {
     /* legacy, don't use extension */
     GHOST_X11_GL_GetAttributes(glx_attribs, 64, stereoVisual, needAlpha, false);
@@ -194,6 +208,8 @@ static XVisualInfo *x11_visualinfo_from_glx(Display *display,
   return NULL;
 }
 
+#endif  // WITH_GL_EGL
+
 GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
                                  Display *display,
                                  const STR_String &title,
@@ -230,8 +246,13 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
       m_is_debug_context(is_debug)
 {
   if (type == GHOST_kDrawingContextTypeOpenGL) {
+#ifdef WITH_GL_EGL
+    m_visualInfo = x11_visualinfo_from_egl(m_display);
+    (void)alphaBackground;
+#else
     m_visualInfo = x11_visualinfo_from_glx(
         m_display, stereoVisual, alphaBackground, (GLXFBConfig *)&m_fbconfig);
+#endif
   }
   else {
     XVisualInfo tmp = {0};
@@ -478,7 +499,7 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
 #ifdef WITH_X11_XINPUT
   refreshXInputDevices();
 
-  m_tabletData.Active = GHOST_kTabletModeNone;
+  m_tabletData = GHOST_TABLET_DATA_DEFAULT;
 #endif
 
   /* now set up the rendering context. */
@@ -1318,17 +1339,40 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
 #endif
 
     const int profile_mask =
-#if defined(WITH_GL_PROFILE_CORE)
+#ifdef WITH_GL_EGL
+#  if defined(WITH_GL_PROFILE_CORE)
+        EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT;
+#  elif defined(WITH_GL_PROFILE_COMPAT)
+        EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT;
+#  else
+#    error  // must specify either core or compat at build time
+#  endif
+#else
+#  if defined(WITH_GL_PROFILE_CORE)
         GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
-#elif defined(WITH_GL_PROFILE_COMPAT)
+#  elif defined(WITH_GL_PROFILE_COMPAT)
         GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-#else
-#  error  // must specify either core or compat at build time
+#  else
+#    error  // must specify either core or compat at build time
+#  endif
 #endif
 
     GHOST_Context *context;
 
     for (int minor = 5; minor >= 0; --minor) {
+#ifdef WITH_GL_EGL
+      context = new GHOST_ContextEGL(
+          m_wantStereoVisual,
+          EGLNativeWindowType(m_window),
+          EGLNativeDisplayType(m_display),
+          profile_mask,
+          4,
+          minor,
+          GHOST_OPENGL_EGL_CONTEXT_FLAGS |
+              (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
+          GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+          EGL_OPENGL_API);
+#else
       context = new GHOST_ContextGLX(m_wantStereoVisual,
                                      m_window,
                                      m_display,
@@ -1339,6 +1383,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
                                      GHOST_OPENGL_GLX_CONTEXT_FLAGS |
                                          (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
                                      GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
+#endif
 
       if (context->initializeDrawingContext())
         return context;
@@ -1346,6 +1391,18 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
         delete context;
     }
 
+#ifdef WITH_GL_EGL
+    context = new GHOST_ContextEGL(m_wantStereoVisual,
+                                   EGLNativeWindowType(m_window),
+                                   EGLNativeDisplayType(m_display),
+                                   profile_mask,
+                                   3,
+                                   3,
+                                   GHOST_OPENGL_EGL_CONTEXT_FLAGS |
+                                       (m_is_debug_context ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
+                                   GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
+                                   EGL_OPENGL_API);
+#else
     context = new GHOST_ContextGLX(m_wantStereoVisual,
                                    m_window,
                                    m_display,
@@ -1356,6 +1413,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
                                    GHOST_OPENGL_GLX_CONTEXT_FLAGS |
                                        (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
                                    GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
+#endif
 
     if (context->initializeDrawingContext())
       return context;
index faf3acba234b355d3e7af955130cbf5e5af4b2ae..a9914d8834057552ad77cba7a3058388ac6c2b16 100644 (file)
@@ -145,14 +145,9 @@ class GHOST_WindowX11 : public GHOST_Window {
    */
   Window getXWindow();
 #ifdef WITH_X11_XINPUT
-  GHOST_TabletData *GetTabletData()
+  GHOST_TabletData &GetTabletData()
   {
-    return &m_tabletData;
-  }
-#else   // WITH_X11_XINPUT
-  const GHOST_TabletData *GetTabletData()
-  {
-    return NULL;
+    return m_tabletData;
   }
 #endif  // WITH_X11_XINPUT
 
index b1a0eda0e229b4af53e2b4722fe3fe5c2430119b..2a4ae5355a0a68aa39a711bc7b27828c1ea5dd7d 100644 (file)
@@ -230,6 +230,10 @@ extern const char *(*MEM_name_ptr)(void *vmemh);
 /* Switch allocator to slower but fully guarded mode. */
 void MEM_use_guarded_allocator(void);
 
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
 #ifdef __cplusplus
 /* alloc funcs for C++ only */
 #  define MEM_CXX_CLASS_ALLOC_FUNCS(_id) \
@@ -253,6 +257,13 @@ void MEM_use_guarded_allocator(void);
         MEM_freeN(mem); \
     }
 
+/* Needed when type includes a namespace, then the namespace should not be
+ * specified after ~, so using a macro fails. */
+template<class T> inline void OBJECT_GUARDED_DESTRUCTOR(T *what)
+{
+  what->~T();
+}
+
 #  if defined __GNUC__
 #    define OBJECT_GUARDED_NEW(type, args...) new (MEM_mallocN(sizeof(type), __func__)) type(args)
 #  else
@@ -262,15 +273,20 @@ void MEM_use_guarded_allocator(void);
 #  define OBJECT_GUARDED_DELETE(what, type) \
     { \
       if (what) { \
-        ((type *)(what))->~type(); \
+        OBJECT_GUARDED_DESTRUCTOR((type *)what); \
         MEM_freeN(what); \
       } \
     } \
     (void)0
-#endif /* __cplusplus */
-
-#ifdef __cplusplus
-}
+#  define OBJECT_GUARDED_SAFE_DELETE(what, type) \
+    { \
+      if (what) { \
+        OBJECT_GUARDED_DESTRUCTOR((type *)what); \
+        MEM_freeN(what); \
+        what = NULL; \
+      } \
+    } \
+    (void)0
 #endif /* __cplusplus */
 
 #endif /* __MEM_GUARDEDALLOC_H__ */
index fa2d0d1e3343fea50c0c0a8310a62780ef7763d7..d24437c85f23aabbfac6f21bac6a07520adb2a2f 100644 (file)
@@ -70,6 +70,9 @@ const char *(*MEM_name_ptr)(void *vmemh) = MEM_lockfree_name_ptr;
 
 void *aligned_malloc(size_t size, size_t alignment)
 {
+  /* posix_memalign requires alignment to be a multiple of sizeof(void *). */
+  assert(alignment >= ALIGNED_MALLOC_MINIMUM_ALIGNMENT);
+
 #ifdef _WIN32
   return _aligned_malloc(size, alignment);
 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
index e6e090703d452f66436f227b35cd4fee7dfbf8eb..876607fdb77f6ec5a997f97bdb4f866df4db0210 100644 (file)
@@ -107,6 +107,8 @@ size_t malloc_usable_size(void *ptr);
 
 #include "mallocn_inline.h"
 
+#define ALIGNED_MALLOC_MINIMUM_ALIGNMENT sizeof(void *)
+
 void *aligned_malloc(size_t size, size_t alignment);
 void aligned_free(void *ptr);
 
index e8fd8de738b297bd0909c919e1b921513e7ca2a0..87091bb986230a1b2feb084c0c677c7ea00a54d8 100644 (file)
@@ -346,7 +346,17 @@ void *MEM_lockfree_malloc_arrayN(size_t len, size_t size, const char *str)
 
 void *MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str)
 {
-  MemHeadAligned *memh;
+  /* Huge alignment values doesn't make sense and they wouldn't fit into 'short' used in the
+   * MemHead. */
+  assert(alignment < 1024);
+
+  /* We only support alignments that are a power of two. */
+  assert(IS_POW2(alignment));
+
+  /* Some OS specific aligned allocators require a certain minimal alignment. */
+  if (alignment < ALIGNED_MALLOC_MINIMUM_ALIGNMENT) {
+    alignment = ALIGNED_MALLOC_MINIMUM_ALIGNMENT;
+  }
 
   /* It's possible that MemHead's size is not properly aligned,
    * do extra padding to deal with this.
@@ -356,17 +366,10 @@ void *MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str
    */
   size_t extra_padding = MEMHEAD_ALIGN_PADDING(alignment);
 
-  /* Huge alignment values doesn't make sense and they
-   * wouldn't fit into 'short' used in the MemHead.
-   */
-  assert(alignment < 1024);
-
-  /* We only support alignment to a power of two. */
-  assert(IS_POW2(alignment));
-
   len = SIZET_ALIGN_4(len);
 
-  memh = (MemHeadAligned *)aligned_malloc(len + extra_padding + sizeof(MemHeadAligned), alignment);
+  MemHeadAligned *memh = (MemHeadAligned *)aligned_malloc(
+      len + extra_padding + sizeof(MemHeadAligned), alignment);
 
   if (LIKELY(memh)) {
     /* We keep padding in the beginning of MemHead,
index f587aee615b9831d15d295991093a0916d335628..1801751523a9e9329223855640ef7e63f9bb6929 100644 (file)
@@ -133,9 +133,11 @@ if(WITH_LIBMV)
     intern/image.h
     intern/logging.h
     intern/reconstruction.h
+    intern/region.h
     intern/track_region.h
     intern/tracks.h
     intern/tracksN.h
+    intern/utildefines.h
     libmv/autotrack/autotrack.h
     libmv/autotrack/callbacks.h
     libmv/autotrack/frame_accessor.h
index 2601a2d6754d5515cf93b4ff4ad8a8489f345b02..48da102b8015ec08c2914141097d924775fbc718 100755 (executable)
@@ -174,9 +174,11 @@ ${third_sources}
     intern/image.h
     intern/logging.h
     intern/reconstruction.h
+    intern/region.h
     intern/track_region.h
     intern/tracks.h
     intern/tracksN.h
+    intern/utildefines.h
 ${headers}
 
 ${third_headers}
index 8a05b618f031582c006c6f62b9e60619ab3eef8b..74afb3ed35e3271b2609feaf67bea6b8bdffe7ca 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 8a05b618f031582c006c6f62b9e60619ab3eef8b
+Subproject commit 74afb3ed35e3271b2609feaf67bea6b8bdffe7ca
index 147b55f60ef1245ed58f3a9f2ed5f4b8989f35d5..1eff85b6129c1ac396ba619e0415767e651bb71b 100644 (file)
@@ -339,6 +339,7 @@ const bTheme U_theme_default = {
     .bone_solid = RGBA(0xb2b2b2ff),
     .bone_pose = RGBA(0x50c8ff50),
     .bone_pose_active = RGBA(0x8cffff50),
+    .bone_locked_weight = RGBA(0xff000080),
     .cframe = RGBA(0x60c040ff),
     .time_keyframe = RGBA(0xddd700ff),
     .time_gp_keyframe = RGBA(0xb5e61dff),
@@ -419,7 +420,7 @@ const bTheme U_theme_default = {
     .list = RGBA(0x282828ff),
     .list_title = RGBA(0xffffffff),
     .list_text = RGBA(0xb8b8b8ff),
-    .list_text_hi = RGBA(0xffffffff),
+    .list_text_hi = RGBA(0xffaf29ff),
     .panelcolors = {
       .header = RGBA(0x424242cc),
       .back = RGBA(0x333333b3),
@@ -453,11 +454,11 @@ const bTheme U_theme_default = {
     .anim_preview_range = RGBA(0xa14d0066),
   },
   .space_info = {
-    .back = RGBA(0x42424200),
-    .title = RGBA(0xeeeeeeff),
-    .text = RGBA(0xe6e6e6ff),
+    .back = RGBA(0x28282800),
+    .title = RGBA(0xffffffff),
+    .text = RGBA(0xc3c3c3ff),
     .text_hi = RGBA(0xffffffff),
-    .header = RGBA(0x424242ff),
+    .header = RGBA(0x454545ff),
     .header_text = RGBA(0xeeeeeeff),
     .header_text_hi = RGBA(0xffffffff),
     .tab_active = RGBA(0x4b4b4bff),
@@ -476,16 +477,20 @@ const bTheme U_theme_default = {
     .vertex_size = 3,
     .outline_width = 1,
     .facedot_size = 4,
-    .info_selected = RGBA(0x6080ffff),
+    .info_selected = RGBA(0x3b5689ff),
     .info_selected_text = RGBA(0xffffffff),
-    .info_error = RGBA(0x990000ff),
+    .info_error = RGBA(0xff613dff),
     .info_error_text = RGBA(0xffffffff),
     .info_warning = RGBA(0xb36a00ff),
     .info_warning_text = RGBA(0xffffffff),
     .info_info = RGBA(0x1d4383ff),
     .info_info_text = RGBA(0xffffffff),
     .info_debug = RGBA(0xd3d3d3ff),
-  },
+    .info_property = RGBA(0x3ace87ff),
+    .info_property_text = RGBA(0xffffffff),
+    .info_operator = RGBA(0x3ace87ff),
+    .info_operator_text = RGBA(0xffffffff),
+    },
   .space_action = {
     .back = RGBA(0x42424200),
     .title = RGBA(0xeeeeeeff),
@@ -505,7 +510,7 @@ const bTheme U_theme_default = {
     .list = RGBA(0x282828ff),
     .list_title = RGBA(0xffffffff),
     .list_text = RGBA(0xb8b8b8ff),
-    .list_text_hi = RGBA(0xffffffff),
+    .list_text_hi = RGBA(0xffaf29ff),
     .panelcolors = {
       .header = RGBA(0x424242cc),
       .back = RGBA(0x333333b3),
@@ -556,14 +561,14 @@ const bTheme U_theme_default = {
     .tab_inactive = RGBA(0x2b2b2bff),
     .tab_back = RGBA(0x232323ff),
     .tab_outline = RGBA(0x232323ff),
-    .button = RGBA(0x282828ff),
+    .button = RGBA(0x424242ff),
     .button_title = RGBA(0xffffffff),
     .button_text = RGBA(0xe5e5e5ff),
     .button_text_hi = RGBA(0xffffffff),
     .list = RGBA(0x282828ff),
     .list_title = RGBA(0xffffffff),
     .list_text = RGBA(0xb8b8b8ff),
-    .list_text_hi = RGBA(0xffffffff),
+    .list_text_hi = RGBA(0xffaf29ff),
     .panelcolors = {
       .header = RGBA(0x424242cc),
       .back = RGBA(0x333333b3),
index 1470f353c65034db91131d21ab9c782d029a2ee9..21dee6f89433249dba6573bf1eaa56a8d5b99c34 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1470f353c65034db91131d21ab9c782d029a2ee9
+Subproject commit 21dee6f89433249dba6573bf1eaa56a8d5b99c34
index ffbaca558a27bab4716bcd51ca7ea1df8e4f4b14..70b649775eeeebedb02c1c7b7aa996a7f6294177 160000 (submodule)
@@ -1 +1 @@
-Subproject commit ffbaca558a27bab4716bcd51ca7ea1df8e4f4b14
+Subproject commit 70b649775eeeebedb02c1c7b7aa996a7f6294177
index 202fd8657234e2657d464fcf8dd926cf6b3dff5c..8dda8c90f85fe99fa87cf2ace6f8af0f25844883 100644 (file)
@@ -277,14 +277,15 @@ def draw(layout, context, context_member, property_type, use_edit=True):
         else:
             val_draw = val
 
-        row = flow.row(align=True)
+        row = layout.row(align=True)
         box = row.box()
 
         if use_edit:
             split = box.split(factor=0.75)
             row = split.row(align=True)
         else:
-            row = box.row(align=True)
+            split = box.split(factor=1.00)
+            row = split.row(align=True)
 
         row.alignment = 'RIGHT'
 
index 8b398d1541cb52cdf8bf7ad1bf8127da25981b7f..629bc24abb356cdb8d421b9a28ad0326efad1555 100644 (file)
@@ -290,12 +290,14 @@ def _template_items_proportional_editing(*, connected=False):
 
 # Tool System Templates
 
-def _template_items_tool_select(params, operator, cursor_operator):
+def _template_items_tool_select(params, operator, cursor_operator, *, extend):
     if params.select_mouse == 'LEFTMOUSE':
         # Immediate select without quick delay.
         return [
             (operator, {"type": 'LEFTMOUSE', "value": 'PRESS'},
              {"properties": [("deselect_all", True)]}),
+            (operator, {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+             {"properties": [(extend, True)]}),
         ]
     else:
         # For right mouse, set the cursor.
@@ -940,6 +942,7 @@ def km_view3d(params):
         # Visibility.
         ("view3d.localview", {"type": 'NUMPAD_SLASH', "value": 'PRESS'}, None),
         ("view3d.localview", {"type": 'SLASH', "value": 'PRESS'}, None),
+        ("view3d.localview", {"type": 'MOUSESMARTZOOM', "value": 'ANY'}, None),
         ("view3d.localview_remove_from", {"type": 'M', "value": 'PRESS'}, None),
         # Navigation.
         ("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
@@ -2032,6 +2035,7 @@ def km_dopesheet(params):
         op_menu_pie("VIEW3D_MT_proportional_editing_falloff_pie", {"type": 'O', "value": 'PRESS', "shift": True}),
         ("marker.add", {"type": 'M', "value": 'PRESS'}, None),
         ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
+        ("marker.camera_bind", {"type": 'B', "value": 'PRESS', "ctrl": True}, None),
         *_template_items_context_menu("DOPESHEET_MT_context_menu", params.context_menu_event),
     ])
 
@@ -2333,6 +2337,7 @@ def km_sequencercommon(_params):
 
     items.extend([
         *_template_space_region_type_toggle(
+            toolbar_key={"type": 'T', "value": 'PRESS'},
             sidebar_key={"type": 'N', "value": 'PRESS'},
         ),
         ("wm.context_toggle", {"type": 'O', "value": 'PRESS', "shift": True},
@@ -2340,6 +2345,13 @@ def km_sequencercommon(_params):
         ("sequencer.view_toggle", {"type": 'TAB', "value": 'PRESS', "ctrl": True}, None),
     ])
 
+    if _params.select_mouse == 'LEFTMOUSE' and not _params.legacy:
+        # Quick switch to select tool, since left select can't easily
+        # select with any tool active.
+        items.extend([
+            op_tool_cycle("builtin.select_box", {"type": 'W', "value": 'PRESS'}),
+        ])
+
     return keymap
 
 
@@ -2918,6 +2930,10 @@ def km_animation_channels(params):
         *_template_items_select_actions(params, "anim.channels_select_all"),
         ("anim.channels_select_box", {"type": 'B', "value": 'PRESS'}, None),
         ("anim.channels_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+        ("anim.channels_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True,},
+         {"properties": [("extend", True)]}),
+        ("anim.channels_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True,},
+         {"properties": [("deselect", True)]}),
         # Delete.
         ("anim.channels_delete", {"type": 'X', "value": 'PRESS'}, None),
         ("anim.channels_delete", {"type": 'DEL', "value": 'PRESS'}, None),
@@ -5055,7 +5071,7 @@ def km_image_editor_tool_uv_select(params):
     return (
         "Image Editor Tool: Uv, Tweak",
         {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
-        {"items": _template_items_tool_select(params, "uv.select", "uv.cursor_set")},
+        {"items": _template_items_tool_select(params, "uv.select", "uv.cursor_set", extend="extend")},
     )
 
 
@@ -5206,7 +5222,7 @@ def km_3d_view_tool_select(params):
     return (
         "3D View Tool: Tweak",
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": _template_items_tool_select(params, "view3d.select", "view3d.cursor3d")},
+        {"items": _template_items_tool_select(params, "view3d.select", "view3d.cursor3d", extend="toggle")},
     )
 
 
@@ -5913,7 +5929,7 @@ def km_3d_view_tool_edit_gpencil_select(params):
     return (
         "3D View Tool: Edit Gpencil, Tweak",
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d")},
+        {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d", extend="toggle")},
     )
 
 
@@ -6018,7 +6034,7 @@ def km_3d_view_tool_sculpt_gpencil_select(params):
     return (
         "3D View Tool: Sculpt Gpencil, Tweak",
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d")},
+        {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d", extend="toggle")},
     )
 
 
@@ -6049,6 +6065,39 @@ def km_3d_view_tool_sculpt_gpencil_select_lasso(params):
     )
 
 
+def km_sequencer_editor_tool_select(params):
+    return (
+        "Sequencer Tool: Select",
+        {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+        {"items": [
+            ("sequencer.select", {"type": params.select_mouse, "value": 'PRESS'},
+             {"properties": [("extend", False), ("deselect_all", not params.legacy)]}),
+        ]},
+    )
+
+
+def km_sequencer_editor_tool_select_box(params):
+    return (
+        "Sequencer Tool: Select Box",
+        {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+        {"items": _template_items_tool_select_actions_simple(
+            "sequencer.select_box", type=params.tool_tweak, value='ANY',
+            properties=[("tweak", True)],
+        )},
+    )
+
+
+def km_sequencer_editor_tool_cut(params):
+    return (
+        "Sequencer Tool: Cut",
+        {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'},
+        {"items":[
+            ("sequencer.cut", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+             {"properties": [("type", 'SOFT'), ("side", 'NO_CHANGE'), ("use_cursor_position", True), ("ignore_selection", True)]}),
+        ]},
+    )
+
+
 # ------------------------------------------------------------------------------
 # Full Configuration
 
@@ -6262,6 +6311,9 @@ def generate_keymaps(params=None):
         km_3d_view_tool_sculpt_gpencil_select_box(params),
         km_3d_view_tool_sculpt_gpencil_select_circle(params),
         km_3d_view_tool_sculpt_gpencil_select_lasso(params),
+        km_sequencer_editor_tool_select(params),
+        km_sequencer_editor_tool_select_box(params),
+        km_sequencer_editor_tool_cut(params),
     ]
 
 # ------------------------------------------------------------------------------
index ceca468744352f6465d9c963f5185dd5b4d35eed..0bffd316f309f32e73f1a820271148ec399af3bc 100644 (file)
@@ -39,6 +39,9 @@ class Params:
             use_mouse_emulate_3_button=False,
     ):
         self.tool_mouse = 'LEFTMOUSE'
+        self.select_mouse = 'LEFTMOUSE'
+        self.select_mouse_value = 'CLICK'
+        self.select_tweak = 'EVT_TWEAK_L'
         self.tool_tweak = 'EVT_TWEAK_L'
         self.action_tweak = 'EVT_TWEAK_R'
         self.use_mouse_emulate_3_button = use_mouse_emulate_3_button
@@ -135,8 +138,13 @@ def _template_items_basic_tools(*, connected=False):
         op_tool_cycle("builtin.cursor", {"type": 'C', "value": 'PRESS'}),
     ]
 
-def _template_items_tool_select(params, operator, cursor_operator):
-        return [(operator, {"type": 'LEFTMOUSE', "value": 'PRESS'}, None)]
+def _template_items_tool_select(params, operator, *, extend):
+        return [
+            (operator, {"type": 'LEFTMOUSE', "value": 'PRESS'},
+             {"properties": [("deselect_all", True)]}),
+            (operator, {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+             {"properties": [(extend, True)]}),
+        ]
 
 
 def _template_items_tool_select_actions(operator, *, type, value):
@@ -622,6 +630,7 @@ def km_view3d(params):
         ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
         # Visibility.
         ("view3d.localview", {"type": 'I', "value": 'PRESS', "shift": True}, None),
+        ("view3d.localview", {"type": 'MOUSESMARTZOOM', "value": 'ANY'}, None),
         op_menu_pie("VIEW3D_MT_view_pie", {"type": 'V', "value": 'PRESS'}),
         # Navigation.
         ("view3d.rotate", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True}, None),
@@ -2182,8 +2191,11 @@ def km_animation_channels(params):
         ("anim.channels_select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
         ("anim.channels_select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, {"properties": [("action", 'DESELECT')]}),
         ("anim.channels_select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'INVERT')]}),
-        ("anim.channels_select_box", {"type": 'B', "value": 'PRESS'}, None),
         ("anim.channels_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None),
+        ("anim.channels_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True,},
+         {"properties": [("extend", True)]}),
+        ("anim.channels_select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True,},
+         {"properties": [("deselect", True)]}),
         # Delete.
         ("anim.channels_delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None),
         ("anim.channels_delete", {"type": 'DEL', "value": 'PRESS'}, None),
@@ -3565,79 +3577,19 @@ def km_transform_modal_map(_params):
 # Named are auto-generated based on the tool name and it's toolbar.
 
 
-def km_image_editor_tool_uv_move(params):
-    return (
-        "Image Editor Tool: Uv, Move",
-        {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.translate", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
-             {"properties": [("release_confirm", True)]}),
-        ]},
-    )
-
-
-def km_image_editor_tool_uv_rotate(params):
-    return (
-        "Image Editor Tool: Uv, Rotate",
-        {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.rotate", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
-             {"properties": [("release_confirm", True)]}),
-        ]},
-    )
-
-
-def km_image_editor_tool_uv_scale(params):
-    return (
-        "Image Editor Tool: Uv, Scale",
-        {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.resize", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
-             {"properties": [("release_confirm", True)]}),
-        ]},
-    )
-
-
-def km_3d_view_tool_move(params):
-    return (
-        "3D View Tool: Move",
-        {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.translate", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
-             {"properties": [("release_confirm", True)]}),
-        ]},
-    )
-
-
-def km_3d_view_tool_rotate(params):
+def km_3d_view_tool_select(params):
     return (
-        "3D View Tool: Rotate",
+        "3D View Tool: Tweak",
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.rotate", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
-             {"properties": [("release_confirm", True)]}),
-        ]},
+        {"items": _template_items_tool_select(params, "view3d.select", extend="toggle")},
     )
 
 
-def km_3d_view_tool_scale(params):
+def km_image_editor_tool_uv_select(params):
     return (
-        "3D View Tool: Scale",
-        {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.resize", {"type": 'EVT_TWEAK_M', "value": 'ANY'},
-             {"properties": [("release_confirm", True)]}),
-        ]},
-    )
-
-
-def km_3d_view_tool_transform(params):
-    return (
-        "3D View Tool: Transform",
-        {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
-        {"items": [
-            ("transform.from_gizmo", {"type": 'EVT_TWEAK_M', "value": 'ANY'}, None),
-        ]},
+        "Image Editor Tool: Uv, Tweak",
+        {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'},
+        {"items": _template_items_tool_select(params, "uv.select", extend="extend")},
     )
 
 
@@ -3759,14 +3711,8 @@ def generate_keymaps_impl(params=None):
         km_generic_gizmo_maybe_drag(params),
 
         # Tool System.
-        km_image_editor_tool_uv_move(params),
-        km_image_editor_tool_uv_rotate(params),
-        km_image_editor_tool_uv_scale(params),
-        km_3d_view_tool_transform(params),
-        km_3d_view_tool_move(params),
-        km_3d_view_tool_rotate(params),
-        km_3d_view_tool_scale(params),
-
+        km_3d_view_tool_select(params),
+        km_image_editor_tool_uv_select(params),
     ]
 
 
index 39d792bd557a9a67b08a5b7699b5817de9b9fc0a..a249599b5d763baabb1df36a2ae90df83136f02d 100644 (file)
@@ -37,6 +37,20 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
     from math import acos
     import array
 
+    # We simulate the accumulation of dirt in the creases of geometric surfaces
+    # by comparing the vertex normal to the average direction of all vertices
+    # connected to that vertex. We can also simulate surfaces being buffed or
+    # worn by testing protruding surfaces.
+    #
+    # So if the angle between the normal and geometric direction is:
+    # < 90 - dirt has accumulated in the crease
+    # > 90 - surface has been worn or buffed
+    # ~ 90 - surface is flat and is generally unworn and clean
+    #
+    # This method is limited by the complexity or lack there of in the geometry.
+    #
+    # Original code and method by Keith "Wahooney" Boshoff.
+
     vert_tone = array.array("f", [0.0]) * len(me.vertices)
 
     # create lookup table for each vertex's connected vertices (via edges)
index dc9c170c65bb86d42564b92fc4442b6374463b02..72946ed126877a7e4c78fcef11c61ebd277531e6 100644 (file)
@@ -37,7 +37,6 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
-        layout.use_property_decorate = False
 
         ob = context.object
 
@@ -45,12 +44,6 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
         layout.prop(ob, "empty_display_size", text="Size")
 
         if ob.empty_display_type == 'IMAGE':
-            layout.prop(ob, "use_empty_image_alpha")
-
-            col = layout.column()
-            col.active = ob.use_empty_image_alpha
-            col.prop(ob, "color", text="Opacity", index=3, slider=True)
-
             col = layout.column(align=True)
             col.prop(ob, "empty_image_offset", text="Offset X", index=0)
             col.prop(ob, "empty_image_offset", text="Y", index=1)
@@ -63,6 +56,25 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
             col.prop(ob, "show_empty_image_only_axis_aligned")
 
 
+class DATA_PT_empty_alpha(DataButtonsPanel, Panel):
+    bl_label = "Transparency"
+    bl_parent_id = "DATA_PT_empty"
+
+    def draw_header(self, context):
+        ob = context.object
+
+        self.layout.prop(ob, "use_empty_image_alpha", text="")
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+
+        ob = context.object
+
+        layout.active = ob.use_empty_image_alpha
+        layout.prop(ob, "color", text="Opacity", index=3, slider=True)
+
+
 class DATA_PT_empty_image(DataButtonsPanel, Panel):
     bl_label = "Image"
 
@@ -81,6 +93,7 @@ class DATA_PT_empty_image(DataButtonsPanel, Panel):
 
 classes = (
     DATA_PT_empty,
+    DATA_PT_empty_alpha,
     DATA_PT_empty_image,
 )
 
index 6f730cf3307f18717ecdcf288c063eb913ff0271..cf894b48e1e0a0b051126bf57418ace771ae659b 100644 (file)
@@ -134,17 +134,15 @@ class DATA_PT_EEVEE_light_distance(DataButtonsPanel, Panel):
         light = context.light
 
         layout = self.layout
-        layout.active = light.use_shadow
         layout.prop(light, "use_custom_distance", text="")
 
     def draw(self, context):
         layout = self.layout
         light = context.light
+        layout.active = light.use_custom_distance
         layout.use_property_split = True
 
-        col = layout.column()
-
-        col.prop(light, "cutoff_distance", text="Distance")
+        layout.prop(light, "cutoff_distance", text="Distance")
 
 
 class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
@@ -311,7 +309,8 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
     def draw(self, context):
         light = context.light
 
-        self.layout.template_curve_mapping(light, "falloff_curve", use_negative_slope=True)
+        self.layout.template_curve_mapping(
+            light, "falloff_curve", use_negative_slope=True)
 
 
 class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel):
index d4b2c39bd5eefc24c71c82267f941ccfd0578a59..197566f16f3875cde415d1732d6322b80a68514c 100644 (file)
@@ -293,7 +293,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         col = split.column()
         col.label(text="Vertex Group:")
-        col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        row = col.row(align=True)
+        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
         col = split.column()
         col.label(text="Control Object:")
         col.prop(md, "object", text="")
index 82ed701aa4cb82dab45935a444c97258bd96fd28..cd65980fc0d28368d0ad49b2bcf7bb0008e43cd9 100644 (file)
@@ -92,7 +92,7 @@ class INFO_MT_area(Menu):
 
         layout.separator()
 
-        layout.operator("screen.area_dupli", icon='DUPLICATE')
+        layout.operator("screen.area_dupli", icon='WINDOW')
 
         layout.separator()
 
index 097564444d0fea28b6155d782dc92057968ce0cb..af0c23e7892a772a688c173b10d98fe062b8d9aa 100644 (file)
@@ -30,6 +30,9 @@ from bpy.app.translations import (
 from bl_ui.properties_grease_pencil_common import (
     AnnotationDataPanel,
 )
+from bl_ui.space_toolsystem_common import (
+    ToolActivePanelHelper,
+)
 from rna_prop_ui import PropertyPanel
 
 
@@ -89,6 +92,35 @@ def draw_color_balance(layout, color_balance):
     split.template_color_picker(color_balance, "gain", value_slider=True, lock_luminosity=True, cubic=True)
 
 
+class SEQUENCER_PT_active_tool(ToolActivePanelHelper, Panel):
+    bl_space_type = 'SEQUENCE_EDITOR'
+    bl_region_type = 'UI'
+    bl_category = "Tool"
+
+
+class SEQUENCER_HT_tool_header(Header):
+    bl_space_type = 'SEQUENCE_EDITOR'
+    bl_region_type = 'TOOL_HEADER'
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.template_header()
+
+        self.draw_tool_settings(context)
+
+        # TODO: options popover.
+
+    def draw_tool_settings(self, context):
+        layout = self.layout
+
+        # Active Tool
+        # -----------
+        from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+        tool = ToolSelectPanelHelper.draw_active_tool_header(context, layout)
+        tool_mode = context.mode if tool is None else tool.mode
+
+
 class SEQUENCER_HT_header(Header):
     bl_space_type = 'SEQUENCE_EDITOR'
 
@@ -97,7 +129,10 @@ class SEQUENCER_HT_header(Header):
 
         st = context.space_data
 
-        layout.template_header()
+        show_region_tool_header = st.show_region_tool_header
+
+        if not show_region_tool_header:
+            layout.template_header()
 
         layout.prop(st, "view_type", text="")
 
@@ -226,8 +261,12 @@ class SEQUENCER_MT_view(Menu):
             # wm_keymap_item_find_props() (see #32595).
             layout.operator_context = 'INVOKE_REGION_PREVIEW'
         layout.prop(st, "show_region_ui")
+        layout.prop(st, "show_region_toolbar")
         layout.operator_context = 'INVOKE_DEFAULT'
 
+        if is_sequencer_view:
+            layout.prop(st, "show_region_hud")
+
         if st.view_type == 'SEQUENCER':
             layout.prop(st, "show_backdrop", text="Preview as Backdrop")
 
@@ -268,6 +307,7 @@ class SEQUENCER_MT_view(Menu):
             layout.operator_context = 'INVOKE_DEFAULT'
 
             layout.prop(st, "show_seconds")
+            layout.prop(st, "show_locked_time")
             layout.prop(st, "show_strip_offset")
             layout.separator()
             layout.prop(st, "show_markers")
@@ -2128,6 +2168,7 @@ class SEQUENCER_PT_custom_props(SequencerButtonsPanel, PropertyPanel, Panel):
 
 classes = (
     SEQUENCER_MT_change,
+    SEQUENCER_HT_tool_header,
     SEQUENCER_HT_header,
     SEQUENCER_MT_editor_menus,
     SEQUENCER_MT_range,
@@ -2153,7 +2194,7 @@ classes = (
     SEQUENCER_MT_strip_input,
     SEQUENCER_MT_strip_lock_mute,
     SEQUENCER_MT_context_menu,
-
+    SEQUENCER_PT_active_tool,
     SEQUENCER_PT_strip,
 
     SEQUENCER_PT_effect,
index 81ccc9216a14eb827a081ac09cf8e94191157560..b7c5dcd5437ea0c549f27419e197387615f74195 100644 (file)
@@ -30,7 +30,7 @@ class TEXT_HT_header(Header):
 
         st = context.space_data
         text = st.text
-
+        is_syntax_highlight_supported = st.is_syntax_highlight_supported()
         layout.template_header()
 
         TEXT_MT_editor_menus.draw_collapsible(context, layout)
@@ -43,7 +43,18 @@ class TEXT_HT_header(Header):
         layout.separator_spacer()
 
         row = layout.row(align=True)
-        row.template_ID(st, "text", new="text.new", unlink="text.unlink", open="text.open")
+        row.template_ID(st, "text", new="text.new",
+                        unlink="text.unlink", open="text.open")
+
+        if text:
+            is_osl = text.name.endswith((".osl", ".osl"))
+            if is_osl:
+                row.operator("node.shader_script_update",
+                             text="", icon='FILE_REFRESH')
+            else:
+                row = layout.row()
+                row.active = is_syntax_highlight_supported
+                row.operator("text.run_script", text="", icon='PLAY')
 
         layout.separator_spacer()
 
@@ -51,28 +62,10 @@ class TEXT_HT_header(Header):
         row.prop(st, "show_line_numbers", text="")
         row.prop(st, "show_word_wrap", text="")
 
-        is_syntax_highlight_supported = st.is_syntax_highlight_supported()
         syntax = row.row(align=True)
         syntax.active = is_syntax_highlight_supported
         syntax.prop(st, "show_syntax_highlight", text="")
 
-        if text:
-            text_name = text.name
-            is_osl = text_name.endswith((".osl", ".oso"))
-
-            row = layout.row()
-            if is_osl:
-                row = layout.row()
-                row.operator("node.shader_script_update")
-            else:
-                row = layout.row()
-                row.active = text_name.endswith(".py")
-                row.prop(text, "use_module")
-
-                row = layout.row()
-                row.active = is_syntax_highlight_supported
-                row.operator("text.run_script")
-
 
 class TEXT_HT_footer(Header):
     bl_space_type = 'TEXT_EDITOR'
index 05785b85dfc0d8a02b810d3e54108ca206af4168..4dc724299f01a008d2fbb24ef4154e0a6e83e8c2 100644 (file)
@@ -390,6 +390,14 @@ class ToolSelectPanelHelper:
             if tool is not None:
                 tool.refresh_from_context()
                 return tool
+        elif space_type == 'SEQUENCE_EDITOR':
+            space_data = context.space_data
+            if mode is None:
+                mode = space_data.view_type
+            tool = context.workspace.tools.from_space_sequencer(mode, create=create)
+            if tool is not None:
+                tool.refresh_from_context()
+                return tool
         return None
 
     @staticmethod
@@ -656,6 +664,8 @@ class ToolSelectPanelHelper:
             return space_type, space_data.mode
         elif space_type == 'NODE_EDITOR':
             return space_type, None
+        elif space_type == 'SEQUENCE_EDITOR':
+            return space_type, context.space_data.view_type
         else:
             return None, None
 
index 0759d37e2b8b8a600157aa01d12cf8df0e81a4e7..c1ad196b5553b8c423e02bf02b41e24ea2c13f18 100644 (file)
@@ -134,6 +134,7 @@ class _defs_view3d_generic:
             idname="builtin.measure",
             label="Measure",
             description=description,
+            cursor='CROSSHAIR',
             icon="ops.view3d.ruler",
             widget="VIEW3D_GGT_ruler",
             keymap="3D View Tool: Measure",
@@ -375,6 +376,7 @@ class _defs_view3d_select:
             label="Select Lasso",
             icon="ops.generic.select_lasso",
             widget=None,
+            cursor='DEFAULT',
             keymap="3D View Tool: Select Lasso",
             draw_settings=draw_settings,
         )
@@ -399,6 +401,7 @@ class _defs_view3d_select:
             label="Select Circle",
             icon="ops.generic.select_circle",
             widget=None,
+            cursor='DEFAULT',
             keymap="3D View Tool: Select Circle",
             draw_settings=draw_settings,
             draw_cursor=draw_cursor,
@@ -1707,6 +1710,51 @@ class _defs_node_edit:
             keymap="Node Tool: Links Cut",
         )
 
+class _defs_sequencer_generic:
+
+    @ToolDef.from_fn
+    def cut():
+        def draw_settings(_context, layout, tool):
+            props = tool.operator_properties("sequencer.cut")
+            row = layout.row()
+            row.use_property_split = False
+            row.prop(props, "type", expand=True)
+        return dict(
+            idname="builtin.cut",
+            label="Cut",
+            icon="ops.mesh.knife_tool",
+            widget=None,
+            keymap="Sequencer Tool: Cut",
+            draw_settings=draw_settings,
+        )
+
+class _defs_sequencer_select:
+    @ToolDef.from_fn
+    def select():
+        return dict(
+            idname="builtin.select",
+            label="Select",
+            icon="ops.generic.select",
+            widget=None,
+            keymap="Sequencer Tool: Select",
+        )
+    @ToolDef.from_fn
+    def box():
+        def draw_settings(_context, layout, tool):
+            props = tool.operator_properties("sequencer.select_box")
+            row = layout.row()
+            row.use_property_split = False
+            row.prop(props, "mode", text="", expand=True, icon_only=True)
+            pass
+        return dict(
+            idname="builtin.select_box",
+            label="Select Box",
+            icon="ops.generic.select_box",
+            widget=None,
+            keymap="Sequencer Tool: Select Box",
+            draw_settings=draw_settings,
+        )
+
 
 class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
     bl_space_type = 'IMAGE_EDITOR'
@@ -2158,12 +2206,71 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             *_tools_annotate,
         ],
     }
+class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, Panel):
+    bl_space_type = 'SEQUENCE_EDITOR'
+    bl_region_type = 'TOOLS'
+    bl_label = "Tools"  # not visible
+    bl_options = {'HIDE_HEADER'}
+
+    # Satisfy the 'ToolSelectPanelHelper' API.
+    keymap_prefix = "Sequence Editor Tool:"
 
+    # Default group to use as a fallback.
+    tool_fallback_id = "builtin.select"
+
+    @classmethod
+    def tools_from_context(cls, context, mode=None):
+        if mode is None:
+            if context.space_data:
+                mode = context.space_data.view_type
+        for tools in (cls._tools[None], cls._tools.get(mode, ())):
+            for item in tools:
+                if not (type(item) is ToolDef) and callable(item):
+                    yield from item(context)
+                else:
+                    yield item
+
+    @classmethod
+    def tools_all(cls):
+        yield from cls._tools.items()
+
+    _tools_select = (
+        (
+            _defs_sequencer_select.select,
+            _defs_sequencer_select.box,
+        ),
+    )
+    _tools_annotate = (
+        (
+            _defs_annotate.scribble,
+            _defs_annotate.line,
+            _defs_annotate.poly,
+            _defs_annotate.eraser,
+        ),
+    )
+
+    _tools = {
+        None: [
+        ],
+        'PREVIEW': [
+            *_tools_annotate,
+        ],
+        'SEQUENCER': [
+            *_tools_select,
+            _defs_sequencer_generic.cut,
+        ],
+        'SEQUENCER_PREVIEW': [
+            *_tools_select,
+            *_tools_annotate,
+            _defs_sequencer_generic.cut,
+        ],
+    }
 
 classes = (
     IMAGE_PT_tools_active,
     NODE_PT_tools_active,
     VIEW3D_PT_tools_active,
+    SEQUENCER_PT_tools_active,
 )
 
 if __name__ == "__main__":  # only for live edit.
index 4f35bcc29dfb01a0fab905bf0c9d057c55350f58..ad5e7b5442c4505c9789752ae7c78fc07f1e67ba 100644 (file)
@@ -997,6 +997,7 @@ class PreferenceThemeSpacePanel:
             "freestyle_face_mark",
             "split_normal",
             "bone_solid",
+            "bone_locked_weight",
             "paint_curve_pivot",
         },
         'GRAPH_EDITOR': {
index 011c2a8b39aef1abc989d5e1e1f18f464bf2d1af..19d5e3da3093776bb56ca4753a8752eb005b686b 100644 (file)
@@ -560,12 +560,23 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
             layout.operator("image.save_all_modified", text="Save All Images", icon='FILE_TICK')
 
 
+class VIEW3D_PT_mask(View3DPanel, Panel):
+    bl_category = "Tool"
+    bl_context = ".imagepaint"  # dot on purpose (access from topbar)
+    bl_label = "Masking"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        pass
+
+
 # TODO, move to space_view3d.py
 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
     bl_category = "Tool"
     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
-    bl_label = "Mask"
+    bl_label = "Stencil Mask"
     bl_options = {'DEFAULT_CLOSED'}
+    bl_parent_id = "VIEW3D_PT_mask"
     bl_ui_units_x = 14
 
     @classmethod
@@ -1192,6 +1203,7 @@ class VIEW3D_PT_tools_imagepaint_options_cavity(View3DPaintPanel, Panel):
     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
     bl_label = "Cavity Mask"
     bl_parent_id = "VIEW3D_PT_tools_imagepaint_options"
+    bl_parent_id = "VIEW3D_PT_mask"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw_header(self, context):
@@ -1876,7 +1888,7 @@ classes = (
     VIEW3D_PT_tools_curveedit_options_stroke,
     VIEW3D_PT_tools_armatureedit_options,
     VIEW3D_PT_tools_posemode_options,
-
+    
     VIEW3D_PT_slots_projectpaint,
     VIEW3D_PT_tools_brush_select,
     VIEW3D_PT_tools_brush_settings,
@@ -1886,7 +1898,6 @@ classes = (
     VIEW3D_PT_tools_brush_clone,
     TEXTURE_UL_texpaintslots,
     VIEW3D_MT_tools_projectpaint_uvlayer,
-    VIEW3D_PT_stencil_projectpaint,
     VIEW3D_PT_tools_brush_texture,
     VIEW3D_PT_tools_mask_texture,
     VIEW3D_PT_tools_brush_stroke,
@@ -1912,9 +1923,13 @@ classes = (
     VIEW3D_PT_tools_vertexpaint_symmetry_for_topbar,
     VIEW3D_PT_tools_vertexpaint_options,
 
+    VIEW3D_PT_mask,
+    VIEW3D_PT_stencil_projectpaint,
+    VIEW3D_PT_tools_imagepaint_options_cavity,
+
     VIEW3D_PT_tools_imagepaint_symmetry,
     VIEW3D_PT_tools_imagepaint_options,
-    VIEW3D_PT_tools_imagepaint_options_cavity,
+    
     VIEW3D_PT_tools_imagepaint_options_external,
     VIEW3D_MT_tools_projectpaint_stencil,
 
index 50aa13bea4f06fd8c0a8f78ff4d392dcf506cf12..3b143356c0448fa4f9598ed466edf5784ee47b6e 100644 (file)
@@ -28,9 +28,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_curve_types.h"
 #include "DNA_object_types.h"
 
index 98387be2e613e691150aafaa35552b8dc62012c1..7eaecd271f4d01f09f7f6a1d7faf56c7d543038c 100644 (file)
@@ -25,9 +25,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
index 732ceffe4673877458b4eae3414d48d61a4cc839..db4b9d82ebfbe49cc8bb46e8d998529b3fc81f68 100644 (file)
@@ -22,6 +22,8 @@
 #include "abc_mesh.h"
 #include "abc_transform.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "DNA_meta_types.h"
 #include "DNA_mesh_types.h"
@@ -35,7 +37,6 @@ extern "C" {
 #include "BKE_object.h"
 
 #include "DEG_depsgraph.h"
-#include "MEM_guardedalloc.h"
 }
 
 AbcMBallWriter::AbcMBallWriter(Main *bmain,
index edcb6263da3f85aacbc14069e05fe12711d968d7..3eee390d7d33e0a686ba42e977d03caad4f73592 100644 (file)
@@ -25,6 +25,8 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
+#include "MEM_guardedalloc.h"
+
 extern "C" {
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
@@ -46,8 +48,6 @@ extern "C" {
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 
-#include "MEM_guardedalloc.h"
-
 #include "WM_api.h"
 #include "WM_types.h"
 
index 739276dffa6c6e56fd1c6b2e1bf39efd601b7b96..c11ca7d57b93cfdb0de4074256f2c0ff779fcfed 100644 (file)
@@ -23,9 +23,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_curve_types.h"
 #include "DNA_object_types.h"
 
index 5efa8c8a446bd4e8a40bab2943c23c9f1c34347c..5519cbef53cf9d4698477a5d672eefdd0ad80ef4 100644 (file)
@@ -32,9 +32,9 @@
 #include "abc_transform.h"
 #include "abc_util.h"
 
-extern "C" {
 #include "MEM_guardedalloc.h"
 
+extern "C" {
 #include "DNA_cachefile_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_modifier_types.h"
index 10bb1bd3c9c7c8fceb436e783700cad8ed93d9f0..2b592c9e550f75889d05045a4bf04c850925921b 100644 (file)
@@ -935,10 +935,7 @@ void blf_draw_buffer__start(FontBLF *font)
 {
   FontBufInfoBLF *buf_info = &font->buf_info;
 
-  buf_info->col_char[0] = buf_info->col_init[0] * 255;
-  buf_info->col_char[1] = buf_info->col_init[1] * 255;
-  buf_info->col_char[2] = buf_info->col_init[2] * 255;
-  buf_info->col_char[3] = buf_info->col_init[3] * 255;
+  rgba_float_to_uchar(buf_info->col_char, buf_info->col_init);
 
   if (buf_info->display) {
     copy_v4_v4(buf_info->col_float, buf_info->col_init);
index 963e3158d467f4e3f005bc2379b253e93c11c35c..9da17d777cdeb6228d77a13806e5215486c71fe1 100644 (file)
@@ -249,6 +249,10 @@ typedef enum eAnimData_Recalc {
   ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM),
 } eAnimData_Recalc;
 
+bool BKE_animsys_store_rna_setting(struct PointerRNA *ptr,
+                                   const char *rna_path,
+                                   const int array_index,
+                                   struct PathResolvedRNA *r_result);
 bool BKE_animsys_read_rna_setting(struct PathResolvedRNA *anim_rna, float *r_value);
 bool BKE_animsys_write_rna_setting(struct PathResolvedRNA *anim_rna, const float value);
 
index 75e14b7efcad8629a3f548409d3d35c68b96f366..2acef7847bcd79dc149f351b2701750e1c9e86c8 100644 (file)
@@ -26,8 +26,8 @@
  *
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
-#define BLENDER_VERSION 282
-#define BLENDER_SUBVERSION 6
+#define BLENDER_VERSION 283
+#define BLENDER_SUBVERSION 2
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
@@ -36,7 +36,7 @@
 /** Can be left blank, otherwise a,b,c... etc with no quotes. */
 #define BLENDER_VERSION_CHAR
 /** alpha/beta/rc/release, docs use this. */
-#define BLENDER_VERSION_CYCLE beta
+#define BLENDER_VERSION_CYCLE alpha
 /** Optionally set to 1,2,... for example to get alpha1 or rc2. */
 #define BLENDER_VERSION_CYCLE_NUMBER
 
index 17de53be42afd88765a19a99b906759bda831cd5..2862dda8ead2d4fd87f03347e303e8f919591c04 100644 (file)
@@ -74,11 +74,11 @@ typedef struct ClothSolverResult {
  * own connectivity of the mesh based on the actual edges in the mesh.
  */
 typedef struct Cloth {
-  struct ClothVertex *verts; /* The vertices that represent this cloth. */
-  struct LinkNode *springs;  /* The springs connecting the mesh. */
-  unsigned int numsprings;   /* The count of springs. */
-  unsigned int mvert_num;    /* The number of verts == m * n. */
-  unsigned int tri_num;
+  struct ClothVertex *verts;     /* The vertices that represent this cloth. */
+  struct LinkNode *springs;      /* The springs connecting the mesh. */
+  unsigned int numsprings;       /* The count of springs. */
+  unsigned int mvert_num;        /* The number of verts == m * n. */
+  unsigned int primitive_num;    /* Number of triangles for cloth and edges for hair. */
   unsigned char old_solver_type; /* unused, only 1 solver here */
   unsigned char pad2;
   short pad3;
@@ -89,6 +89,7 @@ typedef struct Cloth {
   struct EdgeSet *edgeset;        /* used for selfcollisions */
   int last_frame;
   float initial_mesh_volume; /* Initial volume of the mesh. Used for pressure */
+  struct MEdge *edges;       /* Used for hair collisions. */
 } Cloth;
 
 /**
@@ -265,15 +266,6 @@ int cloth_bvh_collision(struct Depsgraph *depsgraph,
                         float step,
                         float dt);
 
-void cloth_find_point_contacts(struct Depsgraph *depsgraph,
-                               struct Object *ob,
-                               struct ClothModifierData *clmd,
-                               float step,
-                               float dt,
-                               ColliderContacts **r_collider_contacts,
-                               int *r_totcolliders);
-void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
-
 ////////////////////////////////////////////////
 
 /////////////////////////////////////////////////
index bd442c97000b8e5279b88621eba8092e08cb0176..153ad9bb915978eac666fa532830a234ff2cf47e 100644 (file)
@@ -29,6 +29,7 @@ struct LightProbe;
 struct Main;
 
 void BKE_lightprobe_init(struct LightProbe *probe);
+void BKE_lightprobe_type_set(struct LightProbe *probe, const short lightprobe_type);
 void *BKE_lightprobe_add(struct Main *bmain, const char *name);
 void BKE_lightprobe_copy_data(struct Main *bmain,
                               struct LightProbe *probe_dst,
index ec6ec027810f2033b8eded231a9e0d0aef49771a..54cd172655e958a6b2c23ad14a27539687447250 100644 (file)
@@ -66,7 +66,6 @@ void BKE_object_free_curve_cache(struct Object *ob);
 
 void BKE_object_free(struct Object *ob);
 void BKE_object_free_derived_caches(struct Object *ob);
-void BKE_object_free_derived_mesh_caches(struct Object *ob);
 void BKE_object_free_caches(struct Object *object);
 
 void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd);
index b1186564dbd2bff3c8cdf524c0d4cf382ce2aab7..bc312c7bb2b5cec0e0488bacb9b52a7dc288def8 100644 (file)
@@ -507,6 +507,7 @@ enum {
   SEQ_SIDE_LEFT,
   SEQ_SIDE_RIGHT,
   SEQ_SIDE_BOTH,
+  SEQ_SIDE_NO_CHANGE,
 };
 int BKE_sequencer_find_next_prev_edit(struct Scene *scene,
                                       int cfra,
index 32420e2e89476e010171026a0539a67d9b2c7ae0..be6622e5d428fa02d1d438a3a76ac82486bc5b8a 100644 (file)
@@ -1665,11 +1665,11 @@ void BKE_keyingsets_free(ListBase *list)
 /* ***************************************** */
 /* Evaluation Data-Setting Backend */
 
-static bool animsys_store_rna_setting(PointerRNA *ptr,
-                                      /* typically 'fcu->rna_path', 'fcu->array_index' */
-                                      const char *rna_path,
-                                      const int array_index,
-                                      PathResolvedRNA *r_result)
+bool BKE_animsys_store_rna_setting(PointerRNA *ptr,
+                                   /* typically 'fcu->rna_path', 'fcu->array_index' */
+                                   const char *rna_path,
+                                   const int array_index,
+                                   PathResolvedRNA *r_result)
 {
   bool success = false;
   const char *path = rna_path;
@@ -1880,7 +1880,7 @@ static void animsys_write_orig_anim_rna(PointerRNA *ptr,
   }
   PathResolvedRNA orig_anim_rna;
   /* TODO(sergey): Should be possible to cache resolved path in dependency graph somehow. */
-  if (animsys_store_rna_setting(&ptr_orig, rna_path, array_index, &orig_anim_rna)) {
+  if (BKE_animsys_store_rna_setting(&ptr_orig, rna_path, array_index, &orig_anim_rna)) {
     BKE_animsys_write_rna_setting(&orig_anim_rna, value);
   }
 }
@@ -1910,7 +1910,7 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr,
       continue;
     }
     PathResolvedRNA anim_rna;
-    if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
+    if (BKE_animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
       const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
       BKE_animsys_write_rna_setting(&anim_rna, curval);
       if (flush_to_original) {
@@ -1944,7 +1944,7 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
          * NOTE: for 'layering' option later on, we should check if we should remove old value
          * before adding new to only be done when drivers only changed. */
         PathResolvedRNA anim_rna;
-        if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
+        if (BKE_animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
           const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
           ok = BKE_animsys_write_rna_setting(&anim_rna, curval);
         }
@@ -2023,7 +2023,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
     /* check if this curve should be skipped */
     if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0 && !BKE_fcurve_is_empty(fcu)) {
       PathResolvedRNA anim_rna;
-      if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
+      if (BKE_animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
         const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
         BKE_animsys_write_rna_setting(&anim_rna, curval);
       }
@@ -3803,7 +3803,7 @@ static void animsys_evaluate_overrides(PointerRNA *ptr, AnimData *adt)
   /* for each override, simply execute... */
   for (aor = adt->overrides.first; aor; aor = aor->next) {
     PathResolvedRNA anim_rna;
-    if (animsys_store_rna_setting(ptr, aor->rna_path, aor->array_index, &anim_rna)) {
+    if (BKE_animsys_store_rna_setting(ptr, aor->rna_path, aor->array_index, &anim_rna)) {
       BKE_animsys_write_rna_setting(&anim_rna, aor->value);
     }
   }
@@ -4125,7 +4125,7 @@ void BKE_animsys_eval_driver(Depsgraph *depsgraph, ID *id, int driver_index, FCu
       // printf("\told val = %f\n", fcu->curval);
 
       PathResolvedRNA anim_rna;
-      if (animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
+      if (BKE_animsys_store_rna_setting(&id_ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
         /* Evaluate driver, and write results to COW-domain destination */
         const float ctime = DEG_get_ctime(depsgraph);
         const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
index c26800aefba37cff3d91f1eb28b89498c01bf3d7..7332c3e0d438b4ef1a14d4703b4265cb2f461020 100644 (file)
@@ -190,22 +190,36 @@ static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
   vt = cloth->tri;
 
   /* in the moment, return zero if no faces there */
-  if (!cloth->tri_num) {
+  if (!cloth->primitive_num) {
     return NULL;
   }
 
   /* create quadtree with k=26 */
-  bvhtree = BLI_bvhtree_new(cloth->tri_num, epsilon, 4, 26);
+  bvhtree = BLI_bvhtree_new(cloth->primitive_num, epsilon, 4, 26);
 
   /* fill tree */
-  for (i = 0; i < cloth->tri_num; i++, vt++) {
-    float co[3][3];
+  if (clmd->hairdata == NULL) {
+    for (i = 0; i < cloth->primitive_num; i++, vt++) {
+      float co[3][3];
 
-    copy_v3_v3(co[0], verts[vt->tri[0]].xold);
-    copy_v3_v3(co[1], verts[vt->tri[1]].xold);
-    copy_v3_v3(co[2], verts[vt->tri[2]].xold);
+      copy_v3_v3(co[0], verts[vt->tri[0]].xold);
+      copy_v3_v3(co[1], verts[vt->tri[1]].xold);
+      copy_v3_v3(co[2], verts[vt->tri[2]].xold);
 
-    BLI_bvhtree_insert(bvhtree, i, co[0], 3);
+      BLI_bvhtree_insert(bvhtree, i, co[0], 3);
+    }
+  }
+  else {
+    MEdge *edges = cloth->edges;
+
+    for (i = 0; i < cloth->primitive_num; i++) {
+      float co[2][3];
+
+      copy_v3_v3(co[0], verts[edges[i].v1].xold);
+      copy_v3_v3(co[1], verts[edges[i].v2].xold);
+
+      BLI_bvhtree_insert(bvhtree, i, co[0], 2);
+    }
   }
 
   /* balance tree */
@@ -222,6 +236,8 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
   ClothVertex *verts = cloth->verts;
   const MVertTri *vt;
 
+  BLI_assert(!(clmd->hairdata != NULL && self));
+
   if (self) {
     bvhtree = cloth->bvhselftree;
   }
@@ -236,39 +252,59 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
   vt = cloth->tri;
 
   /* update vertex position in bvh tree */
-  if (verts && vt) {
-    for (i = 0; i < cloth->tri_num; i++, vt++) {
-      float co[3][3], co_moving[3][3];
-      bool ret;
-
-      /* copy new locations into array */
-      if (moving) {
-        copy_v3_v3(co[0], verts[vt->tri[0]].txold);
-        copy_v3_v3(co[1], verts[vt->tri[1]].txold);
-        copy_v3_v3(co[2], verts[vt->tri[2]].txold);
-
-        /* update moving positions */
-        copy_v3_v3(co_moving[0], verts[vt->tri[0]].tx);
-        copy_v3_v3(co_moving[1], verts[vt->tri[1]].tx);
-        copy_v3_v3(co_moving[2], verts[vt->tri[2]].tx);
-
-        ret = BLI_bvhtree_update_node(bvhtree, i, co[0], co_moving[0], 3);
-      }
-      else {
-        copy_v3_v3(co[0], verts[vt->tri[0]].tx);
-        copy_v3_v3(co[1], verts[vt->tri[1]].tx);
-        copy_v3_v3(co[2], verts[vt->tri[2]].tx);
+  if (clmd->hairdata == NULL) {
+    if (verts && vt) {
+      for (i = 0; i < cloth->primitive_num; i++, vt++) {
+        float co[3][3], co_moving[3][3];
+        bool ret;
+
+        /* copy new locations into array */
+        if (moving) {
+          copy_v3_v3(co[0], verts[vt->tri[0]].txold);
+          copy_v3_v3(co[1], verts[vt->tri[1]].txold);
+          copy_v3_v3(co[2], verts[vt->tri[2]].txold);
+
+          /* update moving positions */
+          copy_v3_v3(co_moving[0], verts[vt->tri[0]].tx);
+          copy_v3_v3(co_moving[1], verts[vt->tri[1]].tx);
+          copy_v3_v3(co_moving[2], verts[vt->tri[2]].tx);
+
+          ret = BLI_bvhtree_update_node(bvhtree, i, co[0], co_moving[0], 3);
+        }
+        else {
+          copy_v3_v3(co[0], verts[vt->tri[0]].tx);
+          copy_v3_v3(co[1], verts[vt->tri[1]].tx);
+          copy_v3_v3(co[2], verts[vt->tri[2]].tx);
 
-        ret = BLI_bvhtree_update_node(bvhtree, i, co[0], NULL, 3);
-      }
+          ret = BLI_bvhtree_update_node(bvhtree, i, co[0], NULL, 3);
+        }
 
-      /* check if tree is already full */
-      if (ret == false) {
-        break;
+        /* check if tree is already full */
+        if (ret == false) {
+          break;
+        }
       }
+
+      BLI_bvhtree_update_tree(bvhtree);
     }
+  }
+  else {
+    if (verts) {
+      MEdge *edges = cloth->edges;
+
+      for (i = 0; i < cloth->primitive_num; i++) {
+        float co[2][3];
 
-    BLI_bvhtree_update_tree(bvhtree);
+        copy_v3_v3(co[0], verts[edges[i].v1].tx);
+        copy_v3_v3(co[1], verts[edges[i].v2].tx);
+
+        if (!BLI_bvhtree_update_node(bvhtree, i, co[0], NULL, 2)) {
+          break;
+        }
+      }
+
+      BLI_bvhtree_update_tree(bvhtree);
+    }
   }
 }
 
@@ -900,7 +936,13 @@ static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh)
   }
 
   /* save face information */
-  clmd->clothObject->tri_num = looptri_num;
+  if (clmd->hairdata == NULL) {
+    clmd->clothObject->primitive_num = looptri_num;
+  }
+  else {
+    clmd->clothObject->primitive_num = mesh->totedge;
+  }
+
   clmd->clothObject->tri = MEM_mallocN(sizeof(MVertTri) * looptri_num, "clothLoopTris");
   if (clmd->clothObject->tri == NULL) {
     cloth_free_modifier(clmd);
@@ -910,6 +952,8 @@ static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh)
   }
   BKE_mesh_runtime_verttri_from_looptri(clmd->clothObject->tri, mloop, looptri, looptri_num);
 
+  clmd->clothObject->edges = mesh->medge;
+
   /* Free the springs since they can't be correct if the vertices
    * changed.
    */
index 220b9417a6c2df5e5f6b10426931182f9dad88c1..5db42618a9e169b5fbd741c218482ebf064139ef 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_blenlib.h"
+#include "BLI_linklist.h"
 #include "BLI_math.h"
 #include "BLI_task.h"
 #include "BLI_threads.h"
@@ -193,17 +194,17 @@ BLI_INLINE int next_ind(int i)
   return (++i < 3) ? i : 0;
 }
 
-static float compute_collision_point(float a1[3],
-                                     const float a2[3],
-                                     const float a3[3],
-                                     const float b1[3],
-                                     const float b2[3],
-                                     const float b3[3],
-                                     bool culling,
-                                     bool use_normal,
-                                     float r_a[3],
-                                     float r_b[3],
-                                     float r_vec[3])
+static float compute_collision_point_tri_tri(const float a1[3],
+                                             const float a2[3],
+                                             const float a3[3],
+                                             const float b1[3],
+                                             const float b2[3],
+                                             const float b3[3],
+                                             bool culling,
+                                             bool use_normal,
+                                             float r_a[3],
+                                             float r_b[3],
+                                             float r_vec[3])
 {
   float a[3][3];
   float b[3][3];
@@ -423,6 +424,179 @@ static float compute_collision_point(float a1[3],
   return dist;
 }
 
+static float compute_collision_point_edge_tri(const float a1[3],
+                                              const float a2[3],
+                                              const float b1[3],
+                                              const float b2[3],
+                                              const float b3[3],
+                                              bool culling,
+                                              bool use_normal,
+                                              float r_a[3],
+                                              float r_b[3],
+                                              float r_vec[3])
+{
+  float a[2][3];
+  float b[3][3];
+  float dist = FLT_MAX;
+  float tmp_co1[3], tmp_co2[3];
+  float isect_a[3];
+  bool isect = false;
+  float tmp, tmp_vec[3];
+  float normal[3], cent[3];
+  bool backside = false;
+
+  copy_v3_v3(a[0], a1);
+  copy_v3_v3(a[1], a2);
+
+  copy_v3_v3(b[0], b1);
+  copy_v3_v3(b[1], b2);
+  copy_v3_v3(b[2], b3);
+
+  normal_tri_v3(normal, b[0], b[1], b[2]);
+
+  /* Find intersection. */
+  if (isect_line_segment_tri_v3(a[0], a[1], b[0], b[1], b[2], &tmp, NULL)) {
+    interp_v3_v3v3(isect_a, a[0], a[1], tmp);
+    isect = true;
+  }
+
+  /* Determine collision side. */
+  if (culling) {
+    if (isect) {
+      backside = true;
+    }
+    else {
+      mid_v3_v3v3v3(cent, b[0], b[1], b[2]);
+
+      for (int i = 0; i < 2; i++) {
+        sub_v3_v3v3(tmp_vec, a[i], cent);
+        if (dot_v3v3(tmp_vec, normal) < 0.0f) {
+          backside = true;
+          break;
+        }
+      }
+    }
+  }
+
+  if (isect) {
+    /* Edge intersection. */
+    copy_v3_v3(r_a, isect_a);
+    copy_v3_v3(r_b, isect_a);
+
+    copy_v3_v3(r_vec, normal);
+
+    return 0.0f;
+  }
+
+  if (backside) {
+    float maxdist = 0.0f;
+    bool found = false;
+
+    /* Point projections. */
+    for (int i = 0; i < 2; i++) {
+      if (isect_ray_tri_v3(a[i], normal, b[0], b[1], b[2], &tmp, NULL)) {
+        if (tmp > maxdist) {
+          maxdist = tmp;
+          copy_v3_v3(r_a, a[i]);
+          madd_v3_v3v3fl(r_b, a[i], normal, tmp);
+          found = true;
+        }
+      }
+    }
+
+    /* Edge projections. */
+    for (int i = 0; i < 3; i++) {
+      float dir[3];
+
+      sub_v3_v3v3(tmp_vec, b[next_ind(i)], b[i]);
+      cross_v3_v3v3(dir, tmp_vec, normal);
+
+      if (isect_line_plane_v3(tmp_co1, a[0], a[1], b[i], dir) &&
+          point_in_slice_seg(tmp_co1, a[0], a[1]) &&
+          point_in_slice_seg(tmp_co1, b[i], b[next_ind(i)])) {
+        closest_to_line_v3(tmp_co2, tmp_co1, b[i], b[next_ind(i)]);
+        sub_v3_v3v3(tmp_vec, tmp_co1, tmp_co2);
+        tmp = len_v3(tmp_vec);
+
+        if ((tmp > maxdist) && (dot_v3v3(tmp_vec, normal) < 0.0f)) {
+          maxdist = tmp;
+          copy_v3_v3(r_a, tmp_co1);
+          copy_v3_v3(r_b, tmp_co2);
+          found = true;
+        }
+      }
+    }
+
+    /* If no point is found, will fallback onto regular proximity test below. */
+    if (found) {
+      sub_v3_v3v3(r_vec, r_b, r_a);
+
+      if (use_normal) {
+        if (dot_v3v3(normal, r_vec) >= 0.0f) {
+          copy_v3_v3(r_vec, normal);
+        }
+        else {
+          negate_v3_v3(r_vec, normal);
+        }
+      }
+
+      return 0.0f;
+    }
+  }
+
+  /* Closest point. */
+  for (int i = 0; i < 2; i++) {
+    closest_on_tri_to_point_v3(tmp_co1, a[i], b[0], b[1], b[2]);
+    tmp = len_squared_v3v3(tmp_co1, a[i]);
+
+    if (tmp < dist) {
+      dist = tmp;
+      copy_v3_v3(r_a, a[i]);
+      copy_v3_v3(r_b, tmp_co1);
+    }
+  }
+
+  /* Closest edge. */
+  if (!isect) {
+    for (int j = 0; j < 3; j++) {
+      isect_seg_seg_v3(a[0], a[1], b[j], b[next_ind(j)], tmp_co1, tmp_co2);
+      tmp = len_squared_v3v3(tmp_co1, tmp_co2);
+
+      if (tmp < dist) {
+        dist = tmp;
+        copy_v3_v3(r_a, tmp_co1);
+        copy_v3_v3(r_b, tmp_co2);
+      }
+    }
+  }
+
+  if (isect) {
+    sub_v3_v3v3(r_vec, r_b, r_a);
+    dist = 0.0f;
+  }
+  else {
+    sub_v3_v3v3(r_vec, r_a, r_b);
+    dist = sqrtf(dist);
+  }
+
+  if (culling && use_normal) {
+    copy_v3_v3(r_vec, normal);
+  }
+  else if (use_normal) {
+    if (dot_v3v3(normal, r_vec) >= 0.0f) {
+      copy_v3_v3(r_vec, normal);
+    }
+    else {
+      negate_v3_v3(r_vec, normal);
+    }
+  }
+  else if (culling && (dot_v3v3(r_vec, normal) < 0.0f)) {
+    return FLT_MAX;
+  }
+
+  return dist;
+}
+
 // w3 is not perfect
 static void collision_compute_barycentric(
     const float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3)
@@ -494,6 +668,7 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
   float v1[3], v2[3], relativeVelocity[3];
   float magrelVel;
   float epsilon2 = BLI_bvhtree_get_epsilon(collmd->bvhtree);
+  const bool is_hair = (clmd->hairdata != NULL);
 
   cloth1 = clmd->clothObject;
 
@@ -509,14 +684,32 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
       continue;
     }
 
-    /* Compute barycentric coordinates for both collision points. */
-    collision_compute_barycentric(collpair->pa,
-                                  cloth1->verts[collpair->ap1].tx,
-                                  cloth1->verts[collpair->ap2].tx,
-                                  cloth1->verts[collpair->ap3].tx,
-                                  &w1,
-                                  &w2,
-                                  &w3);
+    /* Compute barycentric coordinates and relative "velocity" for both collision points. */
+    if (is_hair) {
+      w2 = line_point_factor_v3(
+          collpair->pa, cloth1->verts[collpair->ap1].tx, cloth1->verts[collpair->ap2].tx);
+
+      w1 = 1.0f - w2;
+
+      interp_v3_v3v3(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, w2);
+    }
+    else {
+      collision_compute_barycentric(collpair->pa,
+                                    cloth1->verts[collpair->ap1].tx,
+                                    cloth1->verts[collpair->ap2].tx,
+                                    cloth1->verts[collpair->ap3].tx,
+                                    &w1,
+                                    &w2,
+                                    &w3);
+
+      collision_interpolateOnTriangle(v1,
+                                      cloth1->verts[collpair->ap1].tv,
+                                      cloth1->verts[collpair->ap2].tv,
+                                      cloth1->verts[collpair->ap3].tv,
+                                      w1,
+                                      w2,
+                                      w3);
+    }
 
     collision_compute_barycentric(collpair->pb,
                                   collmd->current_xnew[collpair->bp1].co,
@@ -526,15 +719,6 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
                                   &u2,
                                   &u3);
 
-    /* Calculate relative "velocity". */
-    collision_interpolateOnTriangle(v1,
-                                    cloth1->verts[collpair->ap1].tv,
-                                    cloth1->verts[collpair->ap2].tv,
-                                    cloth1->verts[collpair->ap3].tv,
-                                    w1,
-                                    w2,
-                                    w3);
-
     collision_interpolateOnTriangle(v2,
                                     collmd->current_v[collpair->bp1].co,
                                     collmd->current_v[collpair->bp2].co,
@@ -576,7 +760,10 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
 
         VECADDMUL(i1, vrel_t_pre, w1 * impulse);
         VECADDMUL(i2, vrel_t_pre, w2 * impulse);
-        VECADDMUL(i3, vrel_t_pre, w3 * impulse);
+
+        if (!is_hair) {
+          VECADDMUL(i3, vrel_t_pre, w3 * impulse);
+        }
       }
 
       /* Apply velocity stopping impulse. */
@@ -588,8 +775,10 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
       VECADDMUL(i2, collpair->normal, w2 * impulse);
       cloth1->verts[collpair->ap2].impulse_count++;
 
-      VECADDMUL(i3, collpair->normal, w3 * impulse);
-      cloth1->verts[collpair->ap3].impulse_count++;
+      if (!is_hair) {
+        VECADDMUL(i3, collpair->normal, w3 * impulse);
+        cloth1->verts[collpair->ap3].impulse_count++;
+      }
 
       time_multiplier = 1.0f / (clmd->sim_parms->dt * clmd->sim_parms->timescale);
 
@@ -609,7 +798,10 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
 
         VECADDMUL(i1, collpair->normal, impulse);
         VECADDMUL(i2, collpair->normal, impulse);
-        VECADDMUL(i3, collpair->normal, impulse);
+
+        if (!is_hair) {
+          VECADDMUL(i3, collpair->normal, impulse);
+        }
       }
 
       result = 1;
@@ -627,11 +819,17 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
 
         VECADDMUL(i1, collpair->normal, w1 * impulse);
         VECADDMUL(i2, collpair->normal, w2 * impulse);
-        VECADDMUL(i3, collpair->normal, w3 * impulse);
+
+        if (!is_hair) {
+          VECADDMUL(i3, collpair->normal, w3 * impulse);
+        }
 
         cloth1->verts[collpair->ap1].impulse_count++;
         cloth1->verts[collpair->ap2].impulse_count++;
-        cloth1->verts[collpair->ap3].impulse_count++;
+
+        if (!is_hair) {
+          cloth1->verts[collpair->ap3].impulse_count++;
+        }
 
         result = 1;
       }
@@ -656,9 +854,11 @@ static int cloth_collision_response_static(ClothModifierData *clmd,
           cloth1->verts[collpair->ap2].impulse[j] = i2[j];
         }
 
-        if (cloth1->verts[collpair->ap3].impulse_count > 0 &&
-            ABS(cloth1->verts[collpair->ap3].impulse[j]) < ABS(i3[j])) {
-          cloth1->verts[collpair->ap3].impulse[j] = i3[j];
+        if (!is_hair) {
+          if (cloth1->verts[collpair->ap3].impulse_count > 0 &&
+              ABS(cloth1->verts[collpair->ap3].impulse[j]) < ABS(i3[j])) {
+            cloth1->verts[collpair->ap3].impulse[j] = i3[j];
+          }
         }
       }
     }
@@ -875,17 +1075,17 @@ static void cloth_collision(void *__restrict userdata,
   tri_b = &collmd->tri[data->overlap[index].indexB];
 
   /* Compute distance and normal. */
-  distance = compute_collision_point(verts1[tri_a->tri[0]].tx,
-                                     verts1[tri_a->tri[1]].tx,
-                                     verts1[tri_a->tri[2]].tx,
-                                     collmd->current_xnew[tri_b->tri[0]].co,
-                                     collmd->current_xnew[tri_b->tri[1]].co,
-                                     collmd->current_xnew[tri_b->tri[2]].co,
-                                     data->culling,
-                                     data->use_normal,
-                                     pa,
-                                     pb,
-                                     vect);
+  distance = compute_collision_point_tri_tri(verts1[tri_a->tri[0]].tx,
+                                             verts1[tri_a->tri[1]].tx,
+                                             verts1[tri_a->tri[2]].tx,
+                                             collmd->current_xnew[tri_b->tri[0]].co,
+                                             collmd->current_xnew[tri_b->tri[1]].co,
+                                             collmd->current_xnew[tri_b->tri[2]].co,
+                                             data->culling,
+                                             data->use_normal,
+                                             pa,
+                                             pb,
+                                             vect);
 
   if ((distance <= (epsilon1 + epsilon2 + ALMOST_ZERO)) && (len_squared_v3(vect) > ALMOST_ZERO)) {
     collpair[index].ap1 = tri_a->tri[0];
@@ -946,17 +1146,17 @@ static void cloth_selfcollision(void *__restrict userdata,
   }
 
   /* Compute distance and normal. */
-  distance = compute_collision_point(verts1[tri_a->tri[0]].tx,
-                                     verts1[tri_a->tri[1]].tx,
-                                     verts1[tri_a->tri[2]].tx,
-                                     verts1[tri_b->tri[0]].tx,
-                                     verts1[tri_b->tri[1]].tx,
-                                     verts1[tri_b->tri[2]].tx,
-                                     false,
-                                     false,
-                                     pa,
-                                     pb,
-                                     vect);
+  distance = compute_collision_point_tri_tri(verts1[tri_a->tri[0]].tx,
+                                             verts1[tri_a->tri[1]].tx,
+                                             verts1[tri_a->tri[2]].tx,
+                                             verts1[tri_b->tri[0]].tx,
+                                             verts1[tri_b->tri[1]].tx,
+                                             verts1[tri_b->tri[2]].tx,
+                                             false,
+                                             false,
+                                             pa,
+                                             pb,
+                                             vect);
 
   if ((distance <= (epsilon * 2.0f + ALMOST_ZERO)) && (len_squared_v3(vect) > ALMOST_ZERO)) {
     collpair[index].ap1 = tri_a->tri[0];
@@ -983,6 +1183,64 @@ static void cloth_selfcollision(void *__restrict userdata,
   }
 }
 
+static void hair_collision(void *__restrict userdata,
+                           const int index,
+                           const TaskParallelTLS *__restrict UNUSED(tls))
+{
+  ColDetectData *data = (ColDetectData *)userdata;
+
+  ClothModifierData *clmd = data->clmd;
+  CollisionModifierData *collmd = data->collmd;
+  CollPair *collpair = data->collisions;
+  const MVertTri *tri_coll;
+  const MEdge *edge_coll;
+  ClothVertex *verts1 = clmd->clothObject->verts;
+  float distance = 0.0f;
+  float epsilon1 = clmd->coll_parms->epsilon;
+  float epsilon2 = BLI_bvhtree_get_epsilon(collmd->bvhtree);
+  float pa[3], pb[3], vect[3];
+
+  /* TODO: This is not efficient. Might be wise to instead build an array before iterating, to
+   * avoid walking the list every time. */
+  edge_coll = &clmd->clothObject->edges[data->overlap[index].indexA];
+  tri_coll = &collmd->tri[data->overlap[index].indexB];
+
+  /* Compute distance and normal. */
+  distance = compute_collision_point_edge_tri(verts1[edge_coll->v1].tx,
+                                              verts1[edge_coll->v2].tx,
+                                              collmd->current_x[tri_coll->tri[0]].co,
+                                              collmd->current_x[tri_coll->tri[1]].co,
+                                              collmd->current_x[tri_coll->tri[2]].co,
+                                              data->culling,
+                                              data->use_normal,
+                                              pa,
+                                              pb,
+                                              vect);
+
+  if ((distance <= (epsilon1 + epsilon2 + ALMOST_ZERO)) && (len_squared_v3(vect) > ALMOST_ZERO)) {
+    collpair[index].ap1 = edge_coll->v1;
+    collpair[index].ap2 = edge_coll->v2;
+
+    collpair[index].bp1 = tri_coll->tri[0];
+    collpair[index].bp2 = tri_coll->tri[1];
+    collpair[index].bp3 = tri_coll->tri[2];
+
+    copy_v3_v3(collpair[index].pa, pa);
+    copy_v3_v3(collpair[index].pb, pb);
+    copy_v3_v3(collpair[index].vector, vect);
+
+    normalize_v3_v3(collpair[index].normal, collpair[index].vector);
+
+    collpair[index].distance = distance;
+    collpair[index].flag = 0;
+
+    data->collided = true;
+  }
+  else {
+    collpair[index].flag = COLLISION_INACTIVE;
+  }
+}
+
 static void add_collision_object(ListBase *relations,
                                  Object *ob,
                                  int level,
@@ -1148,6 +1406,7 @@ static bool cloth_bvh_objcollisions_nearcheck(ClothModifierData *clmd,
                                               bool culling,
                                               bool use_normal)
 {
+  const bool is_hair = (clmd->hairdata != NULL);
   *collisions = (CollPair *)MEM_mallocN(sizeof(CollPair) * numresult, "collision array");
 
   ColDetectData data = {
@@ -1163,7 +1422,8 @@ static bool cloth_bvh_objcollisions_nearcheck(ClothModifierData *clmd,
   TaskParallelSettings settings;
   BLI_parallel_range_settings_defaults(&settings);
   settings.use_threading = true;
-  BLI_task_parallel_range(0, numresult, &data, cloth_collision, &settings);
+  BLI_task_parallel_range(
+      0, numresult, &data, is_hair ? hair_collision : cloth_collision, &settings);
 
   return data.collided;
 }
@@ -1308,8 +1568,14 @@ int cloth_bvh_collision(
   if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
     bvhtree_update_from_cloth(clmd, false, false);
 
-    collobjs = BKE_collision_objects_create(
-        depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
+    /* Enable self collision if this is a hair sim */
+    const bool is_hair = (clmd->hairdata != NULL);
+
+    collobjs = BKE_collision_objects_create(depsgraph,
+                                            is_hair ? NULL : ob,
+                                            clmd->coll_parms->group,
+                                            &numcollobj,
+                                            eModifierType_Collision);
 
     if (collobjs) {
       coll_counts_obj = MEM_callocN(sizeof(uint) * numcollobj, "CollCounts");
@@ -1474,286 +1740,3 @@ void collision_get_collider_velocity(float vel_old[3],
   /* XXX assume constant velocity of the collider for now */
   copy_v3_v3(vel_old, vel_new);
 }
-
-BLI_INLINE bool cloth_point_face_collision_params(const float p1[3],
-                                                  const float p2[3],
-                                                  const float v0[3],
-                                                  const float v1[3],
-                                                  const float v2[3],
-                                                  float r_nor[3],
-                                                  float *r_lambda,
-                                                  float r_w[3])
-{
-  float edge1[3], edge2[3], p2face[3], p1p2[3], v0p2[3];
-  float nor_v0p2, nor_p1p2;
-
-  sub_v3_v3v3(edge1, v1, v0);
-  sub_v3_v3v3(edge2, v2, v0);
-  cross_v3_v3v3(r_nor, edge1, edge2);
-  normalize_v3(r_nor);
-
-  sub_v3_v3v3(v0p2, p2, v0);
-  nor_v0p2 = dot_v3v3(v0p2, r_nor);
-  madd_v3_v3v3fl(p2face, p2, r_nor, -nor_v0p2);
-  interp_weights_tri_v3(r_w, v0, v1, v2, p2face);
-
-  sub_v3_v3v3(p1p2, p2, p1);
-  nor_p1p2 = dot_v3v3(p1p2, r_nor);
-  *r_lambda = (nor_p1p2 != 0.0f ? nor_v0p2 / nor_p1p2 : 0.0f);
-
-  return r_w[1] >= 0.0f && r_w[2] >= 0.0f && r_w[1] + r_w[2] <= 1.0f;
-}
-
-static CollPair *cloth_point_collpair(float p1[3],
-                                      const float p2[3],
-                                      const MVert *mverts,
-                                      int bp1,
-                                      int bp2,
-                                      int bp3,
-                                      int index_cloth,
-                                      int index_coll,
-                                      float epsilon,
-                                      CollPair *collpair)
-{
-  const float *co1 = mverts[bp1].co, *co2 = mverts[bp2].co, *co3 = mverts[bp3].co;
-  float lambda /*, distance1 */, distance2;
-  float facenor[3], v1p1[3], v1p2[3];
-  float w[3];
-
-  if (!cloth_point_face_collision_params(p1, p2, co1, co2, co3, facenor, &lambda, w)) {
-    return collpair;
-  }
-
-  sub_v3_v3v3(v1p1, p1, co1);
-  //  distance1 = dot_v3v3(v1p1, facenor);
-  sub_v3_v3v3(v1p2, p2, co1);
-  distance2 = dot_v3v3(v1p2, facenor);
-  //  if (distance2 > epsilon || (distance1 < 0.0f && distance2 < 0.0f))
-  if (distance2 > epsilon) {
-    return collpair;
-  }
-
-  collpair->face1 = index_cloth; /* XXX actually not a face, but equivalent index for point */
-  collpair->face2 = index_coll;
-  collpair->ap1 = index_cloth;
-  collpair->ap2 = collpair->ap3 = -1; /* unused */
-  collpair->bp1 = bp1;
-  collpair->bp2 = bp2;
-  collpair->bp3 = bp3;
-
-  /* note: using the second point here, which is
-   * the current updated position that needs to be corrected
-   */
-  copy_v3_v3(collpair->pa, p2);
-  collpair->distance = distance2;
-  mul_v3_v3fl(collpair->vector, facenor, -distance2);
-
-  interp_v3_v3v3v3(collpair->pb, co1, co2, co3, w);
-
-  copy_v3_v3(collpair->normal, facenor);
-  collpair->time = lambda;
-  collpair->flag = 0;
-
-  collpair++;
-  return collpair;
-}
-
-/* Determines collisions on overlap,
- * collisions are written to collpair[i] and collision+number_collision_found is returned. */
-static CollPair *cloth_point_collision(ModifierData *md1,
-                                       ModifierData *md2,
-                                       BVHTreeOverlap *overlap,
-                                       float epsilon,
-                                       CollPair *collpair,
-                                       float UNUSED(dt))
-{
-  ClothModifierData *clmd = (ClothModifierData *)md1;
-  CollisionModifierData *collmd = (CollisionModifierData *)md2;
-  /* Cloth *cloth = clmd->clothObject; */ /* UNUSED */
-  ClothVertex *vert = NULL;
-  const MVertTri *vt;
-  const MVert *mverts = collmd->current_x;
-
-  vert = &clmd->clothObject->verts[overlap->indexA];
-  vt = &collmd->tri[overlap->indexB];
-
-  collpair = cloth_point_collpair(vert->tx,
-                                  vert->x,
-                                  mverts,
-                                  vt->tri[0],
-                                  vt->tri[1],
-                                  vt->tri[2],
-                                  overlap->indexA,
-                                  overlap->indexB,
-                                  epsilon,
-                                  collpair);
-
-  return collpair;
-}
-
-static void cloth_points_objcollisions_nearcheck(ClothModifierData *clmd,
-                                                 CollisionModifierData *collmd,
-                                                 CollPair **collisions,
-                                                 CollPair **collisions_index,
-                                                 int numresult,
-                                                 BVHTreeOverlap *overlap,
-                                                 float epsilon,
-                                                 double dt)
-{
-  int i;
-
-  /* can return 2 collisions in total */
-  *collisions = (CollPair *)MEM_mallocN(sizeof(CollPair) * numresult * 2, "collision array");
-  *collisions_index = *collisions;
-
-  for (i = 0; i < numresult; i++) {
-    *collisions_index = cloth_point_collision(
-        (ModifierData *)clmd, (ModifierData *)collmd, overlap + i, epsilon, *collisions_index, dt);
-  }
-}
-
-void cloth_find_point_contacts(Depsgraph *depsgraph,
-                               Object *ob,
-                               ClothModifierData *clmd,
-                               float step,
-                               float dt,
-                               ColliderContacts **r_collider_contacts,
-                               int *r_totcolliders)
-{
-  Cloth *cloth = clmd->clothObject;
-  BVHTree *cloth_bvh;
-  unsigned int i = 0, mvert_num = 0;
-  ClothVertex *verts = NULL;
-
-  ColliderContacts *collider_contacts;
-
-  Object **collobjs = NULL;
-  unsigned int numcollobj = 0;
-
-  verts = cloth->verts;
-  mvert_num = cloth->mvert_num;
-
-  ////////////////////////////////////////////////////////////
-  // static collisions
-  ////////////////////////////////////////////////////////////
-
-  /* Check we do have collision objects to test against, before doing anything else. */
-  collobjs = BKE_collision_objects_create(
-      depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
-  if (!collobjs) {
-    *r_collider_contacts = NULL;
-    *r_totcolliders = 0;
-    return;
-  }
-
-  // create temporary cloth points bvh
-  cloth_bvh = BLI_bvhtree_new(mvert_num, clmd->coll_parms->epsilon, 4, 6);
-  /* fill tree */
-  for (i = 0; i < mvert_num; i++) {
-    float co[6];
-
-    copy_v3_v3(&co[0 * 3], verts[i].x);
-    copy_v3_v3(&co[1 * 3], verts[i].tx);
-
-    BLI_bvhtree_insert(cloth_bvh, i, co, 2);
-  }
-  /* balance tree */
-  BLI_bvhtree_balance(cloth_bvh);
-
-  /* move object to position (step) in time */
-  for (i = 0; i < numcollobj; i++) {
-    Object *collob = collobjs[i];
-    CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(
-        collob, eModifierType_Collision);
-    if (!collmd->bvhtree) {
-      continue;
-    }
-
-    /* move object to position (step) in time */
-    collision_move_object(collmd, step + dt, step, true);
-  }
-
-  collider_contacts = MEM_callocN(sizeof(ColliderContacts) * numcollobj, "CollPair");
-
-  // check all collision objects
-  for (i = 0; i < numcollobj; i++) {
-    ColliderContacts *ct = collider_contacts + i;
-    Object *collob = collobjs[i];
-    CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(
-        collob, eModifierType_Collision);
-    BVHTreeOverlap *overlap;
-    unsigned int result = 0;
-    float epsilon;
-
-    ct->ob = collob;
-    ct->collmd = collmd;
-    ct->collisions = NULL;
-    ct->totcollisions = 0;
-
-    if (!collmd->bvhtree) {
-      continue;
-    }
-
-    /* search for overlapping collision pairs */
-    overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
-    epsilon = BLI_bvhtree_get_epsilon(collmd->bvhtree);
-
-    // go to next object if no overlap is there
-    if (result && overlap) {
-      CollPair *collisions_index;
-
-      /* check if collisions really happen (costly near check) */
-      cloth_points_objcollisions_nearcheck(
-          clmd, collmd, &ct->collisions, &collisions_index, result, overlap, epsilon, dt);
-      ct->totcollisions = (int)(collisions_index - ct->collisions);
-
-      /* Resolve nearby collisions. */
-#if 0
-      ret += cloth_points_objcollisions_resolve(
-          clmd, collmd, collob->pd, collisions[i], collisions_index[i], dt);
-#endif
-    }
-
-    if (overlap) {
-      MEM_freeN(overlap);
-    }
-  }
-
-  BKE_collision_objects_free(collobjs);
-
-  BLI_bvhtree_free(cloth_bvh);
-
-  ////////////////////////////////////////////////////////////
-  // update positions
-  // this is needed for bvh_calc_DOP_hull_moving() [kdop.c]
-  ////////////////////////////////////////////////////////////
-
-  // verts come from clmd
-  for (i = 0; i < mvert_num; i++) {
-    if (clmd->sim_parms->vgroup_mass > 0) {
-      if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
-        continue;
-      }
-    }
-
-    add_v3_v3v3(verts[i].tx, verts[i].txold, verts[i].tv);
-  }
-  ////////////////////////////////////////////////////////////
-
-  *r_collider_contacts = collider_contacts;
-  *r_totcolliders = numcollobj;
-}
-
-void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders)
-{
-  if (collider_contacts) {
-    int i;
-    for (i = 0; i < totcolliders; i++) {
-      ColliderContacts *ct = collider_contacts + i;
-      if (ct->collisions) {
-        MEM_freeN(ct->collisions);
-      }
-    }
-    MEM_freeN(collider_contacts);
-  }
-}
index 12bb7b573bde38e146c896bb4995b02d1af5a247..4f0ff8bdcd344e55faae8359cb029631e25048dc 100644 (file)
@@ -1805,91 +1805,88 @@ void BKE_curve_bevel_make(Object *ob, ListBase *disp)
     }
   }
   else {
-    short dnr;
-
-    /* bevel now in three parts, for proper vertex normals */
-    /* part 1, back */
-
-    if ((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) {
-      dnr = nr = 2 + cu->bevresol;
-      if ((cu->flag & (CU_FRONT | CU_BACK)) == 0) {
-        nr = 3 + 2 * cu->bevresol;
-      }
-      dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1");
-      dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), "makebevelcurve p1");
-      BLI_addtail(disp, dl);
-      dl->type = DL_SEGM;
-      dl->parts = 1;
-      dl->flag = DL_BACK_CURVE;
-      dl->nr = nr;
-
-      /* half a circle */
-      fp = dl->verts;
-      dangle = ((float)M_PI_2 / (dnr - 1));
-      angle = -(nr - 1) * dangle;
-
-      for (a = 0; a < nr; a++) {
+    /* The general case for nonzero extrusion or an incomplete loop. */
+    dl = MEM_callocN(sizeof(DispList), "makebevelcurve");
+    if ((cu->flag & (CU_FRONT | CU_BACK)) == 0) {
+      /* The full loop. */
+      nr = 4 * cu->bevresol + 6;
+      dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
+    }
+    else if ((cu->flag & CU_FRONT) && (cu->flag & CU_BACK)) {
+      /* Half the loop. */
+      nr = 2 * (cu->bevresol + 1) + ((cu->ext1 == 0.0f) ? 1 : 2);
+      dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE;
+    }
+    else {
+      /* One quarter of the loop (just front or back). */
+      nr = (cu->ext1 == 0.0f) ? cu->bevresol + 2 : cu->bevresol + 3;
+      dl->flag = (cu->flag & CU_FRONT) ? DL_FRONT_CURVE : DL_BACK_CURVE;
+    }
+
+    dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), "makebevelcurve");
+    BLI_addtail(disp, dl);
+    /* Use a different type depending on whether the loop is complete or not. */
+    dl->type = ((cu->flag & (CU_FRONT | CU_BACK)) == 0) ? DL_POLY : DL_SEGM;
+    dl->parts = 1;
+    dl->nr = nr;
+
+    fp = dl->verts;
+    dangle = (float)M_PI_2 / (cu->bevresol + 1);
+    angle = 0.0;
+
+    /* Build the back section. */
+    if (cu->flag & CU_BACK || !(cu->flag & CU_FRONT)) {
+      angle = (float)M_PI_2 * 3.0f;
+      for (a = 0; a < cu->bevresol + 2; a++) {
         fp[0] = 0.0;
         fp[1] = (float)(cosf(angle) * (cu->ext2));
         fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1;
         angle += dangle;
         fp += 3;
       }
+      if ((cu->ext1 != 0.0f) && !(cu->flag & CU_FRONT) && (cu->flag & CU_BACK)) {
+        /* Add the extrusion if we're only building the back. */
+        fp[0] = 0.0;
+        fp[1] = cu->ext2;
+        fp[2] = cu->ext1;
+      }
     }
 
-    /* part 2, sidefaces */
-    if (cu->ext1 != 0.0f) {
-      nr = 2;
-
-      dl = MEM_callocN(sizeof(DispList), "makebevelcurve p2");
-      dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), "makebevelcurve p2");
-      BLI_addtail(disp, dl);
-      dl->type = DL_SEGM;
-      dl->parts = 1;
-      dl->nr = nr;
-
-      fp = dl->verts;
-      fp[1] = cu->ext2;
-      fp[2] = -cu->ext1;
-      fp[4] = cu->ext2;
-      fp[5] = cu->ext1;
-
-      if ((cu->flag & (CU_FRONT | CU_BACK)) == 0) {
-        dl = MEM_dupallocN(dl);
-        dl->verts = MEM_dupallocN(dl->verts);
-        BLI_addtail(disp, dl);
-
-        fp = dl->verts;
-        fp[1] = -fp[1];
-        fp[2] = -fp[2];
-        fp[4] = -fp[4];
-        fp[5] = -fp[5];
+    /* Build the front section. */
+    if (cu->flag & CU_FRONT || !(cu->flag & CU_BACK)) {
+      if ((cu->ext1 != 0.0f) && !(cu->flag & CU_BACK) && (cu->flag & CU_FRONT)) {
+        /* Add the extrusion if we're only building the back. */
+        fp[0] = 0.0;
+        fp[1] = cu->ext2;
+        fp[2] = -cu->ext1;
+        fp += 3;
+      }
+      /* Don't duplicate the last back vertex. */
+      angle = (cu->ext1 == 0.0f && (cu->flag & CU_BACK)) ? dangle : 0;
+      for (a = 0; a < cu->bevresol + 2; a++) {
+        fp[0] = 0.0;
+        fp[1] = (float)(cosf(angle) * (cu->ext2));
+        fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
+        angle += dangle;
+        fp += 3;
       }
     }
 
-    /* part 3, front */
-    if ((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) {
-      dnr = nr = 2 + cu->bevresol;
-      if ((cu->flag & (CU_FRONT | CU_BACK)) == 0) {
-        nr = 3 + 2 * cu->bevresol;
+    /* Build the other half only if we're building the full loop. */
+    if (!(cu->flag & (CU_FRONT | CU_BACK))) {
+      for (a = 0; a < cu->bevresol + 1; a++) {
+        fp[0] = 0.0;
+        fp[1] = (float)(cosf(angle) * (cu->ext2));
+        fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
+        angle += dangle;
+        fp += 3;
       }
-      dl = MEM_callocN(sizeof(DispList), "makebevelcurve p3");
-      dl->verts = MEM_malloc_arrayN(nr, sizeof(float[3]), "makebevelcurve p3");
-      BLI_addtail(disp, dl);
-      dl->type = DL_SEGM;
-      dl->flag = DL_FRONT_CURVE;
-      dl->parts = 1;
-      dl->nr = nr;
-
-      /* half a circle */
-      fp = dl->verts;
-      angle = 0.0;
-      dangle = ((float)M_PI_2 / (dnr - 1));
 
-      for (a = 0; a < nr; a++) {
+      angle = (float)M_PI;
+      for (a = 0; a < cu->bevresol + 1; a++) {
         fp[0] = 0.0;
         fp[1] = (float)(cosf(angle) * (cu->ext2));
-        fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1;
+        fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1;
         angle += dangle;
         fp += 3;
       }
index fe1f9097562f3da28340743072255c56093daa03..be354b041570f7d0048dca3c541adffa2aca46fa 100644 (file)
@@ -1345,6 +1345,7 @@ char BKE_imtype_valid_channels(const char imtype, bool write_file)
 
   /* bw */
   switch (imtype) {
+    case R_IMF_IMTYPE_BMP:
     case R_IMF_IMTYPE_PNG:
     case R_IMF_IMTYPE_JPEG90:
     case R_IMF_IMTYPE_TARGA:
index 974d6328fcbe794572580e0c401e93d3069e7e62..5fd852ff08997792dbca00dda3087d4f9add8cec 100644 (file)
@@ -340,7 +340,7 @@ static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBas
   FOREACH_FINALIZE_VOID;
 }
 
-/* Used by both real Collection data-blokcs, and the fake horror of master collection from Scene.
+/* Used by both real Collection data-blocks, and the fake horror of master collection from Scene.
  */
 static void library_foreach_collection(LibraryForeachIDData *data, Collection *collection)
 {
index 06f1ee5050bbe9784a5d3857a1a696efa1e5deac..3cba3aa9611d3a610c2910d45cb8623cae94ee6b 100644 (file)
@@ -41,6 +41,30 @@ void BKE_lightprobe_init(LightProbe *probe)
   MEMCPY_STRUCT_AFTER(probe, DNA_struct_default_get(LightProbe), id);
 }
 
+void BKE_lightprobe_type_set(LightProbe *probe, const short lightprobe_type)
+{
+  probe->type = lightprobe_type;
+
+  switch (probe->type) {
+    case LIGHTPROBE_TYPE_GRID:
+      probe->distinf = 0.3f;
+      probe->falloff = 1.0f;
+      probe->clipsta = 0.01f;
+      break;
+    case LIGHTPROBE_TYPE_PLANAR:
+      probe->distinf = 0.1f;
+      probe->falloff = 0.5f;
+      probe->clipsta = 0.001f;
+      break;
+    case LIGHTPROBE_TYPE_CUBE:
+      probe->attenuation_type = LIGHTPROBE_SHAPE_ELIPSOID;
+      break;
+    default:
+      BLI_assert(!"LightProbe type not configured.");
+      break;
+  }
+}
+
 void *BKE_lightprobe_add(Main *bmain, const char *name)
 {
   LightProbe *probe;
index a539aa45cf6acca0a4f4480bb8075b4f76fcb9f8..23fa8dd60d5f97f3658de2f9e6521321355c274d 100644 (file)
@@ -1289,13 +1289,9 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
       int i, j, numGrids, highGridSize, lowGridSize;
       const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
 
-      /* create subsurf DM from original mesh at high level */
-      if (ob->derivedDeform) {
-        cddm = CDDM_copy(ob->derivedDeform);
-      }
-      else {
-        cddm = CDDM_from_mesh(me);
-      }
+      /* Create subsurf DM from original mesh at high level. */
+      /* TODO: use mesh_deform_eval when sculpting on deformed mesh. */
+      cddm = CDDM_from_mesh(me);
       DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
 
       highdm = subsurf_dm_create_local(scene,
@@ -1369,12 +1365,8 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
       DerivedMesh *cddm, *subdm;
       const bool has_mask = CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK);
 
-      if (ob->derivedDeform) {
-        cddm = CDDM_copy(ob->derivedDeform);
-      }
-      else {
-        cddm = CDDM_from_mesh(me);
-      }
+      /* TODO: use mesh_deform_eval when sculpting on deformed mesh. */
+      cddm = CDDM_from_mesh(me);
       DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
 
       subdm = subsurf_dm_create_local(scene,
index da3986d33dffc363e63951b7a994a842c4d87a33..90205286a720121f3ecb82600832d85da8eb8f6c 100644 (file)
@@ -430,7 +430,6 @@ void BKE_object_free_derived_caches(Object *ob)
   MEM_SAFE_FREE(ob->runtime.bb);
 
   object_update_from_subsurf_ccg(ob);
-  BKE_object_free_derived_mesh_caches(ob);
 
   /* Restore initial pointer. */
   if (ob->runtime.mesh_orig != NULL) {
@@ -457,20 +456,6 @@ void BKE_object_free_derived_caches(Object *ob)
   DRW_gpencil_freecache(ob);
 }
 
-void BKE_object_free_derived_mesh_caches(struct Object *ob)
-{
-  if (ob->derivedFinal) {
-    ob->derivedFinal->needsFree = 1;
-    ob->derivedFinal->release(ob->derivedFinal);
-    ob->derivedFinal = NULL;
-  }
-  if (ob->derivedDeform) {
-    ob->derivedDeform->needsFree = 1;
-    ob->derivedDeform->release(ob->derivedDeform);
-    ob->derivedDeform = NULL;
-  }
-}
-
 void BKE_object_free_caches(Object *object)
 {
   ModifierData *md;
@@ -804,6 +789,8 @@ static const char *get_obdata_defname(int type)
       return DATA_("Empty");
     case OB_GPENCIL:
       return DATA_("GPencil");
+    case OB_LIGHTPROBE:
+      return DATA_("LightProbe");
     default:
       CLOG_ERROR(&LOG, "Internal error, bad type: %d", type);
       return DATA_("Empty");
@@ -1425,9 +1412,6 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
 
   BKE_object_copy_particlesystems(ob_dst, ob_src, flag_subdata);
 
-  ob_dst->derivedDeform = NULL;
-  ob_dst->derivedFinal = NULL;
-
   BLI_listbase_clear((ListBase *)&ob_dst->drawdata);
   BLI_listbase_clear(&ob_dst->pc_ids);
 
index 3e449fa6b2508bee511ac71aa75c09e077b87377..f58c20a7d7238dc2f874924e4f442e8d61562fa5 100644 (file)
@@ -247,8 +247,12 @@ WorkSpaceLayout *BKE_workspace_layout_add(Main *bmain,
 
 void BKE_workspace_layout_remove(Main *bmain, WorkSpace *workspace, WorkSpaceLayout *layout)
 {
-  id_us_min(&layout->screen->id);
-  BKE_id_free(bmain, layout->screen);
+  /* Screen should usually be set, but we call this from file reading to get rid of invalid
+   * layouts. */
+  if (layout->screen) {
+    id_us_min(&layout->screen->id);
+    BKE_id_free(bmain, layout->screen);
+  }
   BLI_freelinkN(&workspace->layouts, layout);
 }
 
index 23a8f77557630e28b15e5e38afadb63c10817ec0..2b11213d35153465fc938792492ddbbbb1668a8b 100644 (file)
@@ -39,6 +39,10 @@ bool BLI_rcti_is_empty(const struct rcti *rect);
 bool BLI_rctf_is_empty(const struct rctf *rect);
 void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
 void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
+bool BLI_rctf_is_valid(const struct rctf *rect);
+bool BLI_rcti_is_valid(const struct rcti *rect);
+void BLI_rctf_sanitize(struct rctf *rect);
+void BLI_rcti_sanitize(struct rcti *rect);
 void BLI_rctf_init_pt_radius(struct rctf *rect, const float xy[2], float size);
 void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size);
 void BLI_rcti_init_minmax(struct rcti *rect);
index 4faaf1605e077fad047b742ebfa071cec0398688..118949d1c46786be177bddc5c448ec5c4c9624a0 100644 (file)
@@ -17,8 +17,7 @@
 /** \file
  * \ingroup bli
  *
- * Dynamic Constrained Delaunay Triangulation.
- * See paper by Marcelo Kallmann, Hanspeter Bieri, and Daniel Thalmann
+ * Constrained 2d Delaunay Triangulation.
  */
 
 #include "MEM_guardedalloc.h"
 #include "BLI_math.h"
 #include "BLI_memarena.h"
 #include "BLI_mempool.h"
-#include "BLI_rand.h"
 
 #include "BLI_delaunay_2d.h"
 
 /* Uncomment this define to get helpful debugging functions etc. defined. */
-// #define DEBUG_CDT
+#define DEBUG_CDT
 
 struct CDTEdge;
 struct CDTFace;
@@ -53,20 +51,21 @@ typedef struct CDTVert {
   SymEdge *symedge;    /* Some edge attached to it. */
   LinkNode *input_ids; /* List of corresponding vertex input ids. */
   int index;           /* Index into array that cdt keeps. */
-  int visit_index;     /* Which visit epoch has this been seen. */
+  int merge_to_index;  /* Index of a CDTVert that this has merged to. -1 if no merge. */
 } CDTVert;
 
 typedef struct CDTEdge {
   LinkNode *input_ids; /* List of input edge ids that this is part of. */
   SymEdge symedges[2]; /* The directed edges for this edge. */
+  bool in_queue;       /* Used in flipping algorithm. */
 } CDTEdge;
 
 typedef struct CDTFace {
-  double centroid[2];  /* Average of vertex coords. */
   SymEdge *symedge;    /* A symedge in face; only used during output. */
   LinkNode *input_ids; /* List of input face ids that this is part of. */
   int visit_index;     /* Which visit epoch has this been seen. */
   bool deleted;        /* Marks this face no longer used. */
+  bool in_queue;       /* Used in remove_small_features algorithm. */
 } CDTFace;
 
 typedef struct CDT_state {
@@ -76,6 +75,7 @@ typedef struct CDT_state {
   CDTVert **vert_array;
   int vert_array_len;
   int vert_array_len_alloc;
+  int input_vert_tot;
   double minx;
   double miny;
   double maxx;
@@ -83,19 +83,13 @@ typedef struct CDT_state {
   double margin;
   int visit_count;
   int face_edge_offset;
-  RNG *rng;
   MemArena *arena;
   BLI_mempool *listpool;
   double epsilon;
+  double epsilon_squared;
   bool output_prepared;
 } CDT_state;
 
-typedef struct LocateResult {
-  enum { OnVert, OnEdge, InFace } loc_kind;
-  SymEdge *se;
-  double edge_lambda;
-} LocateResult;
-
 #define DLNY_ARENASIZE 1 << 14
 
 /**
@@ -105,60 +99,57 @@ typedef struct LocateResult {
 #define DLNY_MARGIN_PCT 2000.0
 
 #ifdef DEBUG_CDT
+#  ifdef __GNUC__
+#    define ATTU __attribute__((unused))
+#  else
+#    define ATTU
+#  endif
 #  define F2(p) p[0], p[1]
-static void dump_se(const SymEdge *se, const char *lab);
-static void dump_v(const CDTVert *v, const char *lab);
-static void dump_se_cycle(const SymEdge *se, const char *lab, const int limit);
-static void dump_id_list(const LinkNode *id_list, const char *lab);
-static void dump_cdt(const CDT_state *cdt, const char *lab);
-static void dump_cdt_vert_neighborhood(CDT_state *cdt, int v, int maxdist, const char *lab);
-static void cdt_draw(CDT_state *cdt, const char *lab);
-static void write_cdt_input_to_file(const CDT_input *inp);
-static void validate_face_centroid(SymEdge *se);
-static void validate_cdt(CDT_state *cdt, bool check_all_tris);
+#  define F3(p) p[0], p[1], p[2]
+ATTU static void dump_se(const SymEdge *se, const char *lab);
+ATTU static void dump_v(const CDTVert *v, const char *lab);
+ATTU static void dump_se_cycle(const SymEdge *se, const char *lab, const int limit);
+ATTU static void dump_id_list(const LinkNode *id_list, const char *lab);
+ATTU static void dump_cdt(const CDT_state *cdt, const char *lab);
+ATTU static void dump_cdt_vert_neighborhood(CDT_state *cdt, int v, int maxdist, const char *lab);
+ATTU static void cdt_draw(CDT_state *cdt, const char *lab);
+ATTU static void cdt_draw_vertex_region(CDT_state *cdt, int v, double dist, const char *lab);
+ATTU static void write_cdt_input_to_file(const CDT_input *inp);
+ATTU static void validate_cdt(CDT_state *cdt,
+                              bool check_all_tris,
+                              bool check_delaunay,
+                              bool check_visibility);
 #endif
 
-/**
- * Return 1 if a,b,c forms CCW angle, -1 if a CW angle, 0 if straight.
- * For straight test, allow b to be withing eps of line.
- */
-static int CCW_test(const double a[2], const double b[2], const double c[2], const double eps)
+static void exactinit(void);
+static double orient2d(const double *pa, const double *pb, const double *pc);
+static double incircle(const double *pa, const double *pb, const double *pc, const double *pd);
+
+/** Return other #SymEdge for same #CDTEdge as se. */
+BLI_INLINE SymEdge *sym(const SymEdge *se)
 {
-  double det;
-  double ab;
+  return se->next->rot;
+}
 
-  /* This is twice the signed area of triangle abc. */
-  det = (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]);
-  if (eps == 0.0) {
-    if (det > 0) {
-      return 1;
-    }
-    else if (det < 0) {
-      return -1;
-    }
-    else {
-      return 0;
-    }
-  }
-  ab = len_v2v2_db(a, b);
-  if (ab <= eps) {
-    return 0;
-  }
-  det /= ab;
-  if (det > eps) {
-    return 1;
-  }
-  else if (det < -eps) {
-    return -1;
-  }
-  return 0;
+/** Return SymEdge whose next is se. */
+BLI_INLINE SymEdge *prev(const SymEdge *se)
+{
+  return se->rot->next->rot;
 }
 
-/** return true if a -- b -- c are in that order, assuming they are on a straight line according to
- * CCW_test. */
-static bool in_line(const double a[2], const double b[2], const double c[2], double eps)
+/** Return true if a -- b -- c are in that order, assuming they are on a straight line according to
+ * orient2d and we know the order is either abc or bac.
+ * This means ab . ac and bc . ac must both be non-negative.  */
+static bool in_line(const double a[2], const double b[2], const double c[2])
 {
-  return fabs(len_v2v2_db(a, c) - (len_v2v2_db(a, b) + len_v2v2_db(b, c))) <= eps;
+  double ab[2], bc[2], ac[2];
+  sub_v2_v2v2_db(ab, b, a);
+  sub_v2_v2v2_db(bc, c, b);
+  sub_v2_v2v2_db(ac, c, a);
+  if (dot_v2v2_db(ab, ac) < 0.0) {
+    return false;
+  }
+  return dot_v2v2_db(bc, ac) >= 0.0;
 }
 
 #ifndef NDEBUG
@@ -176,21 +167,6 @@ static bool reachable(SymEdge *s1, SymEdge *s2, int limit)
 }
 #endif
 
-static void calc_face_centroid(SymEdge *se)
-{
-  SymEdge *senext;
-  double *centroidp = se->face->centroid;
-  int count;
-  copy_v2_v2_db(centroidp, se->vert->co);
-  count = 1;
-  for (senext = se->next; senext != se; senext = senext->next) {
-    add_v2_v2_db(centroidp, senext->vert->co);
-    count++;
-  }
-  centroidp[0] /= count;
-  centroidp[1] /= count;
-}
-
 /** Using array to store these instead of linked list so can make a random selection from them. */
 static CDTVert *add_cdtvert(CDT_state *cdt, double x, double y)
 {
@@ -208,7 +184,7 @@ static CDTVert *add_cdtvert(CDT_state *cdt, double x, double y)
   }
   BLI_assert(cdt->vert_array_len < cdt->vert_array_len_alloc);
   v->index = cdt->vert_array_len;
-  v->visit_index = 0;
+  v->merge_to_index = -1;
   cdt->vert_array[cdt->vert_array_len++] = v;
   return v;
 }
@@ -220,6 +196,7 @@ static CDTEdge *add_cdtedge(
   SymEdge *se = &e->symedges[0];
   SymEdge *sesym = &e->symedges[1];
   e->input_ids = NULL;
+  e->in_queue = false;
   BLI_linklist_prepend_arena(&cdt->edges, (void *)e, cdt->arena);
   se->edge = sesym->edge = e;
   se->face = fleft;
@@ -243,6 +220,7 @@ static CDTFace *add_cdtface(CDT_state *cdt)
   f->deleted = false;
   f->symedge = NULL;
   f->input_ids = NULL;
+  f->in_queue = false;
   BLI_linklist_prepend_arena(&cdt->faces, (void *)f, cdt->arena);
   return f;
 }
@@ -290,37 +268,24 @@ static void add_list_to_input_ids(LinkNode **dst, const LinkNode *src, CDT_state
   }
 }
 
-/** Return other #SymEdge for same #CDTEdge as se. */
-static inline SymEdge *sym(const SymEdge *se)
-{
-  return se->next->rot;
-}
-
-/** Return SymEdge whose next is se. */
-static inline SymEdge *prev(const SymEdge *se)
-{
-  return se->rot->next->rot;
-}
-
-static inline bool is_border_edge(const CDTEdge *e, const CDT_state *cdt)
+BLI_INLINE bool is_border_edge(const CDTEdge *e, const CDT_state *cdt)
 {
   return e->symedges[0].face == cdt->outer_face || e->symedges[1].face == cdt->outer_face;
 }
 
-/** Does one edge of this edge touch the frame? */
-static bool edge_touches_frame(const CDTEdge *e)
+BLI_INLINE bool is_constrained_edge(const CDTEdge *e)
 {
-  return e->symedges[0].vert->index < 4 || e->symedges[1].vert->index < 4;
+  return e->input_ids != NULL;
 }
 
-static inline bool is_constrained_edge(const CDTEdge *e)
+BLI_INLINE bool is_deleted_edge(const CDTEdge *e)
 {
-  return e->input_ids != NULL;
+  return e->symedges[0].next == NULL;
 }
 
-static inline bool is_deleted_edge(const CDTEdge *e)
+BLI_INLINE bool is_original_vert(const CDTVert *v, CDT_state *cdt)
 {
-  return e->symedges[0].next == NULL;
+  return (v->index < cdt->input_vert_tot);
 }
 
 /** Is there already an edge between a and b? */
@@ -357,7 +322,6 @@ static bool vert_touches_face(const CDTVert *v, const CDTFace *f)
  * Add an edge from s1->v to s2->v, splitting the face in two.
  * The original face will continue to be associated with the subface
  * that has s1, and a new face will be made for s2's new face.
- * The centroids of both faces are recalculated.
  * Return the new diagonal's CDTEdge *.
  */
 static CDTEdge *add_diagonal(CDT_state *cdt, SymEdge *s1, SymEdge *s2)
@@ -366,8 +330,8 @@ static CDTEdge *add_diagonal(CDT_state *cdt, SymEdge *s1, SymEdge *s2)
   CDTFace *fold, *fnew;
   SymEdge *sdiag, *sdiagsym;
   SymEdge *s1prev, *s1prevsym, *s2prev, *s2prevsym, *se;
-  BLI_assert(reachable(s1, s2, 2000));
-  BLI_assert(reachable(s2, s1, 2000));
+  BLI_assert(reachable(s1, s2, 20000));
+  BLI_assert(reachable(s2, s1, 20000));
   fold = s1->face;
   fnew = add_cdtface(cdt);
   s1prev = prev(s1);
@@ -392,11 +356,60 @@ static CDTEdge *add_diagonal(CDT_state *cdt, SymEdge *s1, SymEdge *s2)
     se->face = fnew;
   }
   add_list_to_input_ids(&fnew->input_ids, fold->input_ids, cdt);
-  calc_face_centroid(sdiag);
-  calc_face_centroid(sdiagsym);
   return ediag;
 }
 
+/**
+ * Add a dangling edge from an isolated v to the vert at se in the same face as se->face.
+ */
+static CDTEdge *add_vert_to_symedge_edge(CDT_state *cdt, CDTVert *v, SymEdge *se)
+{
+  CDTEdge *e;
+  SymEdge *se_rot, *se_rotsym, *new_se, *new_se_sym;
+
+  se_rot = se->rot;
+  se_rotsym = sym(se_rot);
+  e = add_cdtedge(cdt, v, se->vert, se->face, se->face);
+  new_se = &e->symedges[0];
+  new_se_sym = &e->symedges[1];
+  new_se->next = se;
+  new_se_sym->next = new_se;
+  new_se->rot = new_se;
+  new_se_sym->rot = se_rot;
+  se->rot = new_se_sym;
+  se_rotsym->next = new_se_sym;
+  return e;
+}
+
+/* Connect the verts of se1 and se2, assuming that currently those two SymEdges are on
+ * the outer boundary (have face == outer_face) of two components that are isolated from
+ * each other.
+ */
+static CDTEdge *connect_separate_parts(CDT_state *cdt, SymEdge *se1, SymEdge *se2)
+{
+  CDTEdge *e;
+  SymEdge *se1_rot, *se1_rotsym, *se2_rot, *se2_rotsym, *new_se, *new_se_sym;
+  ;
+
+  BLI_assert(se1->face == cdt->outer_face && se2->face == cdt->outer_face);
+  se1_rot = se1->rot;
+  se1_rotsym = sym(se1_rot);
+  se2_rot = se2->rot;
+  se2_rotsym = sym(se2_rot);
+  e = add_cdtedge(cdt, se1->vert, se2->vert, cdt->outer_face, cdt->outer_face);
+  new_se = &e->symedges[0];
+  new_se_sym = &e->symedges[1];
+  new_se->next = se2;
+  new_se_sym->next = se1;
+  new_se->rot = se1_rot;
+  new_se_sym->rot = se2_rot;
+  se1->rot = new_se;
+  se2->rot = new_se_sym;
+  se1_rotsym->next = new_se;
+  se2_rotsym->next = new_se_sym;
+  return e;
+}
+
 /**
  * Split \a se at fraction \a lambda,
  * and return the new #CDTEdge that is the new second half.
@@ -435,14 +448,12 @@ static CDTEdge *split_edge(CDT_state *cdt, SymEdge *se, double lambda)
     newsesym->vert->symedge = newsesym;
   }
   add_list_to_input_ids(&e->input_ids, se->edge->input_ids, cdt);
-  calc_face_centroid(se);
-  calc_face_centroid(sesym);
   return e;
 }
 
 /**
  * Delete an edge from the structure. The new combined face on either side of
- * the deleted edge will be the one that was e's face; the centroid is updated.
+ * the deleted edge will be the one that was e's face.
  * There will be now an unused face, marked by setting its deleted flag,
  * and an unused #CDTEdge, marked by setting the next and rot pointers of
  * its SymEdges to NULL.
@@ -519,820 +530,486 @@ static void delete_edge(CDT_state *cdt, SymEdge *e)
       cdt->outer_face = aface;
     }
   }
-  if (aface != cdt->outer_face) {
-    calc_face_centroid(f);
-  }
 }
 
-/**
- * The initial structure will be the rectangle with opposite corners (minx,miny)
- * and (maxx,maxy), and a diagonal going between those two corners.
- * We keep track of the outer face (surrounding the entire structure; its boundary
- * is the clockwise traversal of the bounding box rectangle initially) in cdt->outer_face.
- *
- * The vertices are kept as pointers in an array (which may need to be reallocated from
- * time to time); the edges and faces are kept in lists. Sometimes edges and faces are deleted,
- * marked by setting all pointers to NULL (for edges), or setting the deleted flag to true (for
- * faces).
- *
- * A #MemArena is allocated to do all allocations from except for link list nodes; a listpool
- * is created for link list node allocations.
- *
- * The epsilon argument is stored and used in "near enough" distance calculations.
- *
- * When done, caller must call BLI_constrained_delaunay_free to free
- * the memory used by the returned #CDT_state.
- */
-static CDT_state *cdt_init(double minx, double maxx, double miny, double maxy, double epsilon)
+static CDT_state *new_cdt_init(const CDT_input *in)
 {
-  double x0, x1, y0, y1;
-  double margin;
-  CDTVert *v[4];
-  CDTEdge *e[4];
-  CDTFace *f0, *fouter;
-  int i, inext, iprev;
+  int i;
   MemArena *arena = BLI_memarena_new(DLNY_ARENASIZE, __func__);
-  CDT_state *cdt = BLI_memarena_alloc(arena, sizeof(CDT_state));
-  cdt->edges = NULL;
-  cdt->faces = NULL;
-  cdt->vert_array_len = 0;
-  cdt->vert_array_len_alloc = 32;
+  CDT_state *cdt = BLI_memarena_calloc(arena, sizeof(CDT_state));
+
+  cdt->epsilon = (double)in->epsilon;
+  cdt->epsilon_squared = cdt->epsilon * cdt->epsilon;
+  cdt->arena = arena;
+  cdt->input_vert_tot = in->verts_len;
+  cdt->vert_array_len_alloc = 2 * in->verts_len;
   cdt->vert_array = BLI_memarena_alloc(arena,
                                        cdt->vert_array_len_alloc * sizeof(*cdt->vert_array));
-  cdt->minx = minx;
-  cdt->miny = miny;
-  cdt->maxx = maxx;
-  cdt->maxy = maxy;
-  cdt->arena = arena;
-  cdt->listpool = BLI_mempool_create(sizeof(LinkNode), 128, 128, 0);
-  cdt->rng = BLI_rng_new(0);
-  cdt->epsilon = epsilon;
-
-  /* Expand bounding box a bit and make initial CDT from it. */
-  margin = DLNY_MARGIN_PCT * max_dd(maxx - minx, maxy - miny) / 100.0;
-  if (margin <= 0.0) {
-    margin = 1.0;
-  }
-  if (margin < epsilon) {
-    margin = 4 * epsilon; /* Make sure constraint verts don't merge with border verts. */
-  }
-  cdt->margin = margin;
-  x0 = minx - margin;
-  y0 = miny - margin;
-  x1 = maxx + margin;
-  y1 = maxy + margin;
-
-  /* Make a quad, then split it with a diagonal. */
-  v[0] = add_cdtvert(cdt, x0, y0);
-  v[1] = add_cdtvert(cdt, x1, y0);
-  v[2] = add_cdtvert(cdt, x1, y1);
-  v[3] = add_cdtvert(cdt, x0, y1);
-  cdt->outer_face = fouter = add_cdtface(cdt);
-  f0 = add_cdtface(cdt);
-  for (i = 0; i < 4; i++) {
-    e[i] = add_cdtedge(cdt, v[i], v[(i + 1) % 4], f0, fouter);
-  }
-  for (i = 0; i < 4; i++) {
-    inext = (i + 1) % 4;
-    iprev = (i + 3) % 4;
-    e[i]->symedges[0].next = &e[inext]->symedges[0];
-    e[inext]->symedges[1].next = &e[i]->symedges[1];
-    e[i]->symedges[0].rot = &e[iprev]->symedges[1];
-    e[iprev]->symedges[1].rot = &e[i]->symedges[0];
-  }
-  calc_face_centroid(&e[0]->symedges[0]);
-  add_diagonal(cdt, &e[0]->symedges[0], &e[2]->symedges[0]);
-  fouter->centroid[0] = fouter->centroid[1] = 0.0;
-
-  cdt->visit_count = 0;
-  cdt->output_prepared = false;
-  cdt->face_edge_offset = 0;
+  cdt->listpool = BLI_mempool_create(
+      sizeof(LinkNode), 128 + 4 * in->verts_len, 128 + in->verts_len, 0);
+
+  for (i = 0; i < in->verts_len; i++) {
+    add_cdtvert(cdt, (double)(in->vert_coords[i][0]), (double)(in->vert_coords[i][1]));
+  }
+  cdt->outer_face = add_cdtface(cdt);
   return cdt;
 }
 
-static void cdt_free(CDT_state *cdt)
+static void new_cdt_free(CDT_state *cdt)
 {
-  BLI_rng_free(cdt->rng);
   BLI_mempool_destroy(cdt->listpool);
   BLI_memarena_free(cdt->arena);
 }
 
-static bool locate_point_final(const double p[2],
-                               SymEdge *tri_se,
-                               bool try_neighbors,
-                               const double epsilon,
-                               LocateResult *r_lr)
-{
-  /* 'p' should be in or on our just outside of 'cur_tri'. */
-  double dist_inside[3];
-  int i;
-  SymEdge *se;
-  const double *a, *b;
-  double lambda, close[2];
-  bool done = false;
-#ifdef DEBUG_CDT
-  int dbg_level = 0;
-
-  if (dbg_level > 0) {
-    fprintf(stderr, "locate_point_final %d\n", try_neighbors);
-    dump_se(tri_se, "tri_se");
-    fprintf(stderr, "\n");
-  }
-#endif
-  se = tri_se;
-  i = 0;
-  do {
-#ifdef DEBUG_CDT
-    if (dbg_level > 1) {
-      fprintf(stderr, "%d: ", i);
-      dump_se(se, "search se");
-    }
-#endif
-    a = se->vert->co;
-    b = se->next->vert->co;
-    lambda = closest_to_line_v2_db(close, p, a, b);
-    double len_close_p = len_v2v2_db(close, p);
-    if (len_close_p < epsilon) {
-      if (len_v2v2_db(p, a) < epsilon) {
-#ifdef DEBUG_CDT
-        if (dbg_level > 0) {
-          fprintf(stderr, "OnVert case a (%.2f,%.2f)\n", F2(a));
-        }
-#endif
-        r_lr->loc_kind = OnVert;
-        r_lr->se = se;
-        r_lr->edge_lambda = 0.0;
-        done = true;
-      }
-      else if (len_v2v2_db(p, b) < epsilon) {
-#ifdef DEBUG_CDT
-        if (dbg_level > 0) {
-          fprintf(stderr, "OnVert case b (%.2f,%.2f)\n", F2(b));
-        }
-#endif
-        r_lr->loc_kind = OnVert;
-        r_lr->se = se->next;
-        r_lr->edge_lambda = 0.0;
-        done = true;
-      }
-      else if (lambda > 0.0 && lambda < 1.0) {
-#ifdef DEBUG_CDT
-        if (dbg_level > 0) {
-          fprintf(stderr, "OnEdge case, lambda=%f\n", lambda);
-          dump_se(se, "se");
-        }
-#endif
-        r_lr->loc_kind = OnEdge;
-        r_lr->se = se;
-        r_lr->edge_lambda = lambda;
-        done = true;
-      }
-    }
-    else {
-      dist_inside[i] = len_close_p;
-      dist_inside[i] = C